本文整理汇总了C++中Spell::Init方法的典型用法代码示例。如果您正苦于以下问题:C++ Spell::Init方法的具体用法?C++ Spell::Init怎么用?C++ Spell::Init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Spell
的用法示例。
在下文中一共展示了Spell::Init方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CastSpellBookSpell
void AI_SUPPORT_TOWER::CastSpellBookSpell( uint32 SpellBookPage, Unit *target )
{
if( SpellBookPage != TOWER_INVALID_SPELL_INDEX )
{
uint64 target_guid = target->GetGUID();
SetNextTarget( target_guid );
SpellCastTargets targets( target_guid );
SpellEntry *spellInfo = dbcSpell.LookupEntry( SpellBook[ SpellBookPage ].spell_id );
if (spellInfo)
{
Spell *spell = SpellPool.PooledNew();
spell->Init( m_Unit, spellInfo ,true, NULL);
spell->forced_basepoints[0] = SpellBook[ SpellBookPage ].spell_effect_scale_fixed[ 0 ];
if( SpellBook[ SpellBookPage ].spell_duration_fixed )
spell->forced_duration = SpellBook[ SpellBookPage ].spell_duration_fixed;
// m_Unit->ModUnsigned32Value( UNIT_FIELD_POWER1, m_Unit->GetUInt32Value( UNIT_FIELD_POWER1 ) * spellInfo->ManaCostPercentage );
spell->prepare(&targets);
}
GlobalCoolDownFinished = TickNow + SpellBook[ SpellBookPage ].spell_global_cooldown;
SpellInstances[ SpellBookPage ].cooldown_finished = TickNow + SpellBook[ SpellBookPage ].spell_cooldown;
LastUsedSpellIndex = SpellBookPage;
}
}
示例2:
SPELL_EFFECT_OVERRIDE_RETURNS AH_48181( Aura *aur, bool apply, uint8 i )
{
if( apply == false )
{
Unit *target = aur->GetTarget();
ProcTriggerSpell *pts = target->HasProcSpell( 50091 );
if( pts )
{
int32 dmg_received = pts->created_with_value;
if( dmg_received > 0 )
{
Unit *caster = aur->GetUnitCaster();
//cast the soul animation
if( target && caster )
target->CastSpell( caster, 50091, false );
//heal the owner
if( caster )
{
SpellEntry *spellInfo = dbcSpell.LookupEntry( 48210 );
Spell *spell = SpellPool.PooledNew( __FILE__, __LINE__ );
spell->Init( caster, spellInfo ,true, NULL);
SpellCastTargets targets2( caster->GetGUID() );
spell->forced_basepoints[0] = dmg_received;
// spell->static_dmg[0] = dmg_received; //some say demon armor should boost this
spell->prepare( &targets2 );
}
}
}
target->UnRegisterProcStruct( NULL, 50091 );
}
return SPELL_EFFECT_OVERRIDE_CONTINUE_EXECUTION;
}
示例3: HandleKillCommand
bool ChatHandler::HandleKillCommand(const char *args, WorldSession *m_session)
{
Unit * target = m_session->GetPlayer()->GetMapMgr()->GetUnit(m_session->GetPlayer()->GetSelection());
if(target == 0)
{
RedSystemMessage(m_session, "A valid selection is required.");
return true;
}
switch(target->GetTypeId())
{
case TYPEID_PLAYER:
sGMLog.writefromsession(m_session, "used kill command on PLAYER %s", static_cast< Player* >( target )->GetName() );
break;
case TYPEID_UNIT:
sGMLog.writefromsession( m_session, "used kill command on CREATURE %u [%s], sqlid %u%s", static_cast< Creature* >( target )->GetEntry(), static_cast< Creature* >( target )->GetCreatureInfo() ? static_cast< Creature* >( target )->GetCreatureInfo()->Name : "unknown", static_cast< Creature* >( target )->GetSQL_id(), m_session->GetPlayer()->InGroup() ? ", in group" : "" );
break;
}
// If we're killing a player, send a message indicating a gm killed them.
if(target->IsPlayer())
{
Player * plr = static_cast< Player* >(target);
// cebernic: kill just is kill,don't use dealdamage for it
// godcheat will not stop the killing,godcheat for DealDamage() only.
//m_session->GetPlayer()->DealDamage(plr, plr->GetUInt32Value(UNIT_FIELD_HEALTH)*2,0,0,0);
plr->SetUInt32Value(UNIT_FIELD_HEALTH, 0);
plr->KillPlayer();
BlueSystemMessageToPlr(plr, "%s killed you with a GM command.", m_session->GetPlayer()->GetName());
}
else
{
// Cast insta-kill.
SpellEntry * se = dbcSpell.LookupEntry(5);
if(se == 0) return false;
SpellCastTargets targets(target->GetGUID());
Spell * sp = SpellPool.PooledNew();
sp->Init(m_session->GetPlayer(), se, true, 0);
sp->prepare(&targets);
/* SpellEntry * se = dbcSpell.LookupEntry(20479);
if(se == 0) return false;
SpellCastTargets targets(target->GetGUID());
Spell * sp = new Spell(target, se, true, 0);
sp->prepare(&targets);*/
}
return true;
}
示例4: HandleCastSelfCommand
bool ChatHandler::HandleCastSelfCommand(const char* args, WorldSession *m_session)
{
Unit *target = m_session->GetPlayer();
//SystemMessage(m_session, "Auto-targeting self.");
GreenSystemMessage(m_session, "Auto-targeting self.");
/* Unit *target = getSelectedChar(m_session, false);
if(!target)
target = getSelectedCreature(m_session, false);
if(!target)
{
RedSystemMessage(m_session, "Must select a char or creature.");
return false;
}
*/
uint32 spellid = atol(args);
SpellEntry *spellentry = dbcSpell.LookupEntry(spellid);
if(!spellentry)
{
RedSystemMessage(m_session, "Invalid spell id!");
return false;
}
Spell *sp = SpellPool.PooledNew();
sp->Init(target, spellentry, false, NULL);
if(!sp)
{
RedSystemMessage(m_session, "Spell failed creation!");
SpellPool.PooledDelete( sp );
return false;
}
BlueSystemMessage(m_session, "You have cast the spell %d on yourself.", spellid);
SpellCastTargets targets;
targets.m_unitTarget = target->GetGUID();
sp->prepare(&targets);
/* switch ( target->GetTypeId() )
{
case TYPEID_PLAYER:
if ( m_session->GetPlayer() != target )
sGMLog.writefromsession( m_session, "used castself with spell %d on PLAYER %s", spellid, static_cast< Player* >( target )->GetName() );
break;
case TYPEID_UNIT:
sGMLog.writefromsession( m_session, "used castself with spell %d on CREATURE %u [%s], sqlid %u", spellid, static_cast< Creature* >( target )->GetEntry(), static_cast< Creature* >( target )->GetCreatureInfo() ? static_cast< Creature* >( target )->GetCreatureInfo()->Name : "unknown", static_cast< Creature* >( target )->GetSQL_id() );
break;
}
*/
return true;
}
示例5: OnDied
void OnDied(Unit *mKiller)
{
Unit *o = _unit->GetTopOwner();
if( o->HasAuraWithNameHash( SPELL_HASH_FUNGAL_GROWTH, 0, AURA_SEARCH_PASSIVE ) )
{
SpellCastTargets targets( NULL );
targets.m_targetMask = TARGET_FLAG_DEST_LOCATION;
targets.m_destX = _unit->GetPositionX();
targets.m_destY = _unit->GetPositionY();
targets.m_destZ = _unit->GetPositionZ();
SpellEntry *spellInfo = dbcSpell.LookupEntry( 94339 ); //Fungal Growth Visual
Spell *spell = SpellPool.PooledNew( __FILE__, __LINE__ );
spell->Init( o, spellInfo ,true, NULL);
spell->prepare(&targets);
}
}
示例6: Update
void Tournament_Supervisor::Update(uint32 p_time)
{
/* //method to pass commands to tournament via any supervizor
debug_commands = m_Unit->GetUInt32Value( UNIT_FIELD_MAXHEALTH );
//make him normal
m_Unit->SetUInt32Value( UNIT_FIELD_MAXHEALTH, SUPERVIZOR_MAX_HEALTH );*/
//see if we need to turn anyone into a spectator
//update spam will be filtered inside function
UpdateTournaments( );
//check for spectators and update their aura
InrangeLoopExitAutoCallback AutoLock;
for( InRangeSetRecProt::iterator itr = m_Unit->GetInRangeSetBegin( AutoLock ); itr != m_Unit->GetInRangeSetEnd(); ++itr)
{
if( !(*itr) || !(*itr)->IsInWorld() )
continue;
if( (*itr)->IsPlayer() )
{
if( IsPlayerSpectator( (Player*)(*itr) ) == false )
continue;
}
else if( (*itr)->IsUnit() && (*itr)->GetUInt32Value( UNIT_FIELD_CREATEDBY ) )
{
Unit *Owner = m_Unit->GetMapMgr()->GetUnit( (*itr)->GetUInt32Value( UNIT_FIELD_CREATEDBY ) );
if( Owner && Owner->IsPlayer() && IsPlayerSpectator( (Player*)(Owner) ) == false )
continue;
//what about totems that summon guardians ? Call GM ?
}
if( (*itr)->IsUnit() && ((Unit *)(*itr))->HasAura( SPECTATOR_AURA_ID, 0, AURA_SEARCH_NEGATIVE ) == false && IsUnitInsideAnyBattleRing( (*itr)->GetMapId(), (*itr)->GetPositionX(), (*itr)->GetPositionY() ) == true )
{
SpellEntry *spellInfo = dbcSpell.LookupEntry( SPECTATOR_AURA_ID );
Spell *spell = SpellPool.PooledNew( __FILE__, __LINE__ );
SpellCastTargets targets( (*itr)->GetGUID() );
spell->Init((*itr), spellInfo ,true, NULL);
spell->prepare(&targets);
}
}
}
示例7: HookOnAreaTrigger
void Arena::HookOnAreaTrigger(Player * plr, uint32 id)
{
int32 buffslot = -1;
ASSERT(plr != NULL);
switch (id)
{
case 4536:
case 4538:
case 4696:
buffslot = 0;
break;
case 4537:
case 4539:
case 4697:
buffslot = 1;
break;
}
if(buffslot >= 0)
{
if(m_buffs[buffslot] != NULL && m_buffs[buffslot]->IsInWorld())
{
/* apply the buff */
SpellEntry * sp = dbcSpell.LookupEntry(m_buffs[buffslot]->GetInfo()->sound3);
Spell * s = SpellPool.PooledNew();
ASSERT(sp != NULL);
ASSERT(s != NULL);
s->Init(plr, sp, true, 0);
SpellCastTargets targets(plr->GetGUID());
s->prepare(&targets);
/* despawn the gameobject (not delete!) */
m_buffs[buffslot]->Despawn(BUFF_RESPAWN_TIME);
}
}
}
示例8: HookFlagStand
void WarsongGulch::HookFlagStand(Player * plr, GameObject * obj)
{
#ifdef ANTI_CHEAT
if(!m_started)
{
Anticheat_Log->writefromsession(plr->GetSession(), "%s tryed to hook the flag in warsong gluch before battleground (ID %u) started.", plr->GetName(), this->m_id);
SendChatMessage(CHAT_MSG_BG_EVENT_NEUTRAL, plr->GetGUID(), "%s will be removed from the game for cheating.", plr->GetName());
// Remove player from battleground.
this->RemovePlayer(plr, false);
// Kick player from server.
plr->Kick(6000);
return;
}
#endif
if(m_flagHolders[plr->GetTeam()] || m_homeFlags[plr->GetTeam()] != obj)
{
// cheater!
return;
}
map<uint32,uint32>::iterator itr = plr->m_forcedReactions.find(1059);
if (itr != plr->m_forcedReactions.end()) {
return;
}
SpellEntry * pSp = dbcSpell.LookupEntry(23333 + (plr->GetTeam() * 2));
Spell * sp = SpellPool.PooledNew();
sp->Init(plr, pSp, true, 0);
SpellCastTargets targets(plr->GetGUID());
sp->prepare(&targets);
/* set the flag holder */
m_flagHolders[plr->GetTeam()] = plr->GetLowGUID();
if(m_homeFlags[plr->GetTeam()]->IsInWorld())
m_homeFlags[plr->GetTeam()]->RemoveFromWorld(false);
PlaySoundToAll(plr->GetTeam() ? SOUND_HORDE_CAPTURE : SOUND_ALLIANCE_CAPTURE);
SetWorldState(plr->GetTeam() ? WSG_ALLIANCE_FLAG_CAPTURED : WSG_HORDE_FLAG_CAPTURED, 2);
}
示例9: HandleUseItemOpcode
//.........这里部分代码省略.........
return;
}
if(p_User->GetStandState()!=1)
p_User->SetStandState(STANDSTATE_SIT);
// loop through the auras and removing existing eating spells
}else
{ // cebernic: why not stand up
if (!p_User->CombatStatus.IsInCombat() && !p_User->IsMounted())
{
if( p_User->GetStandState() )//not standing-> standup
{
p_User->SetStandState( STANDSTATE_STAND );//probably mobs also must standup
}
}
}
// cebernic: remove stealth on using item
if (!(spellInfo->AuraInterruptFlags & ATTRIBUTESEX_NOT_BREAK_STEALTH))
{
if( p_User->IsStealth() )
p_User->RemoveAllAuraType( SPELL_AURA_MOD_STEALTH );
}
if(itemProto->RequiredLevel)
{
if(_player->getLevel() < itemProto->RequiredLevel)
{
_player->GetItemInterface()->BuildInventoryChangeError(tmpItem,NULL,INV_ERR_ITEM_RANK_NOT_ENOUGH);
return;
}
}
if(itemProto->RequiredSkill)
{
if(!_player->_HasSkillLine(itemProto->RequiredSkill))
{
_player->GetItemInterface()->BuildInventoryChangeError(tmpItem,NULL,INV_ERR_ITEM_RANK_NOT_ENOUGH);
return;
}
if(itemProto->RequiredSkillRank)
{
if(_player->_GetSkillLineCurrent(itemProto->RequiredSkill, false) < itemProto->RequiredSkillRank)
{
_player->GetItemInterface()->BuildInventoryChangeError(tmpItem,NULL,INV_ERR_ITEM_RANK_NOT_ENOUGH);
return;
}
}
}
if( itemProto->AllowableClass && !(_player->getClassMask() & itemProto->AllowableClass) || itemProto->AllowableRace && !(_player->getRaceMask() & itemProto->AllowableRace) )
{
_player->GetItemInterface()->BuildInventoryChangeError(tmpItem,NULL,INV_ERR_YOU_CAN_NEVER_USE_THAT_ITEM);
return;
}
if( !_player->Cooldown_CanCast( itemProto, x ) )
{
_player->SendCastResult(spellInfo->Id, SPELL_FAILED_NOT_READY, cn, 0);
return;
}
if(_player->m_currentSpell)
{
_player->SendCastResult(spellInfo->Id, SPELL_FAILED_SPELL_IN_PROGRESS, cn, 0);
return;
}
if( itemProto->ForcedPetId >= 0 )
{
if( itemProto->ForcedPetId == 0 )
{
if( _player->GetGUID() != targets.m_unitTarget )
{
_player->SendCastResult(spellInfo->Id, SPELL_FAILED_BAD_TARGETS, cn, 0);
return;
}
}
else
{
if( !_player->GetSummon() || _player->GetSummon()->GetEntry() != (uint32)itemProto->ForcedPetId )
{
_player->SendCastResult(spellInfo->Id, SPELL_FAILED_SPELL_IN_PROGRESS, cn, 0);
return;
}
}
}
Spell *spell = SpellPool.PooledNew();
spell->Init(_player, spellInfo, false, NULL);
uint8 result;
spell->extra_cast_number=cn;
spell->i_caster = tmpItem;
//GetPlayer()->setCurrentSpell(spell);
result = spell->prepare(&targets);
}
}
}
}
示例10: HandleCastSpellOpcode
//.........这里部分代码省略.........
// WPE allows them to mod the outgoing packet and basicly choose what ever spell they want :(
if( !GetPlayer()->HasSpell(spellId) || spellInfo->Attributes & ATTRIBUTES_PASSIVE )
{
sLog.outDetail("WORLD: Spell isn't casted because player \"%s\" is cheating", GetPlayer()->GetName());
return;
}
if (GetPlayer()->GetOnMeleeSpell() != spellId)
{
//autoshot 75
if((spellInfo->AttributesExB & FLAGS3_ACTIVATE_AUTO_SHOT) /*spellInfo->Attributes == 327698*/) // auto shot..
{
//sLog.outString( "HandleSpellCast: Auto Shot-type spell cast (id %u, name %s)" , spellInfo->Id , spellInfo->Name );
Item *weapon = GetPlayer()->GetItemInterface()->GetInventoryItem(EQUIPMENT_SLOT_RANGED);
if(!weapon)
return;
uint32 spellid;
switch(weapon->GetProto()->SubClass)
{
case 2: // bows
case 3: // guns
case 18: // crossbow
spellid = SPELL_RANGED_GENERAL;
break;
case 16: // thrown
spellid = SPELL_RANGED_THROW;
break;
case 19: // wands
spellid = SPELL_RANGED_WAND;
break;
default:
spellid = 0;
break;
}
if(!spellid)
spellid = spellInfo->Id;
if(!_player->m_onAutoShot)
{
_player->m_AutoShotTarget = _player->GetSelection();
uint32 duration = _player->GetUInt32Value(UNIT_FIELD_RANGEDATTACKTIME);
SpellCastTargets targets(recvPacket,GetPlayer()->GetGUID());
if(!targets.m_unitTarget)
{
sLog.outString( "Cancelling auto-shot cast because targets.m_unitTarget is null!" );
return;
}
SpellEntry *sp = dbcSpell.LookupEntry(spellid);
_player->m_AutoShotSpell = sp;
_player->m_AutoShotDuration = duration;
//This will fix fast clicks
if(_player->m_AutoShotAttackTimer < 500)
_player->m_AutoShotAttackTimer = 500;
_player->m_onAutoShot = true;
}
return;
}
/*const char * name = sSpellStore.LookupString(spellInfo->Name);
if(name)
sChatHandler.SystemMessageToPlr(_player, "%sSpell Cast:%s %s %s[Group %u, family %u]", MSG_COLOR_LIGHTBLUE,
MSG_COLOR_SUBWHITE, name, MSG_COLOR_YELLOW, spellInfo->SpellGroupType, spellInfo->SpellFamilyName);*/
if(_player->m_currentSpell)
{
if( _player->m_currentSpell->getState() == SPELL_STATE_CASTING )
{
// cancel the existing channel spell, cast this one
_player->m_currentSpell->cancel();
}
else
{
// send the error message
_player->SendCastResult(spellInfo->Id, SPELL_FAILED_SPELL_IN_PROGRESS, cn, 0);
return;
}
}
SpellCastTargets targets(recvPacket,GetPlayer()->GetGUID());
// some anticheat stuff
if( spellInfo->self_cast_only )
{
if( targets.m_unitTarget && targets.m_unitTarget != _player->GetGUID() )
{
// send the error message
_player->SendCastResult(spellInfo->Id, SPELL_FAILED_BAD_TARGETS, cn, 0);
return;
}
}
Spell *spell = SpellPool.PooledNew();
spell->Init(GetPlayer(), spellInfo, false, NULL);
spell->extra_cast_number=cn;
spell->prepare(&targets);
}
}
示例11: HookOnAreaTrigger
void ArathiBasin::HookOnAreaTrigger(Player * plr, uint32 id)
{
uint32 spellid = 0;
int32 buffslot = -1;
switch (id)
{
case 3866: // stables
buffslot = AB_BUFF_STABLES;
break;
case 3867: // farm
buffslot = AB_BUFF_FARM;
break;
case 3870: // blacksmith
buffslot = AB_BUFF_BLACKSMITH;
break;
case 3869: // mine
buffslot = AB_BUFF_MINE;
break;
case 3868: // lumbermill
buffslot = AB_BUFF_LUMBERMILL;
break;
case 3948: // alliance/horde exits
case 3949:
{
RemovePlayer(plr, false);
return;
}break;
default:
Log.Error("ArathiBasin", "Encountered unhandled areatrigger id %u", id);
return;
break;
}
if (plr->isDead()) // dont apply to dead players... :P
return;
uint32 x = (uint32)buffslot;
if (m_buffs[x] && m_buffs[x]->IsInWorld())
{
// apply the spell
spellid = m_buffs[x]->GetInfo()->sound3;
m_buffs[x]->RemoveFromWorld(false);
// respawn it in buffrespawntime
sEventMgr.AddEvent(this, &ArathiBasin::SpawnBuff, x, EVENT_AB_RESPAWN_BUFF, AB_BUFF_RESPAWN_TIME, 1, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT);
// cast the spell on the player
SpellEntry * sp = dbcSpell.LookupEntryForced(spellid);
if (sp)
{
Spell * pSpell = SpellPool.PooledNew();
pSpell->Init(plr, sp, true, NULL);
SpellCastTargets targets(plr->GetGUID());
pSpell->prepare(&targets);
}
}
}
示例12: ApplyEnchantmentBonus
//.........这里部分代码省略.........
itr++;
}
}
}break;
case 2: // Mod damage done.
{
int32 val = Entry->min[c];
if( RandomSuffixAmount )
val = RANDOM_SUFFIX_MAGIC_CALCULATION( RandomSuffixAmount, GetItemRandomSuffixFactor() );
if( Apply )
m_owner->ModUnsigned32Value( PLAYER_FIELD_MOD_DAMAGE_DONE_POS, val );
else
m_owner->ModUnsigned32Value( PLAYER_FIELD_MOD_DAMAGE_DONE_POS, -val );
m_owner->CalcDamage();
}break;
case 3: // Cast spell (usually means apply aura)
{
if( Apply )
{
SpellCastTargets targets( m_owner->GetGUID() );
SpellEntry* sp;
Spell* spell;
if( Entry->spell[c] != 0 )
{
sp = dbcSpell.LookupEntry( Entry->spell[c] );
if( sp == NULL )
continue;
spell = SpellPool.PooledNew();
spell->Init( m_owner, sp, true, 0 );
spell->i_caster = this;
spell->prepare( &targets );
}
}
else
{
if( Entry->spell[c] != 0 )
m_owner->RemoveAura( Entry->spell[c] );
}
}break;
case 4: // Modify physical resistance
{
int32 val = Entry->min[c];
if( RandomSuffixAmount )
val = RANDOM_SUFFIX_MAGIC_CALCULATION( RandomSuffixAmount, GetItemRandomSuffixFactor() );
if( Apply )
{
m_owner->FlatResistanceModifierPos[Entry->spell[c]] += val;
}
else
{
m_owner->FlatResistanceModifierPos[Entry->spell[c]] -= val;
}
m_owner->CalcResistance( Entry->spell[c] );
}break;
case 5: //Modify rating ...order is PLAYER_FIELD_COMBAT_RATING_1 and above
{
//spellid is enum ITEM_STAT_TYPE
示例13: HookOnAreaTrigger
void WarsongGulch::HookOnAreaTrigger(Player * plr, uint32 id)
{
int32 buffslot = -1;
switch(id)
{
case 3686: // Speed
buffslot = 0;
break;
case 3687: // Speed (Horde)
buffslot = 1;
break;
case 3706: // Restoration
buffslot = 2;
break;
case 3708: // Restoration (Horde)
buffslot = 3;
break;
case 3707: // Berserking
buffslot = 4;
break;
case 3709: // Berserking (Horde)
buffslot = 5;
break;
}
if(buffslot >= 0)
{
if(m_buffs[buffslot] != 0 && m_buffs[buffslot]->IsInWorld())
{
/* apply the buff */
SpellEntry * sp = dbcSpell.LookupEntry(m_buffs[buffslot]->GetInfo()->sound3);
Spell * s = SpellPool.PooledNew();
s->Init(plr, sp, true, 0);
SpellCastTargets targets(plr->GetGUID());
s->prepare(&targets);
/* despawn the gameobject (not delete!) */
m_buffs[buffslot]->Despawn(BUFF_RESPAWN_TIME);
}
return;
}
if(((id == 3646 && plr->GetTeam() == 0) || (id == 3647 && plr->GetTeam() == 1)) && (plr->m_bgHasFlag && m_flagHolders[plr->GetTeam()] == plr->GetLowGUID()))
{
if(m_flagHolders[plr->GetTeam() ? 0 : 1] != 0 || m_dropFlags[plr->GetTeam() ? 0 : 1]->IsInWorld())
{
/* can't cap while flag dropped */
return;
}
/* remove the bool from the player so the flag doesn't drop */
m_flagHolders[plr->GetTeam()] = 0;
plr->m_bgHasFlag = 0;
/* remove flag aura from player */
plr->RemoveAura(23333+(plr->GetTeam() * 2));
/* capture flag points */
plr->m_bgScore.Misc1++;
PlaySoundToAll( plr->GetTeam() ? SOUND_HORDE_SCORES : SOUND_ALLIANCE_SCORES );
if( plr->GetTeam() == 1 )
SendChatMessage( CHAT_MSG_BG_EVENT_HORDE, plr->GetGUID(), "%s captured the Alliance flag!", plr->GetName() );
else
SendChatMessage( CHAT_MSG_BG_EVENT_ALLIANCE, plr->GetGUID(), "%s captured the Horde flag!", plr->GetName() );
SetWorldState( plr->GetTeam() ? WSG_ALLIANCE_FLAG_CAPTURED : WSG_HORDE_FLAG_CAPTURED, 1 );
/* respawn the home flag */
if( !m_homeFlags[plr->GetTeam()]->IsInWorld() )
m_homeFlags[plr->GetTeam()]->PushToWorld(m_mapMgr);
/* give each player on that team a bonus according to flagHonorTable */
for(set<Player*>::iterator itr = m_players[plr->GetTeam()].begin(); itr != m_players[plr->GetTeam()].end(); ++itr)
{
(*itr)->m_bgScore.BonusHonor += flagHonorTable[m_lgroup];
HonorHandler::AddHonorPointsToPlayer((*itr), flagHonorTable[m_lgroup]);
}
m_scores[plr->GetTeam()]++;
if(m_scores[plr->GetTeam()] == 3)
{
/* victory! */
m_ended = true;
m_winningteam = plr->GetTeam() ? 1 : 0;
m_nextPvPUpdateTime = 0;
sEventMgr.RemoveEvents(this, EVENT_BATTLEGROUND_CLOSE);
sEventMgr.AddEvent(((CBattleground*)this), &CBattleground::Close, EVENT_BATTLEGROUND_CLOSE, 120000, 1,0);
m_mainLock.Acquire();
/* add the marks of honor to all players */
SpellEntry * winner_spell = dbcSpell.LookupEntry(24951);
SpellEntry * loser_spell = dbcSpell.LookupEntry(24950);
for(uint32 i = 0; i < 2; ++i)
{
for(set<Player*>::iterator itr = m_players[i].begin(); itr != m_players[i].end(); ++itr)
{
(*itr)->Root();
//.........这里部分代码省略.........
示例14: HookFlagDrop
void WarsongGulch::HookFlagDrop(Player * plr, GameObject * obj)
{
/* picking up a dropped flag */
if(m_dropFlags[plr->GetTeam()] != obj)
{
/* are we returning it? */
if( (obj->GetEntry() == 179785 && plr->GetTeam() == 0) ||
(obj->GetEntry() == 179786 && plr->GetTeam() == 1) )
{
uint32 x = plr->GetTeam() ? 0 : 1;
sEventMgr.RemoveEvents(this, EVENT_BATTLEGROUND_WSG_AUTO_RETURN_FLAG + plr->GetTeam());
if( m_dropFlags[x]->IsInWorld() )
m_dropFlags[x]->RemoveFromWorld(false);
if(m_homeFlags[x]->IsInWorld() == false)
m_homeFlags[x]->PushToWorld(m_mapMgr);
plr->m_bgScore.Misc2++;
UpdatePvPData();
if( plr->GetTeam() == 1 )
SendChatMessage( CHAT_MSG_BG_EVENT_HORDE, plr->GetGUID(), "The Horde flag was returned to its base by %s!", plr->GetName() );
else
SendChatMessage( CHAT_MSG_BG_EVENT_ALLIANCE, plr->GetGUID(), "The Alliance flag was returned to its base by %s!", plr->GetName() );
SetWorldState(plr->GetTeam() ? WSG_ALLIANCE_FLAG_CAPTURED : WSG_HORDE_FLAG_CAPTURED, 1);
PlaySoundToAll(plr->GetTeam() ? SOUND_HORDE_RETURNED : SOUND_ALLIANCE_RETURNED);
}
return;
}
map<uint32,uint32>::iterator itr = plr->m_forcedReactions.find(1059);
if (itr != plr->m_forcedReactions.end()) {
return;
}
if( plr->GetTeam() == 0 )
sEventMgr.RemoveEvents(this, EVENT_BATTLEGROUND_WSG_AUTO_RETURN_FLAG);
else
sEventMgr.RemoveEvents(this, EVENT_BATTLEGROUND_WSG_AUTO_RETURN_FLAG + 1);
if( m_dropFlags[plr->GetTeam()]->IsInWorld() )
m_dropFlags[plr->GetTeam()]->RemoveFromWorld(false);
m_flagHolders[plr->GetTeam()] = plr->GetLowGUID();
plr->m_bgHasFlag = true;
/* This is *really* strange. Even though the A9 create sent to the client is exactly the same as the first one, if
* you spawn and despawn it, then spawn it again it will not show. So we'll assign it a new guid, hopefully that
* will work.
* - Burlex
*/
m_dropFlags[plr->GetTeam()]->SetNewGuid(m_mapMgr->GenerateGameobjectGuid());
SpellEntry * pSp = dbcSpell.LookupEntry(23333 + (plr->GetTeam() * 2));
Spell * sp = SpellPool.PooledNew();
sp->Init(plr, pSp, true, 0);
SpellCastTargets targets(plr->GetGUID());
sp->prepare(&targets);
SetWorldState(plr->GetTeam() ? WSG_ALLIANCE_FLAG_CAPTURED : WSG_HORDE_FLAG_CAPTURED, 2);
}
示例15: HookOnAreaTrigger
void EyeOfTheStorm::HookOnAreaTrigger(Player * plr, uint32 id)
{
int32 tid = -1;
int32 bonusid = -1;
switch(id)
{
case 4476: // BE Tower
tid = EOTS_TOWER_BE;
break;
case 4568: // BE Tower bonus
bonusid = EOTS_TOWER_BE;
break;
case 4514: // Fel Reaver Tower
tid = EOTS_TOWER_FELREAVER;
break;
case 4569: // Fel Reaver Tower bonus
bonusid = EOTS_TOWER_FELREAVER;
break;
case 4518: // Draenei Tower
tid = EOTS_TOWER_DRAENEI;
break;
case 4571: // Draenei Tower bonus
bonusid = EOTS_TOWER_DRAENEI;
break;
case 4516: // Mage Tower
tid = EOTS_TOWER_MAGE;
break;
case 4570: // Mage Tower bonus
bonusid = EOTS_TOWER_MAGE;
break;
}
if(bonusid > -1){
uint32 spellid=0;
uint32 x = (uint32)bonusid;
if(EOTSm_buffs[x] && EOTSm_buffs[x]->IsInWorld())
{
spellid = EOTSm_buffs[x]->GetInfo()->sound3;
SpellEntry * sp = dbcSpell.LookupEntryForced(spellid);
if(sp)
{
Spell * pSpell = SpellPool.PooledNew();
pSpell->Init(plr, sp, true, NULL);
SpellCastTargets targets(plr->GetGUID());
pSpell->prepare(&targets);
}
EOTSm_buffs[x]->Despawn(EOTS_BUFF_RESPAWN_TIME);
}
}
if( tid < 0 )
return;
#ifdef ANTI_CHEAT
if(!m_started)
{
Anticheat_Log->writefromsession(plr->GetSession(), "%s tryed to hook the flag in eye of the storm before battleground (ID %u) started.", plr->GetName(), this->m_id);
SendChatMessage(CHAT_MSG_BG_EVENT_NEUTRAL, plr->GetGUID(), "%s will be removed from the game for cheating.", plr->GetName());
// Remove player from battleground.
this->RemovePlayer(plr, false);
// Kick player from server.
plr->Kick(6000);
return;
}
#endif
uint32 spellid=0;
uint32 x = (uint32)tid;
if(EOTSm_buffs[x] && EOTSm_buffs[x]->IsInWorld())
{
spellid = EOTSm_buffs[x]->GetInfo()->sound3;
SpellEntry * sp = dbcSpell.LookupEntryForced(spellid);
if(sp)
{
Spell * pSpell = SpellPool.PooledNew();
pSpell->Init(plr, sp, true, NULL);
SpellCastTargets targets(plr->GetGUID());
pSpell->prepare(&targets);
}
EOTSm_buffs[x]->Despawn(EOTS_BUFF_RESPAWN_TIME);
}
uint32 team = plr->GetTeam();
if( plr->GetLowGUID() != m_flagHolder )
return;
int32 val;
uint32 i;
uint32 towers = 0;
if( team == 0 )
val = 100;
else
val = 0;
if( m_CPStatus[tid] != val )
return; // not captured by our team
for(i = 0; i < EOTS_TOWER_COUNT; ++i)
{
if(m_CPStatus[i] == val)
//.........这里部分代码省略.........