本文整理汇总了C++中UnitPointer::GetAIInterface方法的典型用法代码示例。如果您正苦于以下问题:C++ UnitPointer::GetAIInterface方法的具体用法?C++ UnitPointer::GetAIInterface怎么用?C++ UnitPointer::GetAIInterface使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnitPointer
的用法示例。
在下文中一共展示了UnitPointer::GetAIInterface方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleAddDynamicTargetOpcode
void WorldSession::HandleAddDynamicTargetOpcode(WorldPacket & recvPacket)
{
DEBUG_LOG( "WORLD"," got CMSG_PET_CAST_SPELL." );
uint64 guid;
uint8 counter;
uint32 spellid;
uint8 flags;
UnitPointer caster;
SpellCastTargets targets;
SpellEntry *sp;
SpellPointer pSpell;
list<AI_Spell*>::iterator itr;
recvPacket >> guid >> counter >> spellid >> flags;
sp = dbcSpell.LookupEntry(spellid);
// Summoned Elemental's Freeze
if (spellid == 33395)
{
caster = _player->m_Summon;
if( caster && TO_PET(caster)->GetAISpellForSpellId(spellid) == NULL )
return;
}
else
{
caster = _player->m_CurrentCharm;
if( caster != NULL )
{
for(itr = caster->GetAIInterface()->m_spells.begin(); itr != caster->GetAIInterface()->m_spells.end(); ++itr)
{
if( (*itr)->spell->Id == spellid )
break;
}
if( itr == caster->GetAIInterface()->m_spells.end() )
return;
}
}
if( caster == NULL || guid != caster->GetGUID() )
return;
targets.read(recvPacket, _player->GetGUID());
pSpell = SpellPointer(new Spell(caster, sp, false, NULLAURA));
pSpell->prepare(&targets);
}
示例2: AIUpdate
void AIUpdate()
{
if( spark_timer < getMSTime() )
{
spark_timer = 0;
_unit->UnRoot();
_unit->GetAIInterface()->disable_combat = false;
_unit->m_invisible = false;
_unit->UpdateVisibility();
for( uint8 i=0; i<SPARKS_COUNT; i++)
if( sparks[i] != 0 )
{
UnitPointer Spark = _unit->GetMapMgr()->GetUnit( sparks[i] );
if( Spark )
{
Spark->RemoveAllAuras();
Spark->GetAIInterface()->MoveTo(_unit->GetPositionX(), _unit->GetPositionY(), _unit->GetPositionZ(), _unit->GetOrientation());
Spark->Root();
Spark->GetAIInterface()->disable_combat = true;
}
}
}
if( spark_timer == 0 && spells.size() > 0 )
{
for( uint8 i = 0; i<spells.size(); i++ )
{
if( spells[i]->time < getMSTime() )
{
if( Rand( spells[i]->chance ) )
{
CastScriptSpell( spells[i] );
spells[i]->time = getMSTime() + spells[i]->timer;
}
}
}
}
}
示例3: OnCombatStart
void OnCombatStart(UnitPointer mTarget)
{
_unit->GetAIInterface()->m_canMove = false;
_unit->GetAIInterface()->disable_melee = true;
_unit->SetUInt64Value(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
UnitPointer antusul = NULLUNIT;
antusul = _unit->GetMapMgr()->GetInterface()->GetCreatureNearestCoords(1815.030029f, 686.817017f, 14.519000f, 8127);
if(antusul)
{
if(antusul->isAlive())
{
antusul->GetAIInterface()->AttackReaction(mTarget, 0, 0);
antusul->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "Lunch has arrived, my beutiful childern. Tear them to pieces!");
}
}
}
示例4: AIUpdate
void AIUpdate()
{
if (!HasSummoned && _unit->GetHealthPct() <= 8)
{
UnitPointer Warchief = NULLUNIT;
Warchief =_unit->GetMapMgr()->GetInterface()->SpawnCreature(CN_REND_BLACKHAND, 157.366516f, -419.779358f, 110.472336f, 3.056772f, true, false, 0, 0);
if (Warchief != NULL)
{
if (_unit->GetAIInterface()->GetNextTarget() != NULL)
{
Warchief->GetAIInterface()->AttackReaction(_unit->GetAIInterface()->GetNextTarget(), 1, 0);
}
}
HasSummoned = true;
}
float val = (float)RandomFloat(100.0f);
SpellCast(val);
}
示例5: OnDamageTaken
void OnDamageTaken(UnitPointer mAttacker, float fAmount)
{
if( (int)( last_creation_hp - DISPARSE_HP ) >= _unit->GetHealthPct() )
{
switch(rand()%2)
{
case 0:
_unit->SendChatMessage( CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "The slightest spark shall be your undoing." );
break;
case 1:
_unit->SendChatMessage( CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "No one is safe!" );
break;
}
spark_timer = getMSTime() + SPARK_PHASE_DURATION;
last_creation_hp = _unit->GetHealthPct();
_unit->CastSpell(_unit, 52770, true);//disperse, dummy
_unit->Root();
_unit->GetAIInterface()->disable_combat = false;
_unit->m_invisible = false;
_unit->UpdateVisibility();
//disparse
for( uint8 i=0; i<SPARKS_COUNT; i++)
if( sparks[i] != 0 )
{
UnitPointer Spark = _unit->GetMapMgr()->GetUnit( sparks[i] );
if( Spark )
{
uint32 spellid = heroic ? 59833 : 52667;
Spark->CastSpell(Spark, spellid, true);
Spark->UnRoot();
_unit->GetAIInterface()->disable_combat = false;
PlayerPointer p_target = GetRandomPlayerTarget();
if( p_target )
{
Spark->GetAIInterface()->MoveTo(p_target->GetPositionX(),p_target->GetPositionY(), p_target->GetPositionZ(), p_target->GetOrientation());
}
}
}
}
}
示例6: OnEmote
void OnEmote(PlayerPointer pPlayer, uint32 Emote, UnitPointer pUnit)
{
pUnit = pPlayer->GetMapMgr()->GetUnit(pPlayer->GetSelection());
if (!pUnit || !pUnit->isAlive() || pUnit->GetAIInterface()->GetNextTarget())
return;
// Switch For Emote Name (You do EmoteName to Script Name link).
switch(Emote)
{
case EMOTE_ONESHOT_SALUTE: // <- Its EMOTE name.
GuardsOnSalute(pPlayer, pUnit); // <- Its Link.
break;
case EMOTE_ONESHOT_KISS:
GaurdsOnKiss(pPlayer, pUnit);
break;
case EMOTE_ONESHOT_WAVE:
GuardsOnWave(pPlayer, pUnit);
break;
}
}
示例7: 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;
}