本文整理汇总了C++中UnitPointer::GetUInt32Value方法的典型用法代码示例。如果您正苦于以下问题:C++ UnitPointer::GetUInt32Value方法的具体用法?C++ UnitPointer::GetUInt32Value怎么用?C++ UnitPointer::GetUInt32Value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnitPointer
的用法示例。
在下文中一共展示了UnitPointer::GetUInt32Value方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleListAIAgentCommand
bool ChatHandler::HandleListAIAgentCommand(const char* args, WorldSession *m_session)
{
UnitPointer target = m_session->GetPlayer()->GetMapMgr()->GetCreature(GET_LOWGUID_PART(m_session->GetPlayer()->GetSelection()));
if(!target)
{
RedSystemMessage(m_session, "You have to select a Creature!");
return false;
}
std::stringstream sstext;
sstext << "agentlist of creature: " << target->GetGUID() << '\n';
std::stringstream ss;
ss << "SELECT * FROM ai_agents where entry=" << target->GetUInt32Value(OBJECT_FIELD_ENTRY);
QueryResult *result = WorldDatabase.Query( ss.str().c_str() );
if( !result )
return false;
do
{
Field *fields = result->Fetch();
sstext << "agent: " << fields[1].GetUInt16()
<< " | spellId: " << fields[5].GetUInt32()
<< " | Event: " << fields[2].GetUInt32()
<< " | chance: " << fields[3].GetUInt32()
<< " | count: " << fields[4].GetUInt32() << '\n';
} while( result->NextRow() );
delete result;
SendMultilineMessage(m_session, sstext.str().c_str());
return true;
}
示例2: CalculateHonorPointsForKill
int32 HonorHandler::CalculateHonorPointsForKill( PlayerPointer pPlayer, UnitPointer pVictim )
{
// this sucks.. ;p
if( pVictim == NULL )
return 0;
// Suicide lol
if( pVictim == pPlayer )
return 0;
if( pVictim->GetTypeId() != TYPEID_PLAYER )
return 0;
// How dishonorable, you fiend!
if( pVictim->HasActiveAura( PLAYER_HONORLESS_TARGET_SPELL ) )
return 0;
uint32 k_level = pPlayer->GetUInt32Value( UNIT_FIELD_LEVEL );
uint32 v_level = pVictim->GetUInt32Value( UNIT_FIELD_LEVEL );
// formula guessed
int32 honor_points = 6;
if(k_level != v_level)
{
int32 diff = v_level - k_level;
honor_points += diff;
if(honor_points <= 0)
return 0;
if(honor_points >= 8)
honor_points = 8;
}
honor_points = float2int32(float(honor_points) * World::getSingleton().getRate( RATE_HONOR ));
//honor_points *= World::getSingleton().getRate( RATE_HONOR );
return honor_points;
}
示例3: CalculateDamage
uint32 CalculateDamage( UnitPointer pAttacker, UnitPointer pVictim, uint32 weapon_damage_type, SpellEntry* ability ) // spellid is used only for 2-3 spells, that have AP bonus
{
//TODO: Some awesome formula to determine how much damage to deal
//consider this is melee damage
// weapon_damage_type: 0 = melee, 1 = offhand(dualwield), 2 = ranged
// Attack Power increases your base damage-per-second (DPS) by 1 for every 14 attack power.
// (c) wowwiki
//type of this UNIT_FIELD_ATTACK_POWER_MODS is unknown, not even uint32 disabled for now.
uint32 offset;
ItemPointer it = NULLITEM;
if(pAttacker->disarmed && pAttacker->IsPlayer())
{
offset=UNIT_FIELD_MINDAMAGE;
it = TO_PLAYER(pAttacker)->GetItemInterface()->GetInventoryItem(EQUIPMENT_SLOT_MAINHAND);
}
else if( weapon_damage_type == MELEE )
offset = UNIT_FIELD_MINDAMAGE;
else if( weapon_damage_type == OFFHAND )
offset = UNIT_FIELD_MINOFFHANDDAMAGE;
else // weapon_damage_type == RANGED
offset = UNIT_FIELD_MINRANGEDDAMAGE;
float min_damage = pAttacker->GetFloatValue(offset);
float max_damage = pAttacker->GetFloatValue(offset+1);
if(it)
{
min_damage -= it->GetProto()->Damage[0].Min;
max_damage -= it->GetProto()->Damage[0].Max;
}
float ap = 0;
float bonus;
float wspeed;
float appbonuspct = 1.0f;
ItemPointer BonusItem = NULLITEM;
if( pAttacker->IsPlayer() && weapon_damage_type == MELEE )
{
BonusItem = TO_PLAYER(pAttacker)->GetItemInterface()->GetInventoryItem(EQUIPMENT_SLOT_MAINHAND);
}
else if(pAttacker->IsPlayer() && weapon_damage_type == OFFHAND )
{
BonusItem = TO_PLAYER(pAttacker)->GetItemInterface()->GetInventoryItem(EQUIPMENT_SLOT_OFFHAND);
}
else if(pAttacker->IsPlayer() && weapon_damage_type == RANGED )
{
BonusItem = TO_PLAYER(pAttacker)->GetItemInterface()->GetInventoryItem(EQUIPMENT_SLOT_RANGED);
}
if( pAttacker->IsPlayer() && BonusItem )
{
appbonuspct = TO_PLAYER(pAttacker)->m_WeaponSubClassDamagePct[ BonusItem->GetProto()->SubClass ];
}
if(offset == UNIT_FIELD_MINRANGEDDAMAGE)
{
//starting from base attack power then we apply mods on it
//ap += pAttacker->GetRAP();
ap += pVictim->RAPvModifier;
if(!pVictim->IsPlayer() && TO_CREATURE(pVictim)->GetCreatureName())
{
uint32 creatType = TO_CREATURE(pVictim)->GetCreatureName()->Type;
ap += (float)pAttacker->CreatureRangedAttackPowerMod[creatType];
if(pAttacker->IsPlayer())
{
min_damage = (min_damage + TO_PLAYER(pAttacker)->IncreaseDamageByType[creatType]) * (1 + TO_PLAYER(pAttacker)->IncreaseDamageByTypePCT[creatType]);
max_damage = (max_damage + TO_PLAYER(pAttacker)->IncreaseDamageByType[creatType]) * (1 + TO_PLAYER(pAttacker)->IncreaseDamageByTypePCT[creatType]);
}
}
if(pAttacker->IsPlayer())
{
if(!pAttacker->disarmed)
{
ItemPointer it = TO_PLAYER(pAttacker)->GetItemInterface()->GetInventoryItem(EQUIPMENT_SLOT_RANGED);
if(it)
{
wspeed = (float)it->GetProto()->Delay;
}
else
wspeed = 2000;
}
else
wspeed = (float)pAttacker->GetUInt32Value(UNIT_FIELD_RANGEDATTACKTIME);
}
else
{
wspeed = (float)pAttacker->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME);
}
//ranged weapon normalization.
if(pAttacker->IsPlayer() && ability)
{
if(ability->Effect[0] == SPELL_EFFECT_DUMMYMELEE || ability->Effect[1] == SPELL_EFFECT_DUMMYMELEE || ability->Effect[2] == SPELL_EFFECT_DUMMYMELEE)
{
//.........这里部分代码省略.........
示例4: HandleAddAIAgentCommand
bool ChatHandler::HandleAddAIAgentCommand(const char* args, WorldSession *m_session)
{
char* agent = strtok((char*)args, " ");
if(!agent)
return false;
char* procEvent = strtok(NULL, " ");
if(!procEvent)
return false;
char* procChance = strtok(NULL, " ");
if(!procChance)
return false;
char* procCount = strtok(NULL, " ");
if(!procCount)
return false;
char* spellId = strtok(NULL, " ");
if(!spellId)
return false;
char* spellType = strtok(NULL, " ");
if(!spellType)
return false;
char* spelltargetType = strtok(NULL, " ");
if(!spelltargetType)
return false;
char* spellCooldown = strtok(NULL, " ");
if(!spellCooldown)
return false;
char* floatMisc1 = strtok(NULL, " ");
if(!floatMisc1)
return false;
char* Misc2 = strtok(NULL, " ");
if(!Misc2)
return false;
UnitPointer target = m_session->GetPlayer()->GetMapMgr()->GetCreature(GET_LOWGUID_PART(m_session->GetPlayer()->GetSelection()));
if(!target)
{
RedSystemMessage(m_session, "You have to select a Creature!");
return false;
}
AI_Spell * sp = new AI_Spell;
sp->agent = atoi(agent);
sp->procChance = atoi(procChance);
sp->procCount = atoi(procCount);
sp->spell = dbcSpell.LookupEntry(atoi(spellId));
sp->spellType = atoi(spellType);
sp->spelltargetType = atoi(spelltargetType);
sp->floatMisc1 = (float)atof(floatMisc1);
sp->Misc2 = (uint32)atof(Misc2);
sp->cooldown = (uint32)atoi(spellCooldown);
sp->procCounter=0;
sp->cooldowntime=0;
sp->custom_pointer=false;
sp->minrange = GetMinRange(dbcSpellRange.LookupEntry(dbcSpell.LookupEntry(atoi(spellId))->rangeIndex));
sp->maxrange = GetMaxRange(dbcSpellRange.LookupEntry(dbcSpell.LookupEntry(atoi(spellId))->rangeIndex));
if(sp->agent == AGENT_CALLFORHELP)
target->GetAIInterface()->m_canCallForHelp = true;
else if(sp->agent == AGENT_FLEE)
target->GetAIInterface()->m_canFlee = true;
else if(sp->agent == AGENT_RANGED)
target->GetAIInterface()->m_canRangedAttack = true;
else if(sp->agent == AGENT_SPELL)
target->GetAIInterface()->addSpellToList(sp);
std::stringstream qry;
qry << "INSERT INTO ai_agents set entryId = '" << target->GetUInt32Value(OBJECT_FIELD_ENTRY) << "', AI_AGENT = '" << atoi(agent) << "', procChance = '" << atoi(procChance)<< "', procCount = '" << atoi(procCount)<< "', spellId = '" << atoi(spellId)<< "', spellType = '" << atoi(spellType)<< "', spelltargetType = '" << atoi(spelltargetType)<< "', spellCooldown = '" << atoi(spellCooldown)<< "', floatMisc1 = '" << atof(floatMisc1)<< "', Misc2 ='" << atoi(Misc2)<< "'";
WorldDatabase.Execute( qry.str().c_str( ) );
return true;
}