Skip to content

Commit a1d74a8

Browse files
committed
Fix vehicle summoning logic and add combat/flying checks
Corrects vehicle menu item to use vehicleData.Id instead of CreatureId. Adds a combat check to prevent vehicle summoning while in combat. Improves flying vehicle summoning by checking riding skill and restricting flying in certain maps and no-fly zones. Fixes vehicle summoning to use the correct CreatureId and updates event lambda parameters.
1 parent 39afba9 commit a1d74a8

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

src/mod_chromiecraft_smartstone_handler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ void Smartstone::LoadVehicles()
540540
vehicleData.Flags = fields[4].Get<uint32>();
541541
Vehicles.push_back(vehicleData);
542542
MenuItems[ACTION_TYPE_VEHICLE].push_back(MenuItem{
543-
vehicleData.CreatureId,
543+
vehicleData.Id,
544544
vehicleData.Description,
545545
0, // NpcTextId
546546
GOSSIP_ICON_TABARD,

src/mod_chromiecraft_smartstone_scripts.cpp

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,28 +254,42 @@ class item_chromiecraft_smartstone : public ItemScript
254254
break;
255255
}
256256

257+
if (player->IsInCombat())
258+
{
259+
player->SendSystemMessage("You cannot summon a vehicle while in combat.");
260+
break;
261+
}
262+
257263
SmartstoneVehicleData vehicleData = sSmartstone->GetVehicleData(actionId);
258264

259265
if (vehicleData.HasFlag(SMARTSTONE_VEHICLE_FLAG_FLY))
260266
{
267+
if (!player->GetSkillValue(SKILL_RIDING) < 225)
268+
{
269+
player->SendSystemMessage("You need Expert Riding skill to fly this vehicle.");
270+
break;
271+
}
272+
273+
uint32 mapId = player->GetMapId();
261274
Battlefield* Bf = sBattlefieldMgr->GetBattlefieldToZoneId(player->GetZoneId());
262275
if (AreaTableEntry const* pArea = sAreaTableStore.LookupEntry(player->GetAreaId()))
263-
if ((pArea->flags & AREA_FLAG_NO_FLY_ZONE) || (Bf && !Bf->CanFlyIn()))
276+
if ((pArea->flags & AREA_FLAG_NO_FLY_ZONE) || (Bf && !Bf->CanFlyIn()) ||
277+
(mapId == MAP_KALIMDOR || mapId == MAP_EASTERN_KINGDOMS))
264278
{
265279
player->SendSystemMessage("You may not fly here.");
266280
break;
267281
}
268282
}
269283

270-
Creature* creature = player->SummonCreature(actionId, *player, TEMPSUMMON_MANUAL_DESPAWN);
284+
Creature* creature = player->SummonCreature(vehicleData.CreatureId, *player, TEMPSUMMON_MANUAL_DESPAWN);
271285

272286
if (!creature)
273287
break;
274288

275289
if (!vehicleData.HasFlag(SMARTSTONE_VEHICLE_FLAG_FOLLOW))
276290
{
277291
ObjectGuid vehicleGuid = creature->GetGUID();
278-
player->m_Events.AddEventAtOffset([player, actionId, vehicleGuid] {
292+
player->m_Events.AddEventAtOffset([player, vehicleGuid] {
279293
if (Creature* vehicle = ObjectAccessor::GetCreature(*player, vehicleGuid))
280294
{
281295
player->CastCustomSpell(60683, SPELLVALUE_BASE_POINT0, 1, vehicle, true);

0 commit comments

Comments
 (0)