Skip to content
This repository has been archived by the owner on Dec 21, 2020. It is now read-only.

Commit

Permalink
* added method void OnRespawn(Unit* unit)
Browse files Browse the repository at this point in the history
  • Loading branch information
schnek committed Apr 11, 2012
1 parent 628717f commit baa7902
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 67 deletions.
38 changes: 26 additions & 12 deletions src/WorldServer/AIInterface.cpp
Expand Up @@ -105,8 +105,8 @@ void AIInterface::Init(Unit* un, AIType at, MovementType mt)

m_Unit = un;

m_walkSpeed = m_Unit->m_walkSpeed*0.001f;//move distance per ms time
m_runSpeed = m_Unit->m_runSpeed*0.001f;//move distance per ms time
m_walkSpeed = m_Unit->m_walkSpeed*0.001f; // move distance per ms time
m_runSpeed = m_Unit->m_runSpeed*0.001f; // move distance per ms time
m_flySpeed = m_Unit->m_flySpeed * 0.001f;

m_sourceX = un->GetPositionX();
Expand Down Expand Up @@ -149,8 +149,8 @@ void AIInterface::Init(Unit* un, AIType at, MovementType mt, Unit* owner)
m_Unit = un;
m_PetOwner = owner;

m_walkSpeed = m_Unit->m_walkSpeed*0.001f;//move distance per ms time
m_runSpeed = m_Unit->m_runSpeed*0.001f;//move/ms
m_walkSpeed = m_Unit->m_walkSpeed*0.001f; // move distance per ms time
m_runSpeed = m_Unit->m_runSpeed*0.001f; // move/ms
m_flySpeed = m_Unit->m_flySpeed*0.001f;
m_sourceX = un->GetPositionX();
m_sourceY = un->GetPositionY();
Expand Down Expand Up @@ -197,7 +197,7 @@ void AIInterface::HandleEvent(uint32 event, Unit* pUnit, uint32 misc1)
m_returnY = m_Unit->GetPositionY();
m_returnZ = m_Unit->GetPositionZ();

m_moveRun = true; //run to the target
m_moveRun = true; // run to the target

// dismount if mounted
m_Unit->Dismount();
Expand All @@ -218,7 +218,7 @@ void AIInterface::HandleEvent(uint32 event, Unit* pUnit, uint32 misc1)
m_ChainAgroSet->EventEnterCombat( pUnit );
}

//Mark raid as combat in progress if it concerns a boss
// Mark raid as combat in progress if it concerns a boss
if(pUnit->GetMapMgr() && pUnit->GetMapMgr()->GetMapInfo() && pUnit->GetMapMgr()->GetMapInfo()->type == INSTANCE_RAID)
{
if(m_Unit->GetTypeId() == TYPEID_UNIT && m_Unit->m_loadedFromDB )
Expand Down Expand Up @@ -267,8 +267,8 @@ void AIInterface::HandleEvent(uint32 event, Unit* pUnit, uint32 misc1)
}
}

//reset ProcCount
//ResetProcCounts();
// reset ProcCount
// ResetProcCounts();
m_moveRun = true;
m_aiTargets.clear();
m_fleeTimer = 0;
Expand Down Expand Up @@ -409,7 +409,6 @@ void AIInterface::HandleEvent(uint32 event, Unit* pUnit, uint32 misc1)

m_WanderTimer = 0;

//CALL_SCRIPT_EVENT(m_Unit, OnWander)(pUnit, 0); FIXME
m_AIState = STATE_WANDER;
StopMovement(1);

Expand Down Expand Up @@ -441,7 +440,7 @@ void AIInterface::HandleEvent(uint32 event, Unit* pUnit, uint32 misc1)
}
}

//Should be able to do this stuff even when evading
// Should be able to do this stuff even when evading
switch(event)
{
case EVENT_UNITDIED:
Expand Down Expand Up @@ -483,15 +482,15 @@ void AIInterface::HandleEvent(uint32 event, Unit* pUnit, uint32 misc1)

SetNextTarget(NULL);

//reset waypoint to 1
// reset waypoint to 1
m_currentWaypoint = 1;

// There isn't any need to do any attacker checks here, as
// they should all be taken care of in DealDamage

if(cr != NULL && !m_Unit->IsPet())
{
//only save creature which exist in db (don't want to save 0 values in db)
// only save creature which exist in db (don't want to save 0 values in db)
if( m_Unit->m_loadedFromDB && cr->m_spawn != NULL )
{
MapMgr* GMap = m_Unit->GetMapMgr();
Expand All @@ -504,6 +503,16 @@ void AIInterface::HandleEvent(uint32 event, Unit* pUnit, uint32 misc1)
}
}
}break;

case EVENT_UNITRESPAWN:
{
// send the message
if( cr != NULL )
{
if( cr->has_combat_text )
objmgr.HandleMonsterSayEvent( cr, MONSTER_SAY_EVENT_ON_SPAWN );
}
}break;
}
}

Expand Down Expand Up @@ -1270,6 +1279,11 @@ void AIInterface::OnDeath(Object* pKiller)
HandleEvent(EVENT_UNITDIED, m_Unit, 0);
}

void AIInterface::OnRespawn(Unit* unit)
{
HandleEvent(EVENT_UNITRESPAWN, unit, 0);
}

Unit* AIInterface::FindTarget()
{
// find nearest hostile Target to attack
Expand Down
5 changes: 3 additions & 2 deletions src/WorldServer/AIInterface.h
Expand Up @@ -8,7 +8,7 @@

#include "AchievementDefines.h"

#define UNIT_MOVEMENT_INTERPOLATE_INTERVAL 400/*750*/ // ms smoother server/client side moving vs less cpu/ less b/w
#define UNIT_MOVEMENT_INTERPOLATE_INTERVAL 400 /*750*/ // ms smoother server/client side moving vs less cpu/ less b/w
#define TARGET_UPDATE_INTERVAL 600 // ms
#define PLAYER_SIZE 1.5f

Expand Down Expand Up @@ -149,6 +149,7 @@ class SERVER_DECL AIInterface
// Event Handler
void HandleEvent(uint32 event, Unit* pUnit, uint32 misc1);
void OnDeath(Object* pKiller);
void OnRespawn(Unit* unit); // We don't really need the unit anymore.
void AttackReaction( Unit* pUnit, uint32 damage_dealt, uint32 spellId = 0);
bool HealReaction(Unit* caster, Unit* victim, uint32 amount, SpellEntry * sp);
void Event_Summon_Elemental(uint32 summon_duration, uint32 TotemEntry, int32 ResistanceType, uint8 Slot);
Expand Down Expand Up @@ -240,7 +241,7 @@ class SERVER_DECL AIInterface
{
m_Unit->SetTargetGUID(m_nextTarget->GetGUID());
#ifdef ENABLE_GRACEFULL_HIT
have_graceful_hit=false;
have_graceful_hit = false;
#endif
}
else m_Unit->SetTargetGUID(0);
Expand Down
1 change: 1 addition & 0 deletions src/WorldServer/AchievementDefines.h
Expand Up @@ -262,6 +262,7 @@ enum AiEvents
EVENT_WANDER,
EVENT_UNWANDER,
EVENT_UNITDIED,
EVENT_UNITRESPAWN,
};

enum MapMgrTimers
Expand Down
4 changes: 2 additions & 2 deletions src/WorldServer/ChannelHandler.cpp
Expand Up @@ -13,7 +13,7 @@ void WorldSession::HandleChannelJoin(WorldPacket& recvPacket)
CHECK_PACKET_SIZE(recvPacket, 1);
string channelname,pass;
uint32 dbc_id = 0;
uint16 crap; // crap = some sort of channel type?
uint16 crap; // crap = some sort of channel type?
uint32 i;
Channel * chn;

Expand All @@ -31,7 +31,7 @@ void WorldSession::HandleChannelJoin(WorldPacket& recvPacket)
}

if(i == 3)
return; // don't join lfg
return; // don't join lfg
}

if( sWorld.GmClientChannel.size() && !stricmp(sWorld.GmClientChannel.c_str(), channelname.c_str()) && !GetPermissionCount())
Expand Down
10 changes: 4 additions & 6 deletions src/WorldServer/MapMgr.cpp
Expand Up @@ -89,7 +89,7 @@ void MapMgr::Init()

MapMgr::~MapMgr()
{
SetThreadName("thread_proc");//free the name
SetThreadName("thread_proc"); // free the name

sEventMgr.RemoveEvents(this);
sEventMgr.RemoveEventHolder(m_instanceID);
Expand Down Expand Up @@ -508,8 +508,7 @@ void MapMgr::RemoveObject(Object* obj, bool free_guid)
if(!obj->GetMapCell())
{
/* set the map cell correctly */
if(obj->GetPositionX() >= _maxX || obj->GetPositionX() <= _minY ||
obj->GetPositionY() >= _maxY || obj->GetPositionY() <= _minY)
if(obj->GetPositionX() >= _maxX || obj->GetPositionX() <= _minY || obj->GetPositionY() >= _maxY || obj->GetPositionY() <= _minY)
{
// do nothing
}
Expand Down Expand Up @@ -1066,7 +1065,6 @@ void MapMgr::UpdateCellActivity(uint32 x, uint32 y, int radius)
}
}
}

}

void MapMgr::AddForcedCell(MapCell * c)
Expand Down Expand Up @@ -1660,8 +1658,8 @@ void MapMgr::EventRespawnCreature(Creature* c, MapCell * p)
c->m_respawnCell = NULL;
p->_respawnObjects.erase(itr);
c->OnRespawn(this);
//if(c->GetAIInterface())
// c->GetAIInterface()->OnRespawn(c);
if(c->GetAIInterface())
c->GetAIInterface()->OnRespawn(c);
}
}

Expand Down
19 changes: 9 additions & 10 deletions src/WorldServer/MapMgr.h
Expand Up @@ -24,23 +24,23 @@ class CBattleground;
class Instance;
class InstanceScript;

typedef unordered_set<Object* > ObjectSet;
typedef unordered_set<Object* > UpdateQueue;
typedef unordered_set<Player* > PUpdateQueue;
typedef unordered_set<Player* > PlayerSet;
typedef HM_NAMESPACE::hash_map<uint32, Object* > StorageMap;
typedef unordered_set<Object*> ObjectSet;
typedef unordered_set<Object*> UpdateQueue;
typedef unordered_set<Player*> PUpdateQueue;
typedef unordered_set<Player*> PlayerSet;
typedef HM_NAMESPACE::hash_map<uint32, Object*> StorageMap;
typedef unordered_set<uint64> CombatProgressMap;
typedef unordered_set<Vehicle*> VehicleSet;
typedef unordered_set<Creature*> CreatureSet;
typedef unordered_set<GameObject* > GameObjectSet;
typedef HM_NAMESPACE::hash_map<uint32, Vehicle*> VehicleSqlIdMap;
typedef HM_NAMESPACE::hash_map<uint32, Creature*> CreatureSqlIdMap;
typedef HM_NAMESPACE::hash_map<uint32, GameObject* > GameObjectSqlIdMap;
typedef HM_NAMESPACE::hash_map<uint32, GameObject*> GameObjectSqlIdMap;

#define MAX_TRANSPORTERS_PER_MAP 25
#define RESERVE_EXPAND_SIZE 1024

class Transporter;
#define RESERVE_EXPAND_SIZE 1024

#define CALL_INSTANCE_SCRIPT_EVENT( Mgr, Func ) if ( Mgr != NULL && Mgr->GetScript() != NULL ) Mgr->GetScript()->Func

Expand All @@ -52,8 +52,7 @@ class SERVER_DECL MapMgr : public CellHandler <MapCell>, public EventableObject,
friend class MapScriptInterface;

public:
//This will be done in regular way soon

// This will be done in regular way soon
Mutex m_objectinsertlock;
ObjectSet m_objectinsertpool;
void AddObject(Object*);
Expand Down Expand Up @@ -305,7 +304,7 @@ class SERVER_DECL MapMgr : public CellHandler <MapCell>, public EventableObject,
MapScriptInterface * ScriptInterface;

/* Update System */
FastMutex m_updateMutex; // use a user-mode mutex for extra speed
FastMutex m_updateMutex; // use a user-mode mutex for extra speed
UpdateQueue _updates;
PUpdateQueue _processQueue;

Expand Down

0 comments on commit baa7902

Please sign in to comment.