From 3f4abe8c95e4d37a84018ca4d478a908fca423ac Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 8 Aug 2013 09:13:13 +0200 Subject: Addeed OnSpawningEntity, OnSpawnedEntity, OnSpawningMonster, OnSpawnedMonster hooks. As requested in FS 418. --- source/World.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'source/World.cpp') diff --git a/source/World.cpp b/source/World.cpp index 699767d5e..6a83da489 100644 --- a/source/World.cpp +++ b/source/World.cpp @@ -2414,14 +2414,24 @@ int cWorld::SpawnMob(double a_PosX, double a_PosY, double a_PosZ, int a_EntityTy default: { - LOGWARNING("cWorld::SpawnMob(): Unhandled entity type: %d. Not spawning.", a_EntityType); + LOGWARNING("%s: Unhandled entity type: %d. Not spawning.", __FUNCTION__, a_EntityType); return -1; } } Monster->SetPosition(a_PosX, a_PosY, a_PosZ); Monster->SetHealth(Monster->GetMaxHealth()); - Monster->Initialize(this); + if (cPluginManager::Get()->CallHookSpawningMonster(*this, *Monster)) + { + delete Monster; + return -1; + } + if (!Monster->Initialize(this)) + { + delete Monster; + return -1; + } BroadcastSpawnEntity(*Monster); + cPluginManager::Get()->CallHookSpawnedMonster(*this, *Monster); return Monster->GetUniqueID(); } -- cgit v1.2.3