void PlayerCreationManager::addStartingItems(CreatureObject* creature,
		const String& clientTemplate, bool equipmentOnly) {
	SortedVector < String > *items = NULL;

	if (!defaultCharacterEquipment.contains(clientTemplate))
		items = &defaultCharacterEquipment.get(0);
	else
		items = &defaultCharacterEquipment.get(clientTemplate);

	for (int i = 0; i < items->size(); ++i) {
		String itemTemplate = items->get(i);

		//instance()->info("Add Starting Items: " + itemTemplate, true);

		ManagedReference<SceneObject*> item = zoneServer->createObject(
				itemTemplate.hashCode(), 1);

		if (item != NULL) {
			String error;
			if (creature->canAddObject(item, 4, error) == 0) {
				creature->transferObject(item, 4, false);
			} else {
				item->destroyObjectFromDatabase(true);
			}
		}

	}

	// Get inventory.
	if (!equipmentOnly) {
		SceneObject* inventory = creature->getSlottedObject("inventory");
		if (inventory == NULL) {
			return;
		}

		//Add common starting items.
		for (int itemNumber = 0; itemNumber < commonStartingItems.size();
				itemNumber++) {
			ManagedReference<SceneObject*> item = zoneServer->createObject(
					commonStartingItems.get(itemNumber).hashCode(), 1);
			if (item != NULL) {
				if (!inventory->transferObject(item, -1, false)) {
					item->destroyObjectFromDatabase(true);
				}
			}
		}
	}
}
void PetControlDeviceImplementation::destroyObjectFromDatabase(bool destroyContainedObjects) {
	ManagedReference<TangibleObject*> controlledObject = this->controlledObject.get();

	if (controlledObject != NULL) {
		Locker locker(controlledObject);

		ManagedReference<CreatureObject*> object = controlledObject->getSlottedObject("rider").castTo<CreatureObject*>();

		if (object != NULL) {
			Locker clocker(object, controlledObject);

			object->executeObjectControllerAction(STRING_HASHCODE("dismount"));

			object = controlledObject->getSlottedObject("rider").castTo<CreatureObject*>();

			if (object != NULL) {
				controlledObject->removeObject(object, NULL, true);

				Zone* zone = getZone();

				if (zone != NULL)
					zone->transferObject(object, -1, false);
			}
		}

		controlledObject->destroyObjectFromDatabase(true);
	}

	IntangibleObjectImplementation::destroyObjectFromDatabase(destroyContainedObjects);
}
void CellObjectImplementation::destroyAllPlayerItems() {
	ManagedReference<SceneObject*> strongParent = getParent().get();

	if (strongParent == NULL)
		return;

	int containerSize = getContainerObjectsSize();

	for (int j = containerSize - 1; j >= 0; --j) {
		ReadLocker rlocker(getContainerLock());
		ManagedReference<SceneObject*> containerObject = getContainerObject(j);
		rlocker.release();

		if (strongParent->containsChildObject(containerObject))
			continue;

		if (containerObject->isCreatureObject())
			continue;

		containerObject->destroyObjectFromWorld(true);
		//containerObject->broadcastDestroy(containerObject, false);
		//removeObject(containerObject, false);

		containerObject->destroyObjectFromDatabase(true);
	}
}
void SlicingSessionImplementation::handleUseClamp() {
	ManagedReference<CreatureObject*> player = this->player.get();
	ManagedReference<TangibleObject*> tangibleObject = this->tangibleObject.get();


	if (player == NULL || tangibleObject == NULL)
		return;

	ManagedReference<SceneObject*> inventory = player->getSlottedObject("inventory");

	Locker inventoryLocker(inventory);

	for (int i = 0; i < inventory->getContainerObjectsSize(); ++i) {
		ManagedReference<SceneObject*> sceno = inventory->getContainerObject(i);

		uint32 objType = sceno->getGameObjectType();

		if (objType == SceneObjectType::MOLECULARCLAMP) {
			Locker locker(sceno);
			sceno->destroyObjectFromWorld(true);
			sceno->destroyObjectFromDatabase(true);

			player->sendSystemMessage("@slicing/slicing:used_clamp");
			usedClamp = true;
			return;
		}
	}

	player->sendSystemMessage("@slicing/slicing:no_clamp");
}
bool SlicingSessionImplementation::hasArmorUpgradeKit() {
	ManagedReference<CreatureObject*> player = this->player.get();
	ManagedReference<TangibleObject*> tangibleObject = this->tangibleObject.get();


	if (player == NULL)
		return false;

	ManagedReference<SceneObject*> inventory = player->getSlottedObject("inventory");

	if (inventory == NULL)
		return false;

	for (int i = 0; i < inventory->getContainerObjectsSize(); ++i) {
		ManagedReference<SceneObject*> sceno = inventory->getContainerObject(i);

		uint32 objType = sceno->getGameObjectType();

		if (objType == SceneObjectType::ARMORUPGRADEKIT) {
			Locker locker(sceno);
			sceno->destroyObjectFromWorld(true);
			sceno->destroyObjectFromDatabase(true);
			return true;
		}
	}

	return false;

}
bool CreatureManagerImplementation::createCreatureChildrenObjects(CreatureObject* creature, uint32 templateCRC, bool persistent, uint32 mobileTemplateCRC) {
	if (creature->hasSlotDescriptor("default_weapon")) {

		uint32 defaultWeaponCRC = 0;
		if (creature->isNonPlayerCreatureObject()) {
			defaultWeaponCRC = STRING_HASHCODE("object/weapon/melee/unarmed/unarmed_default.iff");
		} else {
			defaultWeaponCRC = STRING_HASHCODE("object/weapon/creature/creature_default_weapon.iff");
		}
		ManagedReference<SceneObject*> defaultWeapon = zoneServer->createObject(defaultWeaponCRC, persistent);
		ManagedReference<SceneObject*> otherWeapon;

		if(mobileTemplateCRC != 0) {
			CreatureTemplate* creoTempl = creatureTemplateManager->getTemplate(mobileTemplateCRC);

			if(creoTempl != NULL && creoTempl->getDefaultWeapon() != ""){
				uint32 otherWeaponCRC = String(creoTempl->getDefaultWeapon()).hashCode();
				otherWeapon = zoneServer->createObject(otherWeaponCRC, persistent);
			}
		}

		if(otherWeapon != NULL) {
			if (defaultWeapon != NULL && defaultWeapon->isPersistent()) {
				Locker clocker(defaultWeapon, creature);
				defaultWeapon->destroyObjectFromDatabase(true);
			}

			defaultWeapon = otherWeapon;
		}

		if (defaultWeapon == NULL) {
			error("could not create creature default weapon");
			return false;
		}

		Locker clocker(defaultWeapon, creature);

		creature->transferObject(defaultWeapon, 4);
	}

	if (creature->hasSlotDescriptor("inventory")) {
		Reference<SceneObject*> creatureInventory = zoneServer->createObject(STRING_HASHCODE("object/tangible/inventory/creature_inventory.iff"), persistent);

		if (creatureInventory == NULL) {
			error("could not create creature inventory");

			return false;
		}

		Locker clocker(creatureInventory, creature);

		creatureInventory->setContainerDefaultDenyPermission(ContainerPermissions::MOVECONTAINER);
		creatureInventory->setContainerDenyPermission("owner", ContainerPermissions::MOVECONTAINER);
		creatureInventory->setContainerInheritPermissionsFromParent(false);

		creature->transferObject(creatureInventory, 4);
	}

	return true;
}
Reference<SceneObject*> PlanetManagerImplementation::createTicket(const String& departurePoint, const String& arrivalPlanet, const String& arrivalPoint) {
	ManagedReference<SceneObject*> obj = server->getZoneServer()->createObject(STRING_HASHCODE("object/tangible/travel/travel_ticket/base/base_travel_ticket.iff"), 1);

	if (obj == NULL)
		return NULL;

	if (!obj->isTangibleObject()) {
		obj->destroyObjectFromDatabase(true);
		return NULL;
	}

	TangibleObject* tano = cast<TangibleObject*>( obj.get());

	if (!tano->isTicketObject()) {
		tano->destroyObjectFromDatabase(true);
		return NULL;
	}

	TicketObject* ticket = cast<TicketObject*>( tano);
	ticket->setDeparturePlanet(zone->getZoneName());
	ticket->setDeparturePoint(departurePoint);
	ticket->setArrivalPlanet(arrivalPlanet);
	ticket->setArrivalPoint(arrivalPoint);

	return ticket;
}
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());
		}

}
Exemplo n.º 9
0
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;
}
void SceneObjectImplementation::destroyObjectFromDatabase(bool destroyContainedObjects) {
	//info("deleting from database", true);

	if (isPlayerCreature()) {
		assert(0 && "attempting to delete a player creature from database");
	}

	if(dataObjectComponent != NULL) {
		dataObjectComponent->notifyObjectDestroyingFromDatabase();
	}

	ZoneServer* server = getZoneServer();

	server->destroyObjectFromDatabase(getObjectID());

	_this.get()->setPersistent(0);

	if (!destroyContainedObjects)
		return;

	SortedVector<ManagedReference<SceneObject*> > destroyedObjects;
	destroyedObjects.setNoDuplicateInsertPlan();

	for (int i = 0; i < getSlottedObjectsSize(); ++i) {
		ManagedReference<SceneObject*> object = getSlottedObject(i);

		if (destroyedObjects.put(object) != -1)
			object->destroyObjectFromDatabase(true);
	}

	for (int j = 0; j < getContainerObjectsSize(); ++j) {
		ManagedReference<SceneObject*> object = getContainerObject(j);

		if (destroyedObjects.put(object) != -1)
			object->destroyObjectFromDatabase(true);
	}

	//Remove all child objects from database
	for (int i = 0; i < childObjects.size(); ++i) {
		ManagedReference<SceneObject*> child = childObjects.get(i);

		if (child == NULL)
			continue;

		child->destroyObjectFromDatabase(true);
	}
}
int WeaponObjectMenuComponent::handleObjectMenuSelect(SceneObject* sceneObject, CreatureObject* player, byte selectedID) {
    if (!sceneObject->isTangibleObject())
        return 0;

    ManagedReference<WeaponObject*> weapon = cast<WeaponObject*>(sceneObject);
    if(weapon == NULL)
        return 1;

    if(weapon->isASubChildOf(player)) {

        if (selectedID == 69 && player->hasSkill("combat_smuggler_slicing_02")) {
            if (weapon->isSliced()) {
                player->sendSystemMessage("@slicing/slicing:already_sliced");
                return 0;
            }

            ManagedReference<Facade*> facade = player->getActiveSession(SessionFacadeType::SLICING);
            ManagedReference<SlicingSession*> session = dynamic_cast<SlicingSession*>(facade.get());

            if (session != NULL) {
                player->sendSystemMessage("@slicing/slicing:already_slicing");
                return 0;
            }

            //Create Session
            session = new SlicingSession(player);
            session->initalizeSlicingMenu(player, weapon);

            return 0;

        }

        if(selectedID == 70) {

            weapon->repair(player);
            return 1;
        }

        if(selectedID == 71) {

            ManagedReference<PowerupObject*> pup = weapon->removePowerup();
            if(pup == NULL)
                return 1;

            Locker locker(pup);

            pup->destroyObjectFromWorld( true );
            pup->destroyObjectFromDatabase( true );

            StringIdChatParameter message("powerup", "prose_remove_powerup"); //You detach your powerup from %TT.
            message.setTT(weapon->getDisplayedName());
            player->sendSystemMessage(message);

            return 1;
        }
    }

    return TangibleObjectMenuComponent::handleObjectMenuSelect(sceneObject, player, selectedID);
}
bool CreatureManagerImplementation::addWearableItem(CreatureObject* creature, TangibleObject* clothing) {

	if (!clothing->isWearableObject() && !clothing->isWeaponObject())
		return false;

	ChatManager* chatMan = zoneServer->getChatManager();

	SharedTangibleObjectTemplate* tanoData = dynamic_cast<SharedTangibleObjectTemplate*>(clothing->getObjectTemplate());
	Vector<uint32>* races = tanoData->getPlayerRaces();
	String race = creature->getObjectTemplate()->getFullTemplateString();

	if(clothing->isWearableObject()) {
		if (!races->contains(race.hashCode())) {
			UnicodeString message;

			if(creature->getObjectTemplate()->getFullTemplateString().contains("ithorian"))
				message = "@player_structure:wear_not_ithorian";
			else
				message = "@player_structure:wear_no";

			chatMan->broadcastMessage(creature, message, clothing->getObjectID(), creature->getMoodID(), 0);

			return false;
		}
	}

	ManagedReference<SceneObject*> clothingParent = clothing->getParent();

	if (clothingParent == NULL)
		return false;

	for (int i = 0; i < clothing->getArrangementDescriptorSize(); ++i) {
		Vector<String> descriptors = clothing->getArrangementDescriptor(i);

		for (int j = 0; j < descriptors.size(); ++j) {
			ManagedReference<SceneObject*> slot = creature->getSlottedObject(descriptors.get(j));

			if (slot != NULL) {
				slot->destroyObjectFromWorld(true);
				slot->destroyObjectFromDatabase(true);
			}
		}
	}

	creature->transferObject(clothing, 4, false);
	creature->doAnimation("pose_proudly");
	creature->broadcastObject(clothing, true);

	UnicodeString message;
	if(clothing->isWeaponObject())
		message = "@player_structure:wear_yes_weapon";
	else
		message = "@player_structure:wear_yes";

	chatMan->broadcastMessage(creature, message, clothing->getObjectID(), creature->getMoodID(), 0);

	return true;
}
Exemplo n.º 13
0
void PetManagerImplementation::killPet(TangibleObject* attacker, AiAgent* pet) {

	// TODO REMOVE AFTER TESTING
	bool attackerIsAdmin = false;
	// END REMOVE

	StringIdChatParameter stringId;

	if (attacker->isPlayerCreature()) {
		stringId.setStringId("base_player", "prose_target_dead");
		stringId.setTT(pet->getObjectID());
		(cast<CreatureObject*>(attacker))->sendSystemMessage(stringId);

		// TODO REMOVE AFTER TESTING
		//ManagedReference<PlayerObject*> ghost = (cast<CreatureObject*>(attacker))->getPlayerObject();
		//if (ghost != NULL && ghost->isPrivileged())
		//	attackerIsAdmin = true;
		// END REMOVE
	}

	pet->setCurrentSpeed(0);
	pet->clearCombatState(true);
	pet->setPosture(CreaturePosture::DEAD, true);
	pet->updateLocomotion();

	pet->updateTimeOfDeath();
	pet->clearBuffs(false);



	ManagedReference<PetControlDevice*> petControlDevice = pet->getControlDevice().get().castTo<PetControlDevice*>();

	if (petControlDevice != NULL) {

		if (petControlDevice->getPetType() == FACTIONPET) {
			ManagedReference<CreatureObject*> owner = zoneServer->getObject(pet->getCreatureLinkID()).castTo<CreatureObject*>();

			if (owner != NULL)
				petControlDevice->storeObject(owner, true);

			petControlDevice->destroyObjectFromWorld(true);
			petControlDevice->destroyObjectFromDatabase(true);

		} else if ( (!attacker->isPlayerCreature() && !attacker->isPet()) || attackerIsAdmin) { // TODO REMOVE attackerIsAdmin AFTER TESTING

			if (pet->getCooldownTimerMap() != NULL && pet->getCooldownTimerMap()->isPast("vitalityLossCooldown")) {

				petControlDevice->setVitality(petControlDevice->getVitality() - 2);
				pet->getCooldownTimerMap()->updateToCurrentAndAddMili("vitalityLossCooldown", 300000);
			}
		}

	}

	pet->notifyObjectKillObservers(attacker);

}
CreatureObject* CreatureManagerImplementation::createCreature(uint32 templateCRC,  bool persistent, uint32 mobileTemplateCRC) {
	ManagedReference<SceneObject*> object = zoneServer->createObject(templateCRC, persistent);

	if (object == NULL) {
		StringBuffer errMsg;
		errMsg << "could not spawn creature... wrong template? 0x" << hex << templateCRC;

		error(errMsg.toString());

		return NULL;
	}

	Locker locker(object);

	if (!object->isCreatureObject()) {
		StringBuffer errMsg;
		errMsg << "server did not create a creature object wrong template? 0x" << hex << templateCRC;

		error(errMsg.toString());

		if (object->isPersistent()) {
			object->destroyObjectFromDatabase(true);
		}

		return NULL;
	}

	CreatureObject* creature = cast<CreatureObject*>( object.get());

	if (!createCreatureChildrenObjects(creature, templateCRC, creature->isPersistent(), mobileTemplateCRC)) {
		StringBuffer errMsg;
		errMsg << "could not create children objects for creature... 0x" << templateCRC;
		error(errMsg.toString());

		if (object->isPersistent()) {
			object->destroyObjectFromDatabase(true);
		}

		return NULL;
	}

	return creature;
}
Exemplo n.º 15
0
TangibleObject* ImageDesignManager::createHairObject(CreatureObject* imageDesigner, CreatureObject* targetObject, const String& hairTemplate, const String& hairCustomization) {
	Reference<TangibleObject*> oldHair = targetObject->getSlottedObject("hair").castTo<TangibleObject*>();

	HairAssetData* hairAssetData = CustomizationIdManager::instance()->getHairAssetData(hairTemplate);

	if (hairTemplate.isEmpty()) {
		if (!CustomizationIdManager::instance()->canBeBald(getSpeciesGenderString(targetObject)))
			return oldHair;
		else
			return NULL;
	}

	if (hairAssetData == NULL)
		return oldHair;

	int skillMod = hairAssetData->getSkillModValue();

	if (imageDesigner->getSkillMod("hair") < skillMod)
		return oldHair;

	if (hairAssetData->getServerPlayerTemplate() != targetObject->getObjectTemplate()->getFullTemplateString()) {
		error("hair " + hairTemplate + " is not compatible with this creature player " + targetObject->getObjectTemplate()->getFullTemplateString());
		return oldHair;
	}

	ManagedReference<SceneObject*> hair = imageDesigner->getZoneServer()->createObject(hairTemplate.hashCode(), 1);

	//TODO: Validate hairCustomization
	if (hair == NULL || !hair->isTangibleObject()) {
		if (hair != NULL) {
			Locker locker(hair);
			hair->destroyObjectFromDatabase(true);
		}

		return oldHair;
	}

	TangibleObject* tanoHair = cast<TangibleObject*>( hair.get());

	Locker locker(tanoHair);

	tanoHair->setContainerDenyPermission("owner", ContainerPermissions::MOVECONTAINER);
	tanoHair->setContainerDefaultDenyPermission(ContainerPermissions::MOVECONTAINER);

	String appearanceFilename = tanoHair->getObjectTemplate()->getAppearanceFilename();

	CustomizationVariables data;

	data.parseFromClientString(hairCustomization);

	if (validateCustomizationString(&data, appearanceFilename, getSkillLevel(imageDesigner, "hair")))
		tanoHair->setCustomizationString(hairCustomization);

	return tanoHair;
}
Exemplo n.º 16
0
void CityRegionImplementation::destroyActiveAreas() {
	for (int i = 0; i < regions.size(); ++i) {
		ManagedReference<Region*> aa = regions.get(i);

		if (aa != NULL) {
			Locker clocker(aa, _this.getReferenceUnsafeStaticCast());
			aa->destroyObjectFromWorld(false);
			aa->destroyObjectFromDatabase(true);
		}
	}

	regions.removeAll();
}
void DestroyMissionObjectiveImplementation::destroyObjectFromDatabase() {
	MissionObjectiveImplementation::destroyObjectFromDatabase();

	ManagedReference<MissionSpawnActiveArea* > spawnActiveArea = this->spawnActiveArea;

	if (spawnActiveArea != NULL) {
		Locker locker(spawnActiveArea);

		spawnActiveArea->destroyObjectFromWorld(true);
		spawnActiveArea->destroyObjectFromDatabase(true);

		this->spawnActiveArea = NULL;
	}
}
void CityRegionImplementation::removeAllDecorations() {
	Locker slocker(&structureListMutex);

	for (int i = cityDecorations.size() - 1; i >= 0 ; --i) {
		ManagedReference<SceneObject*> dec = cityDecorations.get(i);
		if(dec->isStructureObject()) {
			StructureManager::instance()->destroyStructure(cast<StructureObject*>(dec.get()));
		} else {
			dec->destroyObjectFromWorld(false);
			dec->destroyObjectFromDatabase(true);
		}
	}

	cityDecorations.removeAll();
}
void CreateVendorSessionImplementation::randomizeVendorClothing(CreatureObject* vendor, VendorCreatureTemplate* vendorTempl) {

	String randomOutfit = vendorTempl->getOutfitName(System::random(vendorTempl->getOutfitsSize() -1));
	if (randomOutfit.isEmpty())
		return;

	Reference<Outfit*> outfit = VendorOutfitManager::instance()->getOutfit(randomOutfit);
	if (outfit == NULL)
		return;

	Vector<uint32>* clothing = outfit->getClothing();

	for (int i = 0; i < clothing->size(); ++i) {
		ManagedReference<SceneObject*> obj = player->getZoneServer()->createObject(clothing->get(i), 1);
		if (obj == NULL)
			continue;

		for (int j = 0; j < obj->getArrangementDescriptorSize(); ++j) {
			const Vector<String>* descriptors = obj->getArrangementDescriptor(j);

			for (int k = 0; k < descriptors->size(); ++k) {
				ManagedReference<SceneObject*> slot = vendor->getSlottedObject(descriptors->get(k));

				if (slot != NULL) {
					slot->destroyObjectFromWorld(true);
					slot->destroyObjectFromDatabase(true);
				}
			}
		}

		if (!vendor->transferObject(obj, 4)) {
			obj->destroyObjectFromDatabase(true);
		}
	}

}
Exemplo n.º 20
0
void SceneObjectImplementation::destroyChildObjects() {
	int size = childObjects.size();

	for (int i = 0; i < size; i++) {
		ManagedReference<SceneObject*> child = childObjects.get(0);

		if (child == NULL)
			continue;

		Locker clocker(child, asSceneObject());

		childObjects.drop(child);
		child->destroyObjectFromDatabase(true);
		child->destroyObjectFromWorld(true);
	}
}
void PlayerCreationManager::addRacialMods(CreatureObject* creature,
		const String& race, Vector<String>* startingSkills,
		Vector<String>* startingItems, bool equipmentOnly) {
	Reference<RacialCreationData*> racialData = racialCreationData.get(race);

	if (racialData == NULL)
		racialData = racialCreationData.get(0);

	for (int i = 0; i < 6; i++)  {
		int mod = racialData->getAttributeMod(i) + creature->getBaseHAM(i);
		creature->setBaseHAM(i, mod, false);
		creature->setHAM(i, mod, false);
		creature->setMaxHAM(i, mod, false);
	}

	PlayerObject* ghost = creature->getPlayerObject();
	SkillManager::instance()->awardSkill("combat_marksman_novice",creature, false, true, true);
	SkillManager::instance()->awardSkill("combat_brawler_novice",creature, false, true, true);
	SkillManager::instance()->awardSkill("crafting_artisan_novice",creature, false, true, true);
	SkillManager::instance()->awardSkill("science_medic_novice",creature, false, true, true);
	SkillManager::instance()->awardSkill("social_entertainer_novice",creature, false, true, true);
	SkillManager::instance()->awardSkill("outdoors_scout_novice",creature, false, true, true);
	SkillManager::instance()->addAbility(ghost, "rangedShot", false);
	SkillManager::instance()->addAbility(ghost, "meleeHit", false); //Crappy but works for now.
	// Get inventory.
	if (!equipmentOnly) {
		SceneObject* inventory = creature->getSlottedObject("inventory");
		if (inventory == NULL) {
			return;
		}

		if (startingItems != NULL) {
			for (int i = 0; i < startingItems->size(); ++i) {
				ManagedReference<SceneObject*> item = zoneServer->createObject(
						startingItems->get(i).hashCode(), 1);

				if (item != NULL) {
					if (!inventory->transferObject(item, -1, false)) {
						item->destroyObjectFromDatabase(true);
					}
				}

			}
		}
	}
}
Exemplo n.º 22
0
void PlayerCreationManager::addRacialMods(CreatureObject* creature,
		const String& race, Vector<String>* startingSkills,
		Vector<String>* startingItems, bool equipmentOnly) {
	Reference<RacialCreationData*> racialData = racialCreationData.get(race);

	if (racialData == NULL)
		racialData = racialCreationData.get(0);

	for (int i = 0; i < 9; ++i) {
		int mod = racialData->getAttributeMod(i) + creature->getBaseHAM(i);
		creature->setBaseHAM(i, mod, false);
		creature->setHAM(i, mod, false);
		creature->setMaxHAM(i, mod, false);
	}

	if (startingSkills != NULL) {
		for (int i = 0; i < startingSkills->size(); ++i) {
			SkillManager::instance()->awardSkill(startingSkills->get(i),
					creature, false, true, true);
		}
	}

	// Get inventory.
	if (!equipmentOnly) {
		SceneObject* inventory = creature->getSlottedObject("inventory");
		if (inventory == NULL) {
			return;
		}

		if (startingItems != NULL) {
			for (int i = 0; i < startingItems->size(); ++i) {
				ManagedReference<SceneObject*> item = zoneServer->createObject(
						startingItems->get(i).hashCode(), 1);

				if (item != NULL) {
					if (!inventory->transferObject(item, -1, false)) {
						item->destroyObjectFromDatabase(true);
					}
				}

			}
		}
	}
}
void InstallationObjectImplementation::destroyObjectFromDatabase(bool destroyContainedObjects) {
	StructureObjectImplementation::destroyObjectFromDatabase(destroyContainedObjects);

	if (!destroyContainedObjects)
		return;

	ManagedReference<SceneObject*> deed = getZoneServer()->getObject(deedObjectID);

	if (deed != NULL) {
		Locker locker(deed);
		deed->destroyObjectFromDatabase(true);
	}

	for (int i = 0; i < resourceHopper.size(); ++i) {
		ResourceContainer* container = resourceHopper.get(i);

		Locker locker(container);
		container->destroyObjectFromDatabase(true);
	}
}
void WeaponObjectImplementation::decreasePowerupUses(CreatureObject* player) {
	if (hasPowerup()) {
		powerupObject->decreaseUses();
		if (powerupObject->getUses() < 1) {
			Locker locker(_this.getReferenceUnsafeStaticCast());
			StringIdChatParameter message("powerup", "prose_pup_expire"); //The powerup on your %TT has expired.
			message.setTT(getDisplayedName());

			player->sendSystemMessage(message);

			ManagedReference<PowerupObject*> pup = removePowerup();
			if(pup != NULL) {
				Locker plocker(pup);

				pup->destroyObjectFromWorld( true );
				pup->destroyObjectFromDatabase( true );
			}
		}
		sendAttributeListTo(player);
	}
}
void SlicingSessionImplementation::handleUseFlowAnalyzer() {
	ManagedReference<CreatureObject*> player = this->player.get();
	ManagedReference<TangibleObject*> tangibleObject = this->tangibleObject.get();


	if (player == NULL || tangibleObject == NULL)
		return;

	ManagedReference<SceneObject*> inventory = player->getSlottedObject("inventory");

	Locker inventoryLocker(inventory);

	for (int i = 0; i < inventory->getContainerObjectsSize(); ++i) {
		ManagedReference<SceneObject*> sceno = inventory->getContainerObject(i);

		uint32 objType = sceno->getGameObjectType();

		if (objType == SceneObjectType::FLOWANALYZER) {
			SlicingTool* node = cast<SlicingTool*>( sceno.get());
			nodeCable = node->calculateSuccessRate();

			if (nodeCable) // PASSED
				nodeCable = firstCable;
			else if (nodeCable == firstCable) { // Failed but the cables are Correct
				if (firstCable)
					nodeCable = 0; // Failed - Make the Cable incorrect
			}

			Locker locker(sceno);
			sceno->destroyObjectFromWorld(true);
			sceno->destroyObjectFromDatabase(true);

			player->sendSystemMessage("@slicing/slicing:used_node");
			usedNode = true;
			return;
		}
	}

	player->sendSystemMessage("@slicing/slicing:no_node");
}
Exemplo n.º 26
0
TangibleObject* ImageDesignManager::updateHairObject(CreatureObject* creo, TangibleObject* hairObject) {
	if (creo == NULL)
		return NULL;

	ManagedReference<TangibleObject*> hair = creo->getSlottedObject("hair").castTo<TangibleObject*>();

	if (hair != NULL) {
		Locker locker(hair);
		hair->destroyObjectFromWorld(true);
		hair->destroyObjectFromDatabase(true);
	}

	if (hairObject == NULL)
		return NULL;

	Locker locker(hairObject);

	creo->transferObject(hairObject, 4);
	creo->broadcastObject(hairObject, true);

	return hair;
}
Exemplo n.º 27
0
void CityRegionImplementation::setRadius(float rad) {
	if (regions.size() <= 0)
		return;

	ManagedReference<Region*> oldRegion = regions.get(0).get();

	ManagedReference<Region*> newRegion = addRegion(oldRegion->getPositionX(), oldRegion->getPositionY(), rad, true);

	Locker locker(oldRegion, _this.getReferenceUnsafeStaticCast());

	zone->removeObject(oldRegion, NULL, false);
	regions.drop(oldRegion);
	oldRegion->destroyObjectFromDatabase(true);

	locker.release();

	if (registered) {
		Reference<PlanetMapCategory*> cityCat = TemplateManager::instance()->getPlanetMapCategoryByName("city");

		newRegion->setPlanetMapCategory(cityCat);
		newRegion->getZone()->registerObjectWithPlanetaryMap(newRegion);
	}
}
void FireworkObjectImplementation::destroyObjectFromDatabase(bool destroyContainedObjects) {
	ManagedReference<FireworkObject*> firework = _this.getReferenceUnsafeStaticCast();

	if (firework != NULL && firework->isFireworkObject()) {

		DataObjectComponent* data = firework->getDataObjectComponent()->get();

		if(data != NULL && data->isFireworkShowData()) {
			FireworkShowDataComponent* fireworkShowData = cast<FireworkShowDataComponent*>(data);
			if (fireworkShowData->getTotalFireworkCount() > 0) {
				for (int i=0; i< fireworkShowData->getTotalFireworkCount(); i++) {
					ManagedReference<FireworkObject*> firework = fireworkShowData->getFirework(0);
					fireworkShowData->removeFirework(0);
					if (firework != NULL)
						firework->destroyObjectFromDatabase(false);
				}
			}

		}

	}

	TangibleObjectImplementation::destroyObjectFromDatabase(destroyContainedObjects);
}
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; // 1 highest 7 lowest
	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);

	ManagedReference<SceneObject*> inventory = player->getSlottedObject("inventory");

	if (inventory->hasFullContainerObjects()) {
		StringIdChatParameter err("survey", "no_inv_space");
		player->sendSystemMessage(err);
		player->setPosture(CreaturePosture::UPRIGHT, true);
		return;
	}

	// 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());
	if (deed->isSpecialResist(WeaponObject::STUN))
		prototype->setSpecialResist(WeaponObject::STUN);
	if (deed->isSpecialResist(WeaponObject::KINETIC))
		prototype->setSpecialResist(WeaponObject::KINETIC);
	if (deed->isSpecialResist(WeaponObject::ENERGY))
		prototype->setSpecialResist(WeaponObject::ENERGY);
	if (deed->isSpecialResist(WeaponObject::BLAST))
		prototype->setSpecialResist(WeaponObject::BLAST);
	if (deed->isSpecialResist(WeaponObject::HEAT))
		prototype->setSpecialResist(WeaponObject::HEAT);
	if (deed->isSpecialResist(WeaponObject::COLD))
		prototype->setSpecialResist(WeaponObject::COLD);
	if (deed->isSpecialResist(WeaponObject::ELECTRICITY))
		prototype->setSpecialResist(WeaponObject::ELECTRICITY);
	if (deed->isSpecialResist(WeaponObject::ACID))
		prototype->setSpecialResist(WeaponObject::ACID);
	if (deed->isSpecialResist(WeaponObject::LIGHTSABER))
		prototype->setSpecialResist(WeaponObject::LIGHTSABER);

	Locker locker(inventory);
	if (inventory->transferObject(prototype, -1, true, false)) {
		inventory->broadcastObject(prototype, true);
	} else {
		prototype->destroyObjectFromDatabase(true);
	}

}
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);
	}
}