OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
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
void Sell()
Definition: C4Command.cpp:1650
void Drop()
Definition: C4Command.cpp:842
C4Object * cObj
Definition: C4Command.h:80
bool InitEvaluation()
Definition: C4Command.cpp:1393
void Take()
Definition: C4Command.cpp:830
C4CMD
Definition: C4Command.h:26
void Wait()
Definition: C4Command.cpp:921
int32_t Evaluated
Definition: C4Command.h:87
const int32_t C4CMD_Mode_Base
Definition: C4Command.h:60
void Activate()
Definition: C4Command.cpp:1106
C4Value Data
Definition: C4Command.h:85
C4Command * Next
Definition: C4Command.h:90
void Attack()
Definition: C4Command.cpp:1600
int32_t Permit
Definition: C4Command.h:88
void Grab()
Definition: C4Command.cpp:670
bool GetTryEnter()
Definition: C4Command.cpp:927
void Take2()
Definition: C4Command.cpp:836
const int32_t C4CMD_Mode_SilentBase
Definition: C4Command.h:61
void Transfer()
Definition: C4Command.cpp:1571
int32_t Retries
Definition: C4Command.h:88
void Execute()
Definition: C4Command.cpp:1296
int32_t BaseMode
Definition: C4Command.h:92
void Dig()
Definition: C4Command.cpp:455
int32_t Ty
Definition: C4Command.h:83
const char * CommandName(int32_t iCommand)
Definition: C4Command.cpp:47
void MoveTo()
Definition: C4Command.cpp:258
int32_t Finished
Definition: C4Command.h:87
void ClearPointers(C4Object *pObj)
Definition: C4Command.cpp:1289
C4Value Tx
Definition: C4Command.h:82
const int32_t C4CMD_Mode_SilentSub
Definition: C4Command.h:59
int32_t GetExpGain()
Definition: C4Command.cpp:1932
void Enter()
Definition: C4Command.cpp:565
int32_t UpdateInterval
Definition: C4Command.h:86
void Home()
Definition: C4Command.cpp:1805
C4String * Text
Definition: C4Command.h:89
void Buy()
Definition: C4Command.cpp:1645
const int32_t C4CMD_MoveTo_NoPosAdjust
Definition: C4Command.h:65
const int32_t C4CMD_First
Definition: C4Command.h:56
int32_t Failures
Definition: C4Command.h:88
int32_t Command
Definition: C4Command.h:81
void Default()
Definition: C4Command.cpp:208
const int32_t C4CMD_MoveTo_PushTarget
Definition: C4Command.h:66
const int32_t C4CMD_Last
Definition: C4Command.h:57
void Denumerate(C4ValueNumbers *)
Definition: C4Command.cpp:1911
void Fail(const char *szFailMessage=nullptr)
Definition: C4Command.cpp:1703
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 Target
Definition: C4Command.h:84
void Follow()
Definition: C4Command.cpp:513
C4ObjectPtr Target2
Definition: C4Command.h:84
void Call()
Definition: C4Command.cpp:1833
void Exit()
Definition: C4Command.cpp:631
void PushTo()
Definition: C4Command.cpp:702
void Get()
Definition: C4Command.cpp:956
void Throw()
Definition: C4Command.cpp:756
int32_t iExec
Definition: C4Command.h:91
void Jump()
Definition: C4Command.cpp:899
void UnGrab()
Definition: C4Command.cpp:749
void Clear()
Definition: C4Command.cpp:1457
void Put()
Definition: C4Command.cpp:1174
void Finish(bool fSuccess=false, const char *szFailMessage=nullptr)
Definition: C4Command.cpp:1375
int32_t CommandByName(const char *szCommand)
Definition: C4Command.cpp:127
const int32_t C4CMD_Enter_PushTarget
Definition: C4Command.h:68
bool FlightControl()
Definition: C4Command.cpp:1471
void Retry()
Definition: C4Command.cpp:1800
const int32_t C4CMD_Mode_Sub
Definition: C4Command.h:62
int32_t PathChecked
Definition: C4Command.h:87
void CompileFunc(StdCompiler *pComp, C4ValueNumbers *)
Definition: C4Command.cpp:1852
const char * CommandNameID(int32_t iCommand)
Definition: C4Command.cpp:81
int32_t CallFailed()
Definition: C4Command.cpp:1918
void Acquire()
Definition: C4Command.cpp:1655
bool JumpControl()
Definition: C4Command.cpp:1505