1
0
forked from 0ad/0ad

Refactored "generic" order to just call it "contact action", and added support for intercepting targets if performing a contact action while moving.

This was SVN commit r6290.
This commit is contained in:
Matei 2008-07-29 08:22:56 +00:00
parent 0e8b7c5bc7
commit 98dd1a1bb4
22 changed files with 176 additions and 415 deletions

View File

@ -16,7 +16,7 @@
</Traits>
<Script File="scripts/entity_functions.js" />
<Event On="Generic" Function="entityEventGeneric" />
<Event On="ContactAction" Function="entityEventContactAction" />
<Event On="TargetExhausted" Function="entityEventTargetExhausted" />
<Event On="TargetChanged" Function="entityEventTargetChanged" />
<Event On="Notification" Function="entityEventNotification" />
@ -24,4 +24,4 @@
<Event On="Idle" Function="entityEventIdle" />
<Event On="Death" Function="entityDestroyed" />
<Event On="Initialize" Function="entityInit" />
</Entity>
</Entity>

View File

@ -67,7 +67,7 @@ function worldClickHandler(event)
args[1]=event.y;
break;
// entity target commands
case NMT_GENERIC:
case NMT_CONTACT_ACTION:
args[0]=event.entity;
if ( event.clicks == 1)
args[1]=event.action;
@ -109,7 +109,7 @@ function worldClickHandler(event)
return;
}
if (cmd == NMT_GENERIC) // For NMT_GENERIC, add a third argument - whether to run
if (cmd == NMT_CONTACT_ACTION) // For NMT_CONTACT_ACTION, add a third argument - whether to run
issueCommand (selection, isOrderQueued(), cmd, args[0], args[1], event.clicks > 1);
else
issueCommand (selection, isOrderQueued(), cmd, args[0], args[1]);

View File

@ -5,7 +5,7 @@
// ====================================================================
// To add a new generic order, do the following all within template_entity_script.js:
// To add a new ContactAction order, do the following all within template_entity_script.js:
// * Pick a number to be its ID (add this to the "const"s directly below). f
@ -13,7 +13,7 @@
// * Add code in entityEventTargetChanged() to tell the GUI whether the entity should use this action depending on what target the mouse is hovering over. This is also where you can set a cursor for the action.
// * Add code in entityEventGeneric() to deal with new generic order events of your type. Note that if you want to have your action handler in a separate function (is preferable), you need to also add this function to the entity object in entityInit() (its initialize event), e.g. this.processGather = entityEventGather.
// * Add code in entityEventContactAction() to deal with new ContactAction order events of your type. Note that if you want to have your action handler in a separate function (is preferable), you need to also add this function to the entity object in entityInit() (its initialize event), e.g. this.processGather = entityEventGather.
const ACTION_NONE = 0;
const ACTION_ATTACK = 1;
@ -192,7 +192,7 @@ function entityInit( evt )
stopXTimer(3);
startXTimer(4);
// Register our actions with the generic order system
// Register our actions with the ContactAction order system
if( this.actions )
{
if ( this.actions.move && this.actions.move.speed )
@ -987,14 +987,14 @@ function damage( dmg, inflictor )
this.requestNotification( inflictor, NOTIFY_ORDER_CHANGE, false, true );
this.registerDamage( inflictor );
if( this.isIdle() )
this.order( ORDER_GENERIC, inflictor, this.getAttackAction( inflictor ), false );
this.order( ORDER_CONTACT_ACTION, inflictor, this.getAttackAction( inflictor ), false );
}*/
this.onDamaged( inflictor );
}
// ====================================================================
function entityEventGeneric( evt )
function entityEventContactAction( evt )
{
switch( evt.action )
{
@ -1014,7 +1014,7 @@ function entityEventGeneric( evt )
this.performRepair( evt ); break;
default:
console.write( "Unknown generic action: " + evt.action );
console.write( "Unknown contact action: " + evt.action );
}
}
@ -1041,13 +1041,13 @@ function entityEventNotification( evt )
break;
case NOTIFY_ATTACK:
case NOTIFY_DAMAGE:
this.order( ORDER_GENERIC, evt.target, ACTION_ATTACK, false );
this.order( ORDER_CONTACT_ACTION, evt.target, ACTION_ATTACK, false );
break;
case NOTIFY_HEAL:
this.order( ORDER_GENERIC, evt.target, ACTION_HEAL, false );
this.order( ORDER_CONTACT_ACTION, evt.target, ACTION_HEAL, false );
break;
case NOTIFY_GATHER:
this.order( ORDER_GENERIC, evt.target, ACTION_GATHER, false );
this.order( ORDER_CONTACT_ACTION, evt.target, ACTION_GATHER, false );
break;
case NOTIFY_IDLE:
//target is the unit that has become idle. Eventually...do something here.
@ -1104,7 +1104,7 @@ function entityEventTargetExhausted( evt )
// If the target was gatherable, try to gather it.
if( canGather(this, evt.target) )
{
this.order( ORDER_GENERIC, evt.target, ACTION_GATHER, false );
this.order( ORDER_CONTACT_ACTION, evt.target, ACTION_GATHER, false );
return;
}
@ -1127,7 +1127,7 @@ function entityEventTargetExhausted( evt )
}
if( bestTarget != null )
{
this.order( ORDER_GENERIC, bestTarget, ACTION_BUILD, false );
this.order( ORDER_CONTACT_ACTION, bestTarget, ACTION_BUILD, false );
return;
}
@ -1161,7 +1161,7 @@ function chooseGatherTarget( resourceSubType, targetList )
}
if( bestTarget != null )
{
this.order( ORDER_GENERIC, bestTarget, ACTION_GATHER, false );
this.order( ORDER_CONTACT_ACTION, bestTarget, ACTION_GATHER, false );
return true;
}
return false;
@ -1202,11 +1202,11 @@ function entityEventTargetChanged( evt )
evt.target.traits.health &&
evt.target.traits.health.max != 0 )
{
evt.defaultOrder = NMT_GENERIC;
evt.defaultOrder = NMT_CONTACT_ACTION;
evt.defaultAction = this.getAttackAction( evt.target );
evt.defaultCursor = "action-attack";
evt.secondaryOrder = NMT_GENERIC;
evt.secondaryOrder = NMT_CONTACT_ACTION;
evt.secondaryAction = this.getAttackAction( evt.target );
evt.secondaryCursor = "action-attack";
}
@ -1229,12 +1229,12 @@ function entityEventTargetChanged( evt )
if ( canGather( this, evt.target ) )
{
evt.defaultOrder = NMT_GENERIC;
evt.defaultOrder = NMT_CONTACT_ACTION;
evt.defaultAction = ACTION_GATHER;
// Set cursor (eg "action-gather-fruit").
evt.defaultCursor = "action-gather-" + evt.target.traits.supply.subType;
evt.secondaryOrder = NMT_GENERIC;
evt.secondaryOrder = NMT_CONTACT_ACTION;
evt.secondaryAction = ACTION_GATHER;
// Set cursor (eg "action-gather-fruit").
evt.secondaryCursor = "action-gather-" + evt.target.traits.supply.subType;
@ -1242,22 +1242,22 @@ function entityEventTargetChanged( evt )
if ( canBuild( this, evt.target ) )
{
evt.defaultOrder = NMT_GENERIC;
evt.defaultOrder = NMT_CONTACT_ACTION;
evt.defaultAction = ACTION_BUILD;
evt.defaultCursor = "action-build";
evt.secondaryOrder = NMT_GENERIC;
evt.secondaryOrder = NMT_CONTACT_ACTION;
evt.secondaryAction = ACTION_BUILD;
evt.secondaryCursor = "action-build";
}
if ( canRepair( this, evt.target ) )
{
evt.defaultOrder = NMT_GENERIC;
evt.defaultOrder = NMT_CONTACT_ACTION;
evt.defaultAction = ACTION_REPAIR;
evt.defaultCursor = "action-build";
evt.secondaryOrder = NMT_GENERIC;
evt.secondaryOrder = NMT_CONTACT_ACTION;
evt.secondaryAction = ACTION_REPAIR;
evt.secondaryCursor = "action-build";
}
@ -1324,7 +1324,7 @@ function entityEventPrepareOrder( evt )
this.forceCheckListeners( NOTIFY_ORDER_CHANGE, this );
break;
case ORDER_GENERIC:
case ORDER_CONTACT_ACTION:
evt.notifySource = this;
switch ( evt.action )
{
@ -1408,7 +1408,7 @@ function entityEventPrepareOrder( evt )
function entityStartConstruction( evt )
{
this.order( ORDER_GENERIC, evt.target, ACTION_BUILD, false );
this.order( ORDER_CONTACT_ACTION, evt.target, ACTION_BUILD, false );
}
// ====================================================================

View File

@ -1,281 +0,0 @@
#ifndef INCLUDED_ALLNETMESSAGES
#define INCLUDED_ALLNETMESSAGES
#include "ps/CStr.h"
#include "scripting/JSSerialization.h"
enum ENetMessageType
{
/*
All Message Types should be put here. Never change the order of this
list.
First, all negative types are only for internal/local use and may never
be sent over the network.
After that, all "real" network messages are listed, giving them a value
from 0 and upwards (*unique* value)
*/
/**
* A special message that contains a PS_RESULT code, used for delivery of
* OOB error status messages from a CMessageSocket
*/
NMT_ERROR=-256,
/**
* The message socket connect attempt is complete
*/
NMT_CONNECT_COMPLETE,
/**
* Close the message socket
*/
NMT_CLOSE_REQUEST,
/**
* An invalid message type, representing an uninitialized message.
*/
NMT_NONE=0,
/* Handshake Stage */
NMT_ServerHandshake,
NMT_ClientHandshake,
NMT_ServerHandshakeResponse,
/* Authentication Stage */
NMT_Authenticate,
NMT_AuthenticationResult,
/* Common Messages, stage 3-5 */
NMT_ChatMessage,
/* Pre-Game Stage */
NMT_ClientConnect,
NMT_ClientDisconnect,
NMT_SetGameConfig,
NMT_AssignPlayerSlot,
NMT_SetPlayerConfig,
NMT_FilesRequired,
NMT_FileRequest,
NMT_FileChunk,
NMT_FileChunkAck,
NMT_FileProgress,
NMT_StartGame,
/* In-Game Stage */
NMT_EndCommandBatch,
NMT_Goto, NMT_COMMAND_FIRST=NMT_Goto,
NMT_Patrol,
NMT_AddWaypoint,
NMT_Generic,
NMT_Produce,
NMT_PlaceObject,
NMT_Run,
NMT_NotifyRequest,
NMT_FormationGoto,
NMT_FormationGeneric,
NMT_COMMAND_LAST,
/* Post-Game Stage */
/**
* One higher than the highest value of any message type
*/
NMT_LAST // Always put this last in the list
};
/**
Only applies to NMT_AuthenticationResult (as of now).
*/
enum ENetResultCodes
{
NRC_OK,
NRC_PasswordInvalid,
NRC_NickTaken,
NRC_NickInvalid,
};
// These constants (magic numbers) are highly arbitrary, but have been chosen
// such that they should be unlikely to stumble across randomly.
// in network byte order: 'P', 's', 0x01, '?'
#define PS_PROTOCOL_MAGIC 0x5073013f
// in network byte order: 'P', 'c', 0x01, '!'
#define PS_PROTOCOL_MAGIC_RESPONSE 0x50630121
// At a later date, there should be a standard for assigning protocol version
// numbers. For now, this also highly arbitrary number will hold its place
// 1.1.2
#define PS_PROTOCOL_VERSION 0x01010002
// 0x5073 = decimal 20595
// The "symbolism" is that the two bytes of the port number in network byte
// order is 'P' 's'
#define PS_DEFAULT_PORT 0x5073
// Chat Recipient Constants
enum
{
// Any chat recipients lower than this one is an actual session ID
PS_CHAT_RCP_FIRST_SPECIAL=0xfffd,
PS_CHAT_RCP_ENEMIES=0xfffd,
PS_CHAT_RCP_ALLIES=0xfffe,
PS_CHAT_RCP_ALL=0xFFFF,
};
enum
{
PS_ASSIGN_OPEN,
PS_ASSIGN_CLOSED,
PS_ASSIGN_AI,
PS_ASSIGN_SESSION
};
#endif // #ifndef _AllNetMessage_H
#ifdef CREATING_NMT
#define ALLNETMSGS_DONT_CREATE_NMTS
#define START_NMT_CLASS_(_nm) START_NMT_CLASS(C ## _nm, NMT_ ## _nm)
#define DERIVE_NMT_CLASS_(_base, _nm) START_NMT_CLASS_DERIVED(C ## _base, C ## _nm, NMT_ ## _nm)
START_NMTS()
START_NMT_CLASS_(ServerHandshake)
NMT_FIELD_INT(m_Magic, u32, 4)
NMT_FIELD_INT(m_ProtocolVersion, u32, 4)
NMT_FIELD_INT(m_SoftwareVersion, u32, 4)
END_NMT_CLASS()
START_NMT_CLASS_(ClientHandshake)
NMT_FIELD_INT(m_MagicResponse, u32, 4)
NMT_FIELD_INT(m_ProtocolVersion, u32, 4)
NMT_FIELD_INT(m_SoftwareVersion, u32, 4)
END_NMT_CLASS()
START_NMT_CLASS_(ServerHandshakeResponse)
NMT_FIELD_INT(m_UseProtocolVersion, u32, 4)
NMT_FIELD_INT(m_Flags, u32, 4)
NMT_FIELD(CStrW, m_Message)
END_NMT_CLASS()
START_NMT_CLASS_(AuthenticationResult)
NMT_FIELD_INT(m_Code, u32, 4)
NMT_FIELD_INT(m_SessionID, u32, 2)
NMT_FIELD(CStrW, m_Message)
END_NMT_CLASS()
START_NMT_CLASS_(Authenticate)
NMT_FIELD(CStrW, m_Name)
//NMT_FIELD(CPasswordHash, m_Password)
NMT_FIELD(CStrW, m_Password)
END_NMT_CLASS()
START_NMT_CLASS_(ChatMessage)
NMT_FIELD(CStrW, m_Sender)
NMT_FIELD_INT(m_Recipient, u32, 2)
NMT_FIELD(CStrW, m_Message)
END_NMT_CLASS()
START_NMT_CLASS_(ClientConnect)
NMT_START_ARRAY(m_Clients)
NMT_FIELD_INT(m_SessionID, u32, 2)
NMT_FIELD(CStrW, m_Name)
NMT_END_ARRAY()
END_NMT_CLASS()
START_NMT_CLASS_(ClientDisconnect)
NMT_FIELD_INT(m_SessionID, u32, 2)
END_NMT_CLASS()
START_NMT_CLASS_(SetGameConfig)
NMT_START_ARRAY(m_Values)
NMT_FIELD(CStrW, m_Name)
NMT_FIELD(CStrW, m_Value)
NMT_END_ARRAY()
END_NMT_CLASS()
START_NMT_CLASS_(AssignPlayerSlot)
NMT_FIELD_INT(m_SlotID, u32, 2)
NMT_FIELD_INT(m_Assignment, u32, 1)
NMT_FIELD_INT(m_SessionID, u32, 2) // Only applicable for PS_ASSIGN_SESSION
END_NMT_CLASS()
START_NMT_CLASS_(SetPlayerConfig)
NMT_FIELD_INT(m_PlayerID, u32, 2)
NMT_START_ARRAY(m_Values)
NMT_FIELD(CStrW, m_Name)
NMT_FIELD(CStrW, m_Value)
NMT_END_ARRAY()
END_NMT_CLASS()
START_NMT_CLASS_(StartGame)
END_NMT_CLASS()
START_NMT_CLASS_(EndCommandBatch)
NMT_FIELD_INT(m_TurnLength, u32, 2)
END_NMT_CLASS()
START_NMT_CLASS(CNetCommand, NMT_NONE)
NMT_FIELD(CEntityList, m_Entities)
NMT_FIELD_INT(m_IsQueued, u32, 1)
END_NMT_CLASS()
DERIVE_NMT_CLASS_(NetCommand, Goto)
NMT_FIELD_INT(m_TargetX, u32, 2)
NMT_FIELD_INT(m_TargetY, u32, 2)
END_NMT_CLASS()
DERIVE_NMT_CLASS_(NetCommand, Run)
NMT_FIELD_INT(m_TargetX, u32, 2)
NMT_FIELD_INT(m_TargetY, u32, 2)
END_NMT_CLASS()
DERIVE_NMT_CLASS_(NetCommand, Patrol)
NMT_FIELD_INT(m_TargetX, u32, 2)
NMT_FIELD_INT(m_TargetY, u32, 2)
END_NMT_CLASS()
DERIVE_NMT_CLASS_(NetCommand, AddWaypoint)
NMT_FIELD_INT(m_TargetX, u32, 2)
NMT_FIELD_INT(m_TargetY, u32, 2)
END_NMT_CLASS()
DERIVE_NMT_CLASS_(NetCommand, Generic)
NMT_FIELD(HEntity, m_Target)
NMT_FIELD_INT(m_Action, u32, 4)
END_NMT_CLASS()
DERIVE_NMT_CLASS_(NetCommand, Produce)
NMT_FIELD_INT(m_Type, u32, 4)
NMT_FIELD(CStrW, m_Name)
END_NMT_CLASS()
DERIVE_NMT_CLASS_(NetCommand, PlaceObject)
NMT_FIELD(CStrW, m_Template)
NMT_FIELD_INT(m_X, u32, 4)
NMT_FIELD_INT(m_Y, u32, 4)
NMT_FIELD_INT(m_Z, u32, 4)
NMT_FIELD_INT(m_Angle, u32, 4) // Orientation angle
END_NMT_CLASS()
DERIVE_NMT_CLASS_(NetCommand, NotifyRequest)
NMT_FIELD(HEntity, m_Target)
NMT_FIELD_INT(m_Action, u32, 4)
END_NMT_CLASS()
DERIVE_NMT_CLASS_(NetCommand, FormationGoto)
NMT_FIELD_INT(m_TargetX, u32, 2)
NMT_FIELD_INT(m_TargetY, u32, 2)
END_NMT_CLASS()
DERIVE_NMT_CLASS_(NetCommand, FormationGeneric)
NMT_FIELD(HEntity, m_Target)
NMT_FIELD_INT(m_Action, u32, 4)
END_NMT_CLASS()
END_NMTS()
#else
#ifndef ALLNETMSGS_DONT_CREATE_NMTS
# ifdef ALLNETMSGS_IMPLEMENT
# define NMT_CREATOR_IMPLEMENT
# endif
# define NMT_CREATE_HEADER_NAME "AllNetMessages.h"
# include "NMTCreator.h"
#endif // #ifndef ALLNETMSGS_DONT_CREATE_NMTS
#endif // #ifdef CREATING_NMT

View File

@ -182,7 +182,7 @@ bool CNetClient::SetupSession( CNetSession* pSession )
pSession->AddTransition( NCS_INGAME, ( uint )NMT_GOTO, NCS_INGAME, (void*)&OnInGame, pContext );
pSession->AddTransition( NCS_INGAME, ( uint )NMT_PATROL, NCS_INGAME, (void*)&OnInGame, pContext );
pSession->AddTransition( NCS_INGAME, ( uint )NMT_ADD_WAYPOINT, NCS_INGAME, (void*)&OnInGame, pContext );
pSession->AddTransition( NCS_INGAME, ( uint )NMT_GENERIC, NCS_INGAME, (void*)&OnInGame, pContext );
pSession->AddTransition( NCS_INGAME, ( uint )NMT_CONTACT_ACTION, NCS_INGAME, (void*)&OnInGame, pContext );
pSession->AddTransition( NCS_INGAME, ( uint )NMT_PRODUCE, NCS_INGAME, (void*)&OnInGame, pContext );
pSession->AddTransition( NCS_INGAME, ( uint )NMT_PLACE_OBJECT, NCS_INGAME, (void*)&OnInGame, pContext );
pSession->AddTransition( NCS_INGAME, ( uint )NMT_RUN, NCS_INGAME, (void*)&OnInGame, pContext );
@ -190,7 +190,7 @@ bool CNetClient::SetupSession( CNetSession* pSession )
pSession->AddTransition( NCS_INGAME, ( uint )NMT_SET_STANCE, NCS_INGAME, (void*)&OnInGame, pContext );
pSession->AddTransition( NCS_INGAME, ( uint )NMT_NOTIFY_REQUEST, NCS_INGAME, (void*)&OnInGame, pContext );
pSession->AddTransition( NCS_INGAME, ( uint )NMT_FORMATION_GOTO, NCS_INGAME, (void*)&OnInGame, pContext );
pSession->AddTransition( NCS_INGAME, ( uint )NMT_FORMATION_GENERIC, NCS_INGAME, (void*)&OnInGame, pContext );
pSession->AddTransition( NCS_INGAME, ( uint )NMT_FORMATION_CONTACT_ACTION, NCS_INGAME, (void*)&OnInGame, pContext );
pSession->AddTransition( NCS_INGAME, ( uint )NMT_END_COMMAND_BATCH, NCS_INGAME, (void*)&OnInGame, pContext );
// Set first state

View File

@ -210,14 +210,14 @@ void CNetMessage::ScriptingInit()
g_ScriptingHost.DefineConstant( "NMT_RUN", NMT_RUN );
g_ScriptingHost.DefineConstant( "NMT_PATROL", NMT_PATROL );
g_ScriptingHost.DefineConstant( "NMT_ADD_WAYPOINT", NMT_ADD_WAYPOINT );
g_ScriptingHost.DefineConstant( "NMT_GENERIC", NMT_GENERIC );
g_ScriptingHost.DefineConstant( "NMT_CONTACT_ACTION", NMT_CONTACT_ACTION );
g_ScriptingHost.DefineConstant( "NMT_PRODUCE", NMT_PRODUCE );
g_ScriptingHost.DefineConstant( "NMT_PLACE_OBJECT", NMT_PLACE_OBJECT );
g_ScriptingHost.DefineConstant( "NMT_SET_RALLY_POINT", NMT_SET_RALLY_POINT );
g_ScriptingHost.DefineConstant( "NMT_SET_STANCE", NMT_SET_STANCE );
g_ScriptingHost.DefineConstant( "NMT_NOTIFY_REQUEST", NMT_NOTIFY_REQUEST );
g_ScriptingHost.DefineConstant( "NMT_FORMATION_GOTO", NMT_FORMATION_GOTO );
g_ScriptingHost.DefineConstant( "NMT_FORMATION_GENERIC", NMT_FORMATION_GENERIC );
g_ScriptingHost.DefineConstant( "NMT_FORMATION_CONTACT_ACTION", NMT_FORMATION_CONTACT_ACTION );
}
//-----------------------------------------------------------------------------
@ -492,9 +492,9 @@ CNetMessage* CNetMessage::CommandFromJSArgs(
return pMessage;
}
case NMT_GENERIC:
case NMT_CONTACT_ACTION:
{
CGenericMessage* pMessage = new CGenericMessage;
CContactActionMessage* pMessage = new CContactActionMessage;
if ( !pMessage ) return NULL;
pMessage->m_IsQueued = isQueued;
@ -573,9 +573,9 @@ CNetMessage* CNetMessage::CommandFromJSArgs(
return pMessage;
}
case NMT_FORMATION_GENERIC:
case NMT_FORMATION_CONTACT_ACTION:
{
CFormationGenericMessage* pMessage = new CFormationGenericMessage;
CFormationContactActionMessage* pMessage = new CFormationContactActionMessage;
if ( !pMessage ) return NULL;
pMessage->m_IsQueued = isQueued;
@ -832,9 +832,9 @@ CNetMessage* CNetMessage::CreateEntityIntMessage(
{
switch ( type )
{
case NMT_GENERIC:
case NMT_CONTACT_ACTION:
{
CGenericMessage *pMessage = new CGenericMessage;
CContactActionMessage *pMessage = new CContactActionMessage;
if ( !pMessage ) return NULL;
pMessage->m_Entities = entities;
@ -857,9 +857,9 @@ CNetMessage* CNetMessage::CreateEntityIntMessage(
return pMessage;
}
case NMT_FORMATION_GENERIC:
case NMT_FORMATION_CONTACT_ACTION:
{
CFormationGenericMessage *pMessage = new CFormationGenericMessage;
CFormationContactActionMessage *pMessage = new CFormationContactActionMessage;
if ( !pMessage ) return NULL;
pMessage->m_Entities = entities;
@ -978,8 +978,8 @@ CNetMessage* CNetMessageFactory::CreateMessage(const void* pData,
pNewMessage = new CAddWaypointMessage;
break;
case NMT_GENERIC:
pNewMessage = new CGenericMessage;
case NMT_CONTACT_ACTION:
pNewMessage = new CContactActionMessage;
break;
case NMT_PRODUCE:
@ -1010,8 +1010,8 @@ CNetMessage* CNetMessageFactory::CreateMessage(const void* pData,
pNewMessage = new CFormationGotoMessage;
break;
case NMT_FORMATION_GENERIC:
pNewMessage = new CFormationGenericMessage;
case NMT_FORMATION_CONTACT_ACTION:
pNewMessage = new CFormationContactActionMessage;
break;
default:

View File

@ -15,8 +15,8 @@
#include <map>
// We need the enum from AllNetMessages.h, but we can't create any classes in
// AllNetMessages, since they in turn require CNetMessage to be defined
// We need the enum from NetMessages.h, but we can't create any classes in
// NetMessages.h, since they in turn require CNetMessage to be defined
#define ALLNETMSGS_DONT_CREATE_NMTS
#include "NetMessages.h"
#undef ALLNETMSGS_DONT_CREATE_NMTS

View File

@ -52,7 +52,7 @@ enum NetMessageType
NMT_COMMAND_FIRST = NMT_GOTO,
NMT_PATROL,
NMT_ADD_WAYPOINT,
NMT_GENERIC,
NMT_CONTACT_ACTION,
NMT_PRODUCE,
NMT_PLACE_OBJECT,
NMT_RUN,
@ -60,7 +60,7 @@ enum NetMessageType
NMT_SET_STANCE,
NMT_NOTIFY_REQUEST,
NMT_FORMATION_GOTO,
NMT_FORMATION_GENERIC,
NMT_FORMATION_CONTACT_ACTION,
NMT_COMMAND_LAST,
NMT_LAST // Last message in the list
};
@ -209,7 +209,7 @@ DERIVE_NMT_CLASS_(Command, SetStance, NMT_SET_STANCE)
NMT_FIELD(CStrW, m_Stance)
END_NMT_CLASS()
DERIVE_NMT_CLASS_(Command, Generic, NMT_GENERIC)
DERIVE_NMT_CLASS_(Command, ContactAction, NMT_CONTACT_ACTION)
NMT_FIELD(HEntity, m_Target)
NMT_FIELD_INT(m_Action, u32, 4)
NMT_FIELD_INT(m_Run, u32, 1)
@ -238,7 +238,7 @@ DERIVE_NMT_CLASS_(Command, FormationGoto, NMT_FORMATION_GOTO)
NMT_FIELD_INT(m_TargetY, u32, 2)
END_NMT_CLASS()
DERIVE_NMT_CLASS_(Command, FormationGeneric, NMT_FORMATION_GENERIC)
DERIVE_NMT_CLASS_(Command, FormationContactAction, NMT_FORMATION_CONTACT_ACTION)
NMT_FIELD(HEntity, m_Target)
NMT_FIELD_INT(m_Action, u32, 4)
END_NMT_CLASS()

View File

@ -140,7 +140,7 @@ bool CNetServer::SetupSession( CNetSession* pSession )
pSession->AddTransition( NSS_INGAME, ( uint )NMT_GOTO, NSS_INGAME, (void*)&OnInGame, pContext );
pSession->AddTransition( NSS_INGAME, ( uint )NMT_PATROL, NSS_INGAME, (void*)&OnInGame, pContext );
pSession->AddTransition( NSS_INGAME, ( uint )NMT_ADD_WAYPOINT, NSS_INGAME, (void*)&OnInGame, pContext );
pSession->AddTransition( NSS_INGAME, ( uint )NMT_GENERIC, NSS_INGAME, (void*)&OnInGame, pContext );
pSession->AddTransition( NSS_INGAME, ( uint )NMT_CONTACT_ACTION, NSS_INGAME, (void*)&OnInGame, pContext );
pSession->AddTransition( NSS_INGAME, ( uint )NMT_PRODUCE, NSS_INGAME, (void*)&OnInGame, pContext );
pSession->AddTransition( NSS_INGAME, ( uint )NMT_PLACE_OBJECT, NSS_INGAME, (void*)&OnInGame, pContext );
pSession->AddTransition( NSS_INGAME, ( uint )NMT_RUN, NSS_INGAME, (void*)&OnInGame, pContext );
@ -148,7 +148,7 @@ bool CNetServer::SetupSession( CNetSession* pSession )
pSession->AddTransition( NSS_INGAME, ( uint )NMT_SET_STANCE, NSS_INGAME, (void*)&OnInGame, pContext );
pSession->AddTransition( NSS_INGAME, ( uint )NMT_NOTIFY_REQUEST, NSS_INGAME, (void*)&OnInGame, pContext );
pSession->AddTransition( NSS_INGAME, ( uint )NMT_FORMATION_GOTO, NSS_INGAME, (void*)&OnInGame, pContext );
pSession->AddTransition( NSS_INGAME, ( uint )NMT_FORMATION_GENERIC, NSS_INGAME, (void*)&OnInGame, pContext );
pSession->AddTransition( NSS_INGAME, ( uint )NMT_FORMATION_CONTACT_ACTION, NSS_INGAME, (void*)&OnInGame, pContext );
pSession->AddTransition( NSS_INGAME, ( uint )NMT_END_COMMAND_BATCH, NSS_INGAME, (void*)&OnInGame, pContext );
// Set first state

View File

@ -13,7 +13,7 @@ enum EEventType
EVENT_INITIALIZE = 0,
EVENT_DEATH,
EVENT_TICK,
EVENT_GENERIC,
EVENT_CONTACT_ACTION,
EVENT_TARGET_EXHAUSTED,
EVENT_START_CONSTRUCTION,
EVENT_START_PRODUCTION,
@ -44,7 +44,7 @@ static const wchar_t* const EventNames[EVENT_LAST] =
/* EVENT_INITIALIZE */ L"onInitialize",
/* EVENT_DEATH */ L"onDeath",
/* EVENT_TICK */ L"onTick",
/* EVENT_GENERIC */ L"onGeneric", /* For generic contact actions on a target unit, like attack or gather */
/* EVENT_CONTACT_ACTION */ L"onContactAction", /* For generic contact actions on a target unit, like attack or gather */
/* EVENT_TARGET_EXHAUSTED*/ L"onTargetExhausted", /* Called when the target of a generic action dies */
/* EVENT_START_CONSTRUCTION */ L"onStartConstruction", /* We were selected when the user placed a building */
/* EVENT_START_PRODUCTION */ L"onStartProduction", /* We're about to start training/researching something (deduct resources, etc) */

View File

@ -211,10 +211,10 @@ void CreateFormationMessage( std::vector<CNetMessage*>& msgList, CNetMessage* ms
retMsg = CNetMessage::CreatePositionMessage( formation, NMT_FORMATION_GOTO,
CVector2D(tmp->m_TargetX, tmp->m_TargetY) );
}
else if ( type == NMT_GENERIC )
else if ( type == NMT_CONTACT_ACTION )
{
CGenericMessage* tmp = static_cast<CGenericMessage*>(msg);
retMsg = CNetMessage::CreateEntityIntMessage(formation, NMT_FORMATION_GENERIC,
CContactActionMessage* tmp = static_cast<CContactActionMessage*>(msg);
retMsg = CNetMessage::CreateEntityIntMessage(formation, NMT_FORMATION_CONTACT_ACTION,
tmp->m_Target, tmp->m_Action);
}
else

View File

@ -524,12 +524,17 @@ void CEntity::UpdateOrders( int timestep )
break;
UpdateCollisionPatch();
return;
case CEntityOrder::ORDER_GENERIC:
case CEntityOrder::ORDER_GOTO_NOPATHING_CONTACT:
if( ProcessGotoNoPathingContact( current, timestep ) )
break;
UpdateCollisionPatch();
return;
case CEntityOrder::ORDER_CONTACT_ACTION:
// Choose to run if and only if order.m_run is set
entf_set_to(ENTF_TRIGGER_RUN, current->m_run);
if( !entf_get(ENTF_TRIGGER_RUN) )
entf_set_to(ENTF_SHOULD_RUN, false);
if( ProcessGeneric( current, timestep ) )
if( ProcessContactAction( current, timestep, true ) )
break;
UpdateCollisionPatch();
return;
@ -544,8 +549,8 @@ void CEntity::UpdateOrders( int timestep )
ProcessProduce( current );
m_orderQueue.pop_front();
break;
case CEntityOrder::ORDER_GENERIC_NOPATHING:
if( ProcessGenericNoPathing( current, timestep ) )
case CEntityOrder::ORDER_CONTACT_ACTION_NOPATHING:
if( ProcessContactActionNoPathing( current, timestep ) )
break;
UpdateCollisionPatch();
return;

View File

@ -236,15 +236,13 @@ private:
// (returns EGotoSituation, but we don't want to expose that)
int ProcessGotoHelper( CEntityOrder* current, int timestep_millis, HEntity& collide, float& timeLeft );
bool ProcessContactAction( CEntityOrder* current, int timestep_millis, CEntityOrder::EOrderType transition, SEntityAction* action );
bool ProcessContactActionNoPathing( CEntityOrder* current, int timestep_millis, const CStr& animation, CScriptEvent* contactEvent, SEntityAction* action );
bool ProcessGeneric( CEntityOrder* current, int timestep_millis );
bool ProcessGenericNoPathing( CEntityOrder* current, int timestep_millis );
bool ProcessContactAction( CEntityOrder* current, int timestep_millis, bool repath_if_needed );
bool ProcessContactActionNoPathing( CEntityOrder* current, int timestep_millis );
bool ProcessProduce( CEntityOrder* order );
bool ProcessGotoNoPathing( CEntityOrder* current, int timestep_millis );
bool ProcessGotoNoPathingContact( CEntityOrder* current, int timestep_millis );
bool ProcessGoto( CEntityOrder* current, int timestep_millis );
bool ProcessGotoWaypoint( CEntityOrder* current, int timestep_millis, bool contact );

View File

@ -21,7 +21,7 @@
// order queue after it's executed. In this way, the entity will
// circle round a list of patrol points.
// Create this order when a standard patrol order is required.
// ORDER_GENERIC: Generic ranged action. Move towards target entity, then start
// ORDER_CONTACT_ACTION: Generic ranged action. Move towards target entity, then start
// performing an action (call a JS event handler every few seconds).
// If we collide with something (=> line-of-sight tracking no longer
// sufficient) spawns a ORDER_GOTO to target's location and pushes it
@ -73,24 +73,25 @@ class CEntityOrder
public:
enum EOrderType
{
ORDER_INVALID, // 0
ORDER_GOTO_NOPATHING, // 1
ORDER_GOTO_SMOOTHED, // 2
ORDER_GOTO_COLLISION, // 3
ORDER_GOTO_WAYPOINT, // 4
ORDER_GOTO_WAYPOINT_CONTACT,// 5
ORDER_GOTO, // 6
ORDER_RUN, // 7
ORDER_PATROL, // 8
ORDER_PATH_END_MARKER, // 9
ORDER_GENERIC, // 10
ORDER_GENERIC_NOPATHING, // 11
ORDER_PRODUCE, // 12
ORDER_START_CONSTRUCTION, // 13
ORDER_SET_RALLY_POINT, // 14
ORDER_SET_STANCE, // 15
ORDER_NOTIFY_REQUEST, // 16
ORDER_LAST // 17
ORDER_INVALID, // 0
ORDER_GOTO_NOPATHING, // 1
ORDER_GOTO_NOPATHING_CONTACT, // 2
ORDER_GOTO_SMOOTHED, // 3
ORDER_GOTO_COLLISION, // 4
ORDER_GOTO_WAYPOINT, // 5
ORDER_GOTO_WAYPOINT_CONTACT, // 6
ORDER_GOTO, // 7
ORDER_RUN, // 8
ORDER_PATROL, // 9
ORDER_PATH_END_MARKER, // 10
ORDER_CONTACT_ACTION, // 11
ORDER_CONTACT_ACTION_NOPATHING, // 12
ORDER_PRODUCE, // 13
ORDER_START_CONSTRUCTION, // 14
ORDER_SET_RALLY_POINT, // 15
ORDER_SET_STANCE, // 16
ORDER_NOTIFY_REQUEST, // 17
ORDER_LAST // 18
};
EOrderType m_type;
@ -115,8 +116,8 @@ public:
// NMT_ADD_WAYPOINT
CVector2D m_target_location;
// NMT_GENERIC
// NMT_FORMATION_GENERIC
// NMT_CONTACT_ACTION
// NMT_FORMATION_CONTACT_ACTION
// NMT_NOTIFY_REQUEST
HEntity m_target_entity;
int m_action;
@ -127,7 +128,7 @@ public:
// NMT_PRODUCE
int m_produce_type;
// NMT_GENERIC
// NMT_CONTACT_ACTION
bool m_run;
CEntityOrder(): m_type(ORDER_INVALID), m_source(SOURCE_PLAYER) {}

View File

@ -302,7 +302,7 @@ bool CEntity::Order( JSContext* cx, uintN argc, jsval* argv, CEntityOrder::EOrde
}
}
break;
case CEntityOrder::ORDER_GENERIC:
case CEntityOrder::ORDER_CONTACT_ACTION:
JSU_REQUIRE_PARAMS_CPP(4);
target = ToNative<CEntity>( argv[1] );
if( !target )

View File

@ -259,7 +259,7 @@ int CEntity::ProcessGotoHelper( CEntityOrder* current, int timestep_millis, HEnt
return( rc );
}
// Go towards a waypoint, or repath if there is an obstacle in the way
bool CEntity::ProcessGotoNoPathing( CEntityOrder* current, int timestep_millis )
{
HEntity collide;
@ -377,9 +377,48 @@ bool CEntity::ProcessGotoNoPathing( CEntityOrder* current, int timestep_millis )
}
}
// Handles processing common to (at the moment) gather and melee attack actions
bool CEntity::ProcessContactAction( CEntityOrder* current, int UNUSED(timestep_millis), CEntityOrder::EOrderType transition, SEntityAction* action )
// Go towards a waypoint, unless you can perform a contact action
bool CEntity::ProcessGotoNoPathingContact( CEntityOrder* current, int timestep_millis )
{
CEntityOrder* contact_order = 0;
CEntityOrders::iterator it = m_orderQueue.begin();
for(; it != m_orderQueue.end(); ++it)
{
if( it->m_type == CEntityOrder::ORDER_CONTACT_ACTION
|| it->m_type == CEntityOrder::ORDER_CONTACT_ACTION_NOPATHING )
{
contact_order = &(*it);
break;
}
}
if( ProcessContactAction(contact_order, timestep_millis, false ) )
{
// We are in range to do our action; pop off all the pathing orders
while( m_orderQueue.front().m_type != CEntityOrder::ORDER_CONTACT_ACTION
&& m_orderQueue.front().m_type != CEntityOrder::ORDER_CONTACT_ACTION_NOPATHING )
{
m_orderQueue.pop_front();
}
return true;
}
else
{
return ProcessGotoNoPathing( current, timestep_millis );
}
}
// Handles processing common to (at the moment) gather and melee attack actions
bool CEntity::ProcessContactAction( CEntityOrder* current,
int UNUSED(timestep_millis),
bool repath_if_needed )
{
if( m_actions.find( current->m_action ) == m_actions.end() )
{
return false; // we've been tasked as part of a group but we can't do this action
}
SEntityAction* action = &m_actions[current->m_action];
CEntityOrder::EOrderType transition = CEntityOrder::ORDER_CONTACT_ACTION_NOPATHING;
HEntity target = current->m_target_entity;
if( !target || !target->m_extant )
@ -409,7 +448,7 @@ bool CEntity::ProcessContactAction( CEntityOrder* current, int UNUSED(timestep_m
entf_clear(ENTF_IS_RUNNING);
return true;
}
else
else if (repath_if_needed)
{
if( current->m_source == CEntityOrder::SOURCE_UNIT_AI && !m_stance->AllowsMovement() )
{
@ -426,10 +465,26 @@ bool CEntity::ProcessContactAction( CEntityOrder* current, int UNUSED(timestep_m
return true;
}
else
{
return false;
}
}
bool CEntity::ProcessContactActionNoPathing( CEntityOrder* current, int timestep_millis, const CStr& animation, CScriptEvent* contactEvent, SEntityAction* action )
bool CEntity::ProcessContactActionNoPathing( CEntityOrder* current, int timestep_millis )
{
if( m_actions.find( current->m_action ) == m_actions.end() )
{
return false; // we've been tasked as part of a group but we can't do this action
}
if( !m_actor )
{
return( false ); // shouldn't happen, but having no actor would mean we have no animation
}
CEventContactAction contactEvent( current->m_target_entity, current->m_action );
SEntityAction* action = &m_actions[current->m_action];
CStr& animation = action->m_Animation;
HEntity target = current->m_target_entity;
if( m_fsm_cyclepos != NOT_IN_CYCLE )
@ -441,7 +496,7 @@ bool CEntity::ProcessContactActionNoPathing( CEntityOrder* current, int timestep
const size_t soundGroupIndex = m_base->m_SoundGroupTable[animation];
g_soundGroupMgr->PlayNext(soundGroupIndex, m_position);
if(!DispatchEvent( contactEvent ))
if(!DispatchEvent( &contactEvent ))
{
// Cancel current order
entf_clear(ENTF_IS_RUNNING);
@ -600,28 +655,6 @@ bool CEntity::ProcessContactActionNoPathing( CEntityOrder* current, int timestep
return( false );
}
bool CEntity::ProcessGeneric( CEntityOrder* current, int timestep_millis )
{
if( m_actions.find( current->m_action ) == m_actions.end() )
{
return false; // we've been tasked as part of a group but we can't do this action
}
SEntityAction& action_obj = m_actions[current->m_action];
return( ProcessContactAction( current, timestep_millis, CEntityOrder::ORDER_GENERIC_NOPATHING, &action_obj ) );
}
bool CEntity::ProcessGenericNoPathing( CEntityOrder* current, int timestep_millis )
{
if( m_actions.find( current->m_action ) == m_actions.end() )
{
return false; // we've been tasked as part of a group but we can't do this action
}
CEventGeneric evt( current->m_target_entity, current->m_action );
if( !m_actor ) return( false );
SEntityAction& action_obj = m_actions[current->m_action];
return( ProcessContactActionNoPathing( current, timestep_millis, action_obj.m_Animation, &evt, &action_obj ) );
}
bool CEntity::ProcessGoto( CEntityOrder* current, int UNUSED(timestep_millis) )
{
CVector2D pos( m_position.X, m_position.Z );

View File

@ -2,7 +2,7 @@
#include "EventHandlers.h"
#include "Entity.h"
CEventGeneric::CEventGeneric( CEntity* target, int action ) : CScriptEvent( L"generic", EVENT_GENERIC, true)
CEventContactAction::CEventContactAction( CEntity* target, int action ) : CScriptEvent( L"contactAction", EVENT_CONTACT_ACTION, true)
{
m_target = target;
m_action = action;
@ -10,7 +10,7 @@ CEventGeneric::CEventGeneric( CEntity* target, int action ) : CScriptEvent( L"ge
AddLocalProperty( L"action", &m_action );
}
CEventTargetExhausted::CEventTargetExhausted( CEntity* target, int action ) : CScriptEvent( L"TargetExhausted", EVENT_TARGET_EXHAUSTED, true)
CEventTargetExhausted::CEventTargetExhausted( CEntity* target, int action ) : CScriptEvent( L"targetExhausted", EVENT_TARGET_EXHAUSTED, true)
{
m_target = target;
m_action = action;

View File

@ -29,12 +29,12 @@ public:
};
*/
class CEventGeneric : public CScriptEvent
class CEventContactAction : public CScriptEvent
{
CEntity* m_target;
int m_action;
public:
CEventGeneric( CEntity* target, int action );
CEventContactAction( CEntity* target, int action );
};
class CEventTargetExhausted : public CScriptEvent

View File

@ -350,11 +350,14 @@ void CPathfindEngine::RequestPath( HEntity entity, const CVector2D& destination,
}
void CPathfindEngine::RequestTriangulationPath( HEntity entity, const CVector2D& destination, bool UNUSED(contact),
void CPathfindEngine::RequestTriangulationPath( HEntity entity, const CVector2D& destination, bool contact,
float radius, CEntityOrder::EOrderSource orderSource )
{
PROFILE_START("Pathfinding");
CEntityOrder::EOrderType stepType = CEntityOrder::ORDER_GOTO_NOPATHING;
if (contact) stepType = CEntityOrder::ORDER_GOTO_NOPATHING_CONTACT;
if(g_TriPathfind)
{
/* TODO:1. add code to verify the triangulation. done.
@ -452,13 +455,13 @@ void CPathfindEngine::RequestTriangulationPath( HEntity entity, const CVector2D&
node.m_type = CEntityOrder::ORDER_PATH_END_MARKER; // push end marker (used as a sentinel when repathing)
node.m_target_location = finalDest;
entity->m_orderQueue.push_front(node);
node.m_type = CEntityOrder::ORDER_GOTO_NOPATHING; // push final goto step
node.m_type = stepType; // push final goto step
node.m_target_location = finalDest;
entity->m_orderQueue.push_front(node);
for( int i = ((int) path.size()) - 2; i >= 0; i-- )
{
node.m_type = CEntityOrder::ORDER_GOTO_NOPATHING; // TODO: For non-contact paths, do we want some other order type?
node.m_type = stepType; // TODO: For non-contact paths, do we want some other order type?
node.m_target_location = path[i];
entity->m_orderQueue.push_front(node);
}
@ -473,7 +476,7 @@ void CPathfindEngine::RequestTriangulationPath( HEntity entity, const CVector2D&
node.m_type = CEntityOrder::ORDER_PATH_END_MARKER;
node.m_target_location = destination;
entity->m_orderQueue.push_front(node);
node.m_type = CEntityOrder::ORDER_GOTO_NOPATHING;
node.m_type = stepType;
node.m_target_location = destination;
entity->m_orderQueue.push_front(node);
}
@ -484,11 +487,13 @@ void CPathfindEngine::RequestTriangulationPath( HEntity entity, const CVector2D&
PROFILE_END("Pathfinding");
}
void CPathfindEngine::RequestLowLevelPath( HEntity entity, const CVector2D& destination, bool UNUSED(contact),
void CPathfindEngine::RequestLowLevelPath( HEntity entity, const CVector2D& destination, bool contact,
float radius, CEntityOrder::EOrderSource orderSource )
{
PROFILE_START("Pathfinding");
CEntityOrder::EOrderType stepType = CEntityOrder::ORDER_GOTO_NOPATHING;
if (contact) stepType = CEntityOrder::ORDER_GOTO_NOPATHING_CONTACT;
//Kai: added test for terrain information in entityManager
//mLowPathfinder.TAStarTest();
@ -529,13 +534,13 @@ void CPathfindEngine::RequestLowLevelPath( HEntity entity, const CVector2D& dest
node.m_type = CEntityOrder::ORDER_PATH_END_MARKER; // push end marker (used as a sentinel when repathing)
node.m_target_location = finalDest;
entity->m_orderQueue.push_front(node);
node.m_type = CEntityOrder::ORDER_GOTO_NOPATHING; // push final goto step
node.m_type = stepType; // push final goto step
node.m_target_location = finalDest;
entity->m_orderQueue.push_front(node);
for( int i = ((int) path.size()) - 2; i >= 0; i-- )
{
node.m_type = CEntityOrder::ORDER_GOTO_NOPATHING; // TODO: For non-contact paths, do we want some other order type?
node.m_type = stepType;
node.m_target_location = path[i];
entity->m_orderQueue.push_front(node);
}
@ -550,7 +555,7 @@ void CPathfindEngine::RequestLowLevelPath( HEntity entity, const CVector2D& dest
node.m_type = CEntityOrder::ORDER_PATH_END_MARKER;
node.m_target_location = destination;
entity->m_orderQueue.push_front(node);
node.m_type = CEntityOrder::ORDER_GOTO_NOPATHING;
node.m_type = stepType;
node.m_target_location = destination;
entity->m_orderQueue.push_front(node);
}

View File

@ -389,11 +389,11 @@ size_t CSimulation::TranslateMessage(CNetMessage* pMsg, size_t clientMask, void*
ENTITY_POSITION_FORM(CFormationGotoMessage, ORDER_GOTO);
break;
//TODO: make formation move to within range of target and then attack normally
case NMT_GENERIC:
ENTITY_ENTITY_INT_BOOL(CGenericMessage, ORDER_GENERIC);
case NMT_CONTACT_ACTION:
ENTITY_ENTITY_INT_BOOL(CContactActionMessage, ORDER_CONTACT_ACTION);
break;
case NMT_FORMATION_GENERIC:
ENTITY_ENTITY_INT(CFormationGenericMessage, ORDER_GENERIC);
case NMT_FORMATION_CONTACT_ACTION:
ENTITY_ENTITY_INT(CFormationContactActionMessage, ORDER_CONTACT_ACTION);
break;
case NMT_NOTIFY_REQUEST:
ENTITY_ENTITY_INT(CNotifyRequestMessage, ORDER_NOTIFY_REQUEST);

View File

@ -65,7 +65,7 @@ void CDefendStance::OnDamaged(CEntity *source)
float range = m_Entity->m_actions[action].m_MaxRange;
if( ( range + m_Entity->m_los * CELL_SIZE ) >= m_Entity->Distance2D( source ) )
{
CEntityOrder order( CEntityOrder::ORDER_GENERIC, CEntityOrder::SOURCE_UNIT_AI );
CEntityOrder order( CEntityOrder::ORDER_CONTACT_ACTION, CEntityOrder::SOURCE_UNIT_AI );
order.m_target_entity = source->me;
order.m_action = action;
order.m_run = false;
@ -139,7 +139,7 @@ void CStanceUtils::Attack(CEntity* entity, CEntity* target)
int action = entity->GetAttackAction( target->me );
if( action )
{
CEntityOrder order( CEntityOrder::ORDER_GENERIC, CEntityOrder::SOURCE_UNIT_AI );
CEntityOrder order( CEntityOrder::ORDER_CONTACT_ACTION, CEntityOrder::SOURCE_UNIT_AI );
order.m_target_entity = target->me;
order.m_action = action;
order.m_run = false;

View File

@ -51,7 +51,7 @@ void SimulationScriptInit()
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_GENERIC", CEntityOrder::ORDER_GENERIC );
g_ScriptingHost.DefineConstant( "ORDER_CONTACT_ACTION", CEntityOrder::ORDER_CONTACT_ACTION );
g_ScriptingHost.DefineConstant( "ORDER_PRODUCE", CEntityOrder::ORDER_PRODUCE );
g_ScriptingHost.DefineConstant( "ORDER_SET_RALLY_POINT", CEntityOrder::ORDER_SET_RALLY_POINT );
g_ScriptingHost.DefineConstant( "ORDER_SET_STANCE", CEntityOrder::ORDER_SET_STANCE );