OpenClonk
C4Command.h
Go to the documentation of this file.
1 /*
2  * OpenClonk, http://www.openclonk.org
3  *
4  * Copyright (c) 1998-2000, Matthes Bender
5  * Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de/
6  * Copyright (c) 2009-2016, The OpenClonk Team and contributors
7  *
8  * Distributed under the terms of the ISC license; see accompanying file
9  * "COPYING" for details.
10  *
11  * "Clonk" is a registered trademark of Matthes Bender, used with permission.
12  * See accompanying file "TRADEMARK" for details.
13  *
14  * To redistribute this file separately, substitute the full license texts
15  * for the above references.
16  */
17 
18 /* The command stack controls an object's complex and independent behavior */
19 
20 #ifndef INC_C4Command
21 #define INC_C4Command
22 
23 #include "object/C4ObjectPtr.h"
24 #include "script/C4Value.h"
25 
26 enum C4CMD
27 {
54 };
55 
56 const int32_t C4CMD_First = C4CMD_Follow,
57  C4CMD_Last = C4CMD_Take2; // carlo
58 
59 const int32_t C4CMD_Mode_SilentSub = 0, // subcommand; failure will cause base to fail (no message in case of failure)
60  C4CMD_Mode_Base = 1, // regular base command
61  C4CMD_Mode_SilentBase = 2, // silent base command (no message in case of failure)
62  C4CMD_Mode_Sub = 3; // subcommand; failure will cause base to fail
63 
64 // MoveTo and Enter command options: Include push target
65 const int32_t C4CMD_MoveTo_NoPosAdjust = 1,
67 
68 const int32_t C4CMD_Enter_PushTarget = 2;
69 
70 const char *CommandName(int32_t iCommand);
71 const char* CommandNameID(int32_t iCommand);
72 int32_t CommandByName(const char *szCommand);
73 
74 class C4Command
75 {
76 public:
77  C4Command();
78  ~C4Command();
79 public:
81  int32_t Command;
83  int32_t Ty;
86  int32_t UpdateInterval;
91  int32_t iExec; // 0 = not executing, 1 = executing, 2 = executing, command should delete himself on finish
92  int32_t BaseMode; // 0: subcommand/unmarked base (if failing, base will fail, too); 1: base command; 2: silent base command
93 public:
94  void Set(int32_t iCommand, C4Object *pObj, C4Object *pTarget, C4Value iTx, int32_t iTy, C4Object *pTarget2, C4Value iData, int32_t iUpdateInterval, bool fEvaluated, int32_t iRetries, C4String *szText, int32_t iBaseMode);
95  void Clear();
96  void Execute();
97  void ClearPointers(C4Object *pObj);
98  void Default();
99  void Denumerate(C4ValueNumbers *);
100  void CompileFunc(StdCompiler *pComp, C4ValueNumbers *);
101 protected:
102  void Call();
103  void Home();
104  void Retry();
105  void Fail(const char *szFailMessage=nullptr);
106  void Acquire();
107  void Sell();
108  void Buy();
109  void Attack();
110  void Transfer();
111  void Finish(bool fSuccess=false, const char *szFailMessage=nullptr);
112  void Follow();
113  void MoveTo();
114  void Enter();
115  void Exit();
116  void Grab();
117  void UnGrab();
118  void Throw();
119  void Jump();
120  void Wait();
121  void Take();
122  void Take2();
123  bool GetTryEnter(); // at object pos during get-command: Try entering it
124  void Get();
125  void Put();
126  void Drop();
127  void Dig();
128  void Activate();
129  void PushTo();
130  int32_t CallFailed();
131  bool JumpControl();
132  bool FlightControl();
133  bool InitEvaluation();
134  int32_t GetExpGain(); // get control counts gained by this command; 1EXP=5 ControlCounts
135 };
136 
137 #endif
const int32_t C4CMD_MoveTo_NoPosAdjust
Definition: C4Command.h:65
const int32_t C4CMD_Mode_SilentBase
Definition: C4Command.h:61
C4CMD
Definition: C4Command.h:27
@ C4CMD_Acquire
Definition: C4Command.h:48
@ C4CMD_Call
Definition: C4Command.h:51
@ C4CMD_Home
Definition: C4Command.h:50
@ C4CMD_Sell
Definition: C4Command.h:47
@ C4CMD_Drop
Definition: C4Command.h:40
@ C4CMD_Transfer
Definition: C4Command.h:44
@ C4CMD_Follow
Definition: C4Command.h:29
@ C4CMD_Activate
Definition: C4Command.h:42
@ C4CMD_Take
Definition: C4Command.h:52
@ C4CMD_Wait
Definition: C4Command.h:37
@ C4CMD_Attack
Definition: C4Command.h:45
@ C4CMD_Retry
Definition: C4Command.h:49
@ C4CMD_Get
Definition: C4Command.h:38
@ C4CMD_None
Definition: C4Command.h:28
@ C4CMD_MoveTo
Definition: C4Command.h:30
@ C4CMD_Take2
Definition: C4Command.h:53
@ C4CMD_Jump
Definition: C4Command.h:36
@ C4CMD_Put
Definition: C4Command.h:39
@ C4CMD_Enter
Definition: C4Command.h:31
@ C4CMD_PushTo
Definition: C4Command.h:43
@ C4CMD_Exit
Definition: C4Command.h:32
@ C4CMD_UnGrab
Definition: C4Command.h:35
@ C4CMD_Buy
Definition: C4Command.h:46
@ C4CMD_Throw
Definition: C4Command.h:34
@ C4CMD_Dig
Definition: C4Command.h:41
@ C4CMD_Grab
Definition: C4Command.h:33
int32_t CommandByName(const char *szCommand)
Definition: C4Command.cpp:126
const int32_t C4CMD_MoveTo_PushTarget
Definition: C4Command.h:66
const char * CommandName(int32_t iCommand)
Definition: C4Command.cpp:46
const char * CommandNameID(int32_t iCommand)
Definition: C4Command.cpp:80
const int32_t C4CMD_Mode_Base
Definition: C4Command.h:60
const int32_t C4CMD_Enter_PushTarget
Definition: C4Command.h:68
const int32_t C4CMD_Last
Definition: C4Command.h:57
const int32_t C4CMD_First
Definition: C4Command.h:56
const int32_t C4CMD_Mode_Sub
Definition: C4Command.h:62
const int32_t C4CMD_Mode_SilentSub
Definition: C4Command.h:59
int32_t Failures
Definition: C4Command.h:88
bool JumpControl()
Definition: C4Command.cpp:1505
int32_t Evaluated
Definition: C4Command.h:87
C4Value Data
Definition: C4Command.h:85
void Drop()
Definition: C4Command.cpp:841
void Acquire()
Definition: C4Command.cpp:1655
void Dig()
Definition: C4Command.cpp:454
void Put()
Definition: C4Command.cpp:1173
int32_t Finished
Definition: C4Command.h:87
void Buy()
Definition: C4Command.cpp:1645
void ClearPointers(C4Object *pObj)
Definition: C4Command.cpp:1288
void Finish(bool fSuccess=false, const char *szFailMessage=nullptr)
Definition: C4Command.cpp:1374
void Denumerate(C4ValueNumbers *)
Definition: C4Command.cpp:1911
void Enter()
Definition: C4Command.cpp:564
void Retry()
Definition: C4Command.cpp:1800
C4Value Tx
Definition: C4Command.h:82
int32_t Retries
Definition: C4Command.h:88
int32_t GetExpGain()
Definition: C4Command.cpp:1932
void Take2()
Definition: C4Command.cpp:835
bool GetTryEnter()
Definition: C4Command.cpp:926
int32_t UpdateInterval
Definition: C4Command.h:86
void Call()
Definition: C4Command.cpp:1833
C4ObjectPtr Target
Definition: C4Command.h:84
int32_t iExec
Definition: C4Command.h:91
void Sell()
Definition: C4Command.cpp:1650
void Transfer()
Definition: C4Command.cpp:1571
bool FlightControl()
Definition: C4Command.cpp:1471
void Grab()
Definition: C4Command.cpp:669
int32_t CallFailed()
Definition: C4Command.cpp:1918
void Set(int32_t iCommand, C4Object *pObj, C4Object *pTarget, C4Value iTx, int32_t iTy, C4Object *pTarget2, C4Value iData, int32_t iUpdateInterval, bool fEvaluated, int32_t iRetries, C4String *szText, int32_t iBaseMode)
Definition: C4Command.cpp:1810
C4ObjectPtr Target2
Definition: C4Command.h:84
void Get()
Definition: C4Command.cpp:955
C4Object * cObj
Definition: C4Command.h:80
int32_t Permit
Definition: C4Command.h:88
bool InitEvaluation()
Definition: C4Command.cpp:1392
void Execute()
Definition: C4Command.cpp:1295
void Default()
Definition: C4Command.cpp:207
void Throw()
Definition: C4Command.cpp:755
void MoveTo()
Definition: C4Command.cpp:257
void PushTo()
Definition: C4Command.cpp:701
void Attack()
Definition: C4Command.cpp:1600
void Take()
Definition: C4Command.cpp:829
void CompileFunc(StdCompiler *pComp, C4ValueNumbers *)
Definition: C4Command.cpp:1852
void Home()
Definition: C4Command.cpp:1805
void UnGrab()
Definition: C4Command.cpp:748
void Wait()
Definition: C4Command.cpp:920
void Jump()
Definition: C4Command.cpp:898
void Fail(const char *szFailMessage=nullptr)
Definition: C4Command.cpp:1703
int32_t Ty
Definition: C4Command.h:83
void Exit()
Definition: C4Command.cpp:630
int32_t PathChecked
Definition: C4Command.h:87
int32_t Command
Definition: C4Command.h:81
int32_t BaseMode
Definition: C4Command.h:92
void Clear()
Definition: C4Command.cpp:1456
C4String * Text
Definition: C4Command.h:89
C4Command * Next
Definition: C4Command.h:90
void Follow()
Definition: C4Command.cpp:512
void Activate()
Definition: C4Command.cpp:1105