f2e867e239
-Changes to notifications. They take different parameters now-see template_entity_script.js. You can choose to destroy the notifiers yourself in the script (useful for idle) -Added "idle" event with registerIdle and registerDamage to assist with the angle penalty. -Bar border stuff -Angle penalty is set up but untested-it just needs to use this.getAttackDirections() to find the number of directions the entity is being attacked from. The penalty is specified in template_unit There is a problem when the game exits-it attempts to destroy the notifiers in entity.cpp's constructor, where it calls DestroyAllNotifiers(). The problem is that the notifiers don't exist any longer because they've been destroyed. I would fix it but I'm leaving for vacation (Jason told me it was OK to comitt). Hope it isn't too much of a problem. This was SVN commit r3732.
137 lines
3.0 KiB
C++
Executable File
137 lines
3.0 KiB
C++
Executable File
// List of event handlers (for entities) the engine will call in to.
|
|
// Using integer tags should be ever-so-slightly faster than the hashmap lookup
|
|
// Also allows events to be renamed without affecting other code.
|
|
|
|
#ifndef EVENT_HANDLERS_INCLUDED
|
|
#define EVENT_HANDLERS_INCLUDED
|
|
|
|
#include "scripting/DOMEvent.h"
|
|
#include "Vector3D.h"
|
|
#include "EntityOrders.h"
|
|
|
|
class CEventInitialize : public CScriptEvent
|
|
{
|
|
public:
|
|
CEventInitialize() : CScriptEvent( L"initialize", EVENT_INITIALIZE, false ) {}
|
|
};
|
|
|
|
class CEventDeath : public CScriptEvent
|
|
{
|
|
public:
|
|
CEventDeath() : CScriptEvent( L"death", EVENT_DEATH, false ) {}
|
|
};
|
|
|
|
class CEventTick : public CScriptEvent
|
|
{
|
|
public:
|
|
CEventTick() : CScriptEvent( L"tick", EVENT_TICK, false ) {}
|
|
};
|
|
|
|
class CEventGeneric : public CScriptEvent
|
|
{
|
|
CEntity* m_target;
|
|
int m_action;
|
|
public:
|
|
CEventGeneric( CEntity* target, int action );
|
|
};
|
|
|
|
class CEventStartProduction : public CScriptEvent
|
|
{
|
|
int m_productionType;
|
|
CStrW m_name;
|
|
float m_time;
|
|
public:
|
|
CEventStartProduction( int productionType, const CStrW& name );
|
|
inline float GetTime() { return m_time; }
|
|
};
|
|
|
|
class CEventFinishProduction : public CScriptEvent
|
|
{
|
|
int m_productionType;
|
|
CStrW m_name;
|
|
public:
|
|
CEventFinishProduction( int productionType, const CStrW& name );
|
|
};
|
|
|
|
class CEventCancelProduction : public CScriptEvent
|
|
{
|
|
int m_productionType;
|
|
CStrW m_name;
|
|
public:
|
|
CEventCancelProduction( int productionType, const CStrW& name );
|
|
};
|
|
|
|
class CEventTargetChanged : public CScriptEvent
|
|
{
|
|
CEntity* m_target;
|
|
public:
|
|
int m_defaultOrder;
|
|
int m_defaultAction;
|
|
CStrW m_defaultCursor;
|
|
CStrW m_secondaryCursor;
|
|
int m_secondaryOrder;
|
|
int m_secondaryAction;
|
|
CEventTargetChanged( CEntity* target );
|
|
};
|
|
|
|
class CEventPrepareOrder : public CScriptEvent
|
|
{
|
|
public:
|
|
CEntity* m_target;
|
|
int m_orderType;
|
|
int m_action;
|
|
CStrW m_name;
|
|
CEntity* m_notifySource;
|
|
int m_notifyType;
|
|
CEventPrepareOrder( CEntity* target, int orderType, int action, const CStrW& name );
|
|
};
|
|
|
|
class CEventOrderTransition : public CScriptEvent
|
|
{
|
|
int m_orderPrevious;
|
|
int m_orderCurrent;
|
|
CEntity** m_target;
|
|
CVector3D* m_worldPosition;
|
|
public:
|
|
CEventOrderTransition( int orderPrevious, int orderCurrent, CEntity*& target, CVector3D& worldPosition );
|
|
};
|
|
class CEventNotification : public CScriptEvent
|
|
{
|
|
//Same as CEntityOrder data for support of all orders
|
|
CEntity* m_target;
|
|
int m_action; //u64 is unsupported...will this work?
|
|
int m_notifyType;
|
|
CVector3D m_location; //No real use for y, but CVector2D unsupported
|
|
public:
|
|
CEventNotification( CEntityOrder order, int notifyType );
|
|
};
|
|
class CFormationEvent : public CScriptEvent
|
|
{
|
|
int m_formationEvent;
|
|
|
|
public:
|
|
CFormationEvent( int type );
|
|
|
|
enum FormationEventType
|
|
{
|
|
FORMATION_ENTER,
|
|
FORMATION_LEAVE,
|
|
FORMATION_DAMAGE,
|
|
FORMATION_ATTACK,
|
|
|
|
FORMATION_LAST
|
|
};
|
|
};
|
|
class CIdleEvent : public CScriptEvent
|
|
{
|
|
int m_notifyType; //previous order in notification code form
|
|
int m_orderType;
|
|
int m_action; //previous order in terms of generic order action
|
|
CVector3D m_location;
|
|
CEntity* m_target;
|
|
public:
|
|
CIdleEvent( CEntityOrder order, int notifyType );
|
|
};
|
|
|
|
#endif
|