From 9cf709ff5aaa5932ab472f408e2bd439d2018f04 Mon Sep 17 00:00:00 2001 From: pyrolink Date: Sun, 13 Nov 2005 06:42:12 +0000 Subject: [PATCH] Added entity heal capabilities/ This was SVN commit r3127. --- source/simulation/Entity.cpp | 9 +++++++++ source/simulation/Entity.h | 3 +++ source/simulation/EntityOrders.h | 2 ++ source/simulation/EntityStateProcessing.cpp | 11 ++++++++++- source/simulation/EventHandlers.cpp | 6 +++++- source/simulation/EventHandlers.h | 7 ++++++- 6 files changed, 35 insertions(+), 3 deletions(-) diff --git a/source/simulation/Entity.cpp b/source/simulation/Entity.cpp index 2ffc781d82..6624e8ea9c 100755 --- a/source/simulation/Entity.cpp +++ b/source/simulation/Entity.cpp @@ -49,6 +49,9 @@ CEntity::CEntity( CBaseEntity* base, CVector3D position, float orientation ) AddProperty( L"actions.gather.range", &( m_gather.m_MaxRange ) ); AddProperty( L"actions.gather.rangemin", &( m_gather.m_MinRange ) ); AddProperty( L"actions.gather.speed", &( m_gather.m_Speed ) ); + AddProperty( L"actions.heal.range", &( m_heal.m_MaxRange ) ); + AddProperty( L"actions.heal.rangemin", &( m_heal.m_MinRange ) ); + AddProperty( L"actions.heal.speed", &( m_hea;.m_Speed ) ); AddProperty( L"position", &m_graphics_position, false, (NotifyFn)&CEntity::teleport ); AddProperty( L"orientation", &m_graphics_orientation, false, (NotifyFn)&CEntity::reorient ); AddProperty( L"player", &m_player ); @@ -328,6 +331,12 @@ void CEntity::update( size_t timestep ) case CEntityOrder::ORDER_GATHER_NOPATHING: if( processGatherNoPathing( current, timestep ) ) break; return; + case CEntityOrder::ORDER_HEAL: + if( processHeal( current, timestep ) ) break; + return; + case CEntityOrder::ORDER_HEAL_NOTPATHING: + if( processHealNoPathing( current, timestamp ) ) break; + return; case CEntityOrder::ORDER_GOTO: if( processGoto( current, timestep ) ) break; return; diff --git a/source/simulation/Entity.h b/source/simulation/Entity.h index 3540804317..cbc22c2567 100755 --- a/source/simulation/Entity.h +++ b/source/simulation/Entity.h @@ -68,6 +68,7 @@ public: float m_turningRadius; SEntityAction m_melee; SEntityAction m_gather; + SEntityAction m_heal; bool m_selected; i32 m_grouped; @@ -148,6 +149,8 @@ private: bool processAttackMeleeNoPathing( CEntityOrder* current, size_t timestep_milli ); bool processGather( CEntityOrder* current, size_t timestep_milli ); bool processGatherNoPathing( CEntityOrder* current, size_t timestep_milli ); + bool processHeal( CEntityOrder* current, size_t timestep_milli ); + bool processHealNoPathing( CEntityOrder* current, size_t timestep_milli ); bool processGotoNoPathing( CEntityOrder* current, size_t timestep_milli ); bool processGoto( CEntityOrder* current, size_t timestep_milli ); diff --git a/source/simulation/EntityOrders.h b/source/simulation/EntityOrders.h index 6227c32c78..69aad35ad5 100755 --- a/source/simulation/EntityOrders.h +++ b/source/simulation/EntityOrders.h @@ -60,6 +60,8 @@ public: ORDER_ATTACK_MELEE_NOPATHING, ORDER_GATHER, ORDER_GATHER_NOPATHING, + ORDER_HEAL, + ORDER_HEAL_NOTPATHING, ORDER_PATH_END_MARKER, ORDER_LAST } m_type; diff --git a/source/simulation/EntityStateProcessing.cpp b/source/simulation/EntityStateProcessing.cpp index d9943f30ba..8c78c06016 100755 --- a/source/simulation/EntityStateProcessing.cpp +++ b/source/simulation/EntityStateProcessing.cpp @@ -505,7 +505,16 @@ bool CEntity::processGatherNoPathing( CEntityOrder* current, size_t timestep_mil if( !m_actor ) return( false ); return( processContactActionNoPathing( current, timestep_millis, "gather", &evt, &m_gather ) ); } - +bool CEntity::processHeal( CEntityOrder* current, size_t timestep_millis ) +{ + return( processContactAction( current, timestep_millis, CEntityOrder::ORDER_HEAL_NOPATHING, &m_heal ) ); +} +bool CEntity::processHealNoPathing( CEntityOrder* current, size_t timestep_millis ) +{ + CEventHeal evt( current->m_data[0].entity ); + if( !m_actor ) return( false ); + return( processContactActionNoPathing( current, timestep_millis, "heal", &evt, &m_heal ) ); +} bool CEntity::processGoto( CEntityOrder* current, size_t UNUSED(timestep_millis) ) { // float timestep=timestep_millis/1000.0f; diff --git a/source/simulation/EventHandlers.cpp b/source/simulation/EventHandlers.cpp index df2268800c..8249464dc7 100755 --- a/source/simulation/EventHandlers.cpp +++ b/source/simulation/EventHandlers.cpp @@ -7,7 +7,11 @@ CEventAttack::CEventAttack( CEntity* target ) : CScriptEvent( L"attack", EVENT_A m_target = target; AddLocalProperty( L"target", &m_target ); } - +CEventHeal::CEventHeal( CEntity* target ) : CScriptEvent( L"heal", EVENT_HEAL, true) +{ + m_target=target; + AddLocalProperty( L"target", &target ); +} CEventGather::CEventGather( CEntity* target ) : CScriptEvent( L"gather", EVENT_GATHER, true ) { m_target = target; diff --git a/source/simulation/EventHandlers.h b/source/simulation/EventHandlers.h index 268a15b9dc..68f5888740 100755 --- a/source/simulation/EventHandlers.h +++ b/source/simulation/EventHandlers.h @@ -35,7 +35,12 @@ class CEventGather : public CScriptEvent public: CEventGather( CEntity* target ); }; - +class CEventHeal : public CScriptEvent +{ + CEntity* m_target; +public: + CEventHeal( CEntity* target ); +} class CEventDamage : public CScriptEvent { CEntity* m_inflictor;