diff --git a/src/game/Map.cpp b/src/game/Map.cpp index 702608208..e374aec0c 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -2396,6 +2396,62 @@ void Map::ScriptsProcess() pSource->TeleportTo(step.script->teleportTo.mapId, step.script->x, step.script->y, step.script->z, step.script->o); break; } + case SCRIPT_COMMAND_QUEST_EXPLORED: + { + if (!source) + { + sLog.outError("SCRIPT_COMMAND_QUEST_EXPLORED (script id %u) call for NULL source.", step.script->id); + break; + } + + if (!target) + { + sLog.outError("SCRIPT_COMMAND_QUEST_EXPLORED (script id %u) call for NULL target.", step.script->id); + break; + } + + // when script called for item spell casting then target == (unit or GO) and source is player + WorldObject* worldObject; + Player* player; + + if (target->GetTypeId() == TYPEID_PLAYER) + { + if (source->GetTypeId() != TYPEID_UNIT && source->GetTypeId() != TYPEID_GAMEOBJECT && source->GetTypeId() != TYPEID_PLAYER) + { + sLog.outError("SCRIPT_COMMAND_QUEST_EXPLORED (script id %u) call for non-creature, non-gameobject or non-player (TypeId: %u), skipping.", step.script->id, source->GetTypeId()); + break; + } + + worldObject = (WorldObject*)source; + player = (Player*)target; + } + else + { + if (target->GetTypeId() != TYPEID_UNIT && target->GetTypeId() != TYPEID_GAMEOBJECT && target->GetTypeId() != TYPEID_PLAYER) + { + sLog.outError("SCRIPT_COMMAND_QUEST_EXPLORED (script id %u) call for non-creature, non-gameobject or non-player (TypeId: %u), skipping.", step.script->id, target->GetTypeId()); + break; + } + + if (source->GetTypeId() != TYPEID_PLAYER) + { + sLog.outError("SCRIPT_COMMAND_QUEST_EXPLORED (script id %u) call for non-player (TypeId: %u), skipping.", step.script->id, source->GetTypeId()); + break; + } + + worldObject = (WorldObject*)target; + player = (Player*)source; + } + + // quest id and flags checked at script loading + if ((worldObject->GetTypeId() != TYPEID_UNIT || ((Unit*)worldObject)->isAlive()) && + (step.script->questExplored.distance == 0 || worldObject->IsWithinDistInMap(player, float(step.script->questExplored.distance)))) + player->AreaExploredOrEventHappens(step.script->questExplored.questId); + else + player->FailQuest(step.script->questExplored.questId); + + break; + } case SCRIPT_COMMAND_KILL_CREDIT: { // accept player in any one from target/source arg @@ -2425,42 +2481,6 @@ void Map::ScriptsProcess() break; } - case SCRIPT_COMMAND_TEMP_SUMMON_CREATURE: - { - if (!step.script->summonCreature.creatureEntry) - { - sLog.outError("SCRIPT_COMMAND_TEMP_SUMMON_CREATURE (script id %u) call for NULL creature.", step.script->id); - break; - } - - if (!source) - { - sLog.outError("SCRIPT_COMMAND_TEMP_SUMMON_CREATURE (script id %u) call for NULL world object.", step.script->id); - break; - } - - if (!source->isType(TYPEMASK_WORLDOBJECT)) - { - sLog.outError("SCRIPT_COMMAND_TEMP_SUMMON_CREATURE (script id %u) call for non-WorldObject (TypeId: %u), skipping.", step.script->id, source->GetTypeId()); - break; - } - - WorldObject* summoner = (WorldObject*)source; - - float x = step.script->x; - float y = step.script->y; - float z = step.script->z; - float o = step.script->o; - - Creature* pCreature = summoner->SummonCreature(step.script->summonCreature.creatureEntry, x, y, z, o, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, step.script->summonCreature.despawnDelay); - if (!pCreature) - { - sLog.outError("SCRIPT_COMMAND_TEMP_SUMMON (script id %u) failed for creature (entry: %u).", step.script->id, step.script->summonCreature.creatureEntry); - break; - } - - break; - } case SCRIPT_COMMAND_RESPAWN_GAMEOBJECT: { if (!step.script->respawnGo.goGuid) // gameobject not specified @@ -2514,6 +2534,42 @@ void Map::ScriptsProcess() go->GetMap()->Add(go); break; } + case SCRIPT_COMMAND_TEMP_SUMMON_CREATURE: + { + if (!step.script->summonCreature.creatureEntry) + { + sLog.outError("SCRIPT_COMMAND_TEMP_SUMMON_CREATURE (script id %u) call for NULL creature.", step.script->id); + break; + } + + if (!source) + { + sLog.outError("SCRIPT_COMMAND_TEMP_SUMMON_CREATURE (script id %u) call for NULL world object.", step.script->id); + break; + } + + if (!source->isType(TYPEMASK_WORLDOBJECT)) + { + sLog.outError("SCRIPT_COMMAND_TEMP_SUMMON_CREATURE (script id %u) call for non-WorldObject (TypeId: %u), skipping.", step.script->id, source->GetTypeId()); + break; + } + + WorldObject* summoner = (WorldObject*)source; + + float x = step.script->x; + float y = step.script->y; + float z = step.script->z; + float o = step.script->o; + + Creature* pCreature = summoner->SummonCreature(step.script->summonCreature.creatureEntry, x, y, z, o, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, step.script->summonCreature.despawnDelay); + if (!pCreature) + { + sLog.outError("SCRIPT_COMMAND_TEMP_SUMMON (script id %u) failed for creature (entry: %u).", step.script->id, step.script->summonCreature.creatureEntry); + break; + } + + break; + } case SCRIPT_COMMAND_OPEN_DOOR: { if (!step.script->openDoor.goGuid) // door not specified @@ -2615,62 +2671,6 @@ void Map::ScriptsProcess() break; } - case SCRIPT_COMMAND_QUEST_EXPLORED: - { - if (!source) - { - sLog.outError("SCRIPT_COMMAND_QUEST_EXPLORED (script id %u) call for NULL source.", step.script->id); - break; - } - - if (!target) - { - sLog.outError("SCRIPT_COMMAND_QUEST_EXPLORED (script id %u) call for NULL target.", step.script->id); - break; - } - - // when script called for item spell casting then target == (unit or GO) and source is player - WorldObject* worldObject; - Player* player; - - if (target->GetTypeId() == TYPEID_PLAYER) - { - if (source->GetTypeId() != TYPEID_UNIT && source->GetTypeId() != TYPEID_GAMEOBJECT && source->GetTypeId() != TYPEID_PLAYER) - { - sLog.outError("SCRIPT_COMMAND_QUEST_EXPLORED (script id %u) call for non-creature, non-gameobject or non-player (TypeId: %u), skipping.", step.script->id, source->GetTypeId()); - break; - } - - worldObject = (WorldObject*)source; - player = (Player*)target; - } - else - { - if (target->GetTypeId() != TYPEID_UNIT && target->GetTypeId() != TYPEID_GAMEOBJECT && target->GetTypeId() != TYPEID_PLAYER) - { - sLog.outError("SCRIPT_COMMAND_QUEST_EXPLORED (script id %u) call for non-creature, non-gameobject or non-player (TypeId: %u), skipping.", step.script->id, target->GetTypeId()); - break; - } - - if (source->GetTypeId() != TYPEID_PLAYER) - { - sLog.outError("SCRIPT_COMMAND_QUEST_EXPLORED (script id %u) call for non-player (TypeId: %u), skipping.", step.script->id, source->GetTypeId()); - break; - } - - worldObject = (WorldObject*)target; - player = (Player*)source; - } - - // quest id and flags checked at script loading - if ((worldObject->GetTypeId() != TYPEID_UNIT || ((Unit*)worldObject)->isAlive()) && - (step.script->questExplored.distance == 0 || worldObject->IsWithinDistInMap(player, float(step.script->questExplored.distance)))) - player->AreaExploredOrEventHappens(step.script->questExplored.questId); - else - player->FailQuest(step.script->questExplored.questId); - - break; - } case SCRIPT_COMMAND_ACTIVATE_OBJECT: { if (!source) diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 41911a943..da1062ff1 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "10497" + #define REVISION_NR "10498" #endif // __REVISION_NR_H__