diff --git a/source/ps/GameSetup/GameSetup.cpp b/source/ps/GameSetup/GameSetup.cpp index 3be2a2c08b..d2543e6ccb 100644 --- a/source/ps/GameSetup/GameSetup.cpp +++ b/source/ps/GameSetup/GameSetup.cpp @@ -482,7 +482,6 @@ static void InitScripting() CPlayer::ScriptingInit(); PlayerCollection::Init( "PlayerCollection" ); - //CDamageType::ScriptingInit(); CJSComplexPropertyAccessor::ScriptingInit(); // <-- Doesn't really matter which we use, but we know CJSPropertyAccessor is already being compiled for T = CEntity. CScriptEvent::ScriptingInit(); CJSProgressTimer::ScriptingInit(); @@ -500,9 +499,6 @@ static void InitScripting() g_ScriptingHost.DefineConstant( "ORDER_GOTO", CEntityOrder::ORDER_GOTO ); g_ScriptingHost.DefineConstant( "ORDER_RUN", CEntityOrder::ORDER_RUN ); g_ScriptingHost.DefineConstant( "ORDER_PATROL", CEntityOrder::ORDER_PATROL ); - g_ScriptingHost.DefineConstant( "ORDER_ATTACK", CEntityOrder::ORDER_ATTACK_MELEE ); - g_ScriptingHost.DefineConstant( "ORDER_GATHER", CEntityOrder::ORDER_GATHER ); - g_ScriptingHost.DefineConstant( "ORDER_HEAL", CEntityOrder::ORDER_HEAL ); g_ScriptingHost.DefineConstant( "ORDER_GENERIC", CEntityOrder::ORDER_GENERIC ); #define REG_JS_CONSTANT(_name) g_ScriptingHost.DefineConstant(#_name, _name) diff --git a/source/ps/Network/AllNetMessages.h b/source/ps/Network/AllNetMessages.h index 7863c20c96..f8a79fdc35 100755 --- a/source/ps/Network/AllNetMessages.h +++ b/source/ps/Network/AllNetMessages.h @@ -59,9 +59,6 @@ enum ENetMessageType NMT_Goto, NMT_COMMAND_FIRST=NMT_Goto, NMT_Patrol, NMT_AddWaypoint, - NMT_AttackMelee, - NMT_Gather, - NMT_Heal, NMT_Generic, NMT_Run, NMT_COMMAND_LAST, @@ -229,18 +226,6 @@ DERIVE_NMT_CLASS_(NetCommand, AddWaypoint) NMT_FIELD_INT(m_TargetY, u32, 2) END_NMT_CLASS() -DERIVE_NMT_CLASS_(NetCommand, AttackMelee) - NMT_FIELD(HEntity, m_Target) -END_NMT_CLASS() - -DERIVE_NMT_CLASS_(NetCommand, Gather) - NMT_FIELD(HEntity, m_Target) -END_NMT_CLASS() - -DERIVE_NMT_CLASS_(NetCommand, Heal) - NMT_FIELD(HEntity, m_Target) -END_NMT_CLASS() - DERIVE_NMT_CLASS_(NetCommand, Generic) NMT_FIELD(HEntity, m_Target) NMT_FIELD_INT(m_Action, u32, 4) diff --git a/source/ps/Network/NetMessage.cpp b/source/ps/Network/NetMessage.cpp index 5eabfcf19c..f05e460e70 100755 --- a/source/ps/Network/NetMessage.cpp +++ b/source/ps/Network/NetMessage.cpp @@ -81,9 +81,6 @@ void CNetMessage::ScriptingInit() def(NMT_Run); def(NMT_Patrol); def(NMT_AddWaypoint); - def(NMT_AttackMelee); - def(NMT_Gather); - def(NMT_Heal); def(NMT_Generic); } @@ -184,10 +181,6 @@ CNetCommand *CNetMessage::CommandFromJSArgs(const CEntityList &entities, JSConte PositionMessage(Run) PositionMessage(Patrol) PositionMessage(AddWaypoint) - - EntityMessage(AttackMelee) - EntityMessage(Gather) - EntityMessage(Heal) EntityIntMessage(Generic) diff --git a/source/scripting/EventTypes.h b/source/scripting/EventTypes.h index a258801df4..76fc6a6f33 100644 --- a/source/scripting/EventTypes.h +++ b/source/scripting/EventTypes.h @@ -12,10 +12,6 @@ enum EEventType // Entity events EVENT_INITIALIZE = 0, EVENT_TICK, - EVENT_ATTACK, - EVENT_GATHER, - EVENT_DAMAGE, - EVENT_HEAL, EVENT_GENERIC, EVENT_TARGET_CHANGED, EVENT_PREPARE_ORDER, @@ -39,10 +35,6 @@ static const wchar_t* const EventNames[EVENT_LAST] = { /* EVENT_INITIALIZE */ L"onInitialize", /* EVENT_TICK */ L"onTick", - /* EVENT_ATTACK */ L"onAttack", /* This unit is the one doing the attacking... */ - /* EVENT_GATHER */ L"onGather", /* This unit is the one doing the gathering... */ - /* EVENT_DAMAGE */ L"onTakesDamage", - /* EVENT_HEAL */ L"onHeal", /* EVENT_GENERIC */ L"onGeneric", /* EVENT_TARGET_CHANGED */ L"onTargetChanged", /* If this unit is selected and the mouseover object changes */ /* EVENT_PREPARE_ORDER */ L"onPrepareOrder", /* To check if a unit can execute a given order */ diff --git a/source/simulation/BaseEntity.cpp b/source/simulation/BaseEntity.cpp index b86c63cc29..b482d9478e 100755 --- a/source/simulation/BaseEntity.cpp +++ b/source/simulation/BaseEntity.cpp @@ -24,15 +24,6 @@ CBaseEntity::CBaseEntity() AddProperty( L"actions.move.run.range", &( m_run.m_MaxRange ) ); AddProperty( L"actions.move.run.regen_rate", &m_runRegenRate ); AddProperty( L"actions.move.run.decay_rate", &m_runDecayRate ); - AddProperty( L"actions.attack.range", &( m_melee.m_MaxRange ) ); - AddProperty( L"actions.attack.rangemin", &( m_melee.m_MinRange ) ); - AddProperty( L"actions.attack.speed", &( m_melee.m_Speed ) ); - 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_heal.m_Speed ) ); AddProperty( L"actor", &m_actorName ); AddProperty( L"traits.extant", &m_extant ); AddProperty( L"traits.corpse", &m_corpse ); diff --git a/source/simulation/BaseEntity.h b/source/simulation/BaseEntity.h index 7eeb7651fd..157264a3f0 100755 --- a/source/simulation/BaseEntity.h +++ b/source/simulation/BaseEntity.h @@ -86,9 +86,6 @@ public: float m_runDecayRate; SEntityAction m_run; - SEntityAction m_melee; - SEntityAction m_gather; - SEntityAction m_heal; SEntityAction m_generic; float m_turningRadius; diff --git a/source/simulation/Entity.cpp b/source/simulation/Entity.cpp index 6283cd437b..8704ef4481 100755 --- a/source/simulation/Entity.cpp +++ b/source/simulation/Entity.cpp @@ -48,15 +48,6 @@ CEntity::CEntity( CBaseEntity* base, CVector3D position, float orientation ) AddProperty( L"traits.extant", &m_extant ); AddProperty( L"traits.corpse", &m_corpse ); AddProperty( L"actions.move.turningradius", &m_turningRadius ); - AddProperty( L"actions.attack.range", &( m_melee.m_MaxRange ) ); - AddProperty( L"actions.attack.rangemin", &( m_melee.m_MinRange ) ); - AddProperty( L"actions.attack.speed", &( m_melee.m_Speed ) ); - 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_heal.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, false, (NotifyFn)&CEntity::playerChanged ); @@ -109,11 +100,8 @@ CEntity::CEntity( CBaseEntity* base, CVector3D position, float orientation ) m_destroyed = false; m_selected = false; - m_isRunning = false; - m_shouldRun = false; - m_triggerRun = false; m_frameCheck = 0; @@ -398,36 +386,6 @@ void CEntity::update( size_t timestep ) break; updateCollisionPatch(); return; - case CEntityOrder::ORDER_ATTACK_MELEE: - if( processAttackMeleeNoPathing( current, timestep ) ) - break; - updateCollisionPatch(); - return; - case CEntityOrder::ORDER_ATTACK_MELEE_NOPATHING: - if( processAttackMeleeNoPathing( current, timestep ) ) - break; - updateCollisionPatch(); - return; - case CEntityOrder::ORDER_GATHER: - if( processGather( current, timestep ) ) - break; - updateCollisionPatch(); - return; - case CEntityOrder::ORDER_GATHER_NOPATHING: - if( processGatherNoPathing( current, timestep ) ) - break; - updateCollisionPatch(); - return; - case CEntityOrder::ORDER_HEAL: - if( processHeal( current, timestep ) ) - break; - updateCollisionPatch(); - return; - case CEntityOrder::ORDER_HEAL_NOPATHING: - if( processHealNoPathing( current, timestep ) ) - break; - updateCollisionPatch(); - return; case CEntityOrder::ORDER_GENERIC: if( processGeneric( current, timestep ) ) break; @@ -651,13 +609,6 @@ void CEntity::Tick() DispatchEvent( &evt ); } -/*void CEntity::Damage( CDamageType& damage, CEntity* inflictor ) -{ - CEventDamage evt( inflictor, &damage ); - DispatchEvent( &evt ); -}*/ - - void CEntity::clearOrders() { m_orderQueue.clear(); @@ -1023,7 +974,7 @@ void CEntity::renderStaminaBar() if( !m_bounds ) return; if( m_staminaBarHeight < 0 ) - return; // negative bar height means don't display health bar + return; // negative bar height means don't display stamina bar CCamera *g_Camera=g_Game->GetView()->GetCamera(); @@ -1055,6 +1006,7 @@ void CEntity::renderStaminaBar() glEnd(); } + void CEntity::CalculateRun(float timestep) { if ( m_isRunning ) @@ -1062,6 +1014,7 @@ void CEntity::CalculateRun(float timestep) else if ( m_orderQueue.empty() ) m_staminaCurr = min( m_staminaMax, m_staminaCurr + timestep / 1000.0f / m_runRegenRate * m_staminaMax ); } + /* Scripting interface @@ -1076,7 +1029,6 @@ void CEntity::ScriptingInit() AddMethod( "order", 1 ); AddMethod( "orderQueued", 1 ); AddMethod( "kill", 0 ); - //AddMethod( "damage", 1 ); AddMethod( "isIdle", 0 ); AddMethod( "hasClass", 1 ); AddMethod( "getSpawnPoint", 1 ); @@ -1214,22 +1166,6 @@ bool CEntity::Order( JSContext* cx, uintN argc, jsval* argv, bool Queued ) return( false ); } break; - case CEntityOrder::ORDER_ATTACK_MELEE: - case CEntityOrder::ORDER_GATHER: - case CEntityOrder::ORDER_HEAL: - if( argc < 1 ) - { - JS_ReportError( cx, "Too few parameters" ); - return( false ); - } - target = ToNative( argv[1] ); - if( !target ) - { - JS_ReportError( cx, "Invalid target" ); - return( false ); - } - newOrder.m_data[0].entity = target->me; - break; case CEntityOrder::ORDER_GENERIC: if( argc < 3 ) { @@ -1265,44 +1201,6 @@ bool CEntity::Order( JSContext* cx, uintN argc, jsval* argv, bool Queued ) return( true ); } -/*bool CEntity::Damage( JSContext* cx, uintN argc, jsval* argv ) -{ - CEntity* inflictor = NULL; - - if( argc >= 4 ) - inflictor = ToNative( argv[3] ); - - if( argc >= 3 ) - { - CDamageType dmgType( ToPrimitive( argv[0] ), ToPrimitive( argv[1] ), ToPrimitive( argv[2] ) ); - Damage( dmgType, inflictor ); - return( true ); - } - - if( argc >= 2 ) - inflictor = ToNative( argv[1] ); - - // If it's a DamageType, use that. Otherwise, see if it's a float, if so, use - // that as the 'typeless' unblockable damage type. - - CDamageType* dmg = ToNative( argv[0] ); - - if( !dmg ) - { - float dmgN; - if( !ToPrimitive( cx, argv[0], dmgN ) ) - return( false ); - - CDamageType dmgType( dmgN ); - - Damage( dmgType, inflictor ); - return( true ); - } - - Damage( *dmg, inflictor ); - return( true ); -}*/ - bool CEntity::Kill( JSContext* UNUSED(cx), uintN UNUSED(argc), jsval* UNUSED(argv) ) { for( AuraTable::iterator it = m_auras.begin(); it != m_auras.end(); it++ ) @@ -1583,7 +1481,7 @@ jsval CEntity::CheckListeners( JSContext *cx, uintN argc, jsval* argv ) CEntityOrder order = this->m_orderQueue.front(); CEntity* target; - for (int i=0; im_data[0].entity ); - if( !m_actor ) return( false ); - return( processContactActionNoPathing( current, timestep_milli, "melee", &evt, &m_melee ) ); -} - -bool CEntity::processGather( CEntityOrder* current, size_t timestep_millis ) -{ - return( processContactAction( current, timestep_millis, CEntityOrder::ORDER_GATHER_NOPATHING, &m_gather ) ); -} - -bool CEntity::processGatherNoPathing( CEntityOrder* current, size_t timestep_millis ) -{ - CEventGather evt( current->m_data[0].entity ); - 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::processGeneric( CEntityOrder* current, size_t timestep_millis ) { int id = current->m_data[1].data; diff --git a/source/simulation/EntitySupport.h b/source/simulation/EntitySupport.h index bd8ea78edc..556b7ade92 100755 --- a/source/simulation/EntitySupport.h +++ b/source/simulation/EntitySupport.h @@ -8,73 +8,6 @@ class CEntityManager; -/*class CDamageType : public CJSObject -{ -public: - float m_Crush; - float m_Hack; - float m_Pierce; - float m_Typeless; - CDamageType() - { - Init( 0.0f, 0.0f, 0.0f, 0.0f ); - } - virtual ~CDamageType() {} - CDamageType( float Crush, float Hack, float Pierce ) - { - Init( Crush, Hack, Pierce, 0.0f ); - } - CDamageType( float Typeless ) - { - Init( 0.0f, 0.0f, 0.0f, Typeless ); - } - CDamageType( float Crush, float Hack, float Pierce, float Typeless ) - { - Init( Crush, Hack, Pierce, Typeless ); - } - void Init( float Crush, float Hack, float Pierce, float Typeless ) - { - m_Crush = Crush; - m_Hack = Hack; - m_Pierce = Pierce; - m_Typeless = Typeless; - } - static void ScriptingInit() - { - AddProperty( L"crush", &CDamageType::m_Crush ); - AddProperty( L"hack", &CDamageType::m_Hack ); - AddProperty( L"pierce", &CDamageType::m_Pierce ); - AddProperty( L"typeless", &CDamageType::m_Typeless ); - CJSObject::ScriptingInit( "DamageType", Construct, 3 ); - } - static JSBool Construct( JSContext* UNUSED(cx), JSObject* UNUSED(obj), uint argc, jsval* argv, jsval* rval ) - { - CDamageType* dt; - - if( argc == 0 ) - dt = new CDamageType(); - else if( argc == 1 ) - dt = new CDamageType( ToPrimitive( argv[0] ) ); - else if( argc == 3 ) - dt = new CDamageType( ToPrimitive( argv[0] ), - ToPrimitive( argv[1] ), - ToPrimitive( argv[2] ) ); - else if( argc == 4 ) - dt = new CDamageType( ToPrimitive( argv[0] ), - ToPrimitive( argv[1] ), - ToPrimitive( argv[2] ), - ToPrimitive( argv[3] ) ); - else - return( JS_FALSE ); - - dt->m_EngineOwned = false; // Let this object be deallocated when JS GCs it. - - *rval = OBJECT_TO_JSVAL( dt->GetScript() ); - - return( JS_TRUE ); - } -};*/ - struct SEntityAction { float m_MaxRange; diff --git a/source/simulation/EventHandlers.cpp b/source/simulation/EventHandlers.cpp index 2eefb6fbdd..a55a84d58c 100755 --- a/source/simulation/EventHandlers.cpp +++ b/source/simulation/EventHandlers.cpp @@ -2,24 +2,6 @@ #include "EventHandlers.h" #include "Entity.h" -CEventAttack::CEventAttack( CEntity* target ) : CScriptEvent( L"attack", EVENT_ATTACK, true ) -{ - m_target = target; - AddLocalProperty( L"target", &m_target ); -} - -CEventGather::CEventGather( CEntity* target ) : CScriptEvent( L"gather", EVENT_GATHER, true ) -{ - m_target = target; - AddLocalProperty( L"target", &m_target ); -} - -CEventHeal::CEventHeal( CEntity* target ) : CScriptEvent( L"heal", EVENT_HEAL, true) -{ - m_target = target; - AddLocalProperty( L"target", &m_target ); -} - CEventGeneric::CEventGeneric( CEntity* target, int action ) : CScriptEvent( L"generic", EVENT_GENERIC, true) { m_target = target; diff --git a/source/simulation/EventHandlers.h b/source/simulation/EventHandlers.h index 0875b2771f..ec7835f411 100755 --- a/source/simulation/EventHandlers.h +++ b/source/simulation/EventHandlers.h @@ -9,8 +9,6 @@ #include "Vector3D.h" #include "EntityOrders.h" -class CDamageType; - class CEventInitialize : public CScriptEvent { public: @@ -23,35 +21,6 @@ public: CEventTick() : CScriptEvent( L"tick", EVENT_TICK, false ) {} }; -class CEventAttack : public CScriptEvent -{ - CEntity* m_target; -public: - CEventAttack( CEntity* target ); -}; - -class CEventGather : public CScriptEvent -{ - CEntity* m_target; -public: - CEventGather( CEntity* target ); -}; - -/*class CEventDamage : public CScriptEvent -{ - CEntity* m_inflictor; - CDamageType* m_damage; -public: - CEventDamage( CEntity* inflictor, CDamageType* damage ); -};*/ - -class CEventHeal : public CScriptEvent -{ - CEntity* m_target; -public: - CEventHeal( CEntity* target ); -}; - class CEventGeneric : public CScriptEvent { CEntity* m_target; diff --git a/source/simulation/Simulation.cpp b/source/simulation/Simulation.cpp index 8ea78c3dfe..e4ea3a6971 100755 --- a/source/simulation/Simulation.cpp +++ b/source/simulation/Simulation.cpp @@ -269,15 +269,6 @@ uint CSimulation::TranslateMessage(CNetMessage* pMsg, uint clientMask, void* UNU case NMT_Patrol: ENTITY_POSITION(CPatrol, ORDER_PATROL); break; - case NMT_AttackMelee: - ENTITY_ENTITY(CAttackMelee, ORDER_ATTACK_MELEE); - break; - case NMT_Gather: - ENTITY_ENTITY(CGather, ORDER_GATHER); - break; - case NMT_Heal: - ENTITY_ENTITY(CHeal, ORDER_HEAL); - break; case NMT_Generic: ENTITY_ENTITY_INT(CGeneric, ORDER_GENERIC); break;