OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4ObjectCom.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

bool ComDirLike (int32_t iComDir, int32_t iSample)
 
bool ObjectActionWalk (C4Object *cObj)
 
bool ObjectActionStand (C4Object *cObj)
 
bool ObjectActionJump (C4Object *cObj, C4Real xdir, C4Real ydir, bool fByCom)
 
bool ObjectActionDive (C4Object *cObj, C4Real xdir, C4Real ydir)
 
bool ObjectActionTumble (C4Object *cObj, int32_t dir, C4Real xdir, C4Real ydir)
 
bool ObjectActionGetPunched (C4Object *cObj, C4Real xdir, C4Real ydir)
 
bool ObjectActionKneel (C4Object *cObj)
 
bool ObjectActionFlat (C4Object *cObj, int32_t dir)
 
bool ObjectActionScale (C4Object *cObj, int32_t dir)
 
bool ObjectActionHangle (C4Object *cObj)
 
bool ObjectActionThrow (C4Object *cObj, C4Object *pThing=nullptr)
 
bool ObjectActionDig (C4Object *cObj)
 
bool ObjectActionPush (C4Object *cObj, C4Object *pTarget)
 
bool ObjectActionCornerScale (C4Object *cObj)
 
bool ObjectComStop (C4Object *cObj)
 
bool ObjectComGrab (C4Object *cObj, C4Object *pTarget)
 
bool ObjectComPut (C4Object *cObj, C4Object *pTarget, C4Object *pThing=nullptr)
 
bool ObjectComThrow (C4Object *cObj, C4Object *pThing=nullptr)
 
bool ObjectComDrop (C4Object *cObj, C4Object *pThing=nullptr)
 
bool ObjectComUnGrab (C4Object *cObj)
 
bool ObjectComJump (C4Object *cObj)
 
bool ObjectComLetGo (C4Object *cObj, int32_t xdirf)
 
bool ObjectComDig (C4Object *cObj)
 
bool ObjectComPutTake (C4Object *cObj, C4Object *pTarget, C4Object *pThing=nullptr)
 
bool ObjectComTake (C4Object *cObj)
 
bool ObjectComTake2 (C4Object *cObj)
 
bool ObjectComPunch (C4Object *cObj, C4Object *pTarget, int32_t iPunch=0)
 
bool ObjectComCancelAttach (C4Object *cObj)
 
void ObjectComStopDig (C4Object *cObj)
 

Function Documentation

bool ComDirLike ( int32_t  iComDir,
int32_t  iSample 
)

Definition at line 425 of file C4ObjectCom.cpp.

Referenced by C4Object::ContactAction(), C4Object::NoAttachAction(), and ObjectComDrop().

426 {
427  if (iComDir == iSample) return true;
428  if (iComDir % 8 + 1 == iSample) return true;
429  if (iComDir == iSample % 8 + 1 ) return true;
430  return false;
431 }

Here is the caller graph for this function:

bool ObjectActionCornerScale ( C4Object cObj)

Definition at line 167 of file C4ObjectCom.cpp.

References C4Object::Action, C4Action::Dir, DIR_Left, C4Object::fix_x, C4Object::fix_y, itofix(), C4Object::SetActionByName(), C4Object::xdir, and C4Object::ydir.

Referenced by C4Object::ContactAction(), and C4Object::NoAttachAction().

168 {
169  int32_t iRangeX = 1, iRangeY = 1;
170  if (!CornerScaleOkay(cObj,iRangeX,iRangeY)) return false;
171  // Do corner scale
172  if (!cObj->SetActionByName("KneelUp"))
173  cObj->SetActionByName("Walk");
174  cObj->xdir=cObj->ydir=0;
175  if (cObj->Action.Dir==DIR_Left) cObj->fix_x-=itofix(iRangeX);
176  else cObj->fix_x+=itofix(iRangeX);
177  cObj->fix_y-=itofix(iRangeY);
178  return true;
179 }
bool SetActionByName(C4String *ActName, C4Object *pTarget=nullptr, C4Object *pTarget2=nullptr, int32_t iCalls=SAC_StartCall|SAC_AbortCall, bool fForce=false)
Definition: C4Object.cpp:2815
#define DIR_Left
Definition: C4Object.h:41
C4Fixed itofix(int32_t x)
Definition: C4Real.h:261
C4Real fix_x
Definition: C4Object.h:125
int32_t Dir
Definition: C4Object.h:80
C4Real fix_y
Definition: C4Object.h:125
C4Action Action
Definition: C4Object.h:147
C4Real xdir
Definition: C4Object.h:126
C4Real ydir
Definition: C4Object.h:126

Here is the call graph for this function:

Here is the caller graph for this function:

bool ObjectActionDig ( C4Object cObj)

Definition at line 140 of file C4ObjectCom.cpp.

References C4Object::Action, C4Action::Data, and C4Object::SetActionByName().

Referenced by ObjectComDig().

141 {
142  if (!cObj->SetActionByName("Dig")) return false;
143  cObj->Action.Data=0; // Material Dig2Object request
144  return true;
145 }
bool SetActionByName(C4String *ActName, C4Object *pTarget=nullptr, C4Object *pTarget2=nullptr, int32_t iCalls=SAC_StartCall|SAC_AbortCall, bool fForce=false)
Definition: C4Object.cpp:2815
int32_t Data
Definition: C4Object.h:84
C4Action Action
Definition: C4Object.h:147

Here is the call graph for this function:

Here is the caller graph for this function:

bool ObjectActionDive ( C4Object cObj,
C4Real  xdir,
C4Real  ydir 
)

Definition at line 68 of file C4ObjectCom.cpp.

References C4Object::Action, CNAT_Bottom, C4Object::Mobile, C4Object::SetActionByName(), C4Action::t_attach, C4Object::xdir, and C4Object::ydir.

Referenced by ObjectComJump().

69 {
70  if (!cObj->SetActionByName("Dive")) return false;
71  cObj->xdir=xdir; cObj->ydir=ydir;
72  cObj->Mobile=true;
73  // unstick from ground, because jump command may be issued in an Action-callback,
74  // where attach-values have already been determined for that frame
75  cObj->Action.t_attach&=~CNAT_Bottom;
76  return true;
77 }
bool SetActionByName(C4String *ActName, C4Object *pTarget=nullptr, C4Object *pTarget2=nullptr, int32_t iCalls=SAC_StartCall|SAC_AbortCall, bool fForce=false)
Definition: C4Object.cpp:2815
bool Mobile
Definition: C4Object.h:128
int32_t t_attach
Definition: C4Object.h:86
C4Action Action
Definition: C4Object.h:147
C4Real xdir
Definition: C4Object.h:126
const BYTE CNAT_Bottom
Definition: C4Constants.h:112
C4Real ydir
Definition: C4Object.h:126

Here is the call graph for this function:

Here is the caller graph for this function:

bool ObjectActionFlat ( C4Object cObj,
int32_t  dir 
)

Definition at line 100 of file C4ObjectCom.cpp.

References C4Object::SetActionByName(), and C4Object::SetDir().

Referenced by C4Object::ContactAction().

101 {
102  if (!cObj->SetActionByName("FlatUp")) return false;
103  cObj->SetDir(dir);
104  return true;
105 }
void SetDir(int32_t tdir)
Definition: C4Object.cpp:2841
bool SetActionByName(C4String *ActName, C4Object *pTarget=nullptr, C4Object *pTarget2=nullptr, int32_t iCalls=SAC_StartCall|SAC_AbortCall, bool fForce=false)
Definition: C4Object.cpp:2815

Here is the call graph for this function:

Here is the caller graph for this function:

bool ObjectActionGetPunched ( C4Object cObj,
C4Real  xdir,
C4Real  ydir 
)

Definition at line 87 of file C4ObjectCom.cpp.

References C4Object::SetActionByName(), C4Object::xdir, and C4Object::ydir.

Referenced by ObjectComPunch().

88 {
89  if (!cObj->SetActionByName("GetPunched")) return false;
90  cObj->xdir=xdir; cObj->ydir=ydir;
91  return true;
92 }
bool SetActionByName(C4String *ActName, C4Object *pTarget=nullptr, C4Object *pTarget2=nullptr, int32_t iCalls=SAC_StartCall|SAC_AbortCall, bool fForce=false)
Definition: C4Object.cpp:2815
C4Real xdir
Definition: C4Object.h:126
C4Real ydir
Definition: C4Object.h:126

Here is the call graph for this function:

Here is the caller graph for this function:

bool ObjectActionHangle ( C4Object cObj)

Definition at line 114 of file C4ObjectCom.cpp.

References C4Object::SetActionByName().

Referenced by C4Object::ContactAction().

115 {
116  if (!cObj->SetActionByName("Hangle")) return false;
117  return true;
118 }
bool SetActionByName(C4String *ActName, C4Object *pTarget=nullptr, C4Object *pTarget2=nullptr, int32_t iCalls=SAC_StartCall|SAC_AbortCall, bool fForce=false)
Definition: C4Object.cpp:2815

Here is the call graph for this function:

Here is the caller graph for this function:

bool ObjectActionJump ( C4Object cObj,
C4Real  xdir,
C4Real  ydir,
bool  fByCom 
)

Definition at line 52 of file C4ObjectCom.cpp.

References C4Object::Action, C4PropList::Call(), CNAT_Bottom, fixtoi(), C4Object::Mobile, PSF_OnActionJump, C4Object::SetActionByName(), C4Action::t_attach, C4Object::xdir, and C4Object::ydir.

Referenced by C4Object::ContactAction(), C4Object::Fling(), C4Object::NoAttachAction(), ObjectComJump(), and ObjectComLetGo().

53 {
54  // scripted jump?
55  assert(cObj);
56  C4AulParSet pars(fixtoi(xdir, 100), fixtoi(ydir, 100), fByCom);
57  if (!!cObj->Call(PSF_OnActionJump, &pars)) return true;
58  // hardcoded jump by action
59  if (!cObj->SetActionByName("Jump")) return false;
60  cObj->xdir=xdir; cObj->ydir=ydir;
61  cObj->Mobile=true;
62  // unstick from ground, because jump command may be issued in an Action-callback,
63  // where attach-values have already been determined for that frame
64  cObj->Action.t_attach&=~CNAT_Bottom;
65  return true;
66 }
bool SetActionByName(C4String *ActName, C4Object *pTarget=nullptr, C4Object *pTarget2=nullptr, int32_t iCalls=SAC_StartCall|SAC_AbortCall, bool fForce=false)
Definition: C4Object.cpp:2815
bool Mobile
Definition: C4Object.h:128
int32_t t_attach
Definition: C4Object.h:86
#define PSF_OnActionJump
Definition: C4GameScript.h:140
C4Action Action
Definition: C4Object.h:147
int fixtoi(const C4Fixed &x)
Definition: C4Real.h:259
C4Real xdir
Definition: C4Object.h:126
const BYTE CNAT_Bottom
Definition: C4Constants.h:112
C4Real ydir
Definition: C4Object.h:126
C4Value Call(C4PropertyName k, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
Definition: C4PropList.h:110

Here is the call graph for this function:

Here is the caller graph for this function:

bool ObjectActionKneel ( C4Object cObj)

Definition at line 94 of file C4ObjectCom.cpp.

References C4Object::SetActionByName().

Referenced by C4Object::ContactAction().

95 {
96  if (!cObj->SetActionByName("KneelDown")) return false;
97  return true;
98 }
bool SetActionByName(C4String *ActName, C4Object *pTarget=nullptr, C4Object *pTarget2=nullptr, int32_t iCalls=SAC_StartCall|SAC_AbortCall, bool fForce=false)
Definition: C4Object.cpp:2815

Here is the call graph for this function:

Here is the caller graph for this function:

bool ObjectActionPush ( C4Object cObj,
C4Object pTarget 
)

Definition at line 147 of file C4ObjectCom.cpp.

References C4Object::SetActionByName().

Referenced by ObjectComGrab().

148 {
149  return cObj->SetActionByName("Push",target);
150 }
bool SetActionByName(C4String *ActName, C4Object *pTarget=nullptr, C4Object *pTarget2=nullptr, int32_t iCalls=SAC_StartCall|SAC_AbortCall, bool fForce=false)
Definition: C4Object.cpp:2815

Here is the call graph for this function:

Here is the caller graph for this function:

bool ObjectActionScale ( C4Object cObj,
int32_t  dir 
)

Definition at line 107 of file C4ObjectCom.cpp.

References C4Object::SetActionByName(), and C4Object::SetDir().

Referenced by C4Object::ContactAction().

108 {
109  if (!cObj->SetActionByName("Scale")) return false;
110  cObj->SetDir(dir);
111  return true;
112 }
void SetDir(int32_t tdir)
Definition: C4Object.cpp:2841
bool SetActionByName(C4String *ActName, C4Object *pTarget=nullptr, C4Object *pTarget2=nullptr, int32_t iCalls=SAC_StartCall|SAC_AbortCall, bool fForce=false)
Definition: C4Object.cpp:2815

Here is the call graph for this function:

Here is the caller graph for this function:

bool ObjectActionStand ( C4Object cObj)

Definition at line 45 of file C4ObjectCom.cpp.

References C4Object::Action, COMD_Stop, C4Action::ComDir, and ObjectActionWalk().

Referenced by C4Object::ContactAction(), DoBridge(), ObjectComStop(), ObjectComStopDig(), and ObjectComUnGrab().

46 {
47  cObj->Action.ComDir=COMD_Stop;
48  if (!ObjectActionWalk(cObj)) return false;
49  return true;
50 }
bool ObjectActionWalk(C4Object *cObj)
Definition: C4ObjectCom.cpp:39
#define COMD_Stop
Definition: C4Object.h:50
C4Action Action
Definition: C4Object.h:147
int32_t ComDir
Definition: C4Object.h:82

Here is the call graph for this function:

Here is the caller graph for this function:

bool ObjectActionThrow ( C4Object cObj,
C4Object pThing = nullptr 
)

Definition at line 120 of file C4ObjectCom.cpp.

References C4Object::Action, C4REAL100(), C4Object::Contents, C4Action::Dir, DIR_Left, C4Object::Exit(), C4ObjectList::GetObject(), C4PropList::GetPropertyInt(), C4Object::GetX(), C4Object::GetY(), P_ThrowSpeed, Random(), C4Object::SetActionByName(), C4Object::Shape, C4Object::xdir, C4Rect::y, and C4Object::ydir.

Referenced by ObjectComThrow().

121 {
122  // No object specified, first from contents
123  if (!pThing) pThing = cObj->Contents.GetObject();
124  // Nothing to throw
125  if (!pThing) return false;
126  // Force and direction
128  int32_t iDir=1; if (cObj->Action.Dir==DIR_Left) iDir=-1;
129  // Set action
130  if (!cObj->SetActionByName("Throw")) return false;
131  // Exit object
132  pThing->Exit(cObj->GetX(),
133  cObj->GetY()+cObj->Shape.y-1,
134  Random(360),
135  pthrow*iDir+cObj->xdir,-pthrow+cObj->ydir,pthrow*iDir);
136  // Success
137  return true;
138 }
int32_t GetY() const
Definition: C4Object.h:287
uint32_t Random()
Definition: C4Random.cpp:43
bool SetActionByName(C4String *ActName, C4Object *pTarget=nullptr, C4Object *pTarget2=nullptr, int32_t iCalls=SAC_StartCall|SAC_AbortCall, bool fForce=false)
Definition: C4Object.cpp:2815
C4Real C4REAL100(int x)
Definition: C4Real.h:267
Definition: C4Real.h:58
C4NotifyingObjectList Contents
Definition: C4Object.h:152
#define DIR_Left
Definition: C4Object.h:41
int32_t y
Definition: C4Rect.h:30
bool Exit(int32_t iX=0, int32_t iY=0, int32_t iR=0, C4Real iXDir=Fix0, C4Real iYDir=Fix0, C4Real iRDir=Fix0, bool fCalls=true)
Definition: C4Object.cpp:1225
int32_t GetX() const
Definition: C4Object.h:286
C4Object * GetObject(int Index=0) const
int32_t Dir
Definition: C4Object.h:80
int32_t GetPropertyInt(C4PropertyName k, int32_t default_val=0) const
Definition: C4PropList.cpp:886
C4Action Action
Definition: C4Object.h:147
C4Shape Shape
Definition: C4Object.h:148
C4Real xdir
Definition: C4Object.h:126
C4Real ydir
Definition: C4Object.h:126

Here is the call graph for this function:

Here is the caller graph for this function:

bool ObjectActionTumble ( C4Object cObj,
int32_t  dir,
C4Real  xdir,
C4Real  ydir 
)

Definition at line 79 of file C4ObjectCom.cpp.

References C4Object::SetActionByName(), C4Object::SetDir(), C4Object::xdir, and C4Object::ydir.

Referenced by C4Object::ContactAction(), C4Object::Fling(), and ObjectComPunch().

80 {
81  if (!cObj->SetActionByName("Tumble")) return false;
82  cObj->SetDir(dir);
83  cObj->xdir=xdir; cObj->ydir=ydir;
84  return true;
85 }
void SetDir(int32_t tdir)
Definition: C4Object.cpp:2841
bool SetActionByName(C4String *ActName, C4Object *pTarget=nullptr, C4Object *pTarget2=nullptr, int32_t iCalls=SAC_StartCall|SAC_AbortCall, bool fForce=false)
Definition: C4Object.cpp:2815
C4Real xdir
Definition: C4Object.h:126
C4Real ydir
Definition: C4Object.h:126

Here is the call graph for this function:

Here is the caller graph for this function:

bool ObjectActionWalk ( C4Object cObj)

Definition at line 39 of file C4ObjectCom.cpp.

References C4Object::SetActionByName().

Referenced by C4Object::ContactAction(), C4Object::ExecAction(), and ObjectActionStand().

40 {
41  if (!cObj->SetActionByName("Walk")) return false;
42  return true;
43 }
bool SetActionByName(C4String *ActName, C4Object *pTarget=nullptr, C4Object *pTarget2=nullptr, int32_t iCalls=SAC_StartCall|SAC_AbortCall, bool fForce=false)
Definition: C4Object.cpp:2815

Here is the call graph for this function:

Here is the caller graph for this function:

bool ObjectComCancelAttach ( C4Object cObj)

Definition at line 406 of file C4ObjectCom.cpp.

References DFA_ATTACH, C4Object::GetProcedure(), and C4Object::SetAction().

Referenced by C4Object::Collect(), and C4Command::InitEvaluation().

407 {
408  if (cObj->GetProcedure()==DFA_ATTACH)
409  return cObj->SetAction(nullptr);
410  return false;
411 }
bool SetAction(C4PropList *Act, C4Object *pTarget=nullptr, C4Object *pTarget2=nullptr, int32_t iCalls=SAC_StartCall|SAC_AbortCall, bool fForce=false)
Definition: C4Object.cpp:2682
int32_t GetProcedure() const
Definition: C4Object.cpp:2861

Here is the call graph for this function:

Here is the caller graph for this function:

bool ObjectComDig ( C4Object cObj)

Definition at line 253 of file C4ObjectCom.cpp.

References FormatString(), GameMsgObjectError(), C4PropList::GetName(), LoadResStr(), and ObjectActionDig().

Referenced by C4Command::Dig().

254 {
255  if (!ObjectActionDig(cObj))
256  {
257  GameMsgObjectError(FormatString(LoadResStr("IDS_OBJ_NODIG"),cObj->GetName()).getData(),cObj);
258  return false;
259  }
260  return true;
261 }
void GameMsgObjectError(const char *szText, C4Object *pTarget, bool Red)
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
virtual const char * GetName() const
Definition: C4PropList.cpp:649
bool ObjectActionDig(C4Object *cObj)
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:270

Here is the call graph for this function:

Here is the caller graph for this function:

bool ObjectComDrop ( C4Object cObj,
C4Object pThing = nullptr 
)

Definition at line 306 of file C4ObjectCom.cpp.

References C4Object::Action, C4REAL10(), C4REAL100(), COMD_Left, COMD_Right, C4Action::ComDir, ComDirLike(), C4Object::Contents, DFA_HANGLE, DFA_SCALE, DFA_SWIM, C4Object::Exit(), Fix0, C4Object::GetAction(), C4ObjectList::GetObject(), C4PropList::GetPropertyInt(), C4PropList::GetPropertyP(), C4Object::GetX(), C4Object::GetY(), C4Rect::Hgt, ObjectComUnGrab(), P_Procedure, P_ThrowSpeed, right, C4Object::SetOCF(), C4Object::Shape, C4Rect::Wdt, C4Rect::x, C4Object::xdir, and C4Rect::y.

Referenced by C4Command::Drop(), and C4Object::PutAwayUnusedObject().

307 {
308  // No object specified, first from contents
309  if (!pThing) pThing = cObj->Contents.GetObject();
310  // Nothing to throw
311  if (!pThing) return false;
312  // Force and direction
313  // When dropping diagonally, drop from edge of shape
314  // When doing a diagonal forward drop during flight, exit a bit closer to the Clonk to allow planned tumbling
315  // Except when hangling, so you can mine effectively form the ceiling, and when swimming because you cannot tumble then
317  int32_t tdir=0; int right=0;
318  bool isHanglingOrSwimming = false;
319  int32_t iProc = -1;
320  C4PropList* pActionDef = cObj->GetAction();
321  if (pActionDef)
322  {
323  iProc = pActionDef->GetPropertyP(P_Procedure);
324  if (iProc == DFA_HANGLE || iProc == DFA_SWIM) isHanglingOrSwimming = true;
325  }
326  int32_t iOutposReduction = 1; // don't exit object too far forward during jump
327  if (iProc != DFA_SCALE) // never diagonal during scaling (can have com into wall during scaling!)
328  {
329  if (ComDirLike(cObj->Action.ComDir, COMD_Left)) { tdir=-1; right = 0; if (cObj->xdir < C4REAL10(15) && !isHanglingOrSwimming) --iOutposReduction; }
330  if (ComDirLike(cObj->Action.ComDir, COMD_Right)) { tdir=+1; right = 1; if (cObj->xdir > C4REAL10(-15) && !isHanglingOrSwimming) --iOutposReduction; }
331  }
332  // Exit object
333  pThing->Exit(cObj->GetX() + (cObj->Shape.x + cObj->Shape.Wdt * right) * !!tdir * iOutposReduction,
334  cObj->GetY()+cObj->Shape.y+cObj->Shape.Hgt-(pThing->Shape.y+pThing->Shape.Hgt),0,pthrow*tdir,Fix0,Fix0);
335  // Update OCF
336  cObj->SetOCF();
337  // Ungrab
338  ObjectComUnGrab(cObj);
339  // Done
340  return true;
341 }
C4PropertyName GetPropertyP(C4PropertyName k) const
Definition: C4PropList.cpp:855
int32_t GetY() const
Definition: C4Object.h:287
bool ObjectComUnGrab(C4Object *cObj)
C4PropList * GetAction() const
Definition: C4Object.cpp:2675
C4Real C4REAL100(int x)
Definition: C4Real.h:267
Definition: C4Real.h:58
int32_t Wdt
Definition: C4Rect.h:30
C4NotifyingObjectList Contents
Definition: C4Object.h:152
C4Real C4REAL10(int x)
Definition: C4Real.h:269
int32_t y
Definition: C4Rect.h:30
bool Exit(int32_t iX=0, int32_t iY=0, int32_t iR=0, C4Real iXDir=Fix0, C4Real iYDir=Fix0, C4Real iRDir=Fix0, bool fCalls=true)
Definition: C4Object.cpp:1225
bool ComDirLike(int32_t iComDir, int32_t iSample)
int32_t GetX() const
Definition: C4Object.h:286
C4Object * GetObject(int Index=0) const
#define COMD_Right
Definition: C4Object.h:53
int32_t x
Definition: C4Rect.h:30
#define COMD_Left
Definition: C4Object.h:57
int32_t GetPropertyInt(C4PropertyName k, int32_t default_val=0) const
Definition: C4PropList.cpp:886
void SetOCF()
Definition: C4Object.cpp:668
int32_t Hgt
Definition: C4Rect.h:30
C4Action Action
Definition: C4Object.h:147
C4Shape Shape
Definition: C4Object.h:148
C4Real xdir
Definition: C4Object.h:126
int32_t ComDir
Definition: C4Object.h:82
const C4Real Fix0
Definition: C4Real.h:312

Here is the call graph for this function:

Here is the caller graph for this function:

bool ObjectComGrab ( C4Object cObj,
C4Object pTarget 
)

Definition at line 189 of file C4ObjectCom.cpp.

References C4PropList::Call(), DFA_WALK, C4Object::GetProcedure(), ObjectActionPush(), PSF_Grab, PSF_Grabbed, and C4PropList::Status.

Referenced by C4Command::Grab().

190 {
191  if (!pTarget) return false;
192  if (cObj->GetProcedure()!=DFA_WALK) return false;
193  if (!ObjectActionPush(cObj,pTarget)) return false;
194  cObj->Call(PSF_Grab, &C4AulParSet(pTarget, true));
195  if (pTarget->Status && cObj->Status)
196  pTarget->Call(PSF_Grabbed, &C4AulParSet(cObj, true));
197  return true;
198 }
#define PSF_Grabbed
Definition: C4GameScript.h:53
bool ObjectActionPush(C4Object *cObj, C4Object *target)
int32_t Status
Definition: C4PropList.h:168
#define PSF_Grab
Definition: C4GameScript.h:52
int32_t GetProcedure() const
Definition: C4Object.cpp:2861
C4Value Call(C4PropertyName k, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
Definition: C4PropList.h:110

Here is the call graph for this function:

Here is the caller graph for this function:

bool ObjectComJump ( C4Object cObj)

Definition at line 223 of file C4ObjectCom.cpp.

References C4Object::Action, C4M_Liquid, C4REAL100(), COMD_Left, COMD_Right, COMD_UpLeft, COMD_UpRight, C4Action::ComDir, C4Shape::ContactDensity, DFA_WALK, Fix0, C4Object::fix_x, C4Object::fix_y, FullCon, C4Object::GetAction(), C4Shape::GetBottomVertex(), C4Object::GetCon(), C4Object::GetProcedure(), C4PropList::GetPropertyInt(), C4Shape::GetVertexX(), C4Shape::GetVertexY(), itofix(), ObjectActionDive(), ObjectActionJump(), P_JumpSpeed, P_Speed, C4Object::Shape, and SimFlightHitsLiquid().

Referenced by C4Command::Exit(), and C4Command::InitEvaluation().

224 {
225  // Only if walking
226  if (cObj->GetProcedure()!=DFA_WALK) return false;
227  // Calculate direction & forces
228  C4Real TXDir=Fix0;
229  C4PropList *pActionWalk = cObj->GetAction();
230  C4Real iPhysicalWalk = C4REAL100(pActionWalk->GetPropertyInt(P_Speed)) * itofix(cObj->GetCon(), FullCon);
231  C4Real iPhysicalJump = C4REAL100(cObj->GetPropertyInt(P_JumpSpeed)) * itofix(cObj->GetCon(), FullCon);
232 
233  if (cObj->Action.ComDir==COMD_Left || cObj->Action.ComDir==COMD_UpLeft) TXDir=-iPhysicalWalk;
234  else if (cObj->Action.ComDir==COMD_Right || cObj->Action.ComDir==COMD_UpRight) TXDir=+iPhysicalWalk;
235  C4Real x = cObj->fix_x, y = cObj->fix_y;
236  // find bottom-most vertex, correct starting position for simulation
237  int32_t iBtmVtx = cObj->Shape.GetBottomVertex();
238  if (iBtmVtx != -1) { x += cObj->Shape.GetVertexX(iBtmVtx); y += cObj->Shape.GetVertexY(iBtmVtx); }
239  // Try dive
240  if (cObj->Shape.ContactDensity > C4M_Liquid)
241  if (SimFlightHitsLiquid(x,y,TXDir,-iPhysicalJump))
242  if (ObjectActionDive(cObj,TXDir,-iPhysicalJump))
243  return true;
244  // Regular jump
245  return ObjectActionJump(cObj,TXDir,-iPhysicalJump,true);
246 }
#define COMD_UpRight
Definition: C4Object.h:52
int32_t GetCon() const
Definition: C4Object.h:272
C4PropList * GetAction() const
Definition: C4Object.cpp:2675
int32_t ContactDensity
Definition: C4Shape.h:47
C4Real C4REAL100(int x)
Definition: C4Real.h:267
int32_t GetBottomVertex()
Definition: C4Shape.cpp:457
int32_t GetVertexX(int32_t iVertex)
Definition: C4Shape.cpp:422
Definition: C4Real.h:58
const int32_t FullCon
Definition: C4Constants.h:181
C4Fixed itofix(int32_t x)
Definition: C4Real.h:261
#define COMD_Right
Definition: C4Object.h:53
C4Real fix_x
Definition: C4Object.h:125
#define COMD_Left
Definition: C4Object.h:57
int32_t GetProcedure() const
Definition: C4Object.cpp:2861
int32_t GetPropertyInt(C4PropertyName k, int32_t default_val=0) const
Definition: C4PropList.cpp:886
C4Real fix_y
Definition: C4Object.h:125
int32_t GetVertexY(int32_t iVertex)
Definition: C4Shape.cpp:428
C4Action Action
Definition: C4Object.h:147
C4Shape Shape
Definition: C4Object.h:148
const int32_t C4M_Liquid
Definition: C4Constants.h:174
bool SimFlightHitsLiquid(C4Real fcx, C4Real fcy, C4Real xdir, C4Real ydir)
Definition: C4Movement.cpp:656
bool ObjectActionDive(C4Object *cObj, C4Real xdir, C4Real ydir)
Definition: C4ObjectCom.cpp:68
bool ObjectActionJump(C4Object *cObj, C4Real xdir, C4Real ydir, bool fByCom)
Definition: C4ObjectCom.cpp:52
#define COMD_UpLeft
Definition: C4Object.h:58
int32_t ComDir
Definition: C4Object.h:82
const C4Real Fix0
Definition: C4Real.h:312

Here is the call graph for this function:

Here is the caller graph for this function:

bool ObjectComLetGo ( C4Object cObj,
int32_t  xdirf 
)

Definition at line 248 of file C4ObjectCom.cpp.

References Fix0, itofix(), and ObjectActionJump().

Referenced by C4Command::Dig(), C4Command::Grab(), and C4Command::MoveTo().

249 { // by ACTSCALE, ACTHANGLE or ExecCMDFMoveTo
250  return ObjectActionJump(cObj,itofix(xdirf),Fix0,true);
251 }
C4Fixed itofix(int32_t x)
Definition: C4Real.h:261
bool ObjectActionJump(C4Object *cObj, C4Real xdir, C4Real ydir, bool fByCom)
Definition: C4ObjectCom.cpp:52
const C4Real Fix0
Definition: C4Real.h:312

Here is the call graph for this function:

Here is the caller graph for this function:

bool ObjectComPunch ( C4Object cObj,
C4Object pTarget,
int32_t  iPunch = 0 
)

Definition at line 377 of file C4ObjectCom.cpp.

References C4Object::Action, C4FxCall_EngGetPunched, C4REAL100(), C4PropList::Call(), COMD_Stop, C4Action::ComDir, C4Object::Controller, C4Action::Dir, DIR_Left, C4Object::DoEnergy(), Fix0, itofix(), ObjectActionGetPunched(), ObjectActionTumble(), PSF_CatchBlow, and PSF_QueryCatchBlow.

378 {
379  if (!cObj || !pTarget) return false;
380  if (!punch) return true;
381  bool fBlowStopped = !!pTarget->Call(PSF_QueryCatchBlow,&C4AulParSet(cObj));
382  if (fBlowStopped && punch>1) punch=punch/2; // half damage for caught blow, so shield+armor help in fistfight and vs monsters
383  pTarget->DoEnergy(-punch, false, C4FxCall_EngGetPunched, cObj->Controller);
384  int32_t tdir=+1; if (cObj->Action.Dir==DIR_Left) tdir=-1;
385  pTarget->Action.ComDir=COMD_Stop;
386  // No tumbles when blow was caught
387  if (fBlowStopped) return false;
388  // Hard punch
389  if (punch>=10)
390  if (ObjectActionTumble(pTarget,pTarget->Action.Dir,C4REAL100(150)*tdir,itofix(-2)))
391  {
392  pTarget->Call(PSF_CatchBlow,&C4AulParSet(punch, cObj));
393  return true;
394  }
395 
396  // Regular punch
397  if (ObjectActionGetPunched(pTarget,C4REAL100(250)*tdir,Fix0))
398  {
399  pTarget->Call(PSF_CatchBlow,&C4AulParSet(punch, cObj));
400  return true;
401  }
402 
403  return false;
404 }
#define PSF_CatchBlow
Definition: C4GameScript.h:72
C4Real C4REAL100(int x)
Definition: C4Real.h:267
#define DIR_Left
Definition: C4Object.h:41
C4Fixed itofix(int32_t x)
Definition: C4Real.h:261
#define COMD_Stop
Definition: C4Object.h:50
int32_t Dir
Definition: C4Object.h:80
#define C4FxCall_EngGetPunched
Definition: C4Effect.h:63
void DoEnergy(int32_t iChange, bool fExact, int32_t iCause, int32_t iCausedByPlr)
Definition: C4Object.cpp:1107
#define PSF_QueryCatchBlow
Definition: C4GameScript.h:73
C4Action Action
Definition: C4Object.h:147
bool ObjectActionTumble(C4Object *cObj, int32_t dir, C4Real xdir, C4Real ydir)
Definition: C4ObjectCom.cpp:79
int32_t Controller
Definition: C4Object.h:111
bool ObjectActionGetPunched(C4Object *cObj, C4Real xdir, C4Real ydir)
Definition: C4ObjectCom.cpp:87
int32_t ComDir
Definition: C4Object.h:82
const C4Real Fix0
Definition: C4Real.h:312
C4Value Call(C4PropertyName k, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
Definition: C4PropList.h:110

Here is the call graph for this function:

bool ObjectComPut ( C4Object cObj,
C4Object pTarget,
C4Object pThing = nullptr 
)

Definition at line 263 of file C4ObjectCom.cpp.

References C4D_Grab_Put, C4PropList::Call(), C4Object::Contained, C4Object::Contents, C4Object::Def, C4Object::Enter(), C4ObjectList::GetObject(), C4Def::GrabPutGet, C4Object::OCF, OCF_FullCon, PSF_Collection, and PSF_Put.

Referenced by ObjectComPutTake(), C4Command::Put(), and C4Object::PutAwayUnusedObject().

264 {
265  // No object specified, first from contents
266  if (!pThing) pThing = cObj->Contents.GetObject();
267  // Nothing to put
268  if (!pThing) return false;
269  // No target
270  if (!pTarget) return false;
271  // Grabbing: check C4D_Grab_Put
272  if (pTarget!=cObj->Contained)
273  if (!(pTarget->Def->GrabPutGet & C4D_Grab_Put))
274  {
275  // No grab put: fail
276  return false;
277  }
278  // Target no fullcon
279  if (!(pTarget->OCF & OCF_FullCon)) return false;
280  // Transfer thing
281  bool fRejectCollect;
282  if (!pThing->Enter(pTarget, true, true, &fRejectCollect)) return false;
283  // Put call to object script
284  cObj->Call(PSF_Put);
285  // Target collection call
286  pTarget->Call(PSF_Collection,&C4AulParSet(pThing, true));
287  // Success
288  return true;
289 }
bool Enter(C4Object *pTarget, bool fCalls=true, bool fCopyMotion=true, bool *pfRejectCollect=nullptr)
Definition: C4Object.cpp:1261
const uint32_t OCF_FullCon
Definition: C4Constants.h:85
const int32_t C4D_Grab_Put
Definition: C4Def.h:62
C4NotifyingObjectList Contents
Definition: C4Object.h:152
C4Def * Def
Definition: C4Object.h:143
C4Object * GetObject(int Index=0) const
int32_t GrabPutGet
Definition: C4Def.h:124
#define PSF_Collection
Definition: C4GameScript.h:56
C4ObjectPtr Contained
Definition: C4Object.h:144
uint32_t OCF
Definition: C4Object.h:134
#define PSF_Put
Definition: C4GameScript.h:55
C4Value Call(C4PropertyName k, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
Definition: C4PropList.h:110

Here is the call graph for this function:

Here is the caller graph for this function:

bool ObjectComPutTake ( C4Object cObj,
C4Object pTarget,
C4Object pThing = nullptr 
)

Definition at line 343 of file C4ObjectCom.cpp.

References C4Object::ActivateMenu(), C4D_Grab_Get, C4MN_Get, C4Object::Contained, C4Object::Contents, C4Object::Def, C4ObjectList::GetObject(), C4Def::GrabPutGet, ObjectComPut(), and ObjectComTake().

Referenced by C4Command::Drop(), and C4Command::Throw().

344 { // by C4CMD_Drop
345  // Valid checks
346  if (!pTarget) return false;
347  // No object specified, first from contents
348  if (!pThing) pThing = cObj->Contents.GetObject();
349  // Has thing, put to target
350  if (pThing)
351  return ObjectComPut(cObj,pTarget,pThing);
352  // If target is own container, activate activation menu
353  if (pTarget==cObj->Contained)
354  return ObjectComTake(cObj); // carlo
355  // Assuming target is grabbed, check for grab get
356  if (pTarget->Def->GrabPutGet & C4D_Grab_Get)
357  {
358  // Activate get menu
359  return cObj->ActivateMenu(C4MN_Get,0,0,0,pTarget);
360  }
361  // Failure
362  return false;
363 }
const int32_t C4D_Grab_Get
Definition: C4Def.h:63
bool ObjectComPut(C4Object *cObj, C4Object *pTarget, C4Object *pThing)
C4NotifyingObjectList Contents
Definition: C4Object.h:152
C4Def * Def
Definition: C4Object.h:143
C4Object * GetObject(int Index=0) const
bool ObjectComTake(C4Object *cObj)
bool ActivateMenu(int32_t iMenu, int32_t iMenuSelect=0, int32_t iMenuData=0, int32_t iMenuPosition=0, C4Object *pTarget=nullptr)
Definition: C4Object.cpp:1477
int32_t GrabPutGet
Definition: C4Def.h:124
C4ObjectPtr Contained
Definition: C4Object.h:144

Here is the call graph for this function:

Here is the caller graph for this function:

bool ObjectComStop ( C4Object cObj)

Definition at line 181 of file C4ObjectCom.cpp.

References ObjectActionStand(), and C4Object::SetActionByName().

Referenced by C4Command::Activate(), C4Command::Dig(), C4Command::Drop(), C4Command::Enter(), C4Command::Get(), C4Command::Grab(), C4Command::MoveTo(), C4Command::PushTo(), C4Command::Put(), StopActionDelayCommand(), C4Command::Throw(), and C4Command::Wait().

182 {
183  // Cease current action
184  cObj->SetActionByName("Idle");
185  // Action walk if possible
186  return ObjectActionStand(cObj);
187 }
bool SetActionByName(C4String *ActName, C4Object *pTarget=nullptr, C4Object *pTarget2=nullptr, int32_t iCalls=SAC_StartCall|SAC_AbortCall, bool fForce=false)
Definition: C4Object.cpp:2815
bool ObjectActionStand(C4Object *cObj)
Definition: C4ObjectCom.cpp:45

Here is the call graph for this function:

Here is the caller graph for this function:

void ObjectComStopDig ( C4Object cObj)

Definition at line 413 of file C4ObjectCom.cpp.

References C4CMD_Dig, C4Object::ClearCommand(), C4Command::Command, C4Object::Command, ObjectActionStand(), C4Object::xdir, and C4Object::ydir.

Referenced by C4Object::ExecAction().

414 {
415  // Stand - but keep momentum to allow more dyanamic digging
416  C4Real o_xdir = cObj->xdir, o_ydir = cObj->ydir;
417  ObjectActionStand(cObj);
418  cObj->xdir = o_xdir; cObj->ydir = o_ydir;
419  // Clear digging command
420  if (cObj->Command)
421  if (cObj->Command->Command == C4CMD_Dig)
422  cObj->ClearCommand(cObj->Command);
423 }
C4Command * Command
Definition: C4Object.h:166
void ClearCommand(C4Command *pUntil)
Definition: C4Object.cpp:2546
Definition: C4Real.h:58
int32_t Command
Definition: C4Command.h:81
bool ObjectActionStand(C4Object *cObj)
Definition: C4ObjectCom.cpp:45
C4Real xdir
Definition: C4Object.h:126
C4Real ydir
Definition: C4Object.h:126

Here is the call graph for this function:

Here is the caller graph for this function:

bool ObjectComTake ( C4Object cObj)

Definition at line 366 of file C4ObjectCom.cpp.

References C4Object::ActivateMenu(), and C4MN_Activate.

Referenced by ObjectComPutTake(), and C4Command::Take().

367 {
368  return cObj->ActivateMenu(C4MN_Activate);
369 }
bool ActivateMenu(int32_t iMenu, int32_t iMenuSelect=0, int32_t iMenuData=0, int32_t iMenuPosition=0, C4Object *pTarget=nullptr)
Definition: C4Object.cpp:1477

Here is the call graph for this function:

Here is the caller graph for this function:

bool ObjectComTake2 ( C4Object cObj)

Definition at line 372 of file C4ObjectCom.cpp.

References C4Object::ActivateMenu(), C4MN_Get, and C4Object::Contained.

Referenced by C4Command::Take2().

373 {
374  return cObj->ActivateMenu(C4MN_Get,0,0,0,cObj->Contained);
375 }
bool ActivateMenu(int32_t iMenu, int32_t iMenuSelect=0, int32_t iMenuData=0, int32_t iMenuPosition=0, C4Object *pTarget=nullptr)
Definition: C4Object.cpp:1477
C4ObjectPtr Contained
Definition: C4Object.h:144

Here is the call graph for this function:

Here is the caller graph for this function:

bool ObjectComThrow ( C4Object cObj,
C4Object pThing = nullptr 
)

Definition at line 291 of file C4ObjectCom.cpp.

References C4Object::Contents, DFA_WALK, C4ObjectList::GetObject(), C4Object::GetProcedure(), and ObjectActionThrow().

Referenced by C4Command::Throw().

292 {
293  // No object specified, first from contents
294  if (!pThing) pThing = cObj->Contents.GetObject();
295  // Nothing to throw
296  if (!pThing) return false;
297  // Throw com
298  switch (cObj->GetProcedure())
299  {
300  case DFA_WALK: return ObjectActionThrow(cObj,pThing);
301  }
302  // Failure
303  return false;
304 }
C4NotifyingObjectList Contents
Definition: C4Object.h:152
C4Object * GetObject(int Index=0) const
bool ObjectActionThrow(C4Object *cObj, C4Object *pThing)
int32_t GetProcedure() const
Definition: C4Object.cpp:2861

Here is the call graph for this function:

Here is the caller graph for this function:

bool ObjectComUnGrab ( C4Object cObj)

Definition at line 200 of file C4ObjectCom.cpp.

References C4Object::Action, C4PropList::Call(), C4Object::CloseMenu(), DFA_PUSH, C4Object::GetProcedure(), ObjectActionStand(), PSF_Grab, PSF_Grabbed, C4PropList::Status, and C4Action::Target.

Referenced by ObjectComDrop(), and C4Command::UnGrab().

201 {
202  // Only if pushing, -> stand
203  if (cObj->GetProcedure() == DFA_PUSH)
204  {
205  C4Object *pTarget = cObj->Action.Target;
206  if (ObjectActionStand(cObj))
207  {
208  if (!cObj->CloseMenu(false)) return false;
209  cObj->Call(PSF_Grab, &C4AulParSet(pTarget, false));
210  // clear action target
211  cObj->Action.Target = nullptr;
212  if (pTarget && pTarget->Status && cObj->Status)
213  {
214  pTarget->Call(PSF_Grabbed, &C4AulParSet(cObj, false));
215  }
216  return true;
217  }
218  }
219 
220  return false;
221 }
#define PSF_Grabbed
Definition: C4GameScript.h:53
bool CloseMenu(bool fForce)
Definition: C4Object.cpp:1571
int32_t Status
Definition: C4PropList.h:168
#define PSF_Grab
Definition: C4GameScript.h:52
bool ObjectActionStand(C4Object *cObj)
Definition: C4ObjectCom.cpp:45
C4ObjectPtr Target
Definition: C4Object.h:87
int32_t GetProcedure() const
Definition: C4Object.cpp:2861
C4Action Action
Definition: C4Object.h:147
C4Value Call(C4PropertyName k, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
Definition: C4PropList.h:110

Here is the call graph for this function:

Here is the caller graph for this function: