Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

* ADDED: Totems will no longer attack unflagged pets

* ADDED: Pets will no longer attack unflagged totems
* ADDED: Pets will no longer attack unflagged summons
* ADDED: pets will lose/gain PvP flag with their owner
* ADDED: Totems will flag the owner for PvP if we attack a PvP combatant
* ADDED: Pets will flag their owner for PvP if we attack a PvP combatant
* ADDED: Players attacking a PvP combatant will get flagged
* ADDED: Players attacking a PvP combatant with summons will get flagged
* ADDED: Players attacking a PvP NPC will get flagged
* FIXED: my own screwup, Creatures not attacking unflagged Players, tks Andy for pointing this out!
  • Loading branch information...
commit 4decaf8c50c8cf8c008ecc966abc979fcf816056 1 parent 6887858
@dfighter1985 dfighter1985 authored
View
6 src/arcemu-shared/ByteBuffer.h
@@ -355,7 +355,11 @@ class SERVER_DECL ByteBuffer {
// then think some more
// then use something else
// -- qz
- ASSERT(size() < 10000000);
+ // ASSERT(size() < 10000000);
+
+
+ // this way hopefully people will report the callstack after it "crashes"
+ assert( size() < 10000000 );
if (_storage.size() < _wpos + cnt)
_storage.resize(_wpos + cnt);
View
85 src/arcemu-world/AIInterface.cpp
@@ -1722,11 +1722,13 @@ Unit* AIInterface::FindTarget()
Unit *pUnit;
float dist;
- /* Don't remove this please! - dfighter
+ // Don't remove this please! - dfighter
+ /*
if( m_AIType == AITYPE_PET ){
printf("I'm a pet and I'm looking for targets, RAWR!\n");
}
*/
+
/* Commented due to no use
bool pvp=true;
@@ -1805,8 +1807,8 @@ Unit* AIInterface::FindTarget()
++pitr2;
pUnit = *pitr;
-
- if( UnsafeCanOwnerAttackUnit( pUnit ) == false )
+
+ if( UnsafeCanOwnerAttackUnit( pUnit ) == false )
continue;
//on blizz there is no Z limit check
@@ -1815,13 +1817,21 @@ Unit* AIInterface::FindTarget()
if(dist > distance) // we want to find the CLOSEST target
continue;
- // We don't want to attack non-flagged people!
- if( pUnit->IsPlayer() && !pUnit->IsPvPFlagged())
- continue;
+ if( m_Unit->IsCreature() ){
+ Creature *pCreature = static_cast< Creature* >( m_Unit );
- // We don't want to accidentally flag ourselves
- if( pUnit->IsPlayer() && !m_Unit->IsPvPFlagged() )
- continue;
+ // We are only interested in pets, totems, and summons
+ if( pCreature->IsPet() || pCreature->IsTotem() || pCreature->GetOwner() != NULL ){
+
+ // We don't want to attack unflagged players
+ if( pUnit->IsPlayer() && !pUnit->IsPvPFlagged())
+ continue;
+
+ // We don't want to accidentally flag ourselves
+ if( pUnit->IsPlayer() && !m_Unit->IsPvPFlagged() )
+ continue;
+ }
+ }
if(dist <= _CalcAggroRange(pUnit) )
{
@@ -1851,27 +1861,44 @@ Unit* AIInterface::FindTarget()
if( !(*itr)->IsUnit() )
continue;
- // We checked for player targets before
+ // We checked for player targets before, so this shouldn't happen
+ // [14:45] <+burlex> but andy
+ // [14:45] <+burlex> dey have dead pointerz
if( (*itr)->IsPlayer() )
continue;
pUnit = static_cast< Unit* >( (*itr) );
- // We don't want to attack unflagged pets
- if( pUnit->IsPet() && !pUnit->IsPvPFlagged() )
- continue;
-
- // We don't want to accidentally flag ourselves
- if( pUnit->IsPet() && !m_Unit->IsPvPFlagged() )
- continue;
-
- // if the target is not attackable we are not going to attack it and find a new target, if possible
- if( pUnit->IsCreature() )
+ if( pUnit->IsCreature() )
{
- Creature *pCreature = static_cast<Creature*>( pUnit );
- if( pCreature->m_spawn && !pCreature->isattackable( pCreature->m_spawn ) )
- continue;
- }
+ Creature *pCreature = static_cast<Creature*>( pUnit );
+
+ // We are only interested in pets, totems, and summons
+ if( pCreature->IsPet() || pCreature->IsTotem() || pCreature->GetOwner() != NULL ){
+
+ // We don't want to attack unflagged pets
+ if( pUnit->IsPet() && !pUnit->IsPvPFlagged() )
+ continue;
+
+ // We don't want to accidentally flag ourselves
+ if( pUnit->IsPet() && !m_Unit->IsPvPFlagged() )
+ continue;
+
+ // if the target is not attackable we are not going to attack it and find a new target, if possible
+ if( pCreature->m_spawn && !pCreature->isattackable( pCreature->m_spawn ) )
+ continue;
+
+ // We don't attack non-flagged totems
+ if( m_Unit->IsPet() && pCreature->IsTotem() && !pCreature->IsPvPFlagged() )
+ continue;
+
+ // it's a summon and the owner is a player
+ if(pCreature->GetOwner() != NULL && pCreature->GetOwner()->IsPlayer()){
+ if( !pCreature->IsPvPFlagged() )
+ continue;
+ }
+ }
+ }
if( UnsafeCanOwnerAttackUnit( pUnit ) == false )
continue;
@@ -4251,9 +4278,10 @@ void AIInterface::Event_Summon_EE_totem(uint32 summon_duration)
else
ourslave->RemovePvPFlag();
+ static_cast< Creature* >(ourslave)->SetOwner( caster );
+
ourslave->SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED | UNIT_FLAG_SELF_RES);
- ourslave->SetUInt32Value(UNIT_DYNAMIC_FLAGS, 0);
-
+
/*
- Earth Stun (37982)
- taunt
@@ -4285,9 +4313,10 @@ void AIInterface::Event_Summon_FE_totem(uint32 summon_duration)
else
ourslave->RemovePvPFlag();
+ static_cast< Creature* >(ourslave)->SetOwner( caster );
+
ourslave->SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED | UNIT_FLAG_SELF_RES);
- ourslave->SetUInt32Value(UNIT_DYNAMIC_FLAGS, 0);
- /*
+ /*
- also : select * from dbc_spell where name like "%fire blast%"
- also : select * from dbc_spell where name like "%fire nova"
*/
View
2  src/arcemu-world/Creature.cpp
@@ -72,6 +72,8 @@ Creature::Creature(uint64 guid)
totemOwner = NULL;
totemSlot = -1;
+ m_owner = NULL;
+
m_PickPocketed = false;
m_SellItems = NULL;
_myScriptClass = NULL;
View
4 src/arcemu-world/Creature.h
@@ -554,9 +554,12 @@ class SERVER_DECL Creature : public Unit
bool RemoveEnslave();
ARCEMU_INLINE Player *GetTotemOwner() { return totemOwner; }
+ // Owner unit (the one that summoned it)
+ ARCEMU_INLINE Unit *GetOwner(){ return m_owner; }
ARCEMU_INLINE void SetTotemOwner(Player *owner) { totemOwner = owner; }
ARCEMU_INLINE uint32 GetTotemSlot() { return totemSlot; }
ARCEMU_INLINE void SetTotemSlot(uint32 slot) { totemSlot = slot; }
+ ARCEMU_INLINE void SetOwner( Unit *pUnitOwner ){ m_owner = pUnitOwner; }
virtual Group *GetGroup();
@@ -657,6 +660,7 @@ class SERVER_DECL Creature : public Unit
uint32 m_enslaveSpell;
Player * totemOwner;
+ Unit * m_owner;
int32 totemSlot;
bool m_PickPocketed;
View
82 src/arcemu-world/Object.cpp
@@ -1962,25 +1962,69 @@ void Object::DealDamage(Unit *pVictim, uint32 damage, uint32 targetEvent, uint32
pVictim->SetStandState( STANDSTATE_STAND );//probably mobs also must standup
}
- // This one is easy. If we're attacking a hostile target, and we're not flagged, flag us.
- // Also, you WONT get flagged if you are dueling that person - FiShBaIt
- if( pVictim->IsPlayer() && IsPlayer() )
- {
- if( isHostile( this, pVictim ) && static_cast< Player* >( pVictim )->DuelingWith != static_cast< Player* >( this ) )
- static_cast< Player* >( this )->SetPvPFlag();
+/////////////////////////////////////////////////////// PvP flagging on attack ///////////////////////////////////////////////
+{
+ Player *pOwner = NULL; // Player we are attacking, or the owner of totem/pet/etc
+ Player *pAttacker = NULL; // This is the player or the player controlling the totem/pet/summon
+
+ if( pVictim->IsPlayer() ){
+ pOwner = static_cast< Player* >( pVictim );
+ }
+ else
+ if( pVictim->IsPet() ){
+ pOwner = static_cast< Pet* >( pVictim )->GetPetOwner();
+ }
+ else
+ if( pVictim->IsCreature() && static_cast< Creature* >( pVictim )->IsTotem() ){
+ pOwner = static_cast< Creature* >( pVictim )->GetTotemOwner();
+ }
+ else
+ if( pVictim->IsCreature() && static_cast< Creature* >( pVictim )->GetOwner() != NULL && static_cast< Creature* >( pVictim )->GetOwner()->IsPlayer() ){
+ pOwner = static_cast< Player* >( static_cast< Creature* >( pVictim )->GetOwner() );
+ }
+
+
+
+
+ if( this->IsPlayer() ){
+ pAttacker = static_cast< Player* >( this );
}
- //If our pet attacks - flag us.
- if( pVictim->IsPlayer() && IsPet() )
- {
- Player* owner = static_cast< Pet* >( this )->GetPetOwner();
- if( owner != NULL )
- if( owner->isAlive() && static_cast< Player* >( pVictim )->DuelingWith != owner )
- {
- owner->SetPvPFlag();
- static_cast< Unit* >( this )->AggroPvPGuards();
- }
+ else
+ if( this->IsPet() ){
+ pAttacker = static_cast< Pet* >( this )->GetPetOwner();
+
+ // Pet must have an owner
+ assert( pAttacker != NULL );
}
+ else // Player totem
+ if( this->IsCreature() && static_cast< Creature* >( this )->IsTotem() ){
+ pAttacker = static_cast< Creature* >( this )->GetTotemOwner();
+
+ // Totem must have an owner
+ assert( pAttacker != NULL );
+
+ }
+ else // Player summon
+ if( this->IsCreature() && static_cast< Creature* >( this )->GetOwner() != NULL && static_cast< Creature* >( this )->GetOwner()->IsPlayer() ){
+ pAttacker = static_cast< Player*>( static_cast< Creature* >( this )->GetOwner() );
+ }
+
+ // We identified both the attacker and the victim as possible PvP combatants, if we are not dueling we will flag the attacker
+ if( pOwner != NULL && pAttacker != NULL ){
+ if( pOwner != pAttacker->DuelingWith ){
+ pAttacker->SetPvPFlag();
+ pAttacker->AggroPvPGuards();
+ }
+ }
+
+ // PvP NPCs
+ if( pVictim->IsCreature() && pVictim->IsPvPFlagged() && pAttacker != NULL ){
+ pAttacker->SetPvPFlag();
+ pAttacker->AggroPvPGuards();
+ }
+}
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if(!no_remove_auras)
{
//zack 2007 04 24 : root should not remove self (and also other unknown spells)
@@ -2878,6 +2922,12 @@ void Object::DealDamage(Unit *pVictim, uint32 damage, uint32 targetEvent, uint32
// We don't want to reference a possibly logged out player or removed creature, better be safe than sorry!
if(pVictim->GetUInt64Value(UNIT_FIELD_CREATEDBY) != 0)
pVictim->SetUInt64Value(UNIT_FIELD_CREATEDBY, 0);
+ // Same as the above
+ if( pVictim->IsCreature() ){
+ Creature *pCreature = static_cast<Creature*>( pVictim );
+ if(pCreature->GetOwner() != NULL)
+ pCreature->SetOwner( NULL );
+ }
#ifdef ENABLE_ACHIEVEMENTS
if(isCritter)
View
17 src/arcemu-world/PetHandler.cpp
@@ -167,6 +167,23 @@ void WorldSession::HandlePetAction(WorldPacket & recv_data)
pPet->SendActionFeedback( PET_FEEDBACK_CANT_ATTACK_TARGET );
return;
}
+
+ if( pTarget->IsCreature() && static_cast<Creature*>( pTarget )->IsTotem() && !pTarget->IsPvPFlagged() ){
+ pPet->SendActionFeedback( PET_FEEDBACK_CANT_ATTACK_TARGET );
+ return;
+ }
+
+ if( pTarget->IsCreature() ){
+ Creature *pCreature = static_cast< Creature* >( pTarget );
+
+ // it's a summon and the owner is a player
+ if(pCreature->GetOwner() != NULL && pCreature->GetOwner()->IsPlayer()){
+ if( !pCreature->IsPvPFlagged() ){
+ pPet->SendActionFeedback( PET_FEEDBACK_CANT_ATTACK_TARGET );
+ return;
+ }
+ }
+ }
}
if(sp->autocast_type != AUTOCAST_EVENT_ATTACK)
View
10 src/arcemu-world/Player.cpp
@@ -2145,6 +2145,16 @@ void Player::SpawnPet( uint32 pet_number )
}
Pet *pPet = objmgr.CreatePet( itr->second->entry );
pPet->LoadFromDB( this, itr->second );
+
+// For some awesomely weird reason they get 41 as bytes2, this keeps me from flagging them - dfighter
+// dfighter hacks
+ pPet->SetUInt32Value( UNIT_FIELD_BYTES_2, 0 );
+
+ if( this->IsPvPFlagged() )
+ pPet->SetPvPFlag();
+ else
+ pPet->RemovePvPFlag();
+////////////////////////////////////////////////////////////////////////////////
if( itr->second->spellid )
{
View
10 src/arcemu-world/Player.h
@@ -1912,6 +1912,10 @@ class SERVER_DECL Player : public Unit
}
}
+ // flagging the pet too for PvP, if we have one
+ if( m_Summon != NULL )
+ m_Summon->SetPvPFlag();
+
if( CombatStatus.IsInCombat() )
SetFlag(PLAYER_FLAGS, 0x100);
}
@@ -1932,7 +1936,11 @@ class SERVER_DECL Player : public Unit
static_cast<Unit*>( m_TotemSlots[i] )->summonPet->RemovePvPFlag();
}
}
- }
+
+ // If we have a pet we will remove the pvp flag from that too
+ if( m_Summon != NULL )
+ m_Summon->SetPvPFlag();
+ }
ARCEMU_INLINE bool IsFFAPvPFlagged()
{
View
13 src/arcemu-world/faction.cpp
@@ -129,6 +129,18 @@ bool isHostile(Object* objA, Object* objB)// B is hostile for A?
// PvP Flag System Checks
// We check this after the normal isHostile test, that way if we're
// on the opposite team we'll already know :p
+
+
+//// If you break these I'm going to pay a visit to you IRL - dfighter
+
+ if( hostile && ( objA->IsPlayer() || objA->IsPet() || ( objA->IsCreature() && static_cast< Creature* >( objA )->IsTotem() ) ) && objB->IsPlayer() && !static_cast<Player*>( objB )->IsPvPFlagged() ){
+ return false;
+ }
+
+ if( hostile && ( objA->IsPlayer() || objA->IsPet() || ( objA->IsCreature() && static_cast< Creature* >( objA )->IsTotem() ) ) && objB->IsPet()&& !static_cast< Pet* >( objB )->GetPetOwner()->IsPvPFlagged()){
+ return false;
+ }
+////////////////////////////////////////////////////////////////////
if( hostile && ( objA->IsPlayer() || objA->IsPet() || ( objA->IsUnit() && !objA->IsPlayer() && static_cast< Creature* >( objA )->IsTotem() && static_cast< Creature* >( objA )->GetTotemOwner()->IsPvPFlagged() ) ) )
{
@@ -140,6 +152,7 @@ bool isHostile(Object* objA, Object* objB)// B is hostile for A?
else
return false;
}
+
if( objB->IsPet() )
{
#if defined(WIN32) && defined(HACKY_CRASH_FIXES)
Please sign in to comment.
Something went wrong with that request. Please try again.