void PetManagerImplementation::killPet(TangibleObject* attacker, AiAgent* pet) { StringIdChatParameter stringId; if (attacker->isPlayerCreature()) { stringId.setStringId("base_player", "prose_target_dead"); stringId.setTT(pet->getObjectID()); (cast<CreatureObject*>(attacker))->sendSystemMessage(stringId); } pet->clearDots(); pet->setCurrentSpeed(0); pet->clearCombatState(true); pet->setPosture(CreaturePosture::DEAD, true); pet->updateLocomotion(); pet->setOblivious(); pet->storeFollowObject(); pet->updateTimeOfDeath(); Reference<AiAgent*> petAgent = pet; EXECUTE_TASK_1(petAgent, { Locker locker(petAgent_p); petAgent_p->clearBuffs(false); });
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); }
void VendorDataComponent::performVendorBark(SceneObject* target) { if (isOnStrike()) { return; } ManagedReference<CreatureObject*> vendor = cast<CreatureObject*>(parent.get().get()); if (vendor == NULL) return; ManagedReference<CreatureObject*> player = cast<CreatureObject*>(target); if (player == NULL || !player->isPlayerCreature()) return; resetLastBark(); addBarkTarget(target); EXECUTE_TASK_2(vendor, player, { Locker locker(vendor_p); VendorDataComponent* data = cast<VendorDataComponent*>(vendor_p->getDataObjectComponent()->get()); if (data == NULL) return; vendor_p->faceObject(player_p); vendor_p->updateDirection(Math::deg2rad(vendor_p->getDirectionAngle())); SpatialChat* chatMessage = NULL; String barkMessage = data->getAdPhrase(); if (barkMessage.beginsWith("@")) { StringIdChatParameter message; message.setStringId(barkMessage); message.setTT(player_p->getObjectID()); chatMessage = new SpatialChat(vendor_p->getObjectID(), player_p->getObjectID(), message, player_p->getObjectID(), Races::getMoodID(data->getAdMood()), 0); } else { UnicodeString uniMessage(barkMessage); chatMessage = new SpatialChat(vendor_p->getObjectID(), player_p->getObjectID(), uniMessage, player_p->getObjectID(), Races::getMoodID(data->getAdMood()), 0, 0); } vendor_p->broadcastMessage(chatMessage, true); vendor_p->doAnimation(data->getAdAnimation()); Reference<VendorReturnToPositionTask*> returnTask = new VendorReturnToPositionTask(vendor_p, data->getOriginalDirection()); vendor_p->addPendingTask("vendorreturn", returnTask, 3000); });
void GroupManager::inviteToGroup(CreatureObject* leader, CreatureObject* target) { // Pre: leader locked // Post: player invited to leader's group, leader locked Locker clocker(target, leader); if (target == leader) { leader->sendSystemMessage("@group:invite_no_target_self"); return; } if (leader->isGrouped()) { ManagedReference<GroupObject*> group = leader->getGroup(); if (playerIsInvitingOwnPet(leader, target)) { if (!target->isInRange(leader, 120)) { return; } } else if (group->getLeader() != leader) { leader->sendSystemMessage("@group:must_be_leader"); return; } // can't invite if the group is full if (group->getGroupSize() >= 20) { leader->sendSystemMessage("@group:full"); return; } } if (target->isGrouped()) { StringIdChatParameter stringId; stringId.setStringId("group", "already_grouped"); stringId.setTT(target); leader->sendSystemMessage(stringId); //leader->sendSystemMessage("group", "already_grouped", player->getObjectID()); return; } if (target->getGroupInviterID() == leader->getObjectID()) { StringIdChatParameter stringId; stringId.setStringId("group", "considering_your_group"); stringId.setTT(target); leader->sendSystemMessage(stringId); //leader->sendSystemMessage("group", "considering_your_group", player->getObjectID()); return; } else if (target->getGroupInviterID() != 0) { StringIdChatParameter stringId; stringId.setStringId("group", "considering_other_group"); // %TT is considering joining another group. stringId.setTT(target); leader->sendSystemMessage(stringId); return; } target->updateGroupInviterID(leader->getObjectID()); StringIdChatParameter stringId; stringId.setStringId("group", "invite_leader"); stringId.setTT(target->getDisplayedName()); leader->sendSystemMessage(stringId); if (target->isPlayerCreature()) { stringId.setStringId("group", "invite_target"); stringId.setTT(leader->getDisplayedName()); target->sendSystemMessage(stringId); } else if (target->isPet()) { unsigned long long ownerId = target->getCreatureLinkID(); ManagedReference<CreatureObject*> owner = target->getZoneServer()->getObject(ownerId).castTo<CreatureObject*>(); if (owner != NULL && owner != leader) owner->sendSystemMessage("@pet/pet_menu:pet_invited"); // Your pet has been invited to join your group. joinGroup(target); } }