本文整理汇总了C++中ZoneServer::createObject方法的典型用法代码示例。如果您正苦于以下问题:C++ ZoneServer::createObject方法的具体用法?C++ ZoneServer::createObject怎么用?C++ ZoneServer::createObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ZoneServer
的用法示例。
在下文中一共展示了ZoneServer::createObject方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createChildObjects
void WeaponObjectImplementation::createChildObjects() {
// Create any child objects in a weapon.
ZoneServer* zoneServer = server->getZoneServer();
for (int i = 0; i < templateObject->getChildObjectsSize(); ++i) {
ChildObject* child = templateObject->getChildObject(i);
if (child == NULL)
continue;
ManagedReference<SceneObject*> obj = zoneServer->createObject(
child->getTemplateFile().hashCode(), getPersistenceLevel());
if (obj == NULL)
continue;
ContainerPermissions* permissions = obj->getContainerPermissions();
permissions->setOwner(getObjectID());
permissions->setInheritPermissionsFromParent(true);
permissions->setDefaultDenyPermission(ContainerPermissions::MOVECONTAINER);
permissions->setDenyPermission("owner", ContainerPermissions::MOVECONTAINER);
if (!transferObject(obj, child->getContainmentType())) {
obj->destroyObjectFromDatabase(true);
continue;
}
childObjects.put(obj);
obj->initializeChildObject(_this.getReferenceUnsafeStaticCast());
}
}
示例2: createItem
void LootkitObjectImplementation::createItem() {
for (int i = 0; i<comps.size(); ++i) {
if (components.get(comps.get(i)) == 0) {
return; // Still missing pieces
}
}
ManagedReference<CreatureObject*> player = getPlayer();
if (player != NULL) {
player->sendSystemMessage("@loot_kit:new_item_created");
ManagedReference<SceneObject*> inventory = player->getSlottedObject("inventory");
ZoneServer* zoneServer = server->getZoneServer();
ManagedReference<SceneObject*> rewardObject = zoneServer->createObject(reward.get(System::random(reward.size()-1)), 2);
Locker clocker(inventory, player);
rewardObject->sendTo(player, true);
if (inventory->transferObject(rewardObject, -1, true)) {
//getParent()->removeObject(_this, true);
destroyObjectFromWorld(true);
if (isPersistent())
destroyObjectFromDatabase(true);
}
}
}
示例3: handleCharacterBuilderSelectItem
//.........这里部分代码省略.........
if (!player->isInCombat()) {
player->sendSystemMessage("You have been cleansed from the signs of previous battles.");
for (int i = 0; i < 9; ++i) {
player->setWounds(i, 0);
}
player->setShockWounds(0);
} else {
player->sendSystemMessage("Not within combat.");
}
} else if (templatePath == "reset_buffs") {
if (!player->isInCombat()) {
player->sendSystemMessage("Your buffs have been reset.");
player->clearBuffs(true);
ghost->setFoodFilling(0);
ghost->setDrinkFilling(0);
} else {
player->sendSystemMessage("Not within combat.");
}
} else if (templatePath.beginsWith("crafting_apron_")) {
//"object/tangible/wearables/apron/apron_chef_s01.iff"
//"object/tangible/wearables/ithorian/apron_chef_jacket_s01_ith.iff"
uint32 itemCrc = ( player->getSpecies() != CreatureObject::ITHORIAN ) ? 0x5DDC4E5D : 0x6C191FBB;
ManagedReference<WearableObject*> apron = zserv->createObject(itemCrc, 2).castTo<WearableObject*>();
if (apron == NULL) {
player->sendSystemMessage("There was an error creating the requested item. Please contact customer support with this issue.");
ghost->addSuiBox(cbSui);
player->sendMessage(cbSui->generateMessage());
error("could not create frog crafting apron");
return;
}
apron->createChildObjects();
if (apron->isWearableObject()) {
uint32 bitmask = apron->getOptionsBitmask() | OptionBitmask::YELLOW;
apron->setOptionsBitmask(bitmask, false);
UnicodeString modName = "(General)";
apron->addSkillMod(SkillModManager::WEARABLE, "general_assembly", 25);
apron->addSkillMod(SkillModManager::WEARABLE, "general_experimentation", 25);
if(templatePath == "crafting_apron_armorsmith") {
modName = "(Armorsmith)";
apron->addSkillMod(SkillModManager::WEARABLE, "armor_assembly", 25);
apron->addSkillMod(SkillModManager::WEARABLE, "armor_experimentation", 25);
apron->addSkillMod(SkillModManager::WEARABLE, "armor_repair", 25);
} else if(templatePath == "crafting_apron_weaponsmith") {
modName = "(Weaponsmith)";
apron->addSkillMod(SkillModManager::WEARABLE, "weapon_assembly", 25);
apron->addSkillMod(SkillModManager::WEARABLE, "weapon_experimentation", 25);
apron->addSkillMod(SkillModManager::WEARABLE, "weapon_repair", 25);
apron->addSkillMod(SkillModManager::WEARABLE, "grenade_assembly", 25);
apron->addSkillMod(SkillModManager::WEARABLE, "grenade_experimentation", 25);
示例4: 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;
}
示例5: 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 {
//.........这里部分代码省略.........
示例6: createChildObjects
void SceneObjectImplementation::createChildObjects() {
if (getZone() == NULL)
return;
ZoneServer* zoneServer = getZone()->getZoneServer();
bool client = isStaticObject();
for (int i = 0; i < templateObject->getChildObjectsSize(); ++i) {
ChildObject* child = templateObject->getChildObject(i);
if (child == NULL)
continue;
ManagedReference<SceneObject*> obj = NULL;
if (client)
obj = zoneServer->createObject(child->getTemplateFile().hashCode(), "clientobjects", getPersistenceLevel());
else
obj = zoneServer->createObject(child->getTemplateFile().hashCode(), getPersistenceLevel());
if (obj == NULL)
continue;
Locker objLocker(obj, asSceneObject());
Vector3 childPosition = child->getPosition();
childObjects.put(obj);
obj->initializePosition(childPosition.getX(), childPosition.getZ(), childPosition.getY());
obj->setDirection(child->getDirection());
if (isBuildingObject() && child->getCellId() >= 0) {
BuildingObject* buildingObject = asBuildingObject();
int totalCells = buildingObject->getTotalCellNumber();
try {
if (totalCells >= child->getCellId()) {
ManagedReference<CellObject*> cellObject = buildingObject->getCell(child->getCellId());
if (cellObject != NULL) {
if (!cellObject->transferObject(obj, child->getContainmentType(), true)) {
obj->destroyObjectFromDatabase(true);
continue;
}
//cellObject->broadcastObject(obj, false);
} else {
error("NULL CELL OBJECT");
obj->destroyObjectFromDatabase(true);
continue;
}
}
} catch (Exception& e) {
error("unreported exception caught in void SceneObjectImplementation::createChildObjects()!");
e.printStackTrace();
}
} else {
//Create the object outdoors in relation to its parent.
Vector3 position;
if (obj->isActiveArea())
position = getWorldPosition();
else
position = getPosition();
float angle = direction.getRadians();
float x = (Math::cos(angle) * childPosition.getX()) + (childPosition.getY() * Math::sin(angle));
float y = (Math::cos(angle) * childPosition.getY()) - (childPosition.getX() * Math::sin(angle));
x += position.getX();
y += position.getY();
float z = position.getZ() + childPosition.getZ();
float degrees = direction.getDegrees();
Quaternion dir = child->getDirection();
obj->initializePosition(x, z, y);
obj->setDirection(dir.rotate(Vector3(0, 1, 0), degrees));
if (obj->isBuildingObject()) {
BuildingObject* building = obj->asBuildingObject();
if (building != NULL) {
building->createCellObjects();
}
}
if (!getZone()->transferObject(obj, -1, false)) {
obj->destroyObjectFromDatabase(true);
continue;
}
}
//childObjects.put(obj);
ContainerPermissions* permissions = obj->getContainerPermissions();
permissions->setOwner(getObjectID());
permissions->setInheritPermissionsFromParent(false);
permissions->setDefaultDenyPermission(ContainerPermissions::MOVECONTAINER);
permissions->setDenyPermission("owner", ContainerPermissions::MOVECONTAINER);
//.........这里部分代码省略.........