int ResourceManagerImplementation::notifyObserverEvent(uint32 eventType, Observable* observable, ManagedObject* arg1, int64 arg2) {
	if (eventType == ObserverEventType::POSTURECHANGED) {
		CreatureObject* creature = cast<CreatureObject*>( observable);

		if (creature == NULL) {
			return 0;
		}

		// Cancel Sampling on posture change
		Reference<SampleTask*> task = creature->getPendingTask("sample").castTo<SampleTask*>( );
		Reference<SampleResultsTask*> sampleResultsTask = creature->getPendingTask("sampleresults").castTo<SampleResultsTask*>( );

		if (task != NULL) {

			task->stopSampling();
			//creature->removePendingTask("sample");

			if(sampleResultsTask != NULL) {
				sampleResultsTask->cancel();
				creature->removePendingTask("sampleresults");
			}

			creature->sendSystemMessage("@survey:sample_cancel");
		}

		return 1;
	}

	return 0;
}
void CampSiteActiveAreaImplementation::notifyExit(SceneObject* object) {
	object->dropObserver(ObserverEventType::HEALINGPERFORMED, campObserver);

	if (!object->isPlayerCreature())
		return;

	if (camp == NULL || terminal == NULL)
		return;

	CreatureObject* player = cast<CreatureObject*> (object);

	if (player == NULL)
		return;

	if (camp != NULL)
		camp->removeTemplateSkillMods(player);

	StringIdChatParameter stringID("camp", "prose_camp_exit");
	stringID.setTO(terminal->getDisplayedName());
	player->sendSystemMessage(stringID);

	if(abandoned || object != campOwner)
		return;

	Locker locker(&taskMutex);

	if(!abandoned && abandonTask != NULL && !abandonTask->isScheduled()) {
		try {
			abandonTask->schedule(CampSiteActiveArea::ABANDONTIME);
		} catch (Exception& e) {

		}
	}
}
int LootContainerComponent::notifyObjectRemoved(SceneObject* sceneObject, SceneObject* object, SceneObject* destination) {
	if (destination != NULL) {
		ManagedReference<SceneObject*> rootParent = destination->getParent();

		if (rootParent != NULL && rootParent->isCreatureObject()) {
			CreatureObject* creature = cast<CreatureObject*>(rootParent.get());

			if (creature != NULL) {
				ManagedReference<GroupObject*> group = creature->getGroup();

				if (group != NULL) {
					StringIdChatParameter params("group", "notify_single_loot"); //[GROUP] %TU looted %TO from %TT.
					params.setTO(object->getDisplayedName());
					params.setTU(creature->getDisplayedName());
					params.setTT(sceneObject->getParent().get());

					group->sendSystemMessage(params);
				} else {
					StringIdChatParameter params("base_player", "prose_item_looted_self"); //You looted: %TT.
					params.setTT(object);

					creature->sendSystemMessage(params);
				}
			}
		}
	}

	return 0;
}
예제 #4
0
void GarageZoneComponent::notifyPositionUpdate(SceneObject* sceneObject, QuadTreeEntry* entry) const {
	ManagedReference<SceneObject*> obj = cast<SceneObject*>(entry);

	if (obj == NULL || !obj->isPlayerCreature())
		return;

	GarageDataComponent* data = cast<GarageDataComponent*>(sceneObject->getDataObjectComponent()->get());

	if (data == NULL)
		return;

	uint64 objID = obj->getObjectID();

	float deltaX = sceneObject->getPositionX() - obj->getPositionX();
	float deltaY = sceneObject->getPositionY() - obj->getPositionY();
	float rangeSq = deltaX * deltaX + deltaY * deltaY;

	if (rangeSq > 4096) { // 64^2
		if (data->hasNotifiedPlayer(objID))
			data->removeNotifiedPlayer(objID);

	} else {
		ManagedReference<SceneObject*> rootParent = obj->getRootParent().get();

		if (rootParent == NULL || !rootParent->isVehicleObject())
			return;

		if (!data->hasNotifiedPlayer(objID)) {
			data->addNotifiedPlayer(objID);

			CreatureObject* player = obj->asCreatureObject();
			player->sendSystemMessage("@pet/pet_menu:garage_proximity"); //You have entered into the proximity of a vehicle garage.
		}
	}
}
void BountyMissionObjectiveImplementation::handlePlayerKilled(ManagedObject* arg1) {
	CreatureObject* killer = NULL;

	killer = cast<CreatureObject*>(arg1);

	ManagedReference<MissionObject* > mission = this->mission.get();
	ManagedReference<CreatureObject*> owner = getPlayerOwner();

	if (owner != NULL && killer != NULL) {
		if (owner->getObjectID() == killer->getObjectID()) {
			//Target killed by player, complete mission.
			ZoneServer* zoneServer = owner->getZoneServer();
			if (zoneServer != NULL) {
				ManagedReference<CreatureObject*> target = zoneServer->getObject(mission->getTargetObjectId()).castTo<CreatureObject*>();
				if (target != NULL) {
					VisibilityManager::instance()->clearVisibility(target);
					owner->getZoneServer()->getPlayerManager()->awardExperience(target, "jedi_general", -30000, true);

				}
			}

			complete();
		} else if (mission->getTargetObjectId() == killer->getObjectID() ||
				(npcTarget != NULL && npcTarget->getObjectID() == killer->getObjectID())) {
			//Player killed by target, fail mission.
			owner->sendSystemMessage("@mission/mission_generic:failed"); // Mission failed
			killer->sendSystemMessage("You have defeated a bounty hunter, ruining his mission against you!");
			fail();
		}
	}
}
void CampSiteActiveAreaImplementation::notifyEnter(SceneObject* object) {
	if (!object->isPlayerCreature())
		return;

	if (camp == NULL || terminal == NULL)
		return;

	CreatureObject* player = cast<CreatureObject*> (object);

	if (player == NULL)
		return;

	if (camp != NULL)
		camp->addTemplateSkillMods(player);

	if (campObserver == NULL) {
		campObserver = new CampSiteObserver(_this.get());
		campObserver->deploy();
	}

	if(object == campOwner && !abandoned) {

		Locker locker(&taskMutex);

		if(abandonTask != NULL && abandonTask->isScheduled())
			abandonTask->cancel();

		object->registerObserver(ObserverEventType::STARTCOMBAT, campObserver);

	}

	StringIdChatParameter stringID("camp", "prose_camp_enter");
	stringID.setTO(terminal->getDisplayedName());
	player->sendSystemMessage(stringID);

	player->sendSystemMessage("@camp:sys_camp_heal"); // While in the camp, medics and entertainers can heal your wounds.


	if (object->isPlayerCreature() && !visitors.contains(object->getObjectID()))
		visitors.add(object->getObjectID());


	if (object->isPlayerCreature())
		object->registerObserver(ObserverEventType::HEALINGPERFORMED, campObserver);
}
void GroupObjectImplementation::sendSystemMessage(StringIdChatParameter& param, CreatureObject* excluded) {
	Locker lock(_this.getReferenceUnsafeStaticCast());

	for (int i = 0; i < groupMembers.size(); ++i) {
		CreatureObject* member = groupMembers.get(i).get().get();

		if (!member->isPlayerCreature() || member == excluded)
			continue;

		member->sendSystemMessage(param);
	}
}
void GroupObjectImplementation::sendSystemMessage(const String& fullPath, bool sendLeader) {
	Locker lock(_this.getReferenceUnsafeStaticCast());

	for (int i = 0; i < groupMembers.size(); ++i) {
		CreatureObject* member = groupMembers.get(i).get().get();

		if (!member->isPlayerCreature() || (!sendLeader && member == getLeader()))
			continue;

		member->sendSystemMessage(fullPath);
	}
}
void GroupObjectImplementation::sendSystemMessage(const String& fullPath, bool sendLeader) {
	Locker lock(_this.get());

	for (int i = 0; i < groupMembers.size(); ++i) {
		GroupMember* member = &groupMembers.get(i);

		ManagedReference<SceneObject*> obj = member->get();

		if (obj == NULL || !obj->isPlayerCreature() || (!sendLeader && obj == getLeader()))
			continue;

		CreatureObject* creature = cast<CreatureObject*>(obj.get());
		creature->sendSystemMessage(fullPath);
	}
}
void GroupObjectImplementation::sendSystemMessage(StringIdChatParameter& param, CreatureObject* excluded) {
	Locker lock(_this.getReferenceUnsafeStaticCast());

	for (int i = 0; i < groupMembers.size(); ++i) {
		GroupMember* member = &groupMembers.get(i);

		ManagedReference<SceneObject*> obj = member->get();

		if (obj == NULL || !obj->isPlayerCreature() || obj == excluded)
			continue;

		CreatureObject* creature = cast<CreatureObject*>(obj.get());
		creature->sendSystemMessage(param);
	}
}
void FsVillageAreaImplementation::notifyEnter(SceneObject* player) {
	ActiveAreaImplementation::notifyEnter(player);

	if (!player->isPlayerCreature()) {
		return;
	}

	float x = player->getPositionX();
	float y = player->getPositionY();

	float diffY = y - getPositionY();
	float diffX = x - getPositionX();

	float angle = atan2(diffY == 0.f ? 1 : diffY, diffX == 0.f ? 1 : diffX);

	CreatureObject* playerCreature = cast<CreatureObject*>(player);
	PlayerObject* ghost = playerCreature->getPlayerObject();
	float rad = getRadius() * 1.05;

	float newPosX = getPositionX() + (cos(angle) * rad);
	float newPosY = getPositionY() + (sin(angle) * rad);

	// Those who aren't a valid player, do not currently have or have had the Village elder quest cannot enter.
	if (ghost != NULL) {
		if (ghost->hasGodMode())
			return;

		if (!ghost->hasActiveQuestBitSet(PlayerQuestData::FS_VILLAGE_ELDER) && !ghost->hasCompletedQuestsBitSet(PlayerQuestData::FS_VILLAGE_ELDER)) {
			playerCreature->teleport(newPosX, getZone()->getHeight(newPosX, newPosY), newPosY, 0);
			playerCreature->sendSystemMessage("@base_player:fs_village_unavailable");
		} else if (playerCreature->isInCombat()) {
			playerCreature->teleport(newPosX, getZone()->getHeight(newPosX, newPosY), newPosY, 0);
			playerCreature->sendSystemMessage("@base_player:fs_village_no_combat");
		}
	}
}
void BountyMissionObjectiveImplementation::handlePlayerKilled(ManagedObject* arg1) {
	CreatureObject* killer = NULL;

	killer = cast<CreatureObject*>(arg1);

	ManagedReference<MissionObject* > mission = this->mission.get();
	ManagedReference<CreatureObject*> owner = getPlayerOwner();

	if(mission == NULL)
		return;

	if (owner != NULL && killer != NULL) {
		if (owner->getObjectID() == killer->getObjectID()) {
			//Target killed by player, complete mission.
			ZoneServer* zoneServer = owner->getZoneServer();
			if (zoneServer != NULL) {
				ManagedReference<CreatureObject*> target = zoneServer->getObject(mission->getTargetObjectId()).castTo<CreatureObject*>();
				if (target != NULL) {
					int minXpLoss = -50000;
					int maxXpLoss = -500000;

					VisibilityManager::instance()->clearVisibility(target);
					int xpLoss = mission->getRewardCredits() * -2;

					if (xpLoss > minXpLoss)
						xpLoss = minXpLoss;
					else if (xpLoss < maxXpLoss)
						xpLoss = maxXpLoss;

					owner->getZoneServer()->getPlayerManager()->awardExperience(target, "jedi_general", xpLoss, true);
					StringIdChatParameter message("base_player","prose_revoke_xp");
					message.setDI(xpLoss * -1);
					message.setTO("exp_n", "jedi_general");
					target->sendSystemMessage(message);
				}
			}

			complete();
		} else if (mission->getTargetObjectId() == killer->getObjectID() ||
				(npcTarget != NULL && npcTarget->getObjectID() == killer->getObjectID())) {
			//Player killed by target, fail mission.
			owner->sendSystemMessage("@mission/mission_generic:failed"); // Mission failed
			killer->sendSystemMessage("You have defeated a bounty hunter, ruining his mission against you!");
			fail();
		}
	}
}
예제 #13
0
	void GroupManager::notifyMasterLooter(GroupObject* group) {
		//Pre: group is locked
		//Post: group is locked

		if (group == NULL)
			return;

		StringIdChatParameter notificationLeader("group","new_master_looter"); //"%TU is now the master looter."
		notificationLeader.setTU(group->getMasterLooterID());

		//Send system message to leader.
		CreatureObject* groupLeader = cast<CreatureObject*>(group->getLeader().get());
		groupLeader->sendSystemMessage(notificationLeader);

		//Send system message to members.
		if (group->getLeader()->getObjectID() == group->getMasterLooterID())
			group->sendSystemMessage(notificationLeader, false);
		else {
			StringIdChatParameter notificationOther("group","set_new_master_looter"); //"The Group Leader has set %TT as the master looter."
			notificationOther.setTT(group->getMasterLooterID());
			group->sendSystemMessage(notificationOther, false);
		}

	}
예제 #14
0
void CityRegionImplementation::notifyExit(SceneObject* object) {
	//pre: no 2 different city regions should ever overlap, only 2 Regions of the same city region
	if (object->isTangibleObject()) {
		TangibleObject* tano = cast<TangibleObject*>(object);

		ManagedReference<Region*> activeRegion = tano->getActiveRegion().castTo<Region*>();

		if (activeRegion != NULL) {
			ManagedReference<CityRegion*> city = activeRegion->getCityRegion();

			object->setCityRegion(city);

			if (city == _this.getReferenceUnsafeStaticCast()) // if its the same city we wait till the object exits the last region
				return;
		} else {
			object->setCityRegion(NULL);
		}
	} else {
		object->setCityRegion(NULL);
	}


	if (object->isBazaarTerminal() || object->isVendor()) {
		if (object->isBazaarTerminal())
			bazaars.drop(object->getObjectID());

		AuctionTerminalDataComponent* terminalData = NULL;
		DataObjectComponentReference* data = object->getDataObjectComponent();
		if(data != NULL && data->get() != NULL && data->get()->isAuctionTerminalData())
			terminalData = cast<AuctionTerminalDataComponent*>(data->get());

		if(terminalData != NULL)
			terminalData->updateUID();
	}

	if (object->isPlayerCreature())
		currentPlayers.decrement();

	if (isClientRegion())
		return;

	if (object->isCreatureObject()) {

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

		StringIdChatParameter params("city/city", "city_leave_city"); //You have left %TO.
		params.setTO(getRegionName());

		creature->sendSystemMessage(params);

		removeSpecializationModifiers(creature);
	}

	if (object->isStructureObject()) {
		float x = object->getWorldPositionX();
		float y = object->getWorldPositionY();

		StructureObject* structure = cast<StructureObject*>(object);

		Locker slocker(&structureListMutex);

		if (structure->isBuildingObject()) {

			BuildingObject* building = cast<BuildingObject*>(object);
			uint64 ownerID = structure->getOwnerObjectID();

			ZoneServer* zoneServer = building->getZoneServer();

			if (zoneServer != NULL) {
				ManagedReference<CreatureObject*> owner = zoneServer->getObject(ownerID).castTo<CreatureObject*>();

				if(owner != NULL && owner->isPlayerCreature() && building->isResidence() && isCitizen(ownerID)) {
					CityManager* cityManager = zoneServer->getCityManager();
					cityManager->unregisterCitizen(_this.getReferenceUnsafeStaticCast(), owner);
				}
			}
		}

		completeStructureList.drop(structure->getObjectID());

		if (structure->isCivicStructure()) {
			removeStructure(structure);
		} else if (structure->isCommercialStructure()) {
			removeCommercialStructure(structure);
		}
	}

	if (object->isDecoration() && object->getParent().get() == NULL) {
		removeDecoration(object);
	}
}
예제 #15
0
void CityRegionImplementation::notifyEnter(SceneObject* object) {
	if (object->getCityRegion().get() != _this.getReferenceUnsafeStaticCast() && object->isPlayerCreature())
		currentPlayers.increment();

	object->setCityRegion(_this.getReferenceUnsafeStaticCast());

	if (object->isBazaarTerminal() || object->isVendor()) {

		if (object->isBazaarTerminal())
			bazaars.put(object->getObjectID(), cast<TangibleObject*>(object));

		AuctionTerminalDataComponent* terminalData = NULL;
		DataObjectComponentReference* data = object->getDataObjectComponent();
		if(data != NULL && data->get() != NULL && data->get()->isAuctionTerminalData())
			terminalData = cast<AuctionTerminalDataComponent*>(data->get());

		if(terminalData != NULL)
			terminalData->updateUID();
	}

	if (isClientRegion())
		return;

	if (object->isCreatureObject()) {
		CreatureObject* creature = cast<CreatureObject*>(object);

		StringIdChatParameter params("city/city", "city_enter_city"); //You have entered %TT (%TO).
		params.setTT(getRegionName());

		UnicodeString strRank = StringIdManager::instance()->getStringId(String("@city/city:rank" + String::valueOf(cityRank)).hashCode());

		if (citySpecialization.isEmpty()) {
			params.setTO(strRank);
		}
		else {
			UnicodeString citySpec = StringIdManager::instance()->getStringId(citySpecialization.hashCode());
			params.setTO(strRank + ", " + citySpec);
		}

		creature->sendSystemMessage(params);

		applySpecializationModifiers(creature);
	}

	if (object->isStructureObject()) {
		StructureObject* structure = cast<StructureObject*>(object);
		CityManager* cityManager = getZone()->getZoneServer()->getCityManager();

		Locker slocker(&structureListMutex);

		if (isLoaded() && !completeStructureList.contains(structure->getObjectID()) && structure->getBaseMaintenanceRate() > 0) {
			cityManager->sendAddStructureMails(_this.getReferenceUnsafeStaticCast(), structure);
		}

		if (structure->isBuildingObject()) {

			BuildingObject* building = cast<BuildingObject*>(object);
			uint64 ownerID = structure->getOwnerObjectID();

			ManagedReference<CreatureObject*> owner = zone->getZoneServer()->getObject(ownerID).castTo<CreatureObject*>();

			if(owner != NULL && owner->isPlayerCreature() && building->isResidence() && !isCitizen(ownerID)) {
				cityManager->registerCitizen(_this.getReferenceUnsafeStaticCast(), owner);
			}
		 }

		completeStructureList.put(structure->getObjectID());

		if (structure->isCivicStructure() && !structure->isDecoration()) {
			addStructure(structure);
		} else if (structure->isCommercialStructure()) {
			addCommercialStructure(structure);
		}

		if (registered) {
			zone->registerObjectWithPlanetaryMap(structure);
		}
	}

	if (object->isDecoration() && object->getParent().get() == NULL) {
		addDecoration(object);
	}

	if (registered && cityMissionTerminals.contains(object)) {
		zone->registerObjectWithPlanetaryMap(object);
	}

	if (!registered && citySkillTrainers.contains(object)) {
		zone->unregisterObjectWithPlanetaryMap(object);
	}
}
bool FactionRecruiterContainerComponent::transferObject(SceneObject* sceneObject, SceneObject* object, int containmentType, bool notifyClient, bool allowOverflow) {
	CoaMessageDataComponent* data = object->getDataObjectComponent()->castTo<CoaMessageDataComponent*>();

	if (data == NULL) {
		return false;
	}

	CreatureObject* player = object->getParentRecursively(SceneObjectType::PLAYERCREATURE).get().castTo<CreatureObject*>();

	if (player == NULL) {
		return false;
	}

	ZoneServer* zoneServer = player->getZoneServer();
	PlayerObject* ghost = player->getPlayerObject();

	if (zoneServer == NULL || ghost == NULL) {
		return false;
	}

	if (!sceneObject->isAiAgent()) {
		return false;
	}

	AiAgent* recruiter = cast<AiAgent*>(sceneObject);

	String recruiterFaction = recruiter->getFactionString().toLowerCase();

	bool hasBadge = ghost->hasBadge(Badge::EVENT_PROJECT_DEAD_EYE_1);

	String faction = data->getFaction().toLowerCase();

	StringBuffer response;

	response << "@encoded_disk/message_fragment:response_event";

	if (faction == "rebel") {
		response << "reb1_";
	} else if (faction == "imperial") {
		response << "imp1_";
	}

	response << recruiterFaction;

	ChatManager* chatManager = zoneServer->getChatManager();

	if (chatManager == NULL) {
		return false;
	}

	Locker locker(recruiter);
	chatManager->broadcastMessage(recruiter,response.toString(), 0, 0, 0);

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

	int credits = System::random(500) + 500;
	player->sendSystemMessage("You receive " + String::valueOf(credits) + " credits.");
	player->addCashCredits(credits, true);

	if (!hasBadge) {
		ghost->awardBadge(Badge::EVENT_PROJECT_DEAD_EYE_1);
		ghost->increaseFactionStanding(recruiterFaction, 500);
	}

	return true;
}