Skip to content

Commit

Permalink
[9577] Implement SCRIPT_COMMAND_DESPAWN_SELF (self = creature in this…
Browse files Browse the repository at this point in the history
… context)

Signed-off-by: NoFantasy <nofantasy@nf.no>
  • Loading branch information
NoFantasy committed Mar 12, 2010
1 parent 21b37a9 commit 215f31c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
21 changes: 21 additions & 0 deletions src/game/Map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3506,6 +3506,27 @@ void Map::ScriptsProcess()

break;
}
case SCRIPT_COMMAND_DESPAWN_SELF:
{
if (!target && !source)
{
sLog.outError("SCRIPT_COMMAND_DESPAWN_SELF call for NULL object.");
break;
}

// only creature
if ((!target || target->GetTypeId() != TYPEID_UNIT) && (!source || source->GetTypeId() != TYPEID_UNIT))
{
sLog.outError("SCRIPT_COMMAND_DESPAWN_SELF call for non-creature (TypeIdSource: %u)(TypeIdTarget: %u), skipping.", source ? source->GetTypeId() : 0, target ? target->GetTypeId() : 0);
break;
}

Creature* pCreature = target && target->GetTypeId() == TYPEID_UNIT ? (Creature*)target : (Creature*)source;

pCreature->ForcedDespawn(step.script->datalong);

break;
}
default:
sLog.outError("Unknown script command %u called.",step.script->command);
break;
Expand Down
5 changes: 5 additions & 0 deletions src/game/ObjectMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4386,6 +4386,11 @@ void ObjectMgr::LoadScripts(ScriptMapMap& scripts, char const* tablename)
}
break;
}
case SCRIPT_COMMAND_DESPAWN_SELF:
{
// for later, we might consider despawn by database guid, and define in datalong2 as option to despawn self.
break;
}
}

if (scripts.find(tmp.id) == scripts.end())
Expand Down
1 change: 1 addition & 0 deletions src/game/World.h
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ enum RealmZone
#define SCRIPT_COMMAND_CAST_SPELL 15 // source/target cast spell at target/source (script->datalong2: 0: s->t 1: s->s 2: t->t 3: t->s
#define SCRIPT_COMMAND_PLAY_SOUND 16 // source = any object, target=any/player, datalong (sound_id), datalong2 (bitmask: 0/1=anyone/target, 0/2=with distance dependent, so 1|2 = 3 is target with distance dependent)
#define SCRIPT_COMMAND_CREATE_ITEM 17 // source or target must be player, datalong = item entry, datalong2 = amount
#define SCRIPT_COMMAND_DESPAWN_SELF 18 // source or target must be creature, datalong = despawn delay

/// Storage class for commands issued for delayed execution
struct CliCommandHolder
Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "9576"
#define REVISION_NR "9577"
#endif // __REVISION_NR_H__

0 comments on commit 215f31c

Please sign in to comment.