本文整理汇总了C++中ManagedReference::broadcastObject方法的典型用法代码示例。如果您正苦于以下问题:C++ ManagedReference::broadcastObject方法的具体用法?C++ ManagedReference::broadcastObject怎么用?C++ ManagedReference::broadcastObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ManagedReference
的用法示例。
在下文中一共展示了ManagedReference::broadcastObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: givePlayerResource
void ResourceManagerImplementation::givePlayerResource(CreatureObject* playerCreature, const String& restype, const int quantity) {
ManagedReference<ResourceSpawn* > spawn = getResourceSpawn(restype);
if(spawn == NULL) {
playerCreature->sendSystemMessage("Selected spawn does not exist.");
return;
}
ManagedReference<SceneObject*> inventory = playerCreature->getSlottedObject("inventory");
if(inventory != NULL && !inventory->isContainerFullRecursive()) {
Locker locker(spawn);
Reference<ResourceContainer*> newResource = spawn->createResource(quantity);
if(newResource != NULL) {
spawn->extractResource("", quantity);
Locker rlocker(newResource);
if (inventory->transferObject(newResource, -1, true)) {
inventory->broadcastObject(newResource, true);
} else {
newResource->destroyObjectFromDatabase(true);
}
}
}
}
示例2: updateHairObject
TangibleObject* ImageDesignManager::updateHairObject(CreatureObject* creo, TangibleObject* hairObject) {
if (creo == NULL)
return NULL;
ManagedReference<TangibleObject*> hair = creo->getSlottedObject("hair").castTo<TangibleObject*>();
if (hair == hairObject) {
return hairObject;
}
if (hair != NULL) {
Locker locker(hair);
hair->destroyObjectFromWorld(true);
hair->destroyObjectFromDatabase(true);
}
if (hairObject == NULL)
return NULL;
// Some race condition in the client prevents both the destroy and transfer from happening too close together
// Without it placing a hair object in the inventory.
ManagedReference<CreatureObject*> strongCreo = creo;
ManagedReference<TangibleObject*> strongHair = hairObject;
Core::getTaskManager()->scheduleTask([strongCreo, strongHair]{
Locker locker(strongCreo);
Locker cLocker(strongCreo, strongHair);
strongCreo->transferObject(strongHair, 4);
strongCreo->broadcastObject(strongHair, true);
}, "TransferHairTask", 100);
return hair;
}
示例3: generationalSample
void DnaManager::generationalSample(PetDeed* deed, CreatureObject* player,int quality) {
// We are making a generational sample rules are a little different.
// Reduce each stat by lets say 10% as the max to be on par with old docs
int cl = deed->getLevel();
int ferocity = 0;
int factor = (int)System::random(quality) - 7;
int reductionAmount = (factor + 15 + quality) ;
int cle = reduceByPercent(deed->getCleverness(),reductionAmount);
int cou = reduceByPercent(deed->getCourage(),reductionAmount);
int dep = reduceByPercent(deed->getDependency(),reductionAmount);
int dex = reduceByPercent(deed->getDexterity(),reductionAmount);
int end = reduceByPercent(deed->getEndurance(),reductionAmount);
int fie = reduceByPercent(deed->getFierceness(),reductionAmount);
int frt = reduceByPercent(deed->getFortitude(),reductionAmount);
int har = reduceByPercent(deed->getHardiness(),reductionAmount);
int ite = reduceByPercent(deed->getIntelligence(),reductionAmount);
int pow = reduceByPercent(deed->getPower(),reductionAmount);
// calculate rest of stats here
ManagedReference<DnaComponent*> prototype = player->getZoneServer()->createObject(qualityTemplates.get(quality), 1).castTo<DnaComponent*>();
if (prototype == NULL) {
return;
}
Locker clocker(prototype);
// Check Here for unique npcs
prototype->setSource(deed->getTemplateName());
prototype->setQuality(quality);
prototype->setLevel(cl);
String serial = player->getZoneServer()->getCraftingManager()->generateSerial();
prototype->setSerialNumber(serial);
prototype->setStats(cle,end,fie,pow,ite,cou,dep,dex,frt,har);
prototype->setStun(deed->getStun());
prototype->setKinetic(deed->getKinetic());
prototype->setEnergy(deed->getEnergy());
prototype->setBlast(deed->getBlast());
prototype->setHeat(deed->getHeat());
prototype->setCold(deed->getCold());
prototype->setElectric(deed->getElectric());
prototype->setAcid(deed->getAcid());
prototype->setSaber(deed->getSaber());
prototype->setRanged(deed->getRanged());
prototype->setArmorRating(deed->getArmor());
prototype->setSpecialAttackOne(deed->getSpecial1());
prototype->setSpecialAttackTwo(deed->getSpecial2());
ManagedReference<SceneObject*> inventory = player->getSlottedObject("inventory");
if (inventory->hasFullContainerObjects()) {
StringIdChatParameter err("survey", "no_inv_space");
player->sendSystemMessage(err);
player->setPosture(CreaturePosture::UPRIGHT, true);
return;
}
Locker locker(inventory);
inventory->transferObject(prototype, -1, true,false);
inventory->broadcastObject(prototype, true);
}
示例4: handleObjectMenuSelect
int SarlaccMenuComponent::handleObjectMenuSelect(SceneObject* sceneObject, CreatureObject* player, byte selectedID) const {
if (selectedID == 20) {
Locker plocker(player, sceneObject);
ManagedReference<SceneObject*> inventory = player->getSlottedObject("inventory");
if (inventory->isContainerFullRecursive()) {
player->sendSystemMessage("@error_message:inv_full"); // Your inventory is full.
return 0;
}
SceneObject* sco = NULL;
for (int i=0; i< inventory->getContainerObjectsSize(); i++) {
sco = inventory->getContainerObject(i);
if (sco == NULL)
continue;
if (sco->getServerObjectCRC() == STRING_HASHCODE("object/tangible/loot/quest/quest_item_sarlacc_bile_jar.iff")) {
player->sendSystemMessage("@mob/sarlacc:bile_already"); // You already have a good sample of bile. It probably isn't wise to risk getting more.
return 0;
}
if (sco->getContainerObjectsSize() > 0) {
for (int j=0; j < sco->getContainerObjectsSize(); j++) {
SceneObject* child = sco->getContainerObject(j);
if (child == NULL)
continue;
if (child->getServerObjectCRC() == STRING_HASHCODE("object/tangible/loot/quest/quest_item_sarlacc_bile_jar.iff")) {
player->sendSystemMessage("@mob/sarlacc:bile_already"); // You already have a good sample of bile. It probably isn't wise to risk getting more.
return 0;
}
}
}
}
if( !player->getCooldownTimerMap()->isPast("extractBileCooldown") ){
player->sendSystemMessage("@mob/sarlacc:bile_fail"); // You fail to find enough bile to collect. You need to wait for more to accumulate.
return 0;
}
Reference<SceneObject*> bileSceno = player->getZoneServer()->createObject(STRING_HASHCODE("object/tangible/loot/quest/quest_item_sarlacc_bile_jar.iff"), 1);
if (bileSceno == NULL)
return 1;
if (inventory->transferObject(bileSceno, -1)) {
inventory->broadcastObject(bileSceno, true);
player->sendSystemMessage("@mob/sarlacc:bile_success"); // Despite being nearly overwhelmed by the stench of decay and the reaching tentacles, you manage to collect a sufficient sample of bile.
player->getCooldownTimerMap()->updateToCurrentAndAddMili("extractBileCooldown", 1000 * 60 * 30); // 30 min cooldown
return 0;
} else {
bileSceno->destroyObjectFromDatabase(true);
return 1;
}
}
return 0;
}
示例5: redeedStructure
int StructureManager::redeedStructure(CreatureObject* creature) {
ManagedReference<DestroyStructureSession*> session = creature->getActiveSession(SessionFacadeType::DESTROYSTRUCTURE).castTo<DestroyStructureSession*>();
if (session == NULL)
return 0;
ManagedReference<StructureObject*> structureObject =
session->getStructureObject();
if (structureObject == NULL)
return 0;
Locker _locker(structureObject);
ManagedReference<StructureDeed*> deed =
server->getObject(
structureObject->getDeedObjectID()).castTo<StructureDeed*>();
int maint = structureObject->getSurplusMaintenance();
int redeedCost = structureObject->getRedeedCost();
if (deed != NULL && structureObject->isRedeedable()) {
Locker _lock(deed, structureObject);
ManagedReference<SceneObject*> inventory = creature->getSlottedObject(
"inventory");
if (inventory == NULL || inventory->isContainerFull()) {
creature->sendSystemMessage("@player_structure:inventory_full"); //This installation can not be redeeded because your inventory does not have room to put the deed.
creature->sendSystemMessage(
"@player_structure:deed_reclaimed_failed"); //Structure destroy and deed reclaimed FAILED!
return session->cancelSession();
} else {
deed->setSurplusMaintenance(maint - redeedCost);
deed->setSurplusPower(structureObject->getSurplusPower());
structureObject->setDeedObjectID(0); //Set this to 0 so the deed doesn't get destroyed with the structure.
destroyStructure(structureObject);
inventory->transferObject(deed, -1, true);
inventory->broadcastObject(deed, true);
creature->sendSystemMessage("@player_structure:deed_reclaimed"); //Structure destroyed and deed reclaimed.
}
} else {
destroyStructure(structureObject);
creature->sendSystemMessage("@player_structure:structure_destroyed"); //Structured destroyed.
}
return session->cancelSession();
}
示例6: setQuantity
void ResourceContainerImplementation::setQuantity(uint32 quantity, bool doNotify, bool ignoreMax) {
Locker _locker(_this.get());
ManagedReference<SceneObject*> parent = getParent();
stackQuantity = quantity;
if(stackQuantity < 1) {
if(parent != NULL) {
/*parent->broadcastDestroy(_this.get(), true);
parent->removeObject(_this.get(), false);*/
//setParent(NULL);
destroyObjectFromWorld(true);
}
destroyObjectFromDatabase(true);
return;
}
int newStackSize = 0;
if (!ignoreMax && stackQuantity > ResourceContainer::MAXSIZE) {
newStackSize = stackQuantity - ResourceContainer::MAXSIZE;
stackQuantity = ResourceContainer::MAXSIZE;
}
if (newStackSize > 0) {
if (parent != NULL) {
ResourceContainer* harvestedResource = spawnObject->createResource(newStackSize);
parent->transferObject(harvestedResource, -1, true);
parent->broadcastObject(harvestedResource, true);
}
}
if(!doNotify)
return;
ResourceContainerObjectDeltaMessage3* rcnod3 =
new ResourceContainerObjectDeltaMessage3(_this.get());
rcnod3->updateQuantity();
rcnod3->close();
broadcastMessage(rcnod3, true);
}
示例7: split
void ResourceContainerImplementation::split(int newStackSize) {
if (getQuantity() <= newStackSize)
return;
if(newStackSize > getQuantity())
newStackSize = getQuantity();
ManagedReference<ResourceContainer*> newResource = spawnObject->createResource(newStackSize);
if(parent == NULL || newResource == NULL || newResource->getSpawnObject() == NULL)
return;
ManagedReference<SceneObject*> sceneParent = cast<SceneObject*>(parent.get().get());
if(sceneParent->transferObject(newResource, -1, true)) {
sceneParent->broadcastObject(newResource, true);
setQuantity(getQuantity() - newStackSize);
} else {
StringBuffer errorMessage;
errorMessage << "Unable to split resource in container type: " << sceneParent->getGameObjectType() << " " << sceneParent->getDisplayedName();
error(errorMessage.toString());
}
}
示例8: generateSample
void DnaManager::generateSample(Creature* creature, CreatureObject* player,int quality){
if (quality < 0 || quality > 7) {
return;
}
Locker lock(creature,player);
CreatureTemplate* creatureTemplate = dynamic_cast<CreatureTemplate*>(creature->getCreatureTemplate());
int ferocity = creatureTemplate->getFerocity();
int cl = creature->getLevel();
int cle = Genetics::hitChanceToValue(creature->getChanceHit(),quality);
int cou = Genetics::meatTypeToValue(creature->getMeatType(),quality);
int dep = Genetics::dietToValue(creature->getDiet(),quality);
int dex = Genetics::hamToValue(creature->getMaxHAM(3),quality);
int end = Genetics::accelerationToValue(creature->getWalkAcceleration(),quality);
int fie = Genetics::ferocityToValue(ferocity,quality);
int frt = Genetics::resistanceToValue(creature->getEffectiveResist(),creature->getArmor(),quality);
int har = Genetics::hamToValue(creature->getMaxHAM(0),quality);
int ite = Genetics::hamToValue(creature->getMaxHAM(6),quality);
int pow = Genetics::damageToValue((creature->getDamageMax() + creature->getDamageMin())/2,quality);
ManagedReference<SceneObject*> inventory = player->getSlottedObject("inventory");
if (inventory->hasFullContainerObjects()) {
StringIdChatParameter err("survey", "no_inv_space");
player->sendSystemMessage(err);
player->setPosture(CreaturePosture::UPRIGHT, true);
return;
}
// We should now have enough to generate a sample
ManagedReference<DnaComponent*> prototype = player->getZoneServer()->createObject(qualityTemplates.get(quality), 1).castTo<DnaComponent*>();
if (prototype == NULL) {
return;
}
Locker clocker(prototype);
// Check Here for unique npcs
StringId* nameId = creature->getObjectName();
if (nameId->getFile().isEmpty() || nameId->getStringID().isEmpty()) {
prototype->setSource(creature->getCreatureName().toString());
} else {
prototype->setSource(nameId->getFullPath());
}
prototype->setQuality(quality);
prototype->setLevel(cl);
String serial = player->getZoneServer()->getCraftingManager()->generateSerial();
prototype->setSerialNumber(serial);
prototype->setStats(cle,end,fie,pow,ite,cou,dep,dex,frt,har);
prototype->setStun(creatureTemplate->getStun());
prototype->setKinetic(creatureTemplate->getKinetic());
prototype->setEnergy(creatureTemplate->getEnergy());
prototype->setBlast(creatureTemplate->getBlast());
prototype->setHeat(creatureTemplate->getHeat());
prototype->setCold(creatureTemplate->getCold());
prototype->setElectric(creatureTemplate->getElectricity());
prototype->setAcid(creatureTemplate->getAcid());
prototype->setSaber(creatureTemplate->getLightSaber());
prototype->setRanged(creatureTemplate->getWeapons().size() > 0);
prototype->setArmorRating(creatureTemplate->getArmor());
if (creatureTemplate->isSpecialProtection(WeaponObject::STUN))
prototype->setSpecialResist(WeaponObject::STUN);
if (creatureTemplate->isSpecialProtection(WeaponObject::KINETIC))
prototype->setSpecialResist(WeaponObject::KINETIC);
if (creatureTemplate->isSpecialProtection(WeaponObject::ENERGY))
prototype->setSpecialResist(WeaponObject::ENERGY);
if (creatureTemplate->isSpecialProtection(WeaponObject::BLAST))
prototype->setSpecialResist(WeaponObject::BLAST);
if (creatureTemplate->isSpecialProtection(WeaponObject::HEAT))
prototype->setSpecialResist(WeaponObject::HEAT);
if (creatureTemplate->isSpecialProtection(WeaponObject::COLD))
prototype->setSpecialResist(WeaponObject::COLD);
if (creatureTemplate->isSpecialProtection(WeaponObject::ELECTRICITY))
prototype->setSpecialResist(WeaponObject::ELECTRICITY);
if (creatureTemplate->isSpecialProtection(WeaponObject::ACID))
prototype->setSpecialResist(WeaponObject::ACID);
if (creatureTemplate->isSpecialProtection(WeaponObject::LIGHTSABER))
prototype->setSpecialResist(WeaponObject::LIGHTSABER);
CreatureAttackMap* attackMap = creatureTemplate->getAttacks();
if (attackMap->size() > 0) {
prototype->setSpecialAttackOne(String(attackMap->getCommand(0)));
if(attackMap->size() > 1) {
prototype->setSpecialAttackTwo(String(attackMap->getCommand(1)));
}
}
Locker locker(inventory);
if (inventory->transferObject(prototype, -1, true, false)) {
inventory->broadcastObject(prototype, true);
} else {
prototype->destroyObjectFromDatabase(true);
}
}
示例9: handleObjectMenuSelect
//.........这里部分代码省略.........
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();
String name = CustomizationIdManager::instance()->getCustomizationVariable(id);
pet->setCustomizationVariable( name, val, true );
}
}
// then this is complete
StringId s;
s.setStringId(pet->getObjectName()->getFullPath());
controlDevice->setControlledObject(pet);
controlDevice->setObjectName(s);
controlDevice->setPetType(PetManager::CREATUREPET);
controlDevice->setMaxVitality(100);
controlDevice->setVitality(100);
controlDevice->setGrowthStage(1);
controlDevice->updateStatus(1);
if (!datapad->transferObject(controlDevice, -1)) {
controlDevice->destroyObjectFromDatabase(true);
return 1;
}
datapad->broadcastObject(controlDevice, true);
controlDevice->growPet(player,true);
controlDevice->callObject(player);
//Remove the deed from it's container.
ManagedReference<SceneObject*> deedContainer = getParent().get();
if (deedContainer != NULL) {
destroyObjectFromWorld(true);
}
generated = true;
player->sendSystemMessage("@pet/pet_menu:device_added"); // "A control device has been added to your datapad."
return 0;
}
return DeedImplementation::handleObjectMenuSelect(player, selectedID);
}
示例10: handleObjectMenuSelect
int PlantObjectImplementation::handleObjectMenuSelect(CreatureObject* player, byte selectedID) {
ManagedReference<SceneObject*> rootParent = getRootParent();
ManagedReference<SceneObject*> parent = getParent();
if (rootParent == NULL || parent == NULL) {
return 0;
}
ManagedReference<BuildingObject*> building = cast<BuildingObject*>( rootParent.get());
if ((building == NULL || !building->isOnAdminList(player) || !parent->isCellObject()) && selectedID >= 69 && selectedID <= 74) {
player->sendSystemMessage("@plant_grow:must_be_in_building"); // The plant must be in a building which you administrate.
return 0;
}
if (selectedID == 69) { // Add Nutrients
sendResourceSUI(player, 1);
} else if (selectedID == 72) { // Add Water
sendResourceSUI(player, 2);
} else if (selectedID == 70) { // Remove Nutrients
nutrientLevel -= 5;
if (nutrientLevel < 0)
nutrientLevel = 0;
player->sendSystemMessage("@plant_grow:remove_nutrients");
} else if (selectedID == 73) { // Remove Water
waterLevel -= 5;
if (waterLevel < 0)
waterLevel = 0;
player->sendSystemMessage("@plant_grow:remove_water");
} else if (selectedID == 74) { // Pick Fruit
if (fruitCount < 1)
return 0;
ManagedReference<SceneObject*> inventory = player->getSlottedObject("inventory");
if(inventory->isContainerFullRecursive()){
player->sendSystemMessage("@plant_grow:no_inventory"); // You do not have any inventory space.
return 0;
}
ZoneServer* zserv = player->getZoneServer();
fruitCount--;
String fruitTemplate = "object/tangible/item/plant/force_melon.iff";
Reference<SceneObject*> fruit = zserv->createObject(fruitTemplate.hashCode(), 1);
if(fruit == NULL) {
return 0;
}
if (!inventory->transferObject(fruit, -1, false, false) ) {
fruit->destroyObjectFromDatabase(true);
return 0;
}
inventory->broadcastObject(fruit, true);
player->sendSystemMessage("@plant_grow:pick_fruit"); // You pick a piece of fruit from the plant.
}
return 1;
}
示例11: createVendor
void CreateVendorSessionImplementation::createVendor(String& name) {
ManagedReference<CreatureObject*> player = this->player.get();
Locker locker(player);
if (!VendorManager::instance()->isValidVendorName(name)) {
player->sendSystemMessage("@player_structure:obscene");
SuiInputBox* input = new SuiInputBox(player, SuiWindowType::STRUCTURE_NAME_VENDOR);
input->setCallback(new NameVendorSuiCallback(player->getZoneServer()));
input->setCancelButton(true, "@cancel");
input->setPromptTitle("@player_structure:name_t");
input->setPromptText("@player_structure:name_d");
player->sendMessage(input->generateMessage());
player->getPlayerObject()->addSuiBox(input);
return;
}
ManagedReference<SceneObject*> inventory = player->getSlottedObject("inventory");
if (inventory == NULL) {
cancelSession();
return;
}
ManagedReference<TangibleObject*> vendor;
try {
vendor = (player->getZoneServer()->createObject(templatePath.hashCode())).castTo<TangibleObject*>();
} catch (Exception& e) {
error(e.getMessage());
}
if (vendor == NULL) {
error("could not create vendor " + templatePath);
cancelSession();
return;
}
Locker clocker(vendor, player);
if (!vendor->isVendor()) {
error("could not create vendor " + templatePath);
vendor->destroyObjectFromDatabase(true);
cancelSession();
return;
}
vendor->createChildObjects();
if (inventory->isContainerFullRecursive()) {
player->sendSystemMessage("@player_structure:create_failed");
vendor->destroyObjectFromDatabase(true);
cancelSession();
return;
}
DataObjectComponentReference* data = vendor->getDataObjectComponent();
if(data == NULL || data->get() == NULL || !data->get()->isVendorData()) {
error("Invalid vendor, no data component: " + templatePath);
player->sendSystemMessage("@player_structure:create_failed");
vendor->destroyObjectFromDatabase(true);
cancelSession();
return;
}
VendorDataComponent* vendorData = cast<VendorDataComponent*>(data->get());
if(vendorData == NULL) {
error("Invalid vendor, no data component: " + templatePath);
player->sendSystemMessage("@player_structure:create_failed");
vendor->destroyObjectFromDatabase(true);
cancelSession();
return ;
}
vendorData->setOwnerId(player->getObjectID());
vendor->setCustomObjectName("Vendor: " + name, false);
vendor->setContainerOwnerID(player->getObjectID());
vendor->setMaxCondition(1000, false);
vendor->setConditionDamage(0, false);
if(vendor->isCreatureObject()) {
randomizeVendorLooks(cast<CreatureObject*>(vendor.get()));
}
if(!inventory->transferObject(vendor, -1, false)) {
player->sendSystemMessage("@player_structure:create_failed");
vendor->destroyObjectFromDatabase(true);
cancelSession();
return;
}
inventory->broadcastObject(vendor, true);
player->getPlayerObject()->addVendor(vendor);
player->sendSystemMessage("@player_structure:create_success");
cancelSession();
}
示例12: handleObjectMenuSelect
int ForceShrineMenuComponent::handleObjectMenuSelect(SceneObject* sceneObject, CreatureObject* creature, byte selectedID) {
if (selectedID != 213)
return 0;
if (creature->getPosture() != CreaturePosture::CROUCHED){
creature->sendSystemMessage("@jedi_trials:show_respect"); // Must show respect
return 0;
}
ManagedReference<PlayerObject*> ghost = creature->getPlayerObject();
if (ghost == NULL)
return 0;
if (creature->getScreenPlayState("VillageJediProgression") && !creature->hasSkill("force_title_jedi_rank_02")){
ManagedReference<SuiMessageBox*> box = new SuiMessageBox(creature, SuiWindowType::NONE);
box->setPromptTitle("@jedi_trials:padawan_trials_title"); // Jedi Trials
box->setPromptText("@jedi_trials:padawan_trials_completed");
ghost->addSuiBox(box);
creature->sendMessage(box->generateMessage());
SkillManager::instance()->awardSkill("force_title_jedi_rank_02", creature, true, true, true);
creature->playEffect("clienteffect/entertainer_dazzle_level_3.cef", ""); // Not sure if it's the right one for this.
PlayMusicMessage* pmm = new PlayMusicMessage("sound/intro.snd");
creature->sendMessage(pmm);
ghost->setJediState(2);
// Trainer number. Pick a random trainer, there are at least 600 in the galaxy.
ZoneServer* zoneServer = ghost->getZoneServer();
int randomZone = System::random(zoneServer->getZoneCount() - 1);
ManagedReference<Zone*> zone = zoneServer->getZone(randomZone);
Vector3 randomTrainer = zone->getCreatureManager()->getRandomJediTrainer();
if ((randomTrainer.getX() == 0) && (randomTrainer.getY() == 0)) { // No trainers on the zone.
ManagedReference<Zone*> zone = zoneServer->getZone(0);
Vector3 randomTrainer = zone->getCreatureManager()->getRandomJediTrainer();
}
Vector3 trainerPositionFinal(randomTrainer.getX(), randomTrainer.getY(), 0);
String zoneName = zone->getZoneName();
ghost->setTrainerCoordinates(trainerPositionFinal);
ghost->setTrainerZoneName(zoneName); // For the Waypoint.
ManagedReference<SceneObject*> inventory = creature->getSlottedObject("inventory");
//Check if inventory is full.
if (inventory->hasFullContainerObjects()) {
creature->sendSystemMessage("@jedi_spam:inventory_full_jedi_robe"); // You have too many items in your inventory. In order to get your Padawan Robe you must clear out at least one free slot.
return 0;
}
ZoneServer* zserv = creature->getZoneServer();
String PadawanRobe = "object/tangible/wearables/robe/robe_jedi_padawan.iff";
ManagedReference<SceneObject*> padawanRobe = zserv->createObject(PadawanRobe.hashCode(), 1);
if (inventory->transferObject(padawanRobe, -1)) {
inventory->broadcastObject(padawanRobe, true);
} else {
padawanRobe->destroyObjectFromDatabase(true);
}
}
else if (!creature->hasSkill("force_title_jedi_novice")){
int rand = System::random(14) + 1;
StringBuffer sysmsg;
sysmsg << "@jedi_trials:force_shrine_wisdom_" << rand;
creature->sendSystemMessage(sysmsg.toString());
}
else if (creature->hasSkill("force_title_jedi_rank_02")){
ManagedReference<SceneObject*> inventory = creature->getSlottedObject("inventory");
//Check if inventory is full.
if (inventory->hasFullContainerObjects()) {
creature->sendSystemMessage("@jedi_spam:inventory_full_jedi_robe"); // You have too many items in your inventory. In order to get your Padawan Robe you must clear out at least one free slot.
return 0;
}
ZoneServer* zserv = creature->getZoneServer();
String PadawanRobe = "object/tangible/wearables/robe/robe_jedi_padawan.iff";
ManagedReference<SceneObject*> padawanRobe = zserv->createObject(PadawanRobe.hashCode(), 1);
if (inventory->transferObject(padawanRobe, -1)) {
inventory->broadcastObject(padawanRobe, true);
} else {
//.........这里部分代码省略.........
示例13: generateSample
void DnaManager::generateSample(Creature* creature, CreatureObject* player,int quality){
if (quality < 0 || quality > 7) {
return;
}
Locker lock(creature,player);
CreatureTemplate* creatureTemplate = dynamic_cast<CreatureTemplate*>(creature->getCreatureTemplate());
int ferocity = creatureTemplate->getFerocity();
int cl = creature->getLevel();
int cle = instance()->generateScoreFor(DnaManager::CLEVERNESS,cl,quality);
int cou = instance()->generateScoreFor(DnaManager::COURAGE,cl,quality);
int dep = instance()->generateScoreFor(DnaManager::DEPENDABILITY,cl,quality);
int dex = instance()->generateScoreFor(DnaManager::DEXTERITY,cl,quality);
int end = instance()->generateScoreFor(DnaManager::ENDURANCE,cl,quality);
int fie = instance()->generateScoreFor(DnaManager::FIERCENESS,ferocity,quality);
int frt = instance()->generateScoreFor(DnaManager::FORTITUDE,cl,quality);
int har = instance()->generateScoreFor(DnaManager::HARDINESS,cl,quality);
int ite = instance()->generateScoreFor(DnaManager::INTELLIGENCE,cl,quality);
int pow = instance()->generateScoreFor(DnaManager::POWER,cl,quality);
// We should now have enough to generate a sample
ManagedReference<DnaComponent*> prototype = player->getZoneServer()->createObject(qualityTemplates.get(quality), 1).castTo<DnaComponent*>();
if (prototype == NULL) {
return;
}
Locker clocker(prototype);
// Check Here for unique npcs
StringId* nameId = creature->getObjectName();
if (nameId->getFile().isEmpty() || nameId->getStringID().isEmpty()) {
prototype->setSource(creature->getCreatureName().toString());
} else {
prototype->setSource(nameId->getFullPath());
}
prototype->setQuality(quality);
prototype->setLevel(cl);
String serial = player->getZoneServer()->getCraftingManager()->generateSerial();
prototype->setSerialNumber(serial);
prototype->setStats(cle,end,fie,pow,ite,cou,dep,dex,frt,har);
prototype->setStun(creatureTemplate->getStun());
prototype->setKinetic(creatureTemplate->getKinetic());
prototype->setEnergy(creatureTemplate->getEnergy());
prototype->setBlast(creatureTemplate->getBlast());
prototype->setHeat(creatureTemplate->getHeat());
prototype->setCold(creatureTemplate->getCold());
prototype->setElectric(creatureTemplate->getElectricity());
prototype->setAcid(creatureTemplate->getAcid());
prototype->setSaber(creatureTemplate->getLightSaber());
prototype->setRanged(creatureTemplate->getWeapons().size() > 0);
prototype->setArmorRating(creatureTemplate->getArmor());
CreatureAttackMap* attackMap = creatureTemplate->getAttacks();
if (attackMap->size() > 0) {
prototype->setSpecialAttackOne(String(attackMap->getCommand(0)));
if(attackMap->size() > 1) {
prototype->setSpecialAttackTwo(String(attackMap->getCommand(1)));
}
}
ManagedReference<SceneObject*> inventory = player->getSlottedObject("inventory");
if (inventory->hasFullContainerObjects()) {
StringIdChatParameter err("survey", "no_inv_space");
player->sendSystemMessage(err);
player->setPosture(CreaturePosture::UPRIGHT, true);
return;
}
Locker locker(inventory);
inventory->transferObject(prototype, -1, true,false);
inventory->broadcastObject(prototype, true);
}
示例14: handleObjectMenuSelect
//.........这里部分代码省略.........
// 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;
HashTableIterator<String, ManagedReference<DroidComponent*> > iterator = modules.iterator();
droid->setResists(0);
droid->setHitChance(0);
for(int i = 0; i < modules.size(); ++i) {
iterator.getNextKeyAndValue(key, comp);
if (comp) {
satchel->transferObject(comp, -1, false);
DataObjectComponentReference* data = comp->getDataObjectComponent();
BaseDroidModuleComponent* module = NULL;
if(data != NULL && data->get() != NULL && data->get()->isDroidModuleData()) {
module = cast<BaseDroidModuleComponent*>(data->get());
module->initialize(droid);
}
}
}
droid->transferObject(craftingComponents, 4, false);
craftingComponents->setSendToClient(false);
}
// Copy color customization from deed to droid
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();
String name = CustomizationIdManager::instance()->getCustomizationVariable(id);
if( name.contains( "color" ) ){
droid->setCustomizationVariable( name, val, true );
}
}
droid->refreshPaint();
}
StringId s;
s.setStringId(droid->getObjectName()->getFullPath());
controlDevice->setObjectName(s);
controlDevice->setPetType(PetManager::DROIDPET);
controlDevice->setMaxVitality(100);
controlDevice->setVitality(100);
droid->createChildObjects();
controlDevice->setControlledObject(droid);
controlDevice->setDefaultCommands();
if (!datapad->transferObject(controlDevice, -1)) {
controlDevice->destroyObjectFromDatabase(true);
return 1;
}
datapad->broadcastObject(controlDevice, true);
controlDevice->callObject(player);
droid->initDroidModules(true);
float maxHam = DroidMechanics::determineHam(overallQuality,species);
for (int i = 0; i < 9; ++i) {
if (i % 3 == 0) {
droid->setBaseHAM(i,maxHam,true);
droid->setHAM(i,maxHam,true);
} else {
droid->setBaseHAM(i,maxHam/100,true);
droid->setHAM(i,maxHam/100,true);
}
}
//Remove the deed from its container.
ManagedReference<SceneObject*> deedContainer = getParent().get();
if (deedContainer != NULL) {
destroyObjectFromWorld(true);
}
generated = true;
destroyObjectFromDatabase(true);
player->sendSystemMessage("@pet/pet_menu:device_added"); // "A control device has been added to your datapad."
return 0;
}
return DeedImplementation::handleObjectMenuSelect(player, selectedID);
}
示例15: redeedStructure
int StructureManager::redeedStructure(CreatureObject* creature) {
ManagedReference<DestroyStructureSession*> session = creature->getActiveSession(SessionFacadeType::DESTROYSTRUCTURE).castTo<DestroyStructureSession*>();
if (session == NULL)
return 0;
ManagedReference<StructureObject*> structureObject =
session->getStructureObject();
if (structureObject == NULL)
return 0;
Locker _locker(structureObject);
ManagedReference<StructureDeed*> deed =
server->getObject(
structureObject->getDeedObjectID()).castTo<StructureDeed*>();
int maint = structureObject->getSurplusMaintenance();
int redeedCost = structureObject->getRedeedCost();
if (deed != NULL && structureObject->isRedeedable()) {
Locker _lock(deed, structureObject);
ManagedReference<SceneObject*> inventory = creature->getSlottedObject(
"inventory");
bool isSelfPoweredHarvester = false;
HarvesterObject* harvester = structureObject.castTo<HarvesterObject*>();
if(harvester != NULL)
isSelfPoweredHarvester = harvester->isSelfPowered();
if (inventory == NULL || inventory->getCountableObjectsRecursive() > (inventory->getContainerVolumeLimit() - (isSelfPoweredHarvester ? 2 : 1))) {
if(isSelfPoweredHarvester) {
//This installation can not be destroyed because there is no room for the Self Powered Harvester Kit in your inventory.
creature->sendSystemMessage("@player_structure:inventory_full_selfpowered");
} else {
//This installation can not be redeeded because your inventory does not have room to put the deed.
creature->sendSystemMessage("@player_structure:inventory_full");
}
creature->sendSystemMessage("@player_structure:deed_reclaimed_failed"); //Structure destroy and deed reclaimed FAILED!
return session->cancelSession();
} else {
if(isSelfPoweredHarvester) {
Reference<SceneObject*> rewardSceno = server->createObject(STRING_HASHCODE("object/tangible/veteran_reward/harvester.iff"), 1);
if( rewardSceno == NULL ){
creature->sendSystemMessage("@player_structure:deed_reclaimed_failed"); //Structure destroy and deed reclaimed FAILED!
return session->cancelSession();
}
// Transfer to player
if( !inventory->transferObject(rewardSceno, -1, false, true) ){ // Allow overflow
creature->sendSystemMessage("@player_structure:deed_reclaimed_failed"); //Structure destroy and deed reclaimed FAILED!
rewardSceno->destroyObjectFromDatabase(true);
return session->cancelSession();
}
harvester->setSelfPowered(false);
inventory->broadcastObject(rewardSceno, true);
creature->sendSystemMessage("@player_structure:selfpowered");
}
deed->setSurplusMaintenance(maint - redeedCost);
deed->setSurplusPower(structureObject->getSurplusPower());
structureObject->setDeedObjectID(0); //Set this to 0 so the deed doesn't get destroyed with the structure.
destroyStructure(structureObject);
inventory->transferObject(deed, -1, true);
inventory->broadcastObject(deed, true);
creature->sendSystemMessage("@player_structure:deed_reclaimed"); //Structure destroyed and deed reclaimed.
}
} else {
destroyStructure(structureObject);
creature->sendSystemMessage("@player_structure:structure_destroyed"); //Structured destroyed.
}
return session->cancelSession();
}