本文整理汇总了C++中CreatureObject类的典型用法代码示例。如果您正苦于以下问题:C++ CreatureObject类的具体用法?C++ CreatureObject怎么用?C++ CreatureObject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CreatureObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getPlayerOwner
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();
}
}
}
示例2: sendInputBox
void SuiManager::sendInputBox(SceneObject* terminal, SceneObject* player, const String& play, const String& callback, const String& prompt, const String& button) {
if (terminal == NULL)
return;
if (player == NULL || !player->isCreatureObject())
return;
CreatureObject* creature = cast<CreatureObject*>(player);
PlayerObject* playerObject = creature->getPlayerObject();
if (playerObject != NULL) {
ManagedReference<SuiInputBox*> confirmSui = new SuiInputBox(creature, 0x00);
confirmSui->setCallback(new LuaSuiCallback(creature->getZoneServer(), play, callback));
confirmSui->setUsingObject(terminal);
confirmSui->setPromptText(prompt);
confirmSui->setOkButton(true, button);
confirmSui->setOtherButton(false, "");
confirmSui->setCancelButton(false, "");
confirmSui->setForceCloseDistance(32);
creature->sendMessage(confirmSui->generateMessage());
playerObject->addSuiBox(confirmSui);
}
}
示例3: locker
CreatureObject* ThreatMap::getHighestThreatCreature() {
Locker locker(&lockMutex);
ManagedReference<CreatureObject*> currentThreat = this->currentThreat.get();
if(currentThreat != NULL && !currentThreat->isDead() && !currentThreat->isIncapacitated()
&& !currentThreat->isDestroyed() && !cooldownTimerMap.isPast("doEvaluation"))
return currentThreat;
threatMatrix.clear();
for (int i = 0; i < size(); ++i) {
ThreatMapEntry* entry = &elementAt(i).getValue();
CreatureObject* creature = elementAt(i).getKey();
ManagedReference<CreatureObject*> selfStrong = cast<CreatureObject*>(self.get().get());
if (!creature->isDead() && !creature->isIncapacitated() && creature->isInRange(selfStrong, 128.f) && creature->isAttackableBy(selfStrong))
threatMatrix.add(creature, entry);
}
this->currentThreat = threatMatrix.getLargestThreat();
cooldownTimerMap.updateToCurrentAndAddMili("doEvaluation", ThreatMap::EVALUATIONCOOLDOWN);
return this->currentThreat.get().get();
}
示例4: error
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;
}
if (!object->isCreatureObject()) {
StringBuffer errMsg;
errMsg << "server did not create a creature object wrong template? 0x" << hex << templateCRC;
error(errMsg.toString());
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());
return NULL;
}
return creature;
}
示例5: UNREF
/**
* Sets a creature into the "Flee" state where he runs away from another object.
*
* @param env Java environment
* @param self class calling this function
* @param mob id of creature to access
* @param target target id of creature to flee
*
* @return JNI_TRUE if the creature stopped, or false if there was an error
*/
jboolean JNICALL ScriptMethodsActionStatesNamespace::flee(JNIEnv *env, jobject self, jlong mob, jlong target, jfloat minDistance, jfloat maxDistance)
{
UNREF(self);
if (mob == 0 || target == 0)
return JNI_FALSE;
CreatureObject * object = 0;
AICreatureController * controller = 0;
jboolean result=JNI_FALSE;
if (!JavaLibrary::getObjectController(mob, object, controller))
return result;
NetworkId mobId = object->getNetworkId();
NetworkId targetId(target);
if(mobId == targetId)
{
JavaLibrary::throwInternalScriptError("ScriptMethodsActionStatesNamespace::flee - Creature is trying to flee from itself\n");
return JNI_FALSE;
}
if (controller->flee(NetworkId(target), minDistance, maxDistance))
result = JNI_TRUE;
return result;
}
示例6: getPlayerOwner
int BountyMissionObjectiveImplementation::handleNpcTargetReceivesDamage(ManagedObject* arg1) {
CreatureObject* target = NULL;
target = cast<CreatureObject*>(arg1);
ManagedReference<MissionObject* > mission = this->mission.get();
ManagedReference<CreatureObject*> owner = getPlayerOwner();
if (owner != NULL && target != NULL && target->getFirstName() == owner->getFirstName() &&
target->isPlayerCreature() && objectiveStatus == HASBIOSIGNATURESTATUS) {
updateMissionStatus(mission->getMissionLevel());
String diffString = "easy";
if (mission->getMissionLevel() == 3) {
diffString = "hard";
} else if (mission->getMissionLevel() == 2) {
diffString = "medium";
}
target->getZoneServer()->getChatManager()->broadcastMessage(npcTarget, "@mission/mission_bounty_neutral_" + diffString + ":m" + String::valueOf(mission->getMissionNumber()) + "v", 0, 0, 0);
return 1;
}
return 0;
}
示例7: spawnCreatureAsEventMob
CreatureObject* CreatureManagerImplementation::spawnCreatureAsEventMob(uint32 templateCRC, float x, float z, float y, uint64 parentID) {
CreatureTemplate* creoTempl = creatureTemplateManager->getTemplate(templateCRC);
if (creoTempl == NULL)
return NULL;
CreatureObject* creo = NULL;
String templateToSpawn = getTemplateToSpawn(templateCRC);
uint32 objectCRC = templateToSpawn.hashCode();
creo = createCreature(objectCRC, false, templateCRC);
if (creo != NULL && creo->isAiAgent()) {
AiAgent* creature = cast<AiAgent*>(creo);
creature->loadTemplateData(creoTempl);
UnicodeString eventName;
eventName = creature->getDisplayedName() + " (event)";
creature->setCustomObjectName(eventName, false);
} else if (creo == NULL) {
error("could not spawn template " + templateToSpawn);
}
placeCreature(creo, x, z, y, parentID);
if (creo != NULL && creo->isAiAgent())
cast<AiAgent*>(creo)->activateLoad("");
return creo;
}
示例8: getGroupMember
float GroupObjectImplementation::getGroupHarvestModifier(CreatureObject* player) {
String skillNovice = "outdoors_ranger_novice";
String skillMaster = "outdoors_ranger_master";
float modifier = 1.2f;
for(int i = 0; i < groupMembers.size(); ++i) {
Reference<SceneObject*> scno = getGroupMember(i);
if(scno->isPlayerCreature()) {
CreatureObject* groupMember = cast<CreatureObject*>( scno.get());
if(groupMember == player)
continue;
if(groupMember->hasSkill(skillNovice)) {
if(groupMember->isInRange(player, 64.0f)) {
if(groupMember->hasSkill(skillMaster)) {
modifier = 1.4f;
break;
}
modifier = 1.3f;
}
}
}
}
return modifier;
}
示例9: validate
bool EVState::validate(uint32 &reply1, uint32 &reply2, uint64 targetId, uint32 opcode, ObjectControllerCmdProperties*& cmdProperties)
{
CreatureObject* creature = dynamic_cast<CreatureObject*>(mController->getObject());
if(creature && cmdProperties)
{
//gLogger->log(LogManager::DEBUG, "locomotionMask(%u) & creature->getLocomotion (%u) ==%u",
//cmdProperties->mLocomotionMask,mController->getLocoValidator(creature->states.getLocomotion()), cmdProperties->mLocomotionMask & creature->states.getLocomotion());
// skip over commands with no state requirement and check the rest
if((cmdProperties->mStates != 0) && creature->states.checkStates(cmdProperties->mStates))
{
LOG(info) << "EVState::validate :: states Mask" << cmdProperties->mStates << " creature : " << creature->GetStateBitmask();
reply1 = kCannotDoWhileState;
reply2 = this->mController->getLowestCommonBit(creature->GetStateBitmask(), cmdProperties->mStates);
return false;
}
//command_table.deny_in_locomotion
if (cmdProperties->mLocomotionMask !=0 && ((cmdProperties->mLocomotionMask & creature->states.getLocomotion()) != 0))
{
LOG(info) << "EVState::validate :: Locomotion Mask" << cmdProperties->mLocomotionMask << " creature : " << creature->states.getLocomotion();
reply1 = kCannotDoWhileLocomotion;
reply2 = mController->getPostureValidator(creature->states.getLocomotion());
return false;
}
}
return true;
}
示例10: notifyEnter
void SpawnAreaImplementation::notifyEnter(SceneObject* object) {
if (!(tier & SpawnAreaMap::SPAWNAREA)) {
ActiveAreaImplementation::notifyEnter(object);
return;
}
if (!object->isPlayerCreature())
return;
CreatureObject* creo = cast<CreatureObject*>(object);
if (creo->isInvisible()) {
return;
}
ManagedReference<SceneObject*> parent = object->getParent();
if (parent != NULL && parent->isCellObject())
return;
if (object->getCityRegion() != NULL)
return;
ManagedReference<SpawnArea*> spawnArea = _this.getReferenceUnsafeStaticCast();
ManagedReference<SceneObject*> obj = object;
EXECUTE_TASK_2(spawnArea, obj, {
spawnArea_p->tryToSpawn(obj_p);
});
示例11: notifyPositionUpdate
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.
}
}
}
示例12: lua_tonumber
int LuaSceneObject::getPlayersInRange(lua_State *L) {
int range = lua_tonumber(L, -1);
Zone* thisZone = realObject->getZone();
if (thisZone == NULL) {
lua_pushnil(L);
return 1;
}
lua_newtable(L);
Reference<SortedVector<ManagedReference<QuadTreeEntry*> >*> closeObjects = new SortedVector<ManagedReference<QuadTreeEntry*> >();
thisZone->getInRangeObjects(realObject->getWorldPositionX(), realObject->getWorldPositionY(), range, closeObjects, true);
int numPlayers = 0;
for (int i = 0; i < closeObjects->size(); ++i) {
SceneObject* object = cast<SceneObject*>(closeObjects->get(i).get());
if (object == NULL || !object->isPlayerCreature())
continue;
CreatureObject* player = object->asCreatureObject();
if (player == NULL || player->isInvisible())
continue;
numPlayers++;
lua_pushlightuserdata(L, object);
lua_rawseti(L, -2, numPlayers);
}
return 1;
}
示例13: teleport
void PlayerZoneComponent::teleport(SceneObject* sceneObject, float newPositionX, float newPositionZ, float newPositionY, uint64 parentID) {
//sceneObject->setTeleporting(true);
CreatureObject* player = NULL;
if (sceneObject->isPlayerCreature()) {
player = cast<CreatureObject*>( sceneObject);
}
if (player != NULL && sceneObject->getParent() != NULL && parentID != 0) {
ManagedReference<SceneObject*> par = sceneObject->getParent();
if (par->isVehicleObject() || par->isMount()) {
player->executeObjectControllerAction(String("dismount").hashCode());
}
}
ZoneComponent::teleport(sceneObject, newPositionX, newPositionZ, newPositionY, parentID);
if (player != NULL) {
PlayerObject* ghost = player->getPlayerObject();
ghost->setTeleporting(true);
ghost->updateLastValidatedPosition();
player->setMovementCounter(0);
ghost->setClientLastMovementStamp(0);
}
}
示例14: getGroupMember
void GroupObjectImplementation::calcGroupLevel() {
int highestPlayer = 0;
groupLevel = 0;
for (int i = 0; i < getGroupSize(); i++) {
Reference<SceneObject*> member = getGroupMember(i);
if (member->isPet()) {
CreatureObject* creature = cast<CreatureObject*>(member.get());
groupLevel += creature->getLevel() / 5;
} else if (member->isPlayerCreature()) {
CreatureObject* creature = cast<CreatureObject*>(member.get());
int memberLevel = creature->getLevel();
if (memberLevel > highestPlayer) {
groupLevel += (memberLevel - highestPlayer + (highestPlayer / 5));
highestPlayer = memberLevel;
} else {
groupLevel += memberLevel / 5;
}
}
}
GroupObjectDeltaMessage6* msg = new GroupObjectDeltaMessage6(_this.getReferenceUnsafeStaticCast());
msg->updateLevel(this->groupLevel);
msg->close();
broadcastMessage(msg);
}
示例15: isOnList
bool CellPermissions::isOnList(PermissionList const &permList, CreatureObject const &who) // static
{
const int guildId = who.getGuildId();
// if either their name or their guild is on the list, consider them on the list
for (PermissionList::const_iterator i = permList.begin(); i != permList.end(); ++i)
{
const std::string& name = (*i).getName();
// objectId
if (name == who.getNetworkId().getValueString())
return true;
// first name
if (!_stricmp(name.c_str(), Unicode::wideToNarrow(who.getAssignedObjectFirstName()).c_str()))
return true;
// guilds
if (guildId && !_strnicmp(name.c_str(), "Guild:", 6))
{
std::string checkStr(Unicode::getTrim((name).substr(6)));
if ( !_stricmp(checkStr.c_str(), GuildInterface::getGuildAbbrev(guildId).c_str())
|| !_stricmp(checkStr.c_str(), GuildInterface::getGuildName(guildId).c_str()))
return true;
}
}
return false;
}