Instructions Jenkins Doxygen

[Changed] baby spawn checks to a consolidated method 47/1747/1
authorIvojedi <ivojedi@swgemu.com>
Fri, 6 Jun 2014 15:53:55 +0000 (08:53 -0700)
committerIvojedi <ivojedi@swgemu.com>
Fri, 6 Jun 2014 15:53:55 +0000 (08:53 -0700)
Change-Id: I0ee283d0cc75786806ecb4c6aa5793828f1a4f4d

MMOCoreORB/src/server/zone/managers/creature/CreatureManager.idl
MMOCoreORB/src/server/zone/managers/creature/CreatureManagerImplementation.cpp
MMOCoreORB/src/server/zone/managers/creature/LairObserverImplementation.cpp
MMOCoreORB/src/server/zone/managers/creature/TheaterSpawnObserverImplementation.cpp
MMOCoreORB/src/server/zone/managers/mission/DestroyMissionLairObserverImplementation.cpp

index 4df4266..9564cf0 100644 (file)
@@ -94,7 +94,9 @@ class CreatureManager extends ZoneManager {
        
        @dereferenced
        public native string getTemplateToSpawn(unsigned int templateCRC);
-       
+
+       public native boolean checkSpawnAsBaby(float tamingChance, int babiesSpawned, int chance);
+
        /**
         * @pre { destructor and destructedObject locked }
         * @post { destructor and destructedObject locked }
index d8eee7b..32f1c16 100644 (file)
@@ -268,6 +268,20 @@ String CreatureManagerImplementation::getTemplateToSpawn(uint32 templateCRC) {
        return templateToSpawn;
 }
 
+bool CreatureManagerImplementation::checkSpawnAsBaby(float tamingChance, int babiesSpawned, int chance) {
+       if (tamingChance > 0) {
+               if (babiesSpawned == 0) {
+                       if (System::random(chance) < (tamingChance * 100.0f)) {
+                               return true;
+                       }
+               } else if (System::random(chance * babiesSpawned) < (tamingChance * 100.0f)) {
+                       return true;
+               }
+       }
+
+       return false;
+}
+
 CreatureObject* CreatureManagerImplementation::spawnCreatureAsBaby(uint32 templateCRC, float x, float z, float y, uint64 parentID) {
        CreatureTemplate* creoTempl = creatureTemplateManager->getTemplate(templateCRC);
 
index 39e6508..5429012 100644 (file)
@@ -326,16 +326,9 @@ bool LairObserverImplementation::checkForNewSpawns(TangibleObject* lair, Tangibl
 
                        ManagedReference<CreatureObject*> creo = NULL;
 
-                       if (tamingChance > 0) {
-                               if (babiesSpawned == 0) {
-                                       if (System::random(500) < (tamingChance * 100.0f)) {
-                                               creo = creatureManager->spawnCreatureAsBaby(templateToSpawn.hashCode(), x, z, y);
-                                               babiesSpawned++;
-                                       }
-                               } else if (System::random(500 * babiesSpawned) < (tamingChance * 100.0f)) {
-                                       creo = creatureManager->spawnCreatureAsBaby(templateToSpawn.hashCode(), x, z, y);
-                                       babiesSpawned++;
-                               }
+                       if (creatureManager->checkSpawnAsBaby(tamingChance, babiesSpawned, 500)) {
+                               creo = creatureManager->spawnCreatureAsBaby(templateToSpawn.hashCode(), x, z, y);
+                               babiesSpawned++;
                        }
 
                        if (creo == NULL)
index 7430f51..216b5ed 100644 (file)
@@ -88,16 +88,9 @@ void TheaterSpawnObserverImplementation::spawnInitialMobiles(TangibleObject* the
 
                        ManagedReference<CreatureObject*> creo = NULL;
 
-                       if (tamingChance > 0) {
-                               if (babiesSpawned == 0) {
-                                       if (System::random(1000) < (tamingChance * 100.0f)) {
-                                               creo = creatureManager->spawnCreatureAsBaby(templateToSpawn.hashCode(), x, z, y);
-                                               babiesSpawned++;
-                                       }
-                               } else if (System::random(1000 * babiesSpawned) < (tamingChance * 100.0f)) {
-                                       creo = creatureManager->spawnCreatureAsBaby(templateToSpawn.hashCode(), x, z, y);
-                                       babiesSpawned++;
-                               }
+                       if (creatureManager->checkSpawnAsBaby(tamingChance, babiesSpawned, 500)) {
+                               creo = creatureManager->spawnCreatureAsBaby(templateToSpawn.hashCode(), x, z, y);
+                               babiesSpawned++;
                        }
 
                        if (creo == NULL)
index 39deb9e..6b42449 100644 (file)
@@ -125,16 +125,9 @@ bool DestroyMissionLairObserverImplementation::checkForNewSpawns(TangibleObject*
 
                        ManagedReference<CreatureObject*> creo = NULL;
 
-                       if (tamingChance > 0) {
-                               if (babiesSpawned == 0) {
-                                       if (System::random(1000) < (tamingChance * 100.0f)) {
-                                               creo = creatureManager->spawnCreatureAsBaby(templateToSpawn.hashCode(), x, z, y);
-                                               babiesSpawned++;
-                                       }
-                               } else if (System::random(1000 * babiesSpawned) < (tamingChance * 100.0f)) {
-                                       creo = creatureManager->spawnCreatureAsBaby(templateToSpawn.hashCode(), x, z, y);
-                                       babiesSpawned++;
-                               }
+                       if (creatureManager->checkSpawnAsBaby(tamingChance, babiesSpawned, 1000)) {
+                               creo = creatureManager->spawnCreatureAsBaby(templateToSpawn.hashCode(), x, z, y);
+                               babiesSpawned++;
                        }
 
                        if (creo == NULL)