From b29af701b9a0b6bfbd2acaae06e32e9742fd7e78 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Sat, 22 Dec 2012 10:15:53 +0000 Subject: MTRand reference is now passed as a Tick() parameter so that it isn't created and destroyed over and over again. All entities will handle physics (empty callback for now) git-svn-id: http://mc-server.googlecode.com/svn/trunk@1096 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/Mobs/AggressiveMonster.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'source/Mobs/AggressiveMonster.cpp') diff --git a/source/Mobs/AggressiveMonster.cpp b/source/Mobs/AggressiveMonster.cpp index f2e53ce00..14c3135be 100644 --- a/source/Mobs/AggressiveMonster.cpp +++ b/source/Mobs/AggressiveMonster.cpp @@ -23,9 +23,9 @@ cAggressiveMonster::cAggressiveMonster(const AString & a_ConfigName, char a_Prot // What to do if in Chasing State -void cAggressiveMonster::InStateChasing(float a_Dt) +void cAggressiveMonster::InStateChasing(float a_Dt, MTRand & a_TickRandom) { - super::InStateChasing(a_Dt); + super::InStateChasing(a_Dt, a_TickRandom); m_ChaseTime += a_Dt; if (m_Target != NULL) { @@ -58,9 +58,9 @@ void cAggressiveMonster::InStateChasing(float a_Dt) -void cAggressiveMonster::EventSeePlayer(cEntity * a_Entity) +void cAggressiveMonster::EventSeePlayer(cEntity * a_Entity, MTRand & a_TickRandom) { - super::EventSeePlayer(a_Entity); + super::EventSeePlayer(a_Entity, a_TickRandom); m_EMState = CHASING; } @@ -68,27 +68,26 @@ void cAggressiveMonster::EventSeePlayer(cEntity * a_Entity) -void cAggressiveMonster::Tick(float a_Dt) +void cAggressiveMonster::Tick(float a_Dt, MTRand & a_TickRandom) { - super::Tick(a_Dt); + super::Tick(a_Dt, a_TickRandom); m_SeePlayerInterval += a_Dt; if (m_SeePlayerInterval > 1) { - MTRand r1; - int rem = r1.randInt() % 3 + 1; // Check most of the time but miss occasionally + int rem = a_TickRandom.randInt() % 3 + 1; // Check most of the time but miss occasionally m_SeePlayerInterval = 0.0; if (rem >= 2) { if (m_EMState == CHASING) { - CheckEventLostPlayer(); + CheckEventLostPlayer(a_TickRandom); } else { - CheckEventSeePlayer(); + CheckEventSeePlayer(a_TickRandom); } } } -- cgit v1.2.3