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;
}
void MissionObjectImplementation::updateMissionLocation() {
	if (getMissionObjective() == NULL || getMissionObjective()->getPlayerOwner() == NULL) {
		return;
	}
	CreatureObject* playerCreature = getMissionObjective()->getPlayerOwner().castTo<CreatureObject*>();
	
	ManagedReference<WaypointObject* > waypointToMission = this->waypointToMission;

	if (playerCreature != NULL && waypointToMission != NULL) {
		MissionObjectDeltaMessage3* dmiso3 = new MissionObjectDeltaMessage3(_this.get());
		dmiso3->updateWaypoint(waypointToMission);
		dmiso3->close();

		playerCreature->sendMessage(dmiso3);

		if (playerCreature->isGrouped() && playerCreature->getGroup() != NULL) {
			GroupObject* group = playerCreature->getGroup();
			group->scheduleUpdateNearestMissionForGroup(playerCreature->getPlanetCRC());
		}
	}
}
void GroupMissionCriticalObjectsBuilder::updateGroupMissionCriticalObjects(CreatureObject & creatureObject, bool const updateGroup)
{
	GroupObject const * const groupObject = creatureObject.getGroup();
	if (groupObject && updateGroup)
	{
		CreatureObject::GroupMissionCriticalObjectSet groupMissionCriticalObjects;
		buildGroupMissionCriticalObjects(*groupObject, groupMissionCriticalObjects);
		GroupMissionCriticalObjectsBuilderNamespace::updateGroupMissionCriticalObjects(*groupObject, groupMissionCriticalObjects);
	}
	else
	{
		CreatureObject::GroupMissionCriticalObjectSet groupMissionCriticalObjects;
		buildGroupMissionCriticalObjects(creatureObject, groupMissionCriticalObjects);
		GroupMissionCriticalObjectsBuilderNamespace::updateGroupMissionCriticalObjects(creatureObject, groupMissionCriticalObjects);
	}
}
Esempio n. 4
0
CreatureObject* ThreatMap::getHighestDamageGroupLeader() {

	Locker locker(&lockMutex);

	VectorMap<uint64,uint32> groupDamageMap;
	int64 highestGroupDmg = 0;

	//Logger::Logger tlog("Threat");

	ManagedReference<CreatureObject*> leaderCreature = NULL;

	for (int i = 0; i < size(); ++i) {
		ThreatMapEntry* entry = &elementAt(i).getValue();

		uint32 totalDamage = entry->getTotalDamage();

		CreatureObject* creature = elementAt(i).getKey();
		//tlog.info("Group id is " + String::valueOf(creature->getGroupID()),true);
		if (creature->isGrouped()) {

			Reference<CreatureObject*> thisleader = creature->getGroup()->getLeader();
			//tlog.info("leader is " + thisleader->getFirstName(),true);

			if (thisleader == NULL || !thisleader->isPlayerCreature())
				break;

			if (!groupDamageMap.contains(creature->getGroupID())) {
				//tlog.info("first dmg for group " + String::valueOf(creature->getGroupID()) + " dmg: " + String::valueOf(totalDamage), true);
				groupDamageMap.put(creature->getGroupID(),totalDamage);

			} else {
				groupDamageMap.get(creature->getGroupID()) += totalDamage;
				//tlog.info("adding to group " + String::valueOf(creature->getGroupID()) + "  dmg total: " + String::valueOf(groupDamageMap.get(creature->getGroupID())) + " this player dmg: " + String::valueOf(totalDamage),true);
			}

			if (groupDamageMap.get(creature->getGroupID()) > highestGroupDmg) {
				highestGroupDmg = groupDamageMap.get(creature->getGroupID());
				leaderCreature = thisleader;
			}
		} else if (creature->isPet()) {
			CreatureObject* owner = creature->getLinkedCreature().get();

			if (owner != NULL && owner->isPlayerCreature()) {
				if (owner->isGrouped()) {
					Reference<CreatureObject*> thisleader = owner->getGroup()->getLeader();

					if (thisleader == NULL || !thisleader->isPlayerCreature())
						break;

					if (!groupDamageMap.contains(owner->getGroupID())) {
						groupDamageMap.put(owner->getGroupID(),totalDamage);
					} else {
						groupDamageMap.get(owner->getGroupID()) += totalDamage;
					}

					if (groupDamageMap.get(owner->getGroupID()) > highestGroupDmg) {
						highestGroupDmg = groupDamageMap.get(owner->getGroupID());
						leaderCreature = thisleader;
					}
				} else {
					if (!groupDamageMap.contains(owner->getObjectID())) {
						groupDamageMap.put(owner->getObjectID(),totalDamage);
					} else {
						groupDamageMap.get(owner->getObjectID()) += totalDamage;
					}

					if (totalDamage > highestGroupDmg) {
						highestGroupDmg = totalDamage;
						leaderCreature = owner;
					}
				}
			}
		} else {
			//tlog.info("adding single creature damage " + String::valueOf(totalDamage),true);
			groupDamageMap.put(creature->getObjectID(),totalDamage);

			if (totalDamage > highestGroupDmg) {
				highestGroupDmg = totalDamage;
				leaderCreature = creature;
			}

		}
	}
	//tlog.info("highest group is " + leaderCreature->getFirstName() + " damage of " + String::valueOf(highestGroupDmg),true);
	return leaderCreature;
}
void EntertainingSessionImplementation::awardEntertainerExperience() {
	ManagedReference<CreatureObject*> entertainer = this->entertainer.get();
	ManagedReference<PlayerManager*> playerManager = entertainer->getZoneServer()->getPlayerManager();

	CreatureObject* player = entertainer->isPlayerCreature() ? cast<CreatureObject*>(entertainer.get()) : NULL;

	if (player != NULL) {
		if (flourishXp > 0 && (isDancing() || isPlayingMusic())) {
			String xptype;

			if (isDancing())
				xptype = "dance";
			else if (isPlayingMusic())
				xptype = "music";

			int groupBonusPercent = 0;
			int groupBonus  = 0;

			if(player->getGroup() != NULL) {

				ManagedReference<GroupObject*> group = player->getGroup();
				int groupSize = group->getGroupSize();

				for(int i = 0; i < groupSize; ++i) {
					ManagedReference<CreatureObject*> groupMember = group->getGroupMember(i)->isPlayerCreature() ? group->getGroupMember(i).castTo<CreatureObject*>() : NULL;

					if (groupMember != NULL) {
						Locker clocker(groupMember, entertainer);

						if (groupMember->isEntertaining() && groupMember->isInRange(entertainer, 40.0f)
								&& groupMember->hasSkill("social_entertainer_novice")) {
							++groupBonusPercent;
						}
					}
				}

				groupBonus = ceil(flourishXp * (groupBonusPercent / 100));

			}

			flourishXp += groupBonus;

			if (playerManager != NULL)
				playerManager->awardExperience(player, xptype, flourishXp, true);

			//flourishXp--;
			flourishXp = 0;
		}

		if (healingXp > 0) {
			String healxptype("entertainer_healing");

			if (playerManager != NULL)
				playerManager->awardExperience(player, healxptype, healingXp, true);

			healingXp = 0;
		}
	}

	healingXp = 0;
	flourishCount = 0;
}
Esempio n. 6
0
void GroupManager::joinGroup(CreatureObject* player) {
	//Pre: player locked
	//Post: player locked
	uint64 inviterID = player->getGroupInviterID();

	Zone* zone = player->getZone();

	if (zone == NULL)
		return;

	ManagedReference<ZoneServer*> server = zone->getZoneServer();
	ManagedReference<SceneObject*> object = server->getObject(inviterID);

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

	CreatureObject* inviter = cast<CreatureObject*>( object.get());
	GroupObject* group = NULL;

	Locker clocker(inviter, player);

	group = inviter->getGroup();

	if (group == NULL) {
		group = createGroup(inviter);

		if (group == NULL)
			return;
	}

	Locker clocker2(group, player);

	if (group->getGroupSize() >= 20) {
		clocker.release();

		player->updateGroupInviterID(0);

		player->sendSystemMessage("The group is full.");
		return;
	}

	// if inviter IS in the group but is not the leader
	if (group->getLeader() != inviter && !playerIsInvitingOwnPet(inviter, player)) {
		player->updateGroupInviterID(0);
		StringIdChatParameter param("group", "prose_leader_changed"); // "%TU has abdicated group leadership to %TT."
		param.setTU( inviter->getDisplayedName() );
		param.setTT( group->getLeader()->getDisplayedName() ) ;
		player->sendSystemMessage(param);

		return;
    }

	player->info("joining group");

	player->updateGroup(group);
	group->addMember(player);

	if (player->isPlayerCreature()) {
		player->sendSystemMessage("@group:joined_self");

		//Inform new member who the Master Looter is.
		if (group->getLootRule() == MASTERLOOTER) {
			StringIdChatParameter masterLooter("group","set_new_master_looter");
			masterLooter.setTT(group->getMasterLooterID());
			player->sendSystemMessage(masterLooter);
		}

		// clear invitee's LFG setting once a group is joined
		Reference<PlayerObject*> ghost = player->getSlottedObject("ghost").castTo<PlayerObject*>();
		if (ghost != NULL)
			ghost->clearCharacterBit(PlayerObject::LFG, true);

		ManagedReference<ChatRoom*> groupChannel = group->getGroupChannel();

		if (groupChannel != NULL) {
			groupChannel->sendTo(cast<CreatureObject*>(player));
			groupChannel->addPlayer(cast<CreatureObject*>(player), false);
		}

		if (player->isPlayingMusic()) {
			ManagedReference<Facade*> facade = player->getActiveSession(SessionFacadeType::ENTERTAINING);
			ManagedReference<EntertainingSession*> session = dynamic_cast<EntertainingSession*> (facade.get());
			if (session != NULL && session->isPlayingMusic()) {
				String song = session->getPerformanceName();
				String bandSong = group->getBandSong();
				if (bandSong == "") {
					Locker locker(group);

					group->setBandSong(song);
				} else {
					if (bandSong != song) {
						player->sendSystemMessage("@performance:music_join_band_stop"); // You must play the same song as the band.
						session->stopPlayingMusic();
					} else {
						player->sendSystemMessage("@performance:music_join_band_self"); // You join with the band in the currently playing song.
					}
				}
			}
		}
	}

	player->updateGroupInviterID(0);
}