bool ChatHandler::HandleKillCommand(const char *args, WorldSession *m_session) { Unit* unit = getSelectedUnit(m_session); if(!unit) return true; sWorld.LogGM(m_session, "used kill command on %s %s", unit->IsPlayer() ? "Player" : "Creature", unit->GetName()); if(unit->IsPlayer()) { // If we're killing a player, send a message indicating a gm killed them. BlueSystemMessageToPlr(TO_PLAYER(unit), "%s killed you with a GM command.", m_session->GetPlayer()->GetName()); TO_PLAYER(unit)->SetUInt32Value(UNIT_FIELD_HEALTH, 0); // Die, insect TO_PLAYER(unit)->KillPlayer(); GreenSystemMessage(m_session, "Killed player %s.", unit->GetName()); } else if(isTargetDummy(unit->GetEntry())) RedSystemMessage(m_session, "Target cannot be killed."); else { m_session->GetPlayer()->DealDamage(unit, 0xFFFFFFFF, 0, 0, 0); GreenSystemMessage(m_session, "Killed unit %s.", unit->GetName()); } return true; }
bool BerserkerRage(uint32 i, Aura* a, bool apply) { Unit* u = a->GetTarget(); Player* p_target = NULL; if(u->IsPlayer()) p_target = TO_PLAYER(u); if(p_target == NULL) return true; if(apply) p_target->rageFromDamageTaken += 100; else p_target->rageFromDamageTaken -= 100; for(int32 i = 0; i < 3; i++) { if(apply) { p_target->MechanicsDispels[ a->GetSpellProto()->EffectMiscValue[i] ]++; p_target->RemoveAllAurasByMechanic(a->GetSpellProto()->EffectMiscValue[i] , static_cast<uint32>(-1) , false); } else p_target->MechanicsDispels[ a->GetSpellProto()->EffectMiscValue[i] ]--; } return true; }
bool WinterWondervolt(uint32 i, Spell* pSpell) { Unit* target = pSpell->GetUnitTarget(); if(target == NULL || !target->IsPlayer()) return true; uint32 outfitspells[] = { 26157, // green male 26272, // green female 26273, // red male 26274 // red female }; uint32 team = target->GetTeam(); uint32 gender = target->getGender(); uint32 spellid = 0; if(team == TEAM_HORDE) spellid = outfitspells[ 2 + gender ]; else spellid = outfitspells[ gender ]; target->CastSpell(target, spellid, true); return true; }
void AIUpdate() { // Let's see if we are netted Aura* a = _unit->getAuraWithId(51959); if(a != NULL) { Unit* Caster = a->GetUnitCaster(); if (Caster == nullptr) return; if(Caster->IsPlayer()) { QuestLogEntry* qle = static_cast<Player*>(Caster)->GetQuestLogForEntry(12532); if(qle == NULL) qle = static_cast<Player*>(Caster)->GetQuestLogForEntry(12702); if(qle != NULL) { // casting the spell that will create the item for the player _unit->CastSpell(Caster, 51037, true); _unit->Despawn(1000, 360000); } } } }
bool EatenRecently(uint32 i, Aura* pAura, bool apply) { if(pAura == NULL) return true; Unit* caster = pAura->GetUnitCaster(); if(caster == NULL || caster->IsPlayer()) return true; Creature* NetherDrake = TO_CREATURE(caster); if(NetherDrake == NULL) return true; if(apply) { NetherDrake->GetAIInterface()->SetAllowedToEnterCombat(false); NetherDrake->Emote(EMOTE_ONESHOT_EAT); } else { NetherDrake->GetAIInterface()->SetAllowedToEnterCombat(true); NetherDrake->GetAIInterface()->SetFly(); NetherDrake->GetAIInterface()->MoveTo(NetherDrake->GetSpawnX(), NetherDrake->GetSpawnY(), NetherDrake->GetSpawnZ(), NetherDrake->GetSpawnO()); } return true; }
bool ChatHandler::HandleMonsterYellCommand(const char* args, WorldSession* m_session) { Unit* crt = getSelectedCreature(m_session, false); if(!crt) crt = getSelectedChar(m_session, false); if(!crt) { RedSystemMessage(m_session, "Please select a creature or player before using this command."); return true; } if(crt->IsPlayer()) { WorldPacket* data = this->FillMessageData(CHAT_MSG_YELL, LANG_UNIVERSAL, args, crt->GetGUID(), 0); crt->SendMessageToSet(data, true); delete data; } else { crt->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, args); } return true; }
bool ChatHandler::HandleMonsterYellCommand(const char* args, WorldSession *m_session) { Unit* crt = getSelectedUnit(m_session, false); if(!crt) return true; if(crt->IsPlayer()) { WorldPacket * data = FillMessageData(CHAT_MSG_YELL, LANG_UNIVERSAL, args, crt->GetGUID(), 0); crt->SendMessageToSet(data, true); delete data; } else crt->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, args); sWorld.LogGM(m_session, "Used npc yell command on %s %s", crt->IsPlayer() ? "Player" : "Creature", crt->GetName()); return true; }
SPELL_EFFECT_OVERRIDE_RETURNS AH_12043( Aura *aur, bool apply, uint8 i ) { Unit *target = aur->GetTarget(); if( i == 0 && apply == false && target && target->IsPlayer() ) { SafePlayerCast( target )->Cooldown_AddStart( dbcSpell.LookupEntryForced( 12043 ) ); SafePlayerCast( target )->StartClientCooldown( 12043 ); } return SPELL_EFFECT_OVERRIDE_CONTINUE_EXECUTION; }
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 = new Spell(m_session->GetPlayer(), se, true, 0); if (!sp) return true; 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; }
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 %s", static_cast< Creature* >( target )->GetCreatureName() ? static_cast< Creature* >( target )->GetCreatureName()->Name : "unknown"); break; } // If we're killing a player, send a message indicating a gm killed them. if(target->IsPlayer()) { Player * plr = static_cast< Player* >(target); 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 = new Spell(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; }
SPELL_EFFECT_OVERRIDE_RETURNS AH_15473( Aura *aur, bool apply, uint8 i ) { if( i == 0 ) { Unit *target = aur->GetTarget(); //Shadowform - just visual dummy required for 4.3 uint32 SpellId = 107903; if( target->IsPlayer() && SafePlayerCast( target )->HasGlyphWithID( GLYPH_PRIEST_SHADOWFORM ) ) SpellId = 107904; if( apply ) target->CastSpell( target, SpellId, true ); else target->RemoveAura( SpellId,0,AURA_SEARCH_ALL ); } return SPELL_EFFECT_OVERRIDE_CONTINUE_EXECUTION; }
/// Spell Target Handling for type 57: Targeted Party Member void Spell::SpellTargetTargetPartyMember(uint32 i, uint32 j) { if(!m_caster->IsInWorld()) return; if (!m_caster->IsPet() && !m_caster->IsPlayer()) return; TargetsList* tmpMap=&m_targetUnits[i]; Unit* Target = m_caster->GetMapMgr()->GetUnit(m_targets.m_unitTarget); Unit* Caster = static_cast<Unit*>(m_caster); if(!Target || !Caster) return; if (!Target->IsPet() && !Target->IsPlayer()) return; if (Caster->IsPet() && static_cast<Pet*>(Caster)->GetPetOwner() != NULL) Caster = static_cast<Pet*>(Caster)->GetPetOwner(); if(Target->IsPet() && static_cast<Pet*>(Target)->GetPetOwner() != NULL) Target = static_cast<Pet*>(Target)->GetPetOwner(); if (Caster != Target) { Group *c_group = static_cast<Player*>(Caster)->GetGroup(); if( !c_group ) return; //caster or caster master are not in group, cannot cast spell on this target Group *t_group = static_cast<Player*>(Target)->GetGroup(); if( !t_group ) return; //target does not have a group if( t_group != c_group ) return; //caster and target are not in same group } float r=GetMaxRange(dbcSpellRange.LookupEntry(GetProto()->rangeIndex)); if(IsInrange(m_caster->GetPositionX(),m_caster->GetPositionY(),m_caster->GetPositionZ(),Target,r*r)) SafeAddTarget(tmpMap,m_targets.m_unitTarget); }
bool OrbOfTheSindorei(uint32 i, Aura* pAura, bool apply) { Unit* target = pAura->GetTarget(); if(!target->IsPlayer()) return true; if(apply) { uint32 spellid = 0; if(target->getGender() == 0) spellid = 46355; else spellid = 46356; target->CastSpell(target, spellid, true); } return true; }
/// Spell Target Handling for type 18: All Party Members around the Caster in given range NOT RAID void Spell::SpellTargetAllPartyMembersRangeNR(uint32 i, uint32 j) { TargetsList* tmpMap = &m_targetUnits[i]; Player* p = p_caster; if( p == NULL ) { if( static_cast< Creature* >( u_caster)->IsTotem() ) p = static_cast< Player* >( static_cast< Creature* >( u_caster )->GetTotemOwner() ); else if( u_caster->IsPet() && static_cast< Pet* >( u_caster )->GetPetOwner() ) p = static_cast< Pet* >( u_caster )->GetPetOwner(); else if( u_caster->GetUInt64Value( UNIT_FIELD_CREATEDBY ) ) { Unit *t = u_caster->GetMapMgr()->GetUnit( u_caster->GetUInt64Value( UNIT_FIELD_CREATEDBY ) ); if ( t && t->IsPlayer() ) p = static_cast< Player* >( t ); } } if( p == NULL ) return; float r = GetRadius(i); r *= r; if( IsInrange( m_caster->GetPositionX(), m_caster->GetPositionY(), m_caster->GetPositionZ(), p, r ) ) SafeAddTarget( tmpMap, p->GetGUID() ); SubGroup* subgroup = p->GetGroup() ? p->GetGroup()->GetSubGroup( p->GetSubGroup() ) : 0; if( subgroup != NULL ) { p->GetGroup()->Lock(); for(GroupMembersSet::iterator itr = subgroup->GetGroupMembersBegin(); itr != subgroup->GetGroupMembersEnd(); ++itr) { if(!(*itr)->m_loggedInPlayer || m_caster == (*itr)->m_loggedInPlayer) continue; if(IsInrange(m_caster->GetPositionX(),m_caster->GetPositionY(),m_caster->GetPositionZ(),(*itr)->m_loggedInPlayer,r)) SafeAddTarget(tmpMap,(*itr)->m_loggedInPlayer->GetGUID()); } p->GetGroup()->Unlock(); } }
void AIUpdate() { if(_unit->GetHealthPct() < 30) { Unit* pUnit = _unit->GetAIInterface()->GetMostHated(); if(pUnit != NULL && pUnit->IsPlayer()) TO_PLAYER(pUnit)->EventAttackStop(); _unit->SetFaction(35); _unit->GetAIInterface()->WipeHateList(); _unit->GetAIInterface()->WipeTargetList(); _unit->SetStandState(STANDSTATE_SIT); _unit->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); _unit->Despawn(180000, 0); RemoveAIUpdateEvent(); }; };
SPELL_EFFECT_OVERRIDE_RETURNS AH_82926( Aura *aur, bool apply, uint8 i ) { Unit *target = aur->GetTarget(); if( i == 0 && target->IsPlayer() ) { if( apply ) { // SafePlayerCast( target )->addSpell( 82928 ); //Aimed Shot! // SafePlayerCast( target )->SwapActionButtonSpell( 19434, 82928, true, false ); SafePlayerCast( target )->mSpellReplaces[ 19434 ] = 82928; } else { // SafePlayerCast( target )->SwapActionButtonSpell( 82928, 19434, false, true ); // SafePlayerCast( target )->removeSpell( 82928, false, 0, 0 ); //Aimed Shot! SafePlayerCast( target )->mSpellReplaces[ 19434 ] = 0; } } return SPELL_EFFECT_OVERRIDE_CONTINUE_EXECUTION; }
void AIUpdate() { // Let's see if we are netted Aura* a = _unit->FindAura(38177); if(a != NULL) { Unit* Caster = a->GetUnitCaster(); if(Caster->IsPlayer()) { QuestLogEntry* qle = TO_PLAYER(Caster)->GetQuestLogForEntry(10747); if(qle != NULL) { // casting the spell that will create the item for the player _unit->CastSpell(Caster, 38178, true); _unit->Despawn(1000, 360000); } } } }
void AIUpdate() { if(_unit->GetHealthPct() < 30) { Unit *plr = _unit->GetAIInterface()->GetMostHated(); if(plr->IsPlayer()) static_cast<Player*>(plr)->EventAttackStop(); _unit->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, 35); _unit->GetAIInterface()->WipeHateList(); _unit->GetAIInterface()->WipeTargetList(); _unit->_setFaction(); _unit->SetStandState(STANDSTATE_SIT); _unit->SetUInt32Value(UNIT_NPC_FLAGS, 1); _unit->Despawn(180000, 0); RemoveAIUpdateEvent(); } }
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); } } }
bool DeathCoil(uint32 i, Spell* s) { Unit* unitTarget = s->GetUnitTarget(); if(s->p_caster == NULL || unitTarget == NULL) return false; int32 dmg = s->damage; if(isAttackable(s->p_caster, unitTarget, false)) { s->p_caster->CastSpell(unitTarget, 47632, dmg, true); } else if(unitTarget->IsPlayer() && unitTarget->getRace() == RACE_UNDEAD) { dmg *= 1.5; s->p_caster->CastSpell(unitTarget, 47633, dmg, true); } return true; }
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; } sGMLog.writefromsession(m_session, "used kill command on "I64FMT, target->GetGUID()); // If we're killing a player, send a message indicating a gm killed them. if(target->IsPlayer()) { Player * plr = static_cast<Player*>(target); 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 = sSpellStore.LookupEntry(5); if(se == 0) return false; SpellCastTargets targets(target->GetGUID()); Spell * sp = new Spell(m_session->GetPlayer(), se, true, 0); sp->prepare(&targets); */ SpellEntry * se = sSpellStore.LookupEntry(20479); if(se == 0) return false; SpellCastTargets targets(target->GetGUID()); Spell * sp = new Spell(target, se, true, 0); sp->prepare(&targets); } return true; }
SPELL_EFFECT_OVERRIDE_RETURNS AH_82661( Aura *aur, bool apply, uint8 i ) { if( aur->GetSpellProto()->eff[i].EffectApplyAuraName == SPELL_AURA_MOD_IGNORE_INTERRUPT ) { Unit *target = aur->GetTarget(); if( target->IsPlayer() ) { Player *p_target = SafePlayerCast( target ); if(apply) { p_target->AddSpellIgnoringMoveInterrupt( SPELL_HASH_STEADY_SHOT ); p_target->AddSpellIgnoringMoveInterrupt( SPELL_HASH_COBRA_SHOT ); } else { p_target->RemSpellIgnoringMoveInterrupt( SPELL_HASH_STEADY_SHOT ); p_target->RemSpellIgnoringMoveInterrupt( SPELL_HASH_COBRA_SHOT ); } } } return SPELL_EFFECT_OVERRIDE_CONTINUE_EXECUTION; }
void OnLoad() { _unit->SetDisplayId(_unit->GetCreatureInfo()->Female_DisplayID); _unit->SetBaseAttackTime(MELEE, 2000); if (_unit->IsSummon()) { Summon* s = TO< Summon* >(_unit); Unit* owner = s->GetOwner(); if (owner->IsPlayer()) { Player* pOwner = TO< Player* >(owner); Item* item = pOwner->GetItemInterface()->GetInventoryItem(EQUIPMENT_SLOT_MAINHAND); if (item != NULL) { for (int s = 0; s < 5; s++) { if (item->GetProto()->Spells[s].Id == 0) continue; if (item->GetProto()->Spells[s].Trigger == CHANCE_ON_HIT) procSpell[s] = item->GetProto()->Spells[s].Id; } s->SetEquippedItem(MELEE, item->GetEntry()); s->SetBaseAttackTime(MELEE, item->GetProto()->Delay); } pOwner->SetPower(POWER_TYPE_RUNIC_POWER, 0); } s->SetMinDamage(owner->GetDamageDoneMod(SCHOOL_NORMAL)); s->SetMaxDamage(owner->GetDamageDoneMod(SCHOOL_NORMAL)); } }
void OnLoad() { if(!_unit->IsSummon()) return; Unit* summoner = TO< Summon* >(_unit)->GetOwner(); if(summoner != NULL) { if(summoner->IsPlayer()) { Player* p = TO_PLAYER(summoner); if(p->HasQuest(11608)) { GameObject* pSinkhole = p->GetMapMgr()->GetInterface()->GetGameObjectNearestCoords(p->GetPositionX(), p->GetPositionY(), p->GetPositionZ(), 300171); if(pSinkhole != NULL) { _unit->CastSpell(_unit, 45502, true); float posX = pSinkhole->GetPositionX(); if(posX == 2657.13f) sEAS.KillMobForQuest(p, 11608, 0); if(posX == 2716.02f) sEAS.KillMobForQuest(p, 11608, 1); if(posX == 2877.96f) sEAS.KillMobForQuest(p, 11608, 2); if(posX == 2962.16f) sEAS.KillMobForQuest(p, 11608, 3); } } } } _unit->Despawn(500, 0); }
SPELL_EFFECT_OVERRIDE_RETURNS AH_48108( Aura *aur, bool apply, uint8 i ) { Unit *target = aur->GetTarget(); if( i == 0 && target->IsPlayer() ) { if( apply ) { // SafePlayerCast( target )->addSpell( 92315 ); //Pyroblast! // SafePlayerCast( target )->removeSpell( 11366, false, true, 92315 ); //Pyroblast! // SafePlayerCast( target )->SwapActionButtonSpell( 11366, 92315, true, false ); if( SafePlayerCast( target )->HasSpell( 11366 ) ) SafePlayerCast( target )->mSpellReplaces[ 11366 ] = 92315; } else { // SafePlayerCast( target )->SwapActionButtonSpell( 92315, 11366, false, true ); // SafePlayerCast( target )->removeSpell( 92315, false, true, 11366 ); //Pyroblast! // SafePlayerCast( target )->removeSpell( 92315, false, false, 0 ); //Pyroblast! SafePlayerCast( target )->mSpellReplaces[ 11366 ] = 0; } } return SPELL_EFFECT_OVERRIDE_CONTINUE_EXECUTION; }
bool OrbOfTheSindorei(uint32 i, Aura * pAura, bool apply) { Unit* target = pAura->GetTarget(); if( !target || !target->IsPlayer() ) return true; if( apply ) { uint32 spellid = 0; if( target->getGender() == 0 ) spellid = 46355; else spellid = 46356; SpellEntry *sp = dbcSpell.LookupEntry( spellid ); // we need to wait because removing an aura while we are applying leads to a crash // this is because the spell this aura belongs to and the casted spells have the same namehash sEventMgr.AddEvent( target ,&Unit::EventCastSpell , target , sp , EVENT_UNK, 1 , 1, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT ); } return true; }
void Vehicle::EjectPassengerFromSeat( uint32 seatid ){ if( !seats[ seatid ]->Usable() ) return; if( !seats[ seatid ]->HasPassenger() ) return; Unit *passenger = owner->GetMapMgrUnit( seats[ seatid ]->GetPassengerGUID() ); if( passenger == NULL ) return; // set moveflags // set movement info // remove charmed by if passenger was controller if( seats[ seatid ]->Controller() ){ passenger->SetCharmedUnitGUID( 0 ); owner->SetCharmedByGUID( 0 ); if( passenger->IsPlayer() ){ owner->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED_CREATURE | UNIT_FLAG_PVP_ATTACKABLE ); WorldPacket ack( SMSG_CLIENT_CONTROL_UPDATE, 16 ); ack << owner->GetNewGUID(); ack << uint8( 0 ); passenger->SendPacket(&ack); // send null spells if needed static_cast< Player* >( passenger )->SendEmptyPetSpellList(); } } if( passenger->IsPlayer() ) static_cast< Player* >( passenger )->SetFarsightTarget( 0 ); // if we are on a flying vehicle, add a parachute! if( owner->HasAuraWithName( SPELL_AURA_ENABLE_FLIGHT ) || owner->HasAuraWithName( SPELL_AURA_ENABLE_FLIGHT2 ) ) passenger->CastSpell( passenger, 45472, false ); // re-add spellclick flag if needed // despawn vehicle if it was spawned by spell? LocationVector landposition( owner->GetPosition() ); passenger->SendHopOffVehicle( owner, landposition ); passenger->SetPosition( landposition ); passenger->Unroot(); seats[ seatid ]->RemovePassenger(); passenger->SetCurrentVehicle( NULL ); passenger->RemoveFlag( UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_NOT_ATTACKABLE_2 ); passengercount--; freeseats++; if( HasEmptySeat() ){ if( owner->IsPlayer() ) owner->SetFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_PLAYER_VEHICLE ); else owner->SetFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK ); } if( passenger->IsPlayer() ) static_cast< Player* >( passenger )->SpawnActivePet(); if( passenger->IsCreature() ){ Creature *c = static_cast< Creature* >( passenger ); if( c->GetScript() != NULL ){ c->GetScript()->OnExitVehicle(); } } if( owner->IsCreature() ){ Creature *c = static_cast< Creature* >( owner ); if( c->GetScript() != NULL ){ if( passengercount == 0 ) c->GetScript()->OnLastPassengerLeft( passenger ); }else{ // The passenger summoned the vehicle, and we have no script to remove it, so we remove it here if( ( passengercount == 0 ) && ( c->GetSummonedByGUID() == passenger->GetGUID() ) ) c->Despawn( 1 * 1000, 0 ); } } }
void WorldSession::HandleTextEmoteOpcode( WorldPacket & recv_data ) { CHECK_PACKET_SIZE(recv_data, 16); if(!_player->IsInWorld() || !_player->isAlive()) return; uint64 guid; uint32 text_emote, unk, namelen =1; const char* name =" "; recv_data >> text_emote; recv_data >> unk; recv_data >> guid; Unit * pUnit = _player->GetMapMgr()->GetUnit(guid); if(pUnit) { if(pUnit->IsPlayer()) { name = static_cast< Player* >( pUnit )->GetName(); namelen = (uint32)strlen(name) + 1; } else if(pUnit->GetTypeId() == TYPEID_UNIT) { Creature * p = static_cast<Creature*>(pUnit); if(p->GetCreatureName()) { name = p->GetCreatureName()->Name; namelen = (uint32)strlen(name) + 1; } else { name = 0; namelen = 0; } } } emoteentry *em = dbcEmoteEntry.LookupEntry(text_emote); if(em) { WorldPacket data(SMSG_EMOTE, 28 + namelen); sHookInterface.OnEmote(_player, (EmoteType)em->textid); if(pUnit) CALL_SCRIPT_EVENT(pUnit,OnEmote)(_player,(EmoteType)em->textid); switch(em->textid) { case EMOTE_STATE_SLEEP: case EMOTE_STATE_SIT: case EMOTE_STATE_KNEEL: case EMOTE_STATE_DANCE: { _player->SetUInt32Value(UNIT_NPC_EMOTESTATE, em->textid); }break; } data << (uint32)em->textid; data << (uint64)GetPlayer()->GetGUID(); GetPlayer()->SendMessageToSet(&data, true); //If player receives his own emote, his animation stops. data.Initialize(SMSG_TEXT_EMOTE); data << (uint64)GetPlayer()->GetGUID(); data << (uint32)text_emote; data << unk; data << (uint32)namelen; if( namelen > 1 ) data.append(name, namelen); else data << (uint8)0x00; GetPlayer()->SendMessageToSet(&data, true); } }
/// Spell Target Handling for type 6 and 77: Single Target Enemy (grep thinks 77 fits in 6) void Spell::SpellTargetSingleTargetEnemy(uint32 i, uint32 j) { if(!m_caster->IsInWorld()) return; Unit * pTarget = m_caster->GetMapMgr()->GetUnit(m_targets.m_unitTarget); if(!pTarget) return; if(p_caster && p_caster == pTarget) // spell bug: target is supposed to be a single enemy, not self { if(GetProto()) sLog.outDebug("Spell %lu has target single enemy, but is targeting the caster.", GetProto()->Id); } TargetsList* tmpMap=&m_targetUnits[i]; if(m_spellInfo->TargetCreatureType && pTarget->GetTypeId()==TYPEID_UNIT) { Creature* cr = static_cast< Creature* >( pTarget ); if( cr == NULL ) return; if( cr->GetCreatureInfo() ) if(!(1<<(cr->GetCreatureInfo()->Type-1) & m_spellInfo->TargetCreatureType)) return; } if(p_caster && pTarget != p_caster) { // this is mostly used for things like duels if(pTarget->IsPlayer() && !isAttackable(p_caster, pTarget, false)) { cancastresult = SPELL_FAILED_BAD_TARGETS; return; } /* HACK FIX */ /* Please replace if found correct way */ /* SPELL_AURA_SPELL_MAGNET */ int x; for( x = 0; x < 3; ++x ) if( m_spellInfo->EffectApplyAuraName[x] == SPELL_AURA_MOD_POSSESS || m_spellInfo->is_melee_spell ) break; if( pTarget && x == 3 && pTarget->m_magnetcaster != 0) { Unit *MagnetTarget = pTarget->GetMapMgr()->GetUnit(pTarget->m_magnetcaster); if ( MagnetTarget && m_spellInfo->School ) { m_magnetTarget = pTarget->m_magnetcaster; pTarget = MagnetTarget; // Redirected } } } uint8 did_hit_result = DidHit(i,pTarget); if(did_hit_result != SPELL_DID_HIT_SUCCESS) SafeAddModeratedTarget(pTarget->GetGUID(), did_hit_result); else SafeAddTarget(tmpMap, pTarget->GetGUID()); if( m_spellInfo->EffectChainTarget[i] ) { //number of additional targets uint32 jumps = m_spellInfo->EffectChainTarget[i] - 1; // extra targets by auras if( u_caster ) SM_FIValue( u_caster->SM_FAdditionalTargets,(int32*)&jumps, m_spellInfo->SpellGroupType ); float range = GetMaxRange( dbcSpellRange.LookupEntry( m_spellInfo->rangeIndex ) );//this is probably wrong range *= range; std::set<Object*>::iterator itr,itr2; m_caster->AquireInrangeLock(); //make sure to release lock before exit function ! for( itr2 = m_caster->GetInRangeSetBegin(); itr2 != m_caster->GetInRangeSetEnd(); ) { itr = itr2; itr2++; if((*itr)->GetGUID()==m_targets.m_unitTarget) continue; if( !((*itr)->IsUnit()) || !((Unit*)(*itr))->isAlive() || ((*itr)->IsCreature() && ((Creature*)(*itr))->IsTotem())) continue; if( sWorld.Collision && u_caster != NULL ) { if (u_caster->GetMapId() == (*itr)->GetMapId() && !CollideInterface.CheckLOS(u_caster->GetMapId(),u_caster->GetPositionNC(),(*itr)->GetPositionNC())) continue; } if(IsInrange(m_caster->GetPositionX(),m_caster->GetPositionY(),m_caster->GetPositionZ(),(*itr),range)) { if(isAttackable(u_caster,(Unit*)(*itr))) { did_hit_result = DidHit(i,((Unit*)*itr)); if(did_hit_result==SPELL_DID_HIT_SUCCESS) SafeAddTarget(tmpMap, (*itr)->GetGUID()); else SafeAddModeratedTarget((*itr)->GetGUID(), did_hit_result); if(!--jumps) { m_caster->ReleaseInrangeLock(); return; } } } } m_caster->ReleaseInrangeLock(); } }
// Spell Target Handling for type 6 and 77: Single Target Enemy (grep thinks 77 fits in 6) void Spell::SpellTargetSingleTargetEnemy(uint32 i, uint32 j) { if(!m_caster->IsInWorld()) return; Unit* pTarget = m_caster->GetMapMgr()->GetUnit(m_targets.m_unitTarget); if(!pTarget) return; if(m_spellInfo->TargetCreatureType && pTarget->GetTypeId()==TYPEID_UNIT) { Creature* cr = TO_CREATURE( pTarget ); if( cr == NULL ) return; if( cr->GetCreatureInfo() ) if(!(1<<(cr->GetCreatureInfo()->Type-1) & m_spellInfo->TargetCreatureType)) return; } if(p_caster && pTarget != p_caster) { // this is mostly used for things like duels if(pTarget->IsPlayer() && !isAttackable(p_caster, pTarget, false)) { cancastresult = SPELL_FAILED_BAD_TARGETS; return; } } // magnet!!!!! if( pTarget->IsPlayer() && TO_PLAYER(pTarget)->m_magnetAura != NULL && m_magnetTarget == NULL ) { if(!m_spellInfo->is_melee_spell && GetType() == SPELL_DMG_TYPE_MAGIC ) { // redirect it to the magnet m_magnetTarget = TO_PLAYER(pTarget)->m_magnetAura->GetUnitCaster(); // clear the magnet aura TO_PLAYER(pTarget)->m_magnetAura->Remove(); } } if( m_magnetTarget != NULL ) { // if the target exists, shoot it at him. if( m_magnetTarget != NULL && m_magnetTarget->IsInWorld() && !m_magnetTarget->isDead() ) pTarget = m_magnetTarget; } _AddTarget(pTarget, i); if(m_spellInfo->EffectChainTarget[i]) { uint32 jumps=m_spellInfo->EffectChainTarget[i]-1; float range=GetMaxRange(dbcSpellRange.LookupEntry(m_spellInfo->rangeIndex));//this is probably wrong range*=range; unordered_set<Object*>::iterator itr; for( itr = m_caster->GetInRangeSetBegin(); itr != m_caster->GetInRangeSetEnd(); ++itr ) { if((*itr)->GetGUID()==m_targets.m_unitTarget) continue; if( !((*itr)->IsUnit()) || !TO_UNIT(*itr)->isAlive()) continue; if(IsInrange(m_caster->GetPositionX(),m_caster->GetPositionY(),m_caster->GetPositionZ(),(*itr),range)) { if(isAttackable(u_caster,TO_UNIT(*itr))) { _AddTarget(TO_UNIT(*itr), i); if(!--jumps) return; } } } } }