本文整理汇总了C++中PlayerObject::getHam方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayerObject::getHam方法的具体用法?C++ PlayerObject::getHam怎么用?C++ PlayerObject::getHam使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerObject
的用法示例。
在下文中一共展示了PlayerObject::getHam方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handlePreCommandExecuteEvent
bool HamService::handlePreCommandExecuteEvent(IEventPtr triggered_event) {
// Cast the IEvent to the PreCommandEvent.
auto pre_event = std::dynamic_pointer_cast<PreCommandExecuteEvent>(triggered_event);
if (!pre_event) {
assert(!"Received an invalid event!");
return false;
}
// This command doesn't exist in the properties map and shouldn't be executed further.
CmdPropertyMap::const_iterator it = command_property_map_.find(pre_event->command_crc());
if (it == command_property_map_.end()) {
return false;
}
// Lookup the creature and ensure it is a valid object.
PlayerObject* object = dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(pre_event->subject()));
if (!object) {
return false;
}
uint32 actioncost = (*it).second->mActionCost;
uint32 healthcost = (*it).second->mHealthCost;
uint32 mindcost = (*it).second->mMindCost;
if (!object->getHam()->checkMainPools(healthcost, actioncost, mindcost)) {
gMessageLib->SendSystemMessage(L"You cannot <insert command> right now.", object); // the stf doesn't work!
return false;
}
object->getHam()->updatePropertyValue(HamBar_Action, HamProperty_CurrentHitpoints, -static_cast<int32>(actioncost), true);
object->getHam()->updatePropertyValue(HamBar_Health, HamProperty_CurrentHitpoints, -static_cast<int32>(healthcost), true);
object->getHam()->updatePropertyValue(HamBar_Mind, HamProperty_CurrentHitpoints, -static_cast<int32>(mindcost), true);
return true;
}
示例2: _handleHealWound
void ObjectController::_handleHealWound(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties)
{
PlayerObject* Medic = dynamic_cast<PlayerObject*>(mObject);
PlayerObject* Target = dynamic_cast<PlayerObject*>(Medic->getHealingTarget(Medic));
std::string messageResponse = gMedicManager->handleMessage(message,"(action|constitution|health|quickness|stamina|strength)");
if (messageResponse.length() == 0)
{
//you must specify a valid wound type
gMessageLib->SendSystemMessage(::common::OutOfBand("healing_response", "healing_response_65"), Medic);
}
else
{
//check Medic has enough Mind
Ham* ham = Medic->getHam();
if(ham->checkMainPools(0, 0, 140))
{
if (gMedicManager->CheckMedicine(Medic, Target, cmdProperties, messageResponse))
{
//call the event
gMedicManager->startWoundTreatmentEvent(Medic);
return;
}
}
else
gMessageLib->SendSystemMessage(::common::OutOfBand("healing_response", "not_enough_mind"), Medic);
}
}
示例3:
void CampRegion::applyHAMHealing(Object* object)
{
PlayerObject* player = dynamic_cast<PlayerObject*>(object);
//Make sure it's a player.
if(player == NULL)
return;
Ham* hamz = player->getHam();
//Heal the Ham
int32 HealthRegenRate = hamz->getHealthRegenRate();
int32 ActionRegenRate = hamz->getActionRegenRate();
int32 MindRegenRate = hamz->getMindRegenRate();
//Because we tick every 2 seconds, we need to double this.
HealthRegenRate += (int32)(HealthRegenRate * mHealingModifier) * 2;
ActionRegenRate += (int32)(ActionRegenRate * mHealingModifier) * 2;
MindRegenRate += (int32)(MindRegenRate * mHealingModifier) * 2;
if(hamz->mHealth.getModifiedHitPoints() - hamz->mHealth.getCurrentHitPoints() > 0)
{
//Regen Health
int32 oldVal = hamz->mHealth.getCurrentHitPoints();
hamz->updatePropertyValue(HamBar_Health,HamProperty_CurrentHitpoints, HealthRegenRate);
mHealingDone += hamz->mHealth.getCurrentHitPoints() - oldVal;
}
if(hamz->mAction.getModifiedHitPoints() - hamz->mAction.getCurrentHitPoints() > 0)
{
//Regen Action
int32 oldVal = hamz->mAction.getCurrentHitPoints();
hamz->updatePropertyValue(HamBar_Action,HamProperty_CurrentHitpoints, ActionRegenRate);
mHealingDone += hamz->mAction.getCurrentHitPoints() - oldVal;
}
if(hamz->mMind.getModifiedHitPoints() - hamz->mMind.getCurrentHitPoints() > 0)
{
//Regen Mind
int32 oldVal = hamz->mMind.getCurrentHitPoints();
hamz->updatePropertyValue(HamBar_Mind, HamProperty_CurrentHitpoints, MindRegenRate);
mHealingDone += hamz->mMind.getCurrentHitPoints() - oldVal;
}
}
示例4: savePlayerSync
void WorldManager::savePlayerSync(uint32 accId,bool remove)
{
PlayerObject* playerObject = getPlayerByAccId(accId);
Ham* ham = playerObject->getHam();
mDatabase->destroyResult(mDatabase->executeSynchSql("UPDATE characters SET parent_id=%"PRIu64",oX=%f,oY=%f,oZ=%f,oW=%f,x=%f,y=%f,z=%f,planet_id=%u WHERE id=%"PRIu64"",playerObject->getParentId()
,playerObject->mDirection.x,playerObject->mDirection.y,playerObject->mDirection.z,playerObject->mDirection.w
,playerObject->mPosition.x,playerObject->mPosition.y,playerObject->mPosition.z
,mZoneId,playerObject->getId()));
mDatabase->destroyResult(mDatabase->executeSynchSql("UPDATE character_attributes SET health_current=%u,action_current=%u,mind_current=%u"
",health_wounds=%u,strength_wounds=%u,constitution_wounds=%u,action_wounds=%u,quickness_wounds=%u"
",stamina_wounds=%u,mind_wounds=%u,focus_wounds=%u,willpower_wounds=%u,battlefatigue=%u,posture=%u,moodId=%u,title=\'%s\'"
",character_flags=%u,states=%"PRIu64",language=%u, group_id=%"PRIu64" WHERE character_id=%"PRIu64"",
ham->mHealth.getCurrentHitPoints() - ham->mHealth.getModifier(), //Llloydyboy Added the -Modifier so that when buffs are reinitialised, it doesn't screw up HAM
ham->mAction.getCurrentHitPoints() - ham->mAction.getModifier(), //Llloydyboy Added the -Modifier so that when buffs are reinitialised, it doesn't screw up HAM
ham->mMind.getCurrentHitPoints() - ham->mMind.getModifier(), //Llloydyboy Added the -Modifier so that when buffs are reinitialised, it doesn't screw up HAM
ham->mHealth.getWounds(),
ham->mStrength.getWounds(),
ham->mConstitution.getWounds(),
ham->mAction.getWounds(),
ham->mQuickness.getWounds(),
ham->mStamina.getWounds(),
ham->mMind.getWounds(),
ham->mFocus.getWounds(),
ham->mWillpower.getWounds(),
ham->getBattleFatigue(),
playerObject->states.getPosture(),
playerObject->getMoodId(),
playerObject->getTitle().getAnsi(),
playerObject->getPlayerFlags(),
playerObject->states.getAction(),
playerObject->getLanguage(),
playerObject->getGroupId(),
playerObject->getId()));
gBuffManager->SaveBuffs(playerObject, GetCurrentGlobalTick());
if(remove)
destroyObject(playerObject);
}
示例5: _handleQuickHeal
void ObjectController::_handleQuickHeal(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties)
{
PlayerObject* Medic = dynamic_cast<PlayerObject*>(mObject);
PlayerObject* Target = dynamic_cast<PlayerObject*>(Medic->getHealingTarget(Medic));
//check Medic has enough Mind
Ham* ham = Medic->getHam();
if(ham->checkMainPools(0, 0, cmdProperties->mMindCost))
{
if (gMedicManager->HealDamage(Medic, Target, 0, cmdProperties, "quickHeal"))
{
ham->updatePropertyValue(HamBar_Focus ,HamProperty_Wounds, 10);
ham->updatePropertyValue(HamBar_Willpower ,HamProperty_Wounds, 10);
ham->updateBattleFatigue(2, true);
//call the event
gMedicManager->startQuickHealInjuryTreatmentEvent(Medic);
return;
}
}
else
gMessageLib->SendSystemMessage(::common::OutOfBand("healing_response", "not_enough_mind"), Medic);
}
示例6: _handleTendWound
void ObjectController::_handleTendWound(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties)
{
PlayerObject* Medic = dynamic_cast<PlayerObject*>(mObject);
PlayerObject* Target = dynamic_cast<PlayerObject*>(Medic->getHealingTarget(Medic));
//TODO:: add medic droid
/*EMLocationType loc = Medic->getPlayerLocation();
if(loc != EMLocation_Cantina || loc != EMLocation_Camp || loc != EMLocation_PlayerStructure)
{
return;
}*/
std::string messageResponse = gMedicManager->handleMessage(message,"(action|constitution|health|quickness|stamina|strength)");
if (messageResponse.length() == 0)
{
//you must specify a valid wound type
gMessageLib->SendSystemMessage(::common::OutOfBand("healing_response", "healing_response_65"), Medic);
}
else
{
//check Medic has enough Mind
Ham* ham = Medic->getHam();
if(ham->checkMainPools(0, 0, 500))
{
if (gMedicManager->HealWound(Medic, Target, 0, cmdProperties, messageResponse + "tendwound"))
{
ham->updatePropertyValue(HamBar_Focus ,HamProperty_Wounds, 5);
ham->updatePropertyValue(HamBar_Willpower ,HamProperty_Wounds, 5);
ham->updateBattleFatigue(2, true);
//call the event
gMedicManager->startWoundTreatmentEvent(Medic);
return;
}
}
else
gMessageLib->SendSystemMessage(::common::OutOfBand("healing_response", "not_enough_mind"), Medic);
}
}
示例7: addObject
bool WorldManager::addObject(Object* object,bool manual)
{
uint64 key = object->getId();
//make sure objects arnt added several times!!!!
if(getObjectById(key))
{
gLogger->logMsgF("WorldManager::addObject Object already existant added several times or ID messup ???",MSG_HIGH);
return false;
}
mObjectMap.insert(key,object);
// if we want to set the parent manually or the object is from the snapshots and not a building, return
if(manual)
{
return true;
}
#if defined(_MSC_VER)
if(object->getId() < 0x0000000100000000 && object->getType() != ObjType_Building)
#else
if(object->getId() < 0x0000000100000000LLU && object->getType() != ObjType_Building)
#endif
{
// check if a crafting station - in that case add
Item* item = dynamic_cast<Item*> (object);
if(item)
{
if(!(item->getItemFamily() == ItemFamily_CraftingStations))
return true;
}
else
{
return true;
}
}
switch(object->getType())
{
// player, when a player enters a planet
case ObjType_Player:
{
PlayerObject* player = dynamic_cast<PlayerObject*>(object);
gLogger->logMsgF("New Player: %"PRIu64", Total Players on zone : %i",MSG_NORMAL,player->getId(),(getPlayerAccMap())->size() + 1);
// insert into the player map
mPlayerAccMap.insert(std::make_pair(player->getAccountId(),player));
// insert into cell
if(player->getParentId())
{
player->setSubZoneId(0);
if(CellObject* cell = dynamic_cast<CellObject*>(getObjectById(player->getParentId())))
{
cell->addObjectSecure(player);
}
else
{
gLogger->logMsgF("WorldManager::addObject: couldn't find cell %"PRIu64"",MSG_HIGH,player->getParentId());
}
}
// query the rtree for the qt region we are in
else
{
if(QTRegion* region = mSpatialIndex->getQTRegion(player->mPosition.x,player->mPosition.z))
{
player->setSubZoneId((uint32)region->getId());
region->mTree->addObject(player);
}
else
{
// we should never get here !
gLogger->logMsg("WorldManager::addObject: could not find zone region in map");
return false;
}
}
// initialize
initObjectsInRange(player);
gMessageLib->sendCreatePlayer(player,player);
// add ham to regeneration scheduler
player->getHam()->updateRegenRates(); // ERU: Note sure if this is needed here.
player->getHam()->checkForRegen();
// onPlayerEntered event, notify scripts
string params;
params.setLength(sprintf(params.getAnsi(),"%s %s %u",getPlanetNameThis(),player->getFirstName().getAnsi(),static_cast<uint32>(mPlayerAccMap.size())));
mWorldScriptsListener.handleScriptEvent("onPlayerEntered",params);
// Start player world position update. Used when player don't get any events from client (player not moving).
// addPlayerMovementUpdateTime(player, 1000);
}
break;
case ObjType_Structure:
//.........这里部分代码省略.........
示例8: handleRequestSurvey
bool ArtisanManager::handleRequestSurvey(Object* playerObject,Object* target,Message* message,ObjectControllerCmdProperties* cmdProperties)
{
PlayerObject* player = dynamic_cast<PlayerObject*>(playerObject);
std::shared_ptr<SimpleEvent> start_survey_event = nullptr;
if(cmdProperties)
mSurveyMindCost = cmdProperties->mMindCost;
// don't allow survey in buildings
if(player->getParentId())
{
gMessageLib->SendSystemMessage(::common::OutOfBand("error_message", "survey_in_structure"), player);
return false;
}
if(player->getPerformingState() != PlayerPerformance_None)
{
gMessageLib->SendSystemMessage(::common::OutOfBand("error_message", "wrong_state"), player);
return false;
}
if(player->getSurveyState())
{
gMessageLib->SendSystemMessage(::common::OutOfBand("error_message", "survey_cant"), player);
return false;
}
if(player->getSamplingState())
{
gMessageLib->SendSystemMessage(::common::OutOfBand("error_message", "survey_sample"), player);
return false;
}
SurveyTool* tool = dynamic_cast<SurveyTool*>(target);
CurrentResource* resource = NULL;
BString resourceName;
message->getStringUnicode16(resourceName);
resourceName.convert(BSTRType_ANSI);
resource = reinterpret_cast<CurrentResource*>(gResourceManager->getResourceByNameCRC(resourceName.getCrc()));
if(tool && resource)
{
player->setSurveyState(true);
// play effect
std::string effect = gWorldManager->getClientEffect(tool->getInternalAttribute<uint32>("survey_effect"));
gMessageLib->sendPlayClientEffectLocMessage(effect,player->mPosition,player);
PlayerObjectSet* playerList = player->getKnownPlayers();
PlayerObjectSet::iterator it = playerList->begin();
while(it != playerList->end())
{
gMessageLib->sendPlayClientEffectLocMessage(effect,player->mPosition,(*it));
++it;
}
uint32 mindCost = mSurveyMindCost;
Ham* hamz = player->getHam();
//are we able to sample in the first place ??
if(!hamz->checkMainPools(0,0,mindCost))
{
int32 myMind = hamz->mAction.getCurrentHitPoints();
//return message for sampling cancel based on HAM
if(myMind < (int32)mindCost)
{
gMessageLib->SendSystemMessage(::common::OutOfBand("error_message", "sample_mind"), player);
}
//message for stop sampling
gMessageLib->SendSystemMessage(::common::OutOfBand("survey", "sample_cancel"), player);
player->getSampleData()->mPendingSurvey = false;
hamz->updateRegenRates();
player->updateMovementProperties();
return false;
}
hamz->performSpecialAction(0,0,(float)mindCost,HamProperty_CurrentHitpoints);
// send system message
resourceName.convert(BSTRType_Unicode16);
gMessageLib->SendSystemMessage(::common::OutOfBand("survey", "start_survey", L"", L"", resourceName.getUnicode16()), player);
// schedule execution
start_survey_event = std::make_shared<SimpleEvent>(EventType("start_survey"),0, 5000,
std::bind(&ArtisanManager::surveyEvent, this, player, resource, tool));
}
else
{
gMessageLib->SendSystemMessage(::common::OutOfBand("ui","survey_nothingfound"));
return false;
}
// notify any listeners
if (start_survey_event)
gEventDispatcher.Notify(start_survey_event);
return true;
}
示例9: handleUIEvent
void ArtisanManager::handleUIEvent(uint32 action,int32 element,BString inputStr,UIWindow* window)
{
PlayerObject* player = window->getOwner();
std::shared_ptr<SimpleEvent> sample_UI_event = nullptr;
if(!player)
{
return;
}
Inventory* inventory = dynamic_cast<Inventory*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory));
if(!inventory)
{
return;
}
WindowAsyncContainerCommand* asyncContainer = (WindowAsyncContainerCommand*)window->getAsyncContainer();
if(!asyncContainer)
return;
Ham* ham = player->getHam();
switch(window->getWindowType())
{
// Sampling Radioactive Msg Box
case SUI_Window_SmplRadioactive_MsgBox:
{
//we stopped the sampling
if(action == 1)
{
player->getSampleData()->mPassRadioactive = false;
player->getSampleData()->mPendingSample = false;
gStateManager.setCurrentPostureState(player, CreaturePosture_Upright);
return;
}
else
{
player->getSampleData()->mPassRadioactive = true;
player->getSampleData()->mPendingSample = true;
if(ham->checkMainPools(0,mSampleActionCost*2,0))
{
SurveyTool* tool = dynamic_cast<SurveyTool*>(inventory->getObjectById(asyncContainer->ToolId));
CurrentResource* resource = (CurrentResource*)asyncContainer->CurrentResource;
player->getSampleData()->mNextSampleTime = Anh_Utils::Clock::getSingleton()->getLocalTime() + 4000;
sample_UI_event = std::make_shared<SimpleEvent>(EventType("sample_radioactive"),0, 4000,
std::bind(&ArtisanManager::sampleEvent,this, player, resource, tool));
}
else
{
gMessageLib->SendSystemMessage(::common::OutOfBand("survey", "gamble_no_action"), player);
return;
}
}
}
break;
case SUI_Window_SmplGamble_ListBox:
{
//action == 1 is cancel
if(action == 1)
{
player->getSampleData()->mPendingSample = false;
player->getSampleData()->mSampleGambleFlag = false;
gStateManager.setCurrentPostureState(player, CreaturePosture_Upright);
player->updateMovementProperties();
gMessageLib->sendUpdateMovementProperties(player);
gMessageLib->sendPostureAndStateUpdate(player);
gMessageLib->sendSelfPostureUpdate(player);
return;
}
else
{
if(element == 0)
{
player->getSampleData()->mPendingSample = true;
player->getSampleData()->mSampleGambleFlag = false;
SurveyTool* tool = dynamic_cast<SurveyTool*>(inventory->getObjectById(asyncContainer->ToolId));
CurrentResource* resource = (CurrentResource*)asyncContainer->CurrentResource;
player->getSampleData()->mNextSampleTime = Anh_Utils::Clock::getSingleton()->getLocalTime() + 1000;
sample_UI_event = std::make_shared<SimpleEvent>(EventType("sample_gamble"),0, 1000,
std::bind(&ArtisanManager::sampleEvent,this, player, resource, tool));
}
else
{
//action costs
if(!ham->checkMainPools(0,mSampleActionCost*2,0))
{
gStateManager.setCurrentPostureState(player, CreaturePosture_Upright);
player->getSampleData()->mSampleEventFlag = false;
player->getSampleData()->mSampleGambleFlag = false;
gMessageLib->SendSystemMessage(::common::OutOfBand("survey", "gamble_no_action"), player);
return;
}
//.........这里部分代码省略.........