1
0
forked from 0ad/0ad

Removed references to the old attack, gather, heal and damage events (that were no longer used).

This was SVN commit r3375.
This commit is contained in:
Matei 2006-01-20 21:38:58 +00:00
parent c85551a8b0
commit c2c5e87c61
14 changed files with 6 additions and 336 deletions

View File

@ -482,7 +482,6 @@ static void InitScripting()
CPlayer::ScriptingInit();
PlayerCollection::Init( "PlayerCollection" );
//CDamageType::ScriptingInit();
CJSComplexPropertyAccessor<CEntity>::ScriptingInit(); // <-- Doesn't really matter which we use, but we know CJSPropertyAccessor<T> 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)

View File

@ -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)

View File

@ -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)

View File

@ -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 */

View File

@ -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 );

View File

@ -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;

View File

@ -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<bool, &CEntity::OrderSingle>( "order", 1 );
AddMethod<bool, &CEntity::OrderQueued>( "orderQueued", 1 );
AddMethod<bool, &CEntity::Kill>( "kill", 0 );
//AddMethod<bool, &CEntity::Damage>( "damage", 1 );
AddMethod<bool, &CEntity::IsIdle>( "isIdle", 0 );
AddMethod<bool, &CEntity::HasClass>( "hasClass", 1 );
AddMethod<jsval, &CEntity::GetSpawnPoint>( "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<CEntity>( 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<CEntity>( argv[3] );
if( argc >= 3 )
{
CDamageType dmgType( ToPrimitive<float>( argv[0] ), ToPrimitive<float>( argv[1] ), ToPrimitive<float>( argv[2] ) );
Damage( dmgType, inflictor );
return( true );
}
if( argc >= 2 )
inflictor = ToNative<CEntity>( 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<CDamageType>( argv[0] );
if( !dmg )
{
float dmgN;
if( !ToPrimitive<float>( 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; i<m_listeners.size(); i++)
for (size_t i=0; i<m_listeners.size(); i++)
if (m_listeners[i].m_type & type)
{
@ -1616,11 +1514,12 @@ jsval CEntity::CheckListeners( JSContext *cx, uintN argc, jsval* argv )
return JSVAL_VOID;
}
jsval CEntity::TriggerRun( JSContext* cx, uintN argc, jsval* argv )
jsval CEntity::TriggerRun( JSContext* UNUSED(cx), uintN UNUSED(argc), jsval* UNUSED(argv) )
{
m_triggerRun = true;
return JSVAL_VOID;
}
jsval CEntity::SetRun( JSContext* cx, uintN argc, jsval* argv )
{
if( argc < 1 )

View File

@ -76,9 +76,6 @@ public:
float m_runDecayRate;
SEntityAction m_run;
SEntityAction m_melee;
SEntityAction m_gather;
SEntityAction m_heal;
ActionTable m_actions;
@ -179,15 +176,6 @@ private:
bool processContactAction( CEntityOrder* current, size_t timestep_millis, int transition, SEntityAction* action );
bool processContactActionNoPathing( CEntityOrder* current, size_t timestep_millis, const CStr& animation, CScriptEvent* contactEvent, SEntityAction* action );
bool processAttackMelee( CEntityOrder* current, size_t timestep_milli );
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 processGeneric( CEntityOrder* current, size_t timestep_milli );
bool processGenericNoPathing( CEntityOrder* current, size_t timestep_milli );
@ -229,9 +217,6 @@ public:
// Retrieve the player associated with this entity
CPlayer* GetPlayer() { return m_player; }
// Process damage
//void Damage( CDamageType& damage, CEntity* inflictor = NULL );
// Update collision patch (move ourselves to a new one if necessary)
void updateCollisionPatch();
@ -283,7 +268,6 @@ public:
jsval ToString( JSContext* cx, uintN argc, jsval* argv );
//bool Damage( JSContext* cx, uintN argc, jsval* argv );
bool Kill( JSContext* cx, uintN argc, jsval* argv );
jsval GetSpawnPoint( JSContext* cx, uintN argc, jsval* argv );

View File

@ -82,12 +82,6 @@ public:
ORDER_GOTO,
ORDER_RUN,
ORDER_PATROL,
ORDER_ATTACK_MELEE,
ORDER_ATTACK_MELEE_NOPATHING,
ORDER_GATHER,
ORDER_GATHER_NOPATHING,
ORDER_HEAL,
ORDER_HEAL_NOPATHING,
ORDER_PATH_END_MARKER,
ORDER_GENERIC,
ORDER_GENERIC_NOPATHING,

View File

@ -594,42 +594,6 @@ bool CEntity::processContactActionNoPathing( CEntityOrder* current, size_t times
return( false );
}
bool CEntity::processAttackMelee( CEntityOrder* current, size_t timestep_millis )
{
return( processContactAction( current, timestep_millis, CEntityOrder::ORDER_ATTACK_MELEE_NOPATHING, &m_melee ) );
}
bool CEntity::processAttackMeleeNoPathing( CEntityOrder* current, size_t timestep_milli )
{
CEventAttack evt( current->m_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;

View File

@ -8,73 +8,6 @@
class CEntityManager;
/*class CDamageType : public CJSObject<CDamageType>
{
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<float>( L"crush", &CDamageType::m_Crush );
AddProperty<float>( L"hack", &CDamageType::m_Hack );
AddProperty<float>( L"pierce", &CDamageType::m_Pierce );
AddProperty<float>( L"typeless", &CDamageType::m_Typeless );
CJSObject<CDamageType>::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<float>( argv[0] ) );
else if( argc == 3 )
dt = new CDamageType( ToPrimitive<float>( argv[0] ),
ToPrimitive<float>( argv[1] ),
ToPrimitive<float>( argv[2] ) );
else if( argc == 4 )
dt = new CDamageType( ToPrimitive<float>( argv[0] ),
ToPrimitive<float>( argv[1] ),
ToPrimitive<float>( argv[2] ),
ToPrimitive<float>( 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;

View File

@ -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;

View File

@ -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;

View File

@ -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;