本文整理汇总了C++中Reference::createCreature方法的典型用法代码示例。如果您正苦于以下问题:C++ Reference::createCreature方法的具体用法?C++ Reference::createCreature怎么用?C++ Reference::createCreature使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Reference
的用法示例。
在下文中一共展示了Reference::createCreature方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleObjectMenuSelect
//.........这里部分代码省略.........
CreatureTemplateManager* creatureTemplateManager = CreatureTemplateManager::instance();
ManagedReference<CreatureTemplate*> petTemplate = creatureTemplateManager->getTemplate( mobileTemplate.hashCode() );
if (petTemplate == NULL) {
player->sendSystemMessage("wrong pet template;mobileTemplate=[" + mobileTemplate + "]" );
return 1;
}
bool isVicious = petTemplate->getPvpBitmask() & CreatureFlag::AGGRESSIVE;
if (level > 10 || isVicious) {
if (!player->hasSkill("outdoors_creaturehandler_novice") || (level > maxLevelofPets)) {
player->sendSystemMessage("@pet/pet_menu:sys_lack_skill"); // You lack the skill to be able to tame that creature.
return 1;
}
if (isVicious && player->getSkillMod("tame_aggro") < 1) {
player->sendSystemMessage("@pet/pet_menu:sys_lack_skill"); // You lack the skill to be able to tame that creature.
return 1;
}
}
// All checks complete, lets setup the control device and do it.
ManagedReference<PetControlDevice*> controlDevice = (server->getZoneServer()->createObject(controlDeviceObjectTemplate.hashCode(), 1)).castTo<PetControlDevice*>();
if (controlDevice == NULL) {
player->sendSystemMessage("wrong pet control device;controlDevice=[" + controlDeviceObjectTemplate + "]" );
return 1;
}
Locker locker(controlDevice);
String templateToSpawn = creatureManager->getTemplateToSpawn(mobileTemplate.hashCode());
ManagedReference<CreatureObject*> creatureObject = creatureManager->createCreature(templateToSpawn.hashCode(), true, 0 );
if( creatureObject == NULL ) {
controlDevice->destroyObjectFromDatabase(true);
player->sendSystemMessage("wrong pet template;mobileTemplate=[" + mobileTemplate + "]" );
return 1;
}
Locker clocker(creatureObject, player);
ManagedReference<Creature*> pet = creatureObject.castTo<Creature*>();
if( pet == NULL ) {
controlDevice->destroyObjectFromDatabase(true);
creatureObject->destroyObjectFromDatabase(true);
player->sendSystemMessage("Internal Pet Deed Error #348" );
return 1;
}
ObjectManager* objectManager = server->getZoneServer()->getObjectManager();
pet->setPetDeed(_this.get());
pet->loadTemplateData( petTemplate );
pet->setCustomObjectName(StringIdManager::instance()->getStringId(*pet->getObjectName()), true);
pet->createChildObjects();
pet->setBaby(false);
// update base stats on the pet now
// We will store the deed pointer to the aiagent before serialization
// Copy color customization from deed to pet
CustomizationVariables* customVars = getCustomizationVariables();
if( customVars != NULL ){
for (int i = 0; i < customVars->size(); ++i) {
uint8 id = customVars->elementAt(i).getKey();
int16 val = customVars->elementAt(i).getValue();
示例2: handleObjectMenuSelect
int DroidDeedImplementation::handleObjectMenuSelect(CreatureObject* player, byte selectedID) {
if (selectedID == 20) {
if (generated || !isASubChildOf(player))
return 1;
if (player->isInCombat() || player->isRidingMount() || player->isSwimming() || player->isDead() || player->isIncapacitated() ){
player->sendSystemMessage("@pet/pet_menu:cant_call"); // "You cannot call this pet right now."
return 1;
}
ManagedReference<SceneObject*> datapad = player->getSlottedObject("datapad");
if (datapad == NULL) {
player->sendSystemMessage("Datapad doesn't exist when trying to generate droid");
return 1;
}
// Check if this will exceed maximum number of droids allowed
ManagedReference<PlayerManager*> playerManager = player->getZoneServer()->getPlayerManager();
int droidsInDatapad = 0;
int maxStoredDroids = playerManager->getBaseStoredDroids();
for (int i = 0; i < datapad->getContainerObjectsSize(); i++) {
Reference<SceneObject*> obj = datapad->getContainerObject(i).castTo<SceneObject*>();
if (obj != NULL && obj->isPetControlDevice() ){
Reference<PetControlDevice*> petDevice = cast<PetControlDevice*>(obj.get());
if( petDevice != NULL && petDevice->getPetType() == PetManager::DROIDPET){
droidsInDatapad++;
}
}
}
if( droidsInDatapad >= maxStoredDroids){
player->sendSystemMessage("You have too many droids in your datapad");
return 1;
}
Reference<CreatureManager*> creatureManager = player->getZone()->getCreatureManager();
if( creatureManager == NULL )
return 1;
CreatureTemplateManager* creatureTemplateManager = CreatureTemplateManager::instance();
Reference<CreatureTemplate*> creatureTemplate = creatureTemplateManager->getTemplate( mobileTemplate.hashCode() );
if( creatureTemplate == NULL ){
player->sendSystemMessage("wrong droid template;mobileTemplate=[" + mobileTemplate + "]" );
return 1;
}
Reference<PetControlDevice*> controlDevice = (server->getZoneServer()->createObject(controlDeviceObjectTemplate.hashCode(), 1)).castTo<PetControlDevice*>();
if( controlDevice == NULL ){
player->sendSystemMessage("wrong droid control device template " + controlDeviceObjectTemplate);
return 1;
}
Locker locker(controlDevice);
Reference<CreatureObject*> creatureObject = creatureManager->createCreature(generatedObjectTemplate.hashCode(), true, mobileTemplate.hashCode() );
if( creatureObject == NULL ){
controlDevice->destroyObjectFromDatabase(true);
player->sendSystemMessage("wrong droid templates;mobileTemplate=[" + mobileTemplate + "];generatedObjectTemplate=[" + generatedObjectTemplate + "]" );
return 1;
}
Locker clocker(creatureObject, player);
Reference<DroidObject*> droid = creatureObject.castTo<DroidObject*>();
if( droid == NULL ) {
controlDevice->destroyObjectFromDatabase(true);
creatureObject->destroyObjectFromDatabase(true);
return 1;
}
droid->loadTemplateData( creatureTemplate );
droid->setCustomObjectName(StringIdManager::instance()->getStringId(*droid->getObjectName()), true);
// Transfer crafting components from deed to droid
ManagedReference<SceneObject*> craftingComponents = getSlottedObject("crafted_components");
if(craftingComponents != NULL) {
SceneObject* satchel = craftingComponents->getContainerObject(0);
// remove all items form satchel and add int he new items
Vector<ManagedReference<SceneObject*> > toRemove;
for (int i = 0; i < satchel->getContainerObjectsSize(); ++i) {
ManagedReference<SceneObject*> sceno = satchel->getContainerObject(i);
if (sceno != NULL) {
toRemove.add(sceno);
}
}
satchel->removeAllContainerObjects();
for(int i=0;i<toRemove.size();i++) {
SceneObject* component = toRemove.get(i);
Locker componenetLocker(component);
component->destroyObjectFromWorld(true);
}
// this will change to use stacked modules. we wont care about non droid modules as they arent needed.
String key;
ManagedReference<DroidComponent*> comp = NULL;
//.........这里部分代码省略.........