OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4ObjectScript.cpp
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 #include "C4Include.h"
20 
21 #include "control/C4Teams.h"
22 #include "graphics/C4Draw.h"
24 #include "gui/C4GameMessage.h"
25 #include "landscape/C4Material.h"
26 #include "landscape/C4Particles.h"
27 #include "lib/C4Random.h"
28 #include "lib/StdMeshMath.h"
29 #include "object/C4Command.h"
30 #include "object/C4DefList.h"
31 #include "object/C4MeshAnimation.h"
33 #include "object/C4ObjectCom.h"
34 #include "object/C4ObjectInfo.h"
35 #include "object/C4ObjectMenu.h"
36 #include "player/C4Player.h"
37 #include "player/C4PlayerList.h"
38 #include "player/C4RankSystem.h"
39 #include "script/C4Aul.h"
40 #include "script/C4AulDefFunc.h"
41 
42 bool C4ValueToMatrix(C4Value& value, StdMeshMatrix* matrix)
43 {
44  const C4ValueArray* array = value.getArray();
45  if (!array) return false;
46  return C4ValueToMatrix(*array, matrix);
47 }
48 
49 bool C4ValueToMatrix(const C4ValueArray& array, StdMeshMatrix* matrix)
50 {
51  if (array.GetSize() != 12) return false;
52 
53  StdMeshMatrix& trans = *matrix;
54  trans(0,0) = array[0].getInt()/1000.0f;
55  trans(0,1) = array[1].getInt()/1000.0f;
56  trans(0,2) = array[2].getInt()/1000.0f;
57  trans(0,3) = array[3].getInt()/1000.0f;
58  trans(1,0) = array[4].getInt()/1000.0f;
59  trans(1,1) = array[5].getInt()/1000.0f;
60  trans(1,2) = array[6].getInt()/1000.0f;
61  trans(1,3) = array[7].getInt()/1000.0f;
62  trans(2,0) = array[8].getInt()/1000.0f;
63  trans(2,1) = array[9].getInt()/1000.0f;
64  trans(2,2) = array[10].getInt()/1000.0f;
65  trans(2,3) = array[11].getInt()/1000.0f;
66 
67  return true;
68 }
69 
70 static bool FnChangeDef(C4Object *Obj, C4ID to_id)
71 {
72  return !!Obj->ChangeDef(to_id);
73 }
74 
75 static void FnSetSolidMask(C4Object *Obj, long iX, long iY, long iWdt, long iHgt, long iTX, long iTY)
76 {
77  Obj->SetSolidMask(iX,iY,iWdt,iHgt,iTX,iTY);
78 }
79 
80 static void FnSetHalfVehicleSolidMask(C4Object *Obj, bool set)
81 {
82  Obj->SetHalfVehicleSolidMask(set);
83 }
84 
85 static void FnDeathAnnounce(C4Object *Obj)
86 {
87  const long MaxDeathMsg=7;
88  if (Game.C4S.Head.Film)
89  return;
90  // Check if crew member has an own death message
91  if (Obj->Info && *(Obj->Info->DeathMessage))
92  {
93  GameMsgObject(Obj->Info->DeathMessage, Obj);
94  }
95  else
96  {
97  char idDeathMsg[128+1]; sprintf(idDeathMsg, "IDS_OBJ_DEATH%d", 1 + UnsyncedRandom(MaxDeathMsg));
98  GameMsgObject(FormatString(LoadResStr(idDeathMsg), Obj->GetName()).getData(), Obj);
99  }
100 }
101 
102 static bool FnGrabContents(C4Object *Obj, C4Object *from)
103 {
104  if (!from) return false;
105  if (Obj == from) return false;
106  Obj->GrabContents(from);
107  return true;
108 }
109 
110 static bool FnPunch(C4Object *Obj, C4Object *target, long punch)
111 {
112  if (!target) return false;
113  return !!ObjectComPunch(Obj,target,punch);
114 }
115 
116 static bool FnKill(C4PropList * _this, C4Object *pObj, bool fForced)
117 {
118  if (!pObj) pObj=Object(_this); if (!pObj) return false;
119  if (!pObj->GetAlive()) return false;
120  // Trace kills by player-owned objects
121  // Do not trace for NO_OWNER, because that would include e.g. the Suicide-rule
122  if (Object(_this) && ValidPlr(Object(_this)->Controller)) pObj->UpdatLastEnergyLossCause(Object(_this)->Controller);
123  // Do the kill
124  pObj->AssignDeath(!!fForced);
125  return true;
126 }
127 
128 static void FnFling(C4Object *Obj, long iXDir, long iYDir, long iPrec, bool fAddSpeed)
129 {
130  if (!iPrec) iPrec=1;
131  Obj->Fling(itofix(iXDir, iPrec),itofix(iYDir, iPrec),fAddSpeed);
132  // unstick from ground, because Fling command may be issued in an Action-callback,
133  // where attach-values have already been determined for that frame
134  Obj->Action.t_attach=0;
135 }
136 
137 static bool FnJump(C4Object *Obj)
138 {
139  return !!ObjectComJump(Obj);
140 }
141 
142 static bool FnEnter(C4Object *Obj, C4Object *pTarget)
143 {
144  return !!Obj->Enter(pTarget,true,true,nullptr);
145 }
146 
147 static bool FnExit(C4Object *Obj, long tx, long ty, long tr, long txdir, long tydir, long trdir)
148 {
149  tx+=Obj->GetX();
150  ty+=Obj->GetY();
152  return !!Obj->Exit(tx,
153  ty+Obj->Shape.y,
154  tr,
155  itofix(txdir),itofix(tydir),
156  itofix(trdir) / 10);
157 }
158 
159 static bool FnCollect(C4Object *Obj, C4Object *pItem, bool ignoreOCF)
160 {
161  // local call / safety
162  if (!pItem) return false;
163  // check OCF of collector (MaxCarry)
164  if ((Obj->OCF & OCF_Collection) || ignoreOCF)
165  // collect
166  return !!Obj->Collect(pItem);
167  // failure
168  return false;
169 }
170 
171 static void FnRemoveObject(C4Object *Obj, bool fEjectContents)
172 {
173  Obj->AssignRemoval(fEjectContents);
174 }
175 
176 static void FnSetPosition(C4Object *Obj, long iX, long iY, bool fCheckBounds, long iPrec)
177 {
178  if (!iPrec) iPrec = 1;
179  C4Real i_x = itofix(iX, iPrec), i_y = itofix(iY, iPrec);
180  if (fCheckBounds)
181  {
182  // BoundsCheck takes ref to C4Real and not to long
183  Obj->BoundsCheck(i_x, i_y);
184  }
185  Obj->ForcePosition(i_x, i_y);
186  // update liquid
187  Obj->UpdateInLiquid();
188 }
189 
190 static void FnDoCon(C4Object *Obj, long iChange, long iPrec, bool bGrowFromCenter)
191 {
192  if (!iPrec) iPrec = 100;
193  Obj->DoCon(FullCon*iChange / iPrec, bGrowFromCenter);
194 }
195 
196 static long FnGetCon(C4Object *Obj, long iPrec)
197 {
198  if (!iPrec) iPrec = 100;
199  return iPrec*Obj->GetCon()/FullCon;
200 }
201 
202 static bool FnSetName(C4PropList * _this, C4String *pNewName, bool fSetInInfo, bool fMakeValidIfExists)
203 {
204  if (!Object(_this))
205  {
206  if (!_this)
207  throw NeedNonGlobalContext("SetName");
208  else if (fSetInInfo)
209  return false;
210  // Definition name
211  _this->SetName(FnStringPar(pNewName));
212  return true;
213  }
214  else
215  {
216  // Object name
217  if (fSetInInfo)
218  {
219  // setting name in info
220  C4ObjectInfo *pInfo = Object(_this)->Info;
221  if (!pInfo) return false;
222  const char *szName = pNewName->GetCStr();
223  // empty names are bad; e.g., could cause problems in savegames
224  if (!szName || !*szName) return false;
225  // name must not be too long
226  if (std::strlen(szName) > C4MaxName) return false;
227  // any change at all?
228  if (SEqual(szName, pInfo->Name)) return true;
229  // make sure names in info list aren't duplicated
230  // querying owner info list here isn't 100% accurate, as infos might have been stolen by other players
231  // however, there is no good way to track the original list ATM
232  C4ObjectInfoList *pInfoList = nullptr;
233  C4Player *pOwner = ::Players.Get(Object(_this)->Owner);
234  if (pOwner) pInfoList = &pOwner->CrewInfoList;
235  char NameBuf[C4MaxName+1];
236  if (pInfoList) if (pInfoList->NameExists(szName))
237  {
238  if (!fMakeValidIfExists) return false;
239  SCopy(szName, NameBuf, C4MaxName);
240  pInfoList->MakeValidName(NameBuf);
241  szName = NameBuf;
242  }
243  SCopy(szName, pInfo->Name, C4MaxName);
244  Object(_this)->SetName(); // make sure object uses info name
245  Object(_this)->Call(PSF_NameChange,&C4AulParSet(true));
246  }
247  else
248  {
249  if (!pNewName) Object(_this)->SetName();
250  else Object(_this)->SetName(pNewName->GetCStr());
251  Object(_this)->Call(PSF_NameChange,&C4AulParSet(false));
252  }
253  }
254  return true;
255 }
256 
257 static C4Value FnSetCrewExtraData(C4Object *Obj, C4String * DataName, const C4Value & Data)
258 {
259  const char *strDataName = FnStringPar(DataName);
260  // valid crew with info? (for great nullpointer prevention)
261  if (!Obj->Info) return C4Value();
262  // do not allow data type C4V_Array or C4V_C4Object
263  if (Data.GetType() != C4V_Nil &&
264  Data.GetType() != C4V_Int &&
265  Data.GetType() != C4V_Bool &&
266  Data.GetType() != C4V_String) return C4VNull;
267  // get pointer on info...
268  C4ObjectInfo *pInfo = Obj->Info;
269  // no name list created yet?
270  if (!pInfo->ExtraData.pNames)
271  // create name list
272  pInfo->ExtraData.CreateTempNameList();
273  // data name already exists?
274  long ival;
275  if ((ival = pInfo->ExtraData.pNames->GetItemNr(strDataName)) != -1)
276  pInfo->ExtraData[ival] = Data;
277  else
278  {
279  // add name
280  pInfo->ExtraData.pNames->AddName(strDataName);
281  // get val id & set
282  if ((ival = pInfo->ExtraData.pNames->GetItemNr(strDataName)) == -1) return C4Value();
283  pInfo->ExtraData[ival] = Data;
284  }
285  // ok, return the value that has been set
286  return Data;
287 }
288 
289 static C4Value FnGetCrewExtraData(C4Object *Obj, C4String * DataName)
290 {
291  const char *strDataName = FnStringPar(DataName);
292  // valid crew with info?
293  if (!Obj->Info) return C4Value();
294  // get pointer on info...
295  C4ObjectInfo *pInfo = Obj->Info;
296  // no name list?
297  if (!pInfo->ExtraData.pNames) return C4Value();
298  long ival;
299  if ((ival = pInfo->ExtraData.pNames->GetItemNr(strDataName)) == -1) return C4Value();
300  // return data
301  return pInfo->ExtraData[ival];
302 }
303 
304 static void FnDoEnergy(C4Object *Obj, long iChange, bool fExact, Nillable<long> iEngType, Nillable<long> iCausedBy)
305 {
306  if (iEngType.IsNil()) iEngType = C4FxCall_EngScript;
307  if (iCausedBy.IsNil())
308  iCausedBy = NO_OWNER;
309  Obj->DoEnergy(iChange, fExact, iEngType, iCausedBy);
310 }
311 
312 static void FnDoBreath(C4Object *Obj, long iChange)
313 {
314  Obj->DoBreath(iChange);
315 }
316 
317 static void FnDoDamage(C4Object *Obj, long iChange, Nillable<long> iDmgType, Nillable<long> iCausedBy)
318 {
319  if (iDmgType.IsNil()) iDmgType = C4FxCall_DmgScript;
320  if (iCausedBy.IsNil())
321  iCausedBy = NO_OWNER;
322  Obj->DoDamage(iChange, iCausedBy, iDmgType);
323 }
324 
325 static void FnSetEntrance(C4Object *Obj, bool e_status)
326 {
327  Obj->EntranceStatus = e_status;
328 }
329 
330 
331 static void FnSetXDir(C4Object *Obj, long nxdir, long iPrec)
332 {
333  // precision (default 10.0)
334  if (!iPrec) iPrec=10;
335  // update xdir
336  Obj->xdir=itofix(nxdir, iPrec);
337  Obj->Mobile=true;
338 }
339 
340 static void FnSetRDir(C4Object *Obj, long nrdir, long iPrec)
341 {
342  // precision (default 10.0)
343  if (!iPrec) iPrec=10;
344  // update rdir
345  Obj->rdir=itofix(nrdir, iPrec);
346  Obj->Mobile=true;
347 }
348 
349 static void FnSetYDir(C4Object *Obj, long nydir, long iPrec)
350 {
351  // precision (default 10.0)
352  if (!iPrec) iPrec=10;
353  // update ydir
354  Obj->ydir=itofix(nydir, iPrec);
355  Obj->Mobile=true;
356 }
357 
358 static void FnSetR(C4Object *Obj, long nr)
359 {
360  Obj->SetRotation(nr);
361 }
362 
363 static bool FnSetAction(C4Object *Obj, C4String *szAction,
364  C4Object *pTarget, C4Object *pTarget2, bool fDirect)
365 {
366  if (!szAction) return false;
367  return !!Obj->SetActionByName(FnStringPar(szAction),pTarget,pTarget2,
369 }
370 
371 static bool FnSetBridgeActionData(C4Object *Obj, long iBridgeLength, bool fMoveClonk, bool fWall, long iBridgeMaterial)
372 {
373  if (!Obj->Status) return false;
374  C4PropList* pActionDef = Obj->GetAction();
375  // action must be BRIDGE
376  if (!pActionDef) return false;
377  if (pActionDef->GetPropertyP(P_Procedure) != DFA_BRIDGE) return false;
378  // set data
379  Obj->Action.SetBridgeData(iBridgeLength, fMoveClonk, fWall, iBridgeMaterial);
380  return true;
381 }
382 
383 static bool FnSetActionData(C4Object *Obj, long iData)
384 {
385  if (!Obj->Status) return false;
386  C4PropList* pActionDef = Obj->GetAction();
387  // bridge: Convert from old style
388  if (pActionDef && (pActionDef->GetPropertyP(P_Procedure) == DFA_BRIDGE))
389  return FnSetBridgeActionData(Obj, 0, false, false, iData);
390  // attach: check for valid vertex indices
391  if (pActionDef && (pActionDef->GetPropertyP(P_Procedure) == DFA_ATTACH))
392  if (((iData&255) >= C4D_MaxVertex) || ((iData>>8) >= C4D_MaxVertex))
393  return false;
394  // set data
395  Obj->Action.Data = iData;
396  return true;
397 }
398 
399 static void FnSetComDir(C4Object *Obj, long ncomdir)
400 {
401  Obj->Action.ComDir=ncomdir;
402 }
403 
404 static void FnSetDir(C4Object *Obj, long ndir)
405 {
406  Obj->SetDir(ndir);
407 }
408 
409 static void FnSetCategory(C4Object *Obj, long iCategory)
410 {
411  Obj->SetCategory(iCategory);
412 }
413 
414 static void FnSetAlive(C4Object *Obj, bool nalv)
415 {
416  Obj->SetAlive(nalv);
417 }
418 
419 static bool FnSetOwner(C4Object *Obj, long iOwner)
420 {
421  // Set owner
422  return !!Obj->SetOwner(iOwner);
423 }
424 
425 static bool FnSetPhase(C4Object *Obj, long iVal)
426 {
427  return !!Obj->SetPhase(iVal);
428 }
429 
430 static bool FnExecuteCommand(C4Object *Obj)
431 {
432  return !!Obj->ExecuteCommand();
433 }
434 
435 static bool FnSetCommand(C4Object *Obj, C4String * szCommand, C4Object * pTarget,
436  const C4Value & Tx, int iTy, C4Object * pTarget2,
437  const C4Value & Data, int iRetries)
438 {
439  // Command
440  if (!szCommand) return false;
441  long iCommand = CommandByName(FnStringPar(szCommand));
442  if (!iCommand) { Obj->ClearCommands(); return false; }
443  // Special: convert iData to szText
444  C4String *szText=nullptr;
445  if (iCommand==C4CMD_Call)
446  szText=Data.getStr();
447  // FIXME: throw if Tx isn't int
448  // Set
449  Obj->SetCommand(iCommand,pTarget,Tx,iTy,pTarget2,false,Data,iRetries,szText);
450  // Success
451  return true;
452 }
453 
454 static bool FnAddCommand(C4Object *Obj, C4String * szCommand, C4Object * pTarget,
455  const C4Value & Tx, int iTy, C4Object * pTarget2,
456  int iUpdateInterval, const C4Value & Data, int iRetries, int iBaseMode)
457 {
458  // Command
459  if (!szCommand) return false;
460  long iCommand = CommandByName(FnStringPar(szCommand));
461  if (!iCommand) return false;
462  // Special: convert iData to szText
463  C4String *szText=nullptr;
464  if (iCommand==C4CMD_Call)
465  szText=Data.getStr();
466  // Add
467  return Obj->AddCommand(iCommand,pTarget,Tx,iTy,iUpdateInterval,pTarget2,true,Data,false,iRetries,szText,iBaseMode);
468 }
469 
470 static bool FnAppendCommand(C4Object *Obj, C4String * szCommand, C4Object * pTarget,
471  const C4Value & Tx, int iTy, C4Object * pTarget2,
472  int iUpdateInterval, const C4Value & Data, int iRetries, int iBaseMode)
473 {
474  // Command
475  if (!szCommand) return false;
476  long iCommand = CommandByName(FnStringPar(szCommand));
477  if (!iCommand) return false;
478  // Special: convert iData to szText
479  C4String *szText=nullptr;
480  if (iCommand==C4CMD_Call)
481  szText=Data.getStr();
482  // Add
483  return Obj->AddCommand(iCommand,pTarget,Tx,iTy,iUpdateInterval,pTarget2,true,Data,true,iRetries,szText,iBaseMode);
484 }
485 
486 static C4Value FnGetCommand(C4Object *Obj, int iElement, int iCommandNum)
487 {
488  C4Command * Command = Obj->Command;
489  // Move through list to Command iCommandNum
490  while (Command && iCommandNum--) Command = Command->Next;
491  // Object has no command or iCommandNum was to high or < 0
492  if (!Command) return C4VNull;
493  // Return command element
494  switch (iElement)
495  {
496  case 0: // Name
497  return C4VString(CommandName(Command->Command));
498  case 1: // Target
499  return C4VObj(Command->Target);
500  case 2: // Tx
501  return Command->Tx;
502  case 3: // Ty
503  return C4VInt(Command->Ty);
504  case 4: // Target2
505  return C4VObj(Command->Target2);
506  case 5: // Data
507  return Command->Command == C4CMD_Call ? C4VString(Command->Text) : Command->Data;
508  }
509  // Undefined element
510  return C4VNull;
511 }
512 
513 static bool FnFinishCommand(C4Object *Obj, bool fSuccess, long iCommandNum)
514 {
515  C4Command * Command = Obj->Command;
516  // Move through list to Command iCommandNum
517  while (Command && iCommandNum--) Command = Command->Next;
518  // Object has no command or iCommandNum was to high or < 0
519  if (!Command) return false;
520  if (!fSuccess) ++(Command->Failures);
521  else Command->Finished = true;
522  return true;
523 }
524 
525 static C4String *FnGetAction(C4Object *Obj)
526 {
527  C4PropList* pActionDef = Obj->GetAction();
528  if (!pActionDef) return String("Idle");
529  return String(pActionDef->GetName());
530 }
531 
532 static C4Object *FnGetActionTarget(C4Object *Obj, long target_index)
533 {
534  if (target_index==0) return Obj->Action.Target;
535  if (target_index==1) return Obj->Action.Target2;
536  return nullptr;
537 }
538 
539 static void FnSetActionTargets(C4Object *Obj, C4Object *pTarget1, C4Object *pTarget2)
540 {
541  // set targets
542  Obj->Action.Target=pTarget1;
543  Obj->Action.Target2=pTarget2;
544 }
545 
546 static long FnGetDir(C4Object *Obj)
547 {
548  return Obj->Action.Dir;
549 }
550 
551 static bool FnGetEntrance(C4Object *Obj)
552 {
553  return Obj->EntranceStatus;
554 }
555 
556 static long FnGetPhase(C4Object *Obj)
557 {
558  return Obj->Action.Phase;
559 }
560 
561 static long FnGetEnergy(C4Object *Obj)
562 {
563  return 100*Obj->Energy/C4MaxPhysical;
564 }
565 
566 static long FnGetBreath(C4Object *Obj)
567 {
568  return Obj->Breath;
569 }
570 
571 static long FnGetMass(C4PropList * _this)
572 {
573  if (!Object(_this))
574  if (!_this || !_this->GetDef())
575  throw NeedNonGlobalContext("GetMass");
576  else
577  return _this->GetDef()->Mass;
578  else
579  return Object(_this)->Mass;
580 }
581 
582 static long FnGetRDir(C4Object *Obj, long iPrec)
583 {
584  if (!iPrec) iPrec = 10;
585  return fixtoi(Obj->rdir, iPrec);
586 }
587 
588 static long FnGetXDir(C4Object *Obj, long iPrec)
589 {
590  if (!iPrec) iPrec = 10;
591  return fixtoi(Obj->xdir, iPrec);
592 }
593 
594 static long FnGetYDir(C4Object *Obj, long iPrec)
595 {
596  if (!iPrec) iPrec = 10;
597  return fixtoi(Obj->ydir, iPrec);
598 }
599 
600 static long FnGetR(C4Object *Obj)
601 {
602  // Adjust range
603  long iR = Obj->GetR();
604  while (iR > 180) iR -= 360;
605  while (iR < -180) iR += 360;
606  return iR;
607 }
608 
609 static long FnGetComDir(C4Object *Obj)
610 {
611  return Obj->Action.ComDir;
612 }
613 
614 static long FnGetVertexNum(C4Object *Obj)
615 {
616  return Obj->Shape.VtxNum;
617 }
618 
620 {
625 };
627 {
631 };
632 
633 static Nillable<long> FnGetVertex(C4Object *Obj, long iIndex, long iValueToGet)
634 {
635  if (Obj->Shape.VtxNum<1) return C4Void();
636  if (iIndex < 0 || iIndex >= Obj->Shape.VtxNum) return C4Void();
637  iIndex=std::min<long>(iIndex,Obj->Shape.VtxNum-1);
638  switch (static_cast<VertexDataIndex>(iValueToGet))
639  {
640  case VTX_X: return Obj->Shape.VtxX[iIndex]; break;
641  case VTX_Y: return Obj->Shape.VtxY[iIndex]; break;
642  case VTX_CNAT: return Obj->Shape.VtxCNAT[iIndex]; break;
643  case VTX_Friction: return Obj->Shape.VtxFriction[iIndex]; break;
644  default:
645  DebugLog(FormatString("GetVertex: Unknown vertex attribute: %ld", iValueToGet).getData());
646  return C4Void();
647  break;
648  }
649  // impossible mayhem!
650  assert(!"FnGetVertex: unreachable code reached");
651  return C4Void();
652 }
653 
654 static bool FnSetVertex(C4Object *Obj, long iIndex, long iValueToSet, long iValue, long iOwnVertexMode)
655 {
656  // own vertex mode?
657  if (iOwnVertexMode)
658  {
659  // enter own custom vertex mode if not already set
660  if (!Obj->fOwnVertices)
661  {
662  Obj->Shape.CreateOwnOriginalCopy(Obj->Def->Shape);
663  Obj->fOwnVertices = true;
664  }
665  // set vertices at end of buffer
666  iIndex += C4D_VertexCpyPos;
667  }
668  // range check
669  if (!Inside<long>(iIndex,0,C4D_MaxVertex-1)) return false;
670  // set desired value
671  switch (static_cast<VertexDataIndex>(iValueToSet))
672  {
673  case VTX_X: Obj->Shape.VtxX[iIndex]=iValue; break;
674  case VTX_Y: Obj->Shape.VtxY[iIndex]=iValue; break;
675  case VTX_CNAT: Obj->Shape.VtxCNAT[iIndex]=iValue; break;
676  case VTX_Friction: Obj->Shape.VtxFriction[iIndex]=iValue; break;
677  default:
678  DebugLogF("SetVertex: Unknown vertex attribute: %ld", iValueToSet);
679  return false;
680  break;
681  }
682  // vertex update desired?
683  if (iOwnVertexMode==VTX_SetPermanentUpd) Obj->UpdateShape(true);
684  return true;
685 }
686 
687 static bool FnAddVertex(C4Object *Obj, long iX, long iY)
688 {
689  return !!Obj->Shape.AddVertex(iX,iY);
690 }
691 
692 static bool FnInsertVertex(C4Object *Obj, long iIndex, long iX, long iY)
693 {
694  return !!Obj->Shape.InsertVertex(iIndex,iX,iY);
695 }
696 
697 static bool FnRemoveVertex(C4Object *Obj, long iIndex)
698 {
699  return !!Obj->Shape.RemoveVertex(iIndex);
700 }
701 
702 static void FnSetContactDensity(C4Object *Obj, long iDensity)
703 {
704  Obj->Shape.ContactDensity = iDensity;
705 }
706 
707 static bool FnGetAlive(C4Object *Obj)
708 {
709  return Obj->GetAlive();
710 }
711 
712 static long FnGetOwner(C4Object *Obj)
713 {
714  return Obj->Owner;
715 }
716 
717 static long FnGetController(C4Object *Obj)
718 {
719  return Obj->Controller;
720 }
721 
722 static bool FnSetController(C4Object *Obj, long iNewController)
723 {
724  // validate player
725  if (iNewController != NO_OWNER && !ValidPlr(iNewController)) return false;
726  // Set controller
727  Obj->Controller = iNewController;
728  return true;
729 }
730 
731 static long FnGetKiller(C4Object *Obj)
732 {
733  return Obj->LastEnergyLossCausePlayer;
734 }
735 
736 static bool FnSetKiller(C4Object *Obj, long iNewKiller)
737 {
738  // validate player
739  if (iNewKiller != NO_OWNER && !ValidPlr(iNewKiller)) return false;
740  // set killer as last energy loss cause
741  Obj->LastEnergyLossCausePlayer = iNewKiller;
742  return true;
743 }
744 
745 static long FnGetCategory(C4PropList * _this)
746 {
747  if (!Object(_this))
748  if (!_this || !_this->GetDef())
749  throw NeedNonGlobalContext("GetCategory");
750  else
751  return _this->GetDef()->Category;
752  else
753  return Object(_this)->Category;
754 }
755 
756 static long FnGetOCF(C4Object *Obj)
757 {
758  return Obj->OCF;
759 }
760 
761 static long FnGetDamage(C4Object *Obj)
762 {
763  return Obj->Damage;
764 }
765 
766 static long FnGetValue(C4PropList * _this, C4Object *pInBase, long iForPlayer)
767 {
768  if (!Object(_this))
769  if (!_this || !_this->GetDef())
770  throw NeedNonGlobalContext("GetValue");
771  else
772  return _this->GetDef()->GetValue(pInBase, iForPlayer);
773  else
774  return Object(_this)->GetValue(pInBase, iForPlayer);
775 }
776 
777 static long FnGetRank(C4Object *Obj)
778 {
779  if (!Obj->Info) return 0;
780  return Obj->Info->Rank;
781 }
782 
783 static long FnGetActTime(C4Object *Obj)
784 {
785  return Obj->Action.Time;
786 }
787 
788 static C4PropList* FnGetID(C4Object *Obj)
789 {
790  // return id of object
791  return Obj->GetPrototype();
792 }
793 
794 static Nillable<C4Def*> FnGetMenu(C4Object *Obj)
795 {
796  if (Obj->Menu && Obj->Menu->IsActive())
797  return C4Id2Def(C4ID(Obj->Menu->GetIdentification()));
798  return C4Void();
799 }
800 
801 static bool FnCreateMenu(C4Object *Obj, C4Def *pDef, C4Object *pCommandObj,
802  long iExtra, C4String *szCaption, long iExtraData,
803  long iStyle, bool fPermanent, C4ID idMenuID)
804 {
805  if (pCommandObj)
806  // object menu: Validate object
807  if (!pCommandObj->Status) return false;
808  // else scenario script callback: No command object OK
809 
810  // Create symbol
811  C4FacetSurface fctSymbol;
812  fctSymbol.Create(C4SymbolSize,C4SymbolSize);
813  if (pDef) pDef->Draw(fctSymbol);
814 
815  // Clear any old menu, init new menu
816  if (!Obj->CloseMenu(false)) return false;
817  if (!Obj->Menu) Obj->Menu = new C4ObjectMenu; else Obj->Menu->ClearItems();
818  Obj->Menu->Init(fctSymbol,FnStringPar(szCaption),pCommandObj,iExtra,iExtraData,(idMenuID ? idMenuID : pDef ? pDef->id : C4ID::None).GetHandle(),iStyle,true);
819 
820  // Set permanent
821  Obj->Menu->SetPermanent(fPermanent);
822 
823  return true;
824 }
825 
826 const int C4MN_Add_ImgRank = 1,
833  C4MN_Add_MaxImage = 127, // mask for param which decides what to draw as the menu symbol
837 
838 #ifndef _MSC_VER
839 #define _snprintf snprintf
840 #endif
841 
842 static bool FnAddMenuItem(C4Object *Obj, C4String * szCaption, C4String * szCommand, C4Def * pDef, int iCount, const C4Value & Parameter, C4String * szInfoCaption, int iExtra, const C4Value & XPar, const C4Value & XPar2)
843 {
844  if (!Obj->Menu) return false;
845 
846  char caption[256+1];
847  char parameter[256+1];
848  char dummy[256+1];
849  char command[512+1];
850  char command2[512+1];
851  char infocaption[C4MaxTitle+1];
852 
853  // get needed symbol size
854  int iSymbolSize = Obj->Menu->GetSymbolSize();
855 
856  // Compose caption with def name
857  if (szCaption)
858  {
859  const char * s = FnStringPar(szCaption);
860  const char * sep = strstr(s, "%s");
861  if (sep && pDef)
862  {
863  strncpy(caption, s, std::min<intptr_t>(sep - s,256));
864  caption[std::min<intptr_t>(sep - s,256)] = 0;
865  strncat(caption, pDef->GetName(), 256);
866  strncat(caption, sep + 2, 256);
867  }
868  else
869  {
870  strncpy(caption, s, 256);
871  caption[256] = 0;
872  }
873  }
874  else
875  caption[0] = 0;
876 
877  // create string to include type-information in command
878  switch (Parameter.GetType())
879  {
880  case C4V_Int:
881  sprintf(parameter, "%d", Parameter.getInt());
882  break;
883  case C4V_Bool:
884  SCopy(Parameter.getBool() ? "true" : "false", parameter);
885  break;
886  case C4V_PropList:
887  if (Parameter.getPropList()->GetObject())
888  sprintf(parameter, "Object(%d)", Parameter.getPropList()->GetObject()->Number);
889  else if (Parameter.getPropList()->GetDef())
890  sprintf(parameter, R"(C4Id("%s"))", Parameter.getPropList()->GetDef()->id.ToString());
891  else
892  throw C4AulExecError("proplist as parameter to AddMenuItem");
893  break;
894  case C4V_String:
895  // note this breaks if there is '"' in the string.
896  parameter[0] = '"';
897  SCopy(Parameter.getStr()->GetCStr(), parameter + 1, sizeof(command)-3);
898  SAppendChar('"', command);
899  break;
900  case C4V_Nil:
901  SCopy("nil", parameter);
902  break;
903  case C4V_Array:
904  // Arrays were never allowed, so tell the scripter
905  throw C4AulExecError("array as parameter to AddMenuItem");
906  default:
907  return false;
908  }
909 
910  // own value
911  bool fOwnValue = false; long iValue=0;
912  if (iExtra & C4MN_Add_PassValue)
913  {
914  fOwnValue = true;
915  iValue = XPar2.getInt();
916  }
917 
918  // New Style: native script command
919  size_t i = 0;
920  for (; i < SLen(FnStringPar(szCommand)); i++)
921  if (!IsIdentifier(FnStringPar(szCommand)[i]))
922  break;
923  if (i < SLen(FnStringPar(szCommand)))
924  {
925  // Search for "%d" an replace it by "%s" for insertion of formatted parameter
926  SCopy(FnStringPar(szCommand), dummy, 256);
927  auto* pFound = const_cast<char*>(SSearch(dummy, "%d"));
928  if (pFound != nullptr)
929  *(pFound - 1) = 's';
930  // Compose left-click command
931  sprintf(command, dummy, parameter, 0);
932  // Compose right-click command
933  sprintf(command2, dummy, parameter, 1);
934  }
935 
936  // Old style: function name with id and parameter
937  else
938  {
939  const char *szScriptCom = FnStringPar(szCommand);
940  if (szScriptCom && *szScriptCom)
941  {
942  if (iExtra & C4MN_Add_PassValue)
943  {
944  // with value
945  sprintf(command,"%s(%s,%s,0,%ld)",szScriptCom,pDef ? pDef->id.ToString() : "nil",parameter,iValue);
946  sprintf(command2,"%s(%s,%s,1,%ld)",szScriptCom,pDef ? pDef->id.ToString() : "nil",parameter,iValue);
947  }
948  else
949  {
950  // without value
951  sprintf(command,"%s(%s,%s)",szScriptCom,pDef ? pDef->id.ToString() : "nil",parameter);
952  sprintf(command2,"%s(%s,%s,1)",szScriptCom,pDef ? pDef->id.ToString() : "nil",parameter);
953  }
954  }
955  else
956  {
957  // no command
958  *command = *command2 = '\0';
959  }
960  }
961 
962  // Info caption
963  SCopy(FnStringPar(szInfoCaption),infocaption,C4MaxTitle);
964 
965  // Create symbol
966  C4FacetSurface fctSymbol;
967  C4DefGraphics* pGfx = nullptr;
968  C4Object* pGfxObj = nullptr;
969  switch (iExtra & C4MN_Add_MaxImage)
970  {
971  case C4MN_Add_ImgRank:
972  {
973  // symbol by rank
974  C4Facet *pfctRankSym = &::GraphicsResource.fctRank;
975  int32_t iRankSymNum = ::GraphicsResource.iNumRanks;
976  if (pDef && pDef->pRankSymbols)
977  {
978  pfctRankSym = pDef->pRankSymbols;
979  iRankSymNum = pDef->iNumRankSymbols;
980  }
981  C4RankSystem::DrawRankSymbol(&fctSymbol, iCount, pfctRankSym, iRankSymNum, true);
982  iCount=0;
983  break;
984  }
985  case C4MN_Add_ImgIndexed:
986  // draw indexed facet
987  fctSymbol.Create(iSymbolSize,iSymbolSize);
988  if (pDef)
989  pDef->Draw(fctSymbol, false, 0, nullptr, XPar.getInt());
990  break;
991  case C4MN_Add_ImgObjRank:
992  {
993  // draw current gfx of XPar_C4V including rank
994  if (!XPar.CheckConversion(C4V_Object)) return false;
995  C4Object *pGfxObj = XPar.getObj();
996  if (pGfxObj && pGfxObj->Status)
997  {
998  // create graphics
999  // get rank gfx
1000  C4Facet *pRankRes=&::GraphicsResource.fctRank;
1001  long iRankCnt=::GraphicsResource.iNumRanks;
1002  C4Def *pDef=pGfxObj->Def;
1003  if (pDef->pRankSymbols)
1004  {
1005  pRankRes=pDef->pRankSymbols;
1006  iRankCnt=pDef->iNumRankSymbols;
1007  }
1008  // context menu
1009  C4Facet fctRank;
1010  if (Obj->Menu->IsContextMenu())
1011  {
1012  // context menu entry: left object gfx
1013  long C4MN_SymbolSize = Obj->Menu->GetItemHeight();
1014  fctSymbol.Create(C4MN_SymbolSize * 2,C4MN_SymbolSize);
1015  fctSymbol.Wdt = C4MN_SymbolSize;
1016  pGfxObj->Def->Draw(fctSymbol, false, pGfxObj->Color, pGfxObj);
1017  // right of it the rank
1018  fctRank = fctSymbol;
1019  fctRank.X = C4MN_SymbolSize;
1020  fctSymbol.Wdt *= 2;
1021  }
1022  else
1023  {
1024  // regular menu: draw object picture
1025  fctSymbol.Create(iSymbolSize,iSymbolSize);
1026  pGfxObj->Def->Draw(fctSymbol, false, pGfxObj->Color, pGfxObj);
1027  // rank at top-right corner
1028  fctRank = fctSymbol;
1029  fctRank.X = fctRank.Wdt - pRankRes->Wdt;
1030  fctRank.Wdt = pRankRes->Wdt;
1031  fctRank.Hgt = pRankRes->Hgt;
1032  }
1033  // draw rank
1034  if (pGfxObj->Info)
1035  {
1036  C4Facet fctBackup = (const C4Facet &) fctSymbol;
1037  fctSymbol.Set(fctRank);
1038  C4RankSystem::DrawRankSymbol(&fctSymbol, pGfxObj->Info->Rank, pRankRes, iRankCnt, true);
1039  fctSymbol.Set(fctBackup);
1040  }
1041  }
1042  }
1043  break;
1044  case C4MN_Add_ImgObject:
1045  {
1046  // draw object picture
1047  if (!XPar.CheckConversion(C4V_Object))
1048  throw C4AulExecError(FormatString(R"(call to "%s" parameter %d: got "%s", but expected "%s"!)",
1049  "AddMenuItem", 8, XPar.GetTypeName(), GetC4VName(C4V_Object)
1050  ).getData());
1051  pGfxObj = XPar.getObj();
1052  }
1053  break;
1054 
1055  case C4MN_Add_ImgTextSpec:
1056  {
1057  C4Def* pDef = C4Id2Def(C4ID(std::string(caption)));
1058  if(pDef)
1059  {
1060  pGfx = &pDef->Graphics;
1061  }
1062  else
1063  {
1064  fctSymbol.Create(iSymbolSize,iSymbolSize);
1065  uint32_t dwClr = XPar.getInt();
1066  if (!szCaption || !Game.DrawTextSpecImage(fctSymbol, caption, nullptr, dwClr ? dwClr : 0xff))
1067  return false;
1068  }
1069  *caption = '\0';
1070  }
1071  break;
1072 
1074  {
1075  C4PropList *gfx_proplist = XPar.getPropList();
1076  fctSymbol.Create(iSymbolSize,iSymbolSize);
1077  if (!Game.DrawPropListSpecImage(fctSymbol, gfx_proplist))
1078  return false;
1079  }
1080  break;
1081 
1082  case C4MN_Add_ImgColor:
1083  // draw colored def facet
1084  fctSymbol.Create(iSymbolSize,iSymbolSize);
1085  if (pDef)
1086  pDef->Draw(fctSymbol, false, XPar.getInt());
1087  break;
1088 
1089  default:
1090  // default: by def, if it is not specifically NONE
1091  if (pDef)
1092  {
1093  fctSymbol.Create(iSymbolSize,iSymbolSize);
1094  pDef->Draw(fctSymbol);
1095  }
1096  else
1097  {
1098  // otherwise: Clear symbol!
1099  }
1100  break;
1101  }
1102 
1103  // Convert default zero count to no count
1104  if (iCount==0 && !(iExtra & C4MN_Add_ForceCount)) iCount=C4MN_Item_NoCount;
1105 
1106  // menuitems without commands are never selectable
1107  bool fIsSelectable = !!*command;
1108 
1109  // Add menu item
1110  if(pGfxObj)
1111  Obj->Menu->Add(caption,pGfxObj,command,iCount,nullptr,infocaption,pDef ? pDef->id : C4ID::None,command2,fOwnValue,iValue,fIsSelectable);
1112  else if(pGfx)
1113  Obj->Menu->Add(caption,pGfx,command,iCount,nullptr,infocaption,pDef ? pDef->id : C4ID::None,command2,fOwnValue,iValue,fIsSelectable);
1114  else
1115  Obj->Menu->Add(caption,fctSymbol,command,iCount,nullptr,infocaption,pDef ? pDef->id : C4ID::None,command2,fOwnValue,iValue,fIsSelectable);
1116 
1117  return true;
1118 }
1119 
1120 static bool FnSelectMenuItem(C4Object *Obj, long iItem)
1121 {
1122  if (!Obj->Menu) return false;
1123  return !!Obj->Menu->SetSelection(iItem, false, true);
1124 }
1125 
1126 static bool FnSetMenuDecoration(C4Object *Obj, C4ID idNewDeco)
1127 {
1128  if (!Obj->Menu) return false;
1130  if (!pNewDeco->SetByDef(idNewDeco))
1131  {
1132  delete pNewDeco;
1133  return false;
1134  }
1135  Obj->Menu->SetFrameDeco(pNewDeco);
1136  return true;
1137 }
1138 
1139 static bool FnSetMenuTextProgress(C4Object *Obj, long iNewProgress)
1140 {
1141  if (!Obj->Menu) return false;
1142  return Obj->Menu->SetTextProgress(iNewProgress, false);
1143 }
1144 
1145 
1146 // Check / Status
1147 
1148 static C4Object *FnContained(C4Object *Obj)
1149 {
1150  return Obj->Contained;
1151 }
1152 
1153 static C4Object *FnContents(C4Object *Obj, long index)
1154 {
1155  // Special: objects attaching to another object
1156  // cannot be accessed by FnContents
1157  C4Object *cobj;
1158  while ((cobj=Obj->Contents.GetObject(index++)))
1159  if (cobj->GetProcedure()!=DFA_ATTACH) return cobj;
1160 
1161  return nullptr;
1162 }
1163 
1164 static bool FnShiftContents(C4Object *Obj, bool fShiftBack, C4Def * idTarget, bool fDoCalls)
1165 {
1166  // regular shift
1167  if (!idTarget) return !!Obj->ShiftContents(fShiftBack, fDoCalls);
1168  // check if ID is present within target
1169  C4Object *pNewFront = Obj->Contents.Find(idTarget);
1170  if (!pNewFront) return false;
1171  // select it
1172  Obj->DirectComContents(pNewFront, fDoCalls);
1173  // done, success
1174  return true;
1175 }
1176 
1177 static C4Object *FnScrollContents(C4Object *Obj)
1178 {
1179  C4Object *pMove = Obj->Contents.GetObject();
1180  if (pMove)
1181  {
1182  Obj->Contents.Remove(pMove);
1183  Obj->Contents.Add(pMove,C4ObjectList::stNone);
1184  }
1185 
1186  return Obj->Contents.GetObject();
1187 }
1188 
1189 static long FnContentsCount(C4Object *Obj, C4ID id)
1190 {
1191  return Obj->Contents.ObjectCount(id);
1192 }
1193 
1194 static C4Object *FnFindContents(C4Object *Obj, C4Def * c_id)
1195 {
1196  return Obj->Contents.Find(c_id);
1197 }
1198 
1199 static C4Object *FnFindOtherContents(C4Object *Obj, C4ID c_id)
1200 {
1201  return Obj->Contents.FindOther(c_id);
1202 }
1203 
1204 static bool FnActIdle(C4Object *Obj)
1205 {
1206  return !Obj->GetAction();
1207 }
1208 
1209 static bool FnStuck(C4Object *Obj, long off_x, long off_y)
1210 {
1211  return !!Obj->Shape.CheckContact(Obj->GetX()+off_x,Obj->GetY()+off_y);
1212 }
1213 
1214 static bool FnInLiquid(C4Object *Obj)
1215 {
1216  return Obj->InLiquid;
1217 }
1218 
1219 static bool FnOnFire(C4Object *Obj)
1220 {
1221  if (Obj->GetOnFire()) return true;
1222  // check for effect
1223  if (!Obj->pEffects) return false;
1224  return !!Obj->pEffects->Get(C4Fx_AnyFire);
1225 }
1226 
1227 static C4Object *FnCreateContents(C4Object *Obj, C4PropList * PropList, Nillable<long> iCount)
1228 {
1229  // default amount parameter
1230  if (iCount.IsNil()) iCount = 1;
1231  // create objects
1232  C4Object *pNewObj = nullptr;
1233  while (iCount-- > 0) pNewObj = Obj->CreateContents(PropList);
1234  // controller will automatically be set upon entrance
1235  // return last created
1236  return pNewObj;
1237 }
1238 
1239 static bool FnMakeCrewMember(C4Object *Obj, long iPlayer)
1240 {
1241  if (!ValidPlr(iPlayer)) return false;
1242  return !!::Players.Get(iPlayer)->MakeCrewMember(Obj);
1243 }
1244 
1245 static bool FnGrabObjectInfo(C4Object *Obj, C4Object *pFrom)
1246 {
1247  // local call, safety
1248  if (!pFrom) return false;
1249  // grab info
1250  return !!Obj->GrabInfo(pFrom);
1251 }
1252 
1253 static bool FnSetCrewStatus(C4Object *Obj, long iPlr, bool fInCrew)
1254 {
1255  // validate player
1256  C4Player *pPlr = ::Players.Get(iPlr);
1257  if (!pPlr) return false;
1258  // set crew status
1259  return !!pPlr->SetObjectCrewStatus(Obj, fInCrew);
1260 }
1261 
1262 static long FnSetTransferZone(C4Object *Obj, long iX, long iY, long iWdt, long iHgt)
1263 {
1264  iX+=Obj->GetX(); iY+=Obj->GetY();
1265  return Game.TransferZones.Set(iX,iY,iWdt,iHgt,Obj);
1266 }
1267 
1268 static long FnObjectDistance(C4PropList * _this, C4Object *pObj2, C4Object *pObj)
1269 {
1270  if (!pObj) pObj=Object(_this); if (!pObj || !pObj2) return 0;
1271  return Distance(pObj->GetX(),pObj->GetY(),pObj2->GetX(),pObj2->GetY());
1272 }
1273 
1274 static long FnObjectNumber(C4Object *Obj)
1275 {
1276  return Obj->Number;
1277  // See FnObject
1278 }
1279 
1280 static long FnShowInfo(C4Object *Obj, C4Object *pObj)
1281 {
1282  if (!pObj) pObj=Obj; if (!pObj) return false;
1283  return Obj->ActivateMenu(C4MN_Info,0,0,0,pObj);
1284 }
1285 
1286 static void FnSetMass(C4Object *Obj, long iValue)
1287 {
1288  Obj->OwnMass=iValue-Obj->Def->Mass;
1289  Obj->UpdateMass();
1290 }
1291 
1292 static long FnGetColor(C4Object *Obj)
1293 {
1294  return Obj->Color;
1295 }
1296 
1297 static void FnSetColor(C4Object *Obj, long iValue)
1298 {
1299  Obj->Color=iValue;
1300  Obj->UpdateGraphics(false);
1301  Obj->UpdateFace(false);
1302 }
1303 
1304 static void FnSetLightRange(C4Object *Obj, long iRange, Nillable<long> iFadeoutRange)
1305 {
1306  if (iFadeoutRange.IsNil())
1307  {
1308  if(iRange == 0)
1309  iFadeoutRange = 0;
1310  else
1311  iFadeoutRange = C4FOW_DefLightFadeoutRangeX;
1312  }
1313  // set range
1314  Obj->SetLightRange(iRange, iFadeoutRange);
1315 }
1316 
1317 static long FnGetLightColor(C4Object *Obj)
1318 {
1319  // get it
1320  return Obj->GetLightColor();
1321 }
1322 
1323 
1324 static void FnSetLightColor(C4Object *Obj, long iValue)
1325 {
1326  Obj->SetLightColor(iValue);
1327 }
1328 
1329 static void FnSetPicture(C4Object *Obj, long iX, long iY, long iWdt, long iHgt)
1330 {
1331  // set new picture rect
1332  Obj->PictureRect.Set(iX, iY, iWdt, iHgt);
1333 }
1334 
1335 static C4String *FnGetProcedure(C4Object *Obj)
1336 {
1337  // no action?
1338  C4PropList* pActionDef = Obj->GetAction();
1339  if (!pActionDef) return nullptr;
1340  // get proc
1341  return pActionDef->GetPropertyStr(P_Procedure);
1342 }
1343 
1344 static bool FnCheckVisibility(C4Object *Obj, int plr) {
1345  return Obj->IsVisible(plr, false);
1346 }
1347 
1348 static bool FnSetClrModulation(C4Object *Obj, Nillable<long> dwClr, long iOverlayID)
1349 {
1350  uint32_t clr = 0xffffffff;
1351  if (!dwClr.IsNil()) clr = dwClr;
1352 
1353  // overlay?
1354  if (iOverlayID)
1355  {
1356  C4GraphicsOverlay *pOverlay = Obj->GetGraphicsOverlay(iOverlayID, false);
1357  if (!pOverlay)
1358  {
1359  DebugLogF("SetClrModulation: Overlay %d not defined for object %d (%s)", (int) iOverlayID, (int) Obj->Number, Obj->GetName());
1360  return false;
1361  }
1362  pOverlay->SetClrModulation(clr);
1363  // C4GraphicsOverlay Does not have an StdMeshInstance (yet), no need to
1364  // update faceordering
1365  }
1366  else
1367  {
1368  // set it
1369  Obj->ColorMod=clr;
1370  if (Obj->pMeshInstance)
1372  }
1373  // success
1374  return true;
1375 }
1376 
1377 static Nillable<long> FnGetClrModulation(C4Object *Obj, long iOverlayID)
1378 {
1379  // overlay?
1380  if (iOverlayID)
1381  {
1382  C4GraphicsOverlay *pOverlay = Obj->GetGraphicsOverlay(iOverlayID, false);
1383  if (!pOverlay)
1384  {
1385  DebugLogF("GetClrModulation: Overlay %d not defined for object %d (%s)", (int) iOverlayID, (int) Obj->Number, Obj->GetName());
1386  return C4Void();
1387  }
1388  return pOverlay->GetClrModulation();
1389  }
1390  else
1391  // get it
1392  return Obj->ColorMod;
1393 }
1394 
1395 static bool FnCloseMenu(C4Object *Obj)
1396 {
1397  return !!Obj->CloseMenu(true);
1398 }
1399 
1400 static Nillable<long> FnGetMenuSelection(C4Object *Obj)
1401 {
1402  if (!Obj->Menu || !Obj->Menu->IsActive()) return C4Void();
1403  return Obj->Menu->GetSelection();
1404 }
1405 
1406 static bool FnCanConcatPictureWith(C4Object *Obj, C4Object *pObj)
1407 {
1408  // safety
1409  if (!Obj->Status || !pObj) return false;
1410  // Call the function in the object
1411  return Obj->CanConcatPictureWith(pObj);
1412 }
1413 
1414 static bool FnSetGraphics(C4Object *Obj, C4String *pGfxName, C4Def *pSrcDef, long iOverlayID, long iOverlayMode, C4String *pAction, long dwBlitMode, C4Object *pOverlayObject)
1415 {
1416  // safety
1417  if (!Obj->Status) return false;
1418  // setting overlay?
1419  if (iOverlayID)
1420  {
1421  // any overlays must be positive for now
1422  if (iOverlayID<0) { Log("SetGraphics: Background overlays not implemented!"); return false; }
1423  // deleting overlay?
1424  C4DefGraphics *pGrp = nullptr;
1425  if (iOverlayMode == C4GraphicsOverlay::MODE_Object || iOverlayMode == C4GraphicsOverlay::MODE_Rank || iOverlayMode == C4GraphicsOverlay::MODE_ObjectPicture)
1426  {
1427  if (!pOverlayObject) return Obj->RemoveGraphicsOverlay(iOverlayID);
1428  }
1429  else
1430  {
1431  if (!pSrcDef) return Obj->RemoveGraphicsOverlay(iOverlayID);
1432  pGrp = pSrcDef->Graphics.Get(FnStringPar(pGfxName));
1433  if (!pGrp) return false;
1434  }
1435  // adding/setting
1436  C4GraphicsOverlay *pOverlay = Obj->GetGraphicsOverlay(iOverlayID, true);
1437  switch (iOverlayMode)
1438  {
1440  pOverlay->SetAsBase(pGrp, dwBlitMode);
1441  break;
1442 
1444  pOverlay->SetAsAction(pGrp, FnStringPar(pAction), dwBlitMode);
1445  break;
1446 
1448  pOverlay->SetAsIngamePicture(pGrp, dwBlitMode);
1449  break;
1450 
1452  pOverlay->SetAsPicture(pGrp, dwBlitMode);
1453  break;
1454 
1456  if (pOverlayObject && !pOverlayObject->Status) pOverlayObject = nullptr;
1457  pOverlay->SetAsObject(pOverlayObject, dwBlitMode);
1458  break;
1459 
1461  pOverlay->SetAsExtraGraphics(pGrp, dwBlitMode);
1462  break;
1463 
1465  if (pOverlayObject && !pOverlayObject->Status) pOverlayObject = nullptr;
1466  pOverlay->SetAsRank(dwBlitMode, pOverlayObject);
1467  break;
1468 
1470  if (pOverlayObject && !pOverlayObject->Status) pOverlayObject = nullptr;
1471  pOverlay->SetAsObjectPicture(pOverlayObject, dwBlitMode);
1472  break;
1473 
1474  default:
1475  DebugLog("SetGraphics: Invalid overlay mode");
1476  pOverlay->SetAsBase(nullptr, 0); // make invalid, so it will be removed
1477  break;
1478  }
1479  // remove if invalid
1480  if (!pOverlay->IsValid(Obj))
1481  {
1482  Obj->RemoveGraphicsOverlay(iOverlayID);
1483  return false;
1484  }
1485  // Okay, valid overlay set!
1486  return true;
1487  }
1488  // no overlay: Base graphics
1489  // set graphics - pSrcDef==nullptr defaults to pObj->pDef
1490  return Obj->SetGraphics(FnStringPar(pGfxName), pSrcDef);
1491 }
1492 
1493 static long FnGetDefBottom(C4PropList * _this)
1494 {
1495  if (!_this || !_this->GetDef())
1496  throw NeedNonGlobalContext("GetDefBottom");
1497 
1498  C4Object *obj = Object(_this);
1499  C4Def *def = _this->GetDef();
1500  assert(!obj || obj->Def == def);
1501 
1502  if (obj)
1503  return obj->GetY() + obj->Shape.GetBottom();
1504  else if (def)
1505  return def->Shape.GetBottom();
1506  else
1507  return 0;
1508 }
1509 
1510 static bool FnSetMenuSize(C4Object *Obj, long iCols, long iRows)
1511 {
1512  // get menu
1513  C4Menu *pMnu=Obj->Menu;
1514  if (!pMnu || !pMnu->IsActive()) return false;
1515  pMnu->SetSize(Clamp<long>(iCols, 0, 50), Clamp<long>(iRows, 0, 50));
1516  return true;
1517 }
1518 
1519 static bool FnGetCrewEnabled(C4Object *Obj)
1520 {
1521  // return status
1522  return !Obj->CrewDisabled;
1523 }
1524 
1525 static void FnSetCrewEnabled(C4Object *Obj, bool fEnabled)
1526 {
1527  bool change = (Obj->CrewDisabled == fEnabled) ? true : false;
1528 
1529  // set status
1530  Obj->CrewDisabled=!fEnabled;
1531  // deselect
1532  if (!fEnabled)
1533  {
1534  C4Player *pOwner;
1535  if ((pOwner=::Players.Get(Obj->Owner)))
1536  {
1537  // if viewed player cursor gets deactivated and no new cursor is found, follow the old in target mode
1538  bool fWasCursorMode = (pOwner->ViewMode == C4PVM_Cursor);
1539  if (pOwner->Cursor==Obj)
1540  pOwner->AdjustCursorCommand();
1541  if (!pOwner->ViewCursor && !pOwner->Cursor && fWasCursorMode)
1542  pOwner->SetViewMode(C4PVM_Target, Obj);
1543  }
1544  }
1545 
1546  // call to crew
1547  if (change)
1548  {
1549  if (fEnabled)
1550  Obj->Call(PSF_CrewEnabled);
1551  else
1552  Obj->Call(PSF_CrewDisabled);
1553  }
1554 }
1555 
1556 static void FnDoCrewExp(C4Object *Obj, long iChange)
1557 {
1558  // do exp
1559  Obj->DoExperience(iChange);
1560 }
1561 
1562 static bool FnClearMenuItems(C4Object *Obj)
1563 {
1564  // check menu
1565  if (!Obj->Menu) return false;
1566  // clear the items
1567  Obj->Menu->ClearItems();
1568  // success
1569  return true;
1570 }
1571 
1572 static C4Object *FnGetObjectLayer(C4Object *Obj)
1573 {
1574  // get layer object
1575  return Obj->Layer;
1576 }
1577 
1578 static void FnSetObjectLayer(C4Object *Obj, C4Object *pNewLayer)
1579 {
1580  // set layer object
1581  Obj->Layer = pNewLayer;
1582  // set for all contents as well
1583  for (C4Object* contentObj : Obj->Contents)
1584  if (contentObj && contentObj->Status)
1585  contentObj->Layer = pNewLayer;
1586 }
1587 
1588 static void FnSetShape(C4Object *Obj, long iX, long iY, long iWdt, long iHgt)
1589 {
1590  // update shape
1591  Obj->Shape.x = iX;
1592  Obj->Shape.y = iY;
1593  Obj->Shape.Wdt = iWdt;
1594  Obj->Shape.Hgt = iHgt;
1595  // section list needs refresh
1596  Obj->UpdatePos();
1597 }
1598 
1599 static bool FnSetObjDrawTransform(C4Object *Obj, long iA, long iB, long iC, long iD, long iE, long iF, long iOverlayID)
1600 {
1601  C4DrawTransform *pTransform;
1602  // overlay?
1603  if (iOverlayID)
1604  {
1605  // set overlay transform
1606  C4GraphicsOverlay *pOverlay = Obj->GetGraphicsOverlay(iOverlayID, false);
1607  if (!pOverlay) return false;
1608  pTransform = pOverlay->GetTransform();
1609  }
1610  else
1611  {
1612  // set base transform
1613  pTransform = Obj->pDrawTransform;
1614  // del transform?
1615  if (!iB && !iC && !iD && !iF && iA==iE && (!iA || iA==1000))
1616  {
1617  // identity/0 and no transform defined: nothing to do
1618  if (!pTransform) return true;
1619  // transform has no flipdir?
1620  if (pTransform->FlipDir == 1)
1621  {
1622  // kill identity-transform, then
1623  delete pTransform;
1624  Obj->pDrawTransform=nullptr;
1625  return true;
1626  }
1627  // flipdir must remain: set identity
1628  pTransform->Set(1,0,0,0,1,0,0,0,1);
1629  return true;
1630  }
1631  // create draw transform if not already present
1632  if (!pTransform) pTransform = Obj->pDrawTransform = new C4DrawTransform();
1633  }
1634  // assign values
1635  pTransform->Set((float) iA/1000, (float) iB/1000, (float) iC/1000, (float) iD/1000, (float) iE/1000, (float) iF/1000, 0, 0, 1);
1636  // done, success
1637  return true;
1638 }
1639 
1640 static bool FnSetObjDrawTransform2(C4Object *Obj, long iA, long iB, long iC, long iD, long iE, long iF, long iG, long iH, long iI, long iOverlayID)
1641 {
1642  // local call / safety
1643  C4Object * pObj = Obj;
1644  C4DrawTransform *pTransform;
1645  // overlay?
1646  if (iOverlayID)
1647  {
1648  // set overlay transform
1649  C4GraphicsOverlay *pOverlay = pObj->GetGraphicsOverlay(iOverlayID, false);
1650  if (!pOverlay) return false;
1651  pTransform = pOverlay->GetTransform();
1652  }
1653  else
1654  {
1655  // set base transform
1656  pTransform = pObj->pDrawTransform;
1657  // create draw transform if not already present
1658  if (!pTransform) pTransform = pObj->pDrawTransform = new C4DrawTransform(1);
1659  }
1660  // assign values
1661 #define L2F(l) ((float)l/1000)
1662  C4BltTransform matrix;
1663  matrix.Set(L2F(iA), L2F(iB), L2F(iC), L2F(iD), L2F(iE), L2F(iF), L2F(iG), L2F(iH), L2F(iI));
1664  *pTransform *= matrix;
1665 #undef L2F
1666  // done, success
1667  return true;
1668 }
1669 
1670 static bool FnSetObjectStatus(C4Object *Obj, long iNewStatus, bool fClearPointers)
1671 {
1672  // local call / safety
1673  if (!Obj->Status) return false;
1674  // no change
1675  if (Obj->Status == iNewStatus) return true;
1676  // set new status
1677  switch (iNewStatus)
1678  {
1679  case C4OS_NORMAL:
1680  return Obj->StatusActivate();
1681  case C4OS_INACTIVE:
1682  return Obj->StatusDeactivate(fClearPointers);
1683  default:
1684  return false; // status unknown
1685  }
1686 }
1687 
1688 static long FnGetObjectStatus(C4Object *Obj)
1689 {
1690  return Obj->Status;
1691 }
1692 
1693 static bool FnAdjustWalkRotation(C4Object *Obj, long iRangeX, long iRangeY, long iSpeed)
1694 {
1695  // must be rotateable and attached to solid ground
1696  if (!Obj->Def->Rotateable || ~Obj->Action.t_attach&CNAT_Bottom || Obj->Shape.AttachMat == MNone)
1697  return false;
1698  // adjust rotation
1699  return Obj->AdjustWalkRotation(iRangeX, iRangeY, iSpeed);
1700 }
1701 
1702 static long FnGetContact(C4Object *Obj, long iVertex, long dwCheck)
1703 {
1704  // vertex not specified: check all
1705  if (iVertex == -1)
1706  {
1707  long iResult = 0;
1708  for (int i=0; i<Obj->Shape.VtxNum; ++i)
1709  iResult |= Obj->Shape.GetVertexContact(i, dwCheck, Obj->GetX(), Obj->GetY());
1710  return iResult;
1711  }
1712  // vertex specified: check it
1713  if (!Inside<long>(iVertex, 0, Obj->Shape.VtxNum-1)) return 0;
1714  return Obj->Shape.GetVertexContact(iVertex, dwCheck, Obj->GetX(), Obj->GetY());
1715 }
1716 
1717 static long FnSetObjectBlitMode(C4Object *Obj, long dwNewBlitMode, long iOverlayID)
1718 {
1719  // overlay?
1720  if (iOverlayID)
1721  {
1722  C4GraphicsOverlay *pOverlay = Obj->GetGraphicsOverlay(iOverlayID, false);
1723  if (!pOverlay)
1724  {
1725  DebugLogF("SetObjectBlitMode: Overlay %d not defined for object %d (%s)", (int) iOverlayID, (int) Obj->Number, Obj->GetName());
1726  return false;
1727  }
1728  pOverlay->SetBlitMode(dwNewBlitMode);
1729  return true;
1730  }
1731  // get prev blit mode
1732  DWORD dwPrevMode = Obj->BlitMode;
1733  // iNewBlitMode = 0: reset to definition default
1734  if (!dwNewBlitMode)
1735  Obj->BlitMode = Obj->Def->BlitMode;
1736  else
1737  // otherwise, set the desired value
1738  // also ensure that the custom flag is set
1739  Obj->BlitMode = dwNewBlitMode | C4GFXBLIT_CUSTOM;
1740  // return previous value
1741  return dwPrevMode;
1742 }
1743 
1744 static Nillable<long> FnGetObjectBlitMode(C4Object *Obj, long iOverlayID)
1745 {
1746  // overlay?
1747  if (iOverlayID)
1748  {
1749  C4GraphicsOverlay *pOverlay = Obj->GetGraphicsOverlay(iOverlayID, false);
1750  if (!pOverlay)
1751  {
1752  DebugLogF("SetObjectBlitMode: Overlay %d not defined for object %d (%s)", (int) iOverlayID, (int) Obj->Number, Obj->GetName());
1753  return C4Void();
1754  }
1755  return pOverlay->GetBlitMode();
1756  }
1757  // get blitting mode
1758  return Obj->BlitMode;
1759 }
1760 
1761 static long FnGetUnusedOverlayID(C4Object *Obj, long iBaseIndex)
1762 {
1763  // safety
1764  if (!iBaseIndex) return 0;
1765  // find search first unused index from there on
1766  int iSearchDir = (iBaseIndex < 0) ? -1 : 1;
1767  while (Obj->GetGraphicsOverlay(iBaseIndex, false)) iBaseIndex += iSearchDir;
1768  return iBaseIndex;
1769 }
1770 
1771 static Nillable<int> FnPlayAnimation(C4Object *Obj, C4String *szAnimation, int iSlot, C4ValueArray* PositionProvider, Nillable<C4ValueArray*> WeightProvider, Nillable<int> iSibling, Nillable<int> iAttachNumber)
1772 {
1773  if (!Obj) return C4Void();
1774  if (!Obj->pMeshInstance) return C4Void();
1775  if (iSlot == 0) return C4Void(); // Reserved for ActMap animations
1776  if (!PositionProvider) return C4Void();
1777  // If no weight provider is passed, this animation should be played exclusively.
1778  bool stop_previous_animations = WeightProvider.IsNil();
1779  // Exclusive mode cannot work with a sibling
1780  if (!iSibling.IsNil() && stop_previous_animations) return C4Void();
1781 
1782  StdMeshInstance* Instance = Obj->pMeshInstance;
1783  if (!iAttachNumber.IsNil())
1784  {
1785  const StdMeshInstance::AttachedMesh* Attached = Instance->GetAttachedMeshByNumber(iAttachNumber);
1786  // OwnChild is set if an object's instance is attached. In that case the animation should be set directly on that object.
1787  if (!Attached || !Attached->OwnChild) return C4Void();
1788  Instance = Attached->Child;
1789  }
1790 
1791  StdMeshInstance::AnimationNode* s_node = nullptr;
1792  if (!iSibling.IsNil())
1793  {
1794  s_node = Instance->GetAnimationNodeByNumber(iSibling);
1795  if (!s_node || s_node->GetSlot() != iSlot) return C4Void();
1796  }
1797 
1798  const StdMeshAnimation* animation = Instance->GetMesh().GetSkeleton().GetAnimationByName(szAnimation->GetData());
1799  if (!animation) return C4Void();
1800 
1801  StdMeshInstance::ValueProvider* p_provider = CreateValueProviderFromArray(Obj, *PositionProvider, animation);
1802  StdMeshInstance::ValueProvider* w_provider;
1803  if (stop_previous_animations)
1804  {
1805  w_provider = new C4ValueProviderConst(Fix1);
1806  }
1807  else
1808  {
1809  w_provider = CreateValueProviderFromArray(Obj, *WeightProvider);
1810  }
1811  if (!p_provider || !w_provider)
1812  {
1813  delete p_provider;
1814  delete w_provider;
1815  return C4Void();
1816  }
1817 
1818  StdMeshInstance::AnimationNode* n_node = Instance->PlayAnimation(*animation, iSlot, s_node, p_provider, w_provider, stop_previous_animations);
1819  if (!n_node) return C4Void();
1820 
1821  return n_node->GetNumber();
1822 }
1823 
1824 static Nillable<int> FnTransformBone(C4Object *Obj, C4String *szBoneName, C4ValueArray* Transformation, int iSlot, C4ValueArray* WeightProvider, Nillable<int> iSibling, Nillable<int> iAttachNumber)
1825 {
1826  if (!Obj) return C4Void();
1827  if (!Obj->pMeshInstance) return C4Void();
1828  if (iSlot == 0) return C4Void(); // Reserved for ActMap animations
1829  if (!Transformation) return C4Void();
1830  if (!WeightProvider) return C4Void();
1831 
1832  StdMeshInstance* Instance = Obj->pMeshInstance;
1833  if (!iAttachNumber.IsNil())
1834  {
1835  const StdMeshInstance::AttachedMesh* Attached = Instance->GetAttachedMeshByNumber(iAttachNumber);
1836  // OwnChild is set if an object's instance is attached. In that case the animation should be set directly on that object.
1837  if (!Attached || !Attached->OwnChild) return C4Void();
1838  Instance = Attached->Child;
1839  }
1840 
1841  StdMeshInstance::AnimationNode* s_node = nullptr;
1842  if (!iSibling.IsNil())
1843  {
1844  s_node = Instance->GetAnimationNodeByNumber(iSibling);
1845  if (!s_node || s_node->GetSlot() != iSlot) return C4Void();
1846  }
1847 
1848  const StdMeshBone* bone = Instance->GetMesh().GetSkeleton().GetBoneByName(szBoneName->GetData());
1849  if(!bone) return C4Void();
1850 
1851  StdMeshInstance::ValueProvider* w_provider = CreateValueProviderFromArray(Obj, *WeightProvider);
1852  if (!w_provider) return C4Void();
1853 
1854  StdMeshMatrix matrix;
1855  if (!C4ValueToMatrix(*Transformation, &matrix))
1856  throw C4AulExecError("TransformBone: Transformation is not a valid 3x4 matrix");
1857 
1858  // For bone transformations we cannot use general matrix transformations, but we use decomposed
1859  // translate, scale and rotation components (represented by the StdMeshTransformation class). This
1860  // is less generic since it does not support skewing.
1861  // Still, in the script API we want to expose a matrix parameter so that the convenient Trans_*
1862  // functions can be used. We decompose the passed matrix at this point. If the matrix indeed has
1863  // skewing components, the results will probably look strange since the decomposition would yield
1864  // bogus values, however I don't think that's a practical use case. In the worst case we could add
1865  // a check here and return nil if the matrix cannot be decomposed.
1866  StdMeshTransformation trans = matrix.Decompose();
1867 
1868  StdMeshInstance::AnimationNode* n_node = Instance->PlayAnimation(bone, trans, iSlot, s_node, w_provider, false);
1869  if (!n_node) return C4Void();
1870 
1871  return n_node->GetNumber();
1872 }
1873 
1874 static bool FnStopAnimation(C4Object *Obj, Nillable<int> iAnimationNumber, Nillable<int> iAttachNumber)
1875 {
1876  if (!Obj) return false;
1877  if (!Obj->pMeshInstance) return false;
1878  if (iAnimationNumber.IsNil()) return false; // distinguish nil from 0
1879 
1880  StdMeshInstance* Instance = Obj->pMeshInstance;
1881  if (!iAttachNumber.IsNil())
1882  {
1883  const StdMeshInstance::AttachedMesh* Attached = Instance->GetAttachedMeshByNumber(iAttachNumber);
1884  // OwnChild is set if an object's instance is attached. In that case the animation should be set directly on that object.
1885  if (!Attached || !Attached->OwnChild) return false;
1886  Instance = Attached->Child;
1887  }
1888 
1889  StdMeshInstance::AnimationNode* node = Instance->GetAnimationNodeByNumber(iAnimationNumber);
1890  // slot 0 is reserved for ActMap animations
1891  if (!node || node->GetSlot() == 0) return false;
1892  Instance->StopAnimation(node);
1893  return true;
1894 }
1895 
1896 static Nillable<int> FnGetRootAnimation(C4Object *Obj, int iSlot, Nillable<int> iAttachNumber)
1897 {
1898  if (!Obj) return C4Void();
1899  if (!Obj->pMeshInstance) return C4Void();
1900 
1901  StdMeshInstance* Instance = Obj->pMeshInstance;
1902  if (!iAttachNumber.IsNil())
1903  {
1904  const StdMeshInstance::AttachedMesh* Attached = Instance->GetAttachedMeshByNumber(iAttachNumber);
1905  // OwnChild is set if an object's instance is attached. In that case the animation should be set directly on that object.
1906  if (!Attached || !Attached->OwnChild) return C4Void();
1907  Instance = Attached->Child;
1908  }
1909 
1911  if (!node) return C4Void();
1912  return node->GetNumber();
1913 }
1914 
1915 static Nillable<C4ValueArray*> FnGetAnimationList(C4PropList* _this, Nillable<int> iAttachNumber)
1916 {
1917  C4Object *Obj = Object(_this);
1918  const StdMeshSkeleton* skeleton;
1919  if (!Obj)
1920  {
1921  if (!_this || !_this->GetDef()) throw NeedNonGlobalContext("GetAnimationList");
1922  C4Def *def = _this->GetDef();
1923  if (!def->Graphics.IsMesh()) return C4Void();
1924 
1925  skeleton = &def->Graphics.Mesh->GetSkeleton();
1926  }
1927  else
1928  {
1929  if (!Obj) return C4Void();
1930  if (!Obj->pMeshInstance) return C4Void();
1931 
1932  StdMeshInstance* Instance = Obj->pMeshInstance;
1933  if (!iAttachNumber.IsNil())
1934  {
1935  const StdMeshInstance::AttachedMesh* Attached = Instance->GetAttachedMeshByNumber(iAttachNumber);
1936  // OwnChild is set if an object's instance is attached. In that case the animation list should be obtained directly on that object.
1937  if (!Attached || !Attached->OwnChild) return C4Void();
1938  Instance = Attached->Child;
1939  }
1940 
1941  skeleton = &Instance->GetMesh().GetSkeleton();
1942  }
1943 
1944  const std::vector<const StdMeshAnimation*> animations = skeleton->GetAnimations();
1945 
1946  C4ValueArray* retval = new C4ValueArray(animations.size());
1947  for(unsigned int i = 0; i < animations.size(); ++i)
1948  (*retval)[i] = C4VString(animations[i]->Name);
1949  return retval;
1950 }
1951 
1952 static Nillable<int> FnGetAnimationLength(C4Object *Obj, C4String *szAnimation, Nillable<int> iAttachNumber)
1953 {
1954  if (!Obj) return C4Void();
1955  if (!Obj->pMeshInstance) return C4Void();
1956 
1957  StdMeshInstance* Instance = Obj->pMeshInstance;
1958  if (!iAttachNumber.IsNil())
1959  {
1960  const StdMeshInstance::AttachedMesh* Attached = Instance->GetAttachedMeshByNumber(iAttachNumber);
1961  // OwnChild is set if an object's instance is attached. In that case the animation should be set directly on that object.
1962  if (!Attached || !Attached->OwnChild) return C4Void();
1963  Instance = Attached->Child;
1964  }
1965 
1966  const StdMeshAnimation* animation = Instance->GetMesh().GetSkeleton().GetAnimationByName(szAnimation->GetData());
1967  if (!animation) return C4Void();
1968  return fixtoi(ftofix(animation->Length), 1000); // sync critical!
1969 }
1970 
1971 static Nillable<C4String*> FnGetAnimationName(C4Object *Obj, Nillable<int> iAnimationNumber, Nillable<int> iAttachNumber)
1972 {
1973  if (!Obj) return C4Void();
1974  if (!Obj->pMeshInstance) return C4Void();
1975  if (iAnimationNumber.IsNil()) return C4Void(); // distinguish nil from 0
1976 
1977  StdMeshInstance* Instance = Obj->pMeshInstance;
1978  if (!iAttachNumber.IsNil())
1979  {
1980  const StdMeshInstance::AttachedMesh* Attached = Instance->GetAttachedMeshByNumber(iAttachNumber);
1981  // OwnChild is set if an object's instance is attached. In that case the animation should be set directly on that object.
1982  if (!Attached || !Attached->OwnChild) return C4Void();
1983  Instance = Attached->Child;
1984  }
1985 
1986  StdMeshInstance::AnimationNode* node = Instance->GetAnimationNodeByNumber(iAnimationNumber);
1987  if (!node || node->GetType() != StdMeshInstance::AnimationNode::LeafNode) return C4Void();
1988  return String(node->GetAnimation()->Name.getData());
1989 }
1990 
1991 static Nillable<int> FnGetAnimationPosition(C4Object *Obj, Nillable<int> iAnimationNumber, Nillable<int> iAttachNumber)
1992 {
1993  if (!Obj) return C4Void();
1994  if (!Obj->pMeshInstance) return C4Void();
1995  if (iAnimationNumber.IsNil()) return C4Void(); // distinguish nil from 0
1996 
1997  StdMeshInstance* Instance = Obj->pMeshInstance;
1998  if (!iAttachNumber.IsNil())
1999  {
2000  const StdMeshInstance::AttachedMesh* Attached = Instance->GetAttachedMeshByNumber(iAttachNumber);
2001  // OwnChild is set if an object's instance is attached. In that case the animation should be set directly on that object.
2002  if (!Attached || !Attached->OwnChild) return C4Void();
2003  Instance = Attached->Child;
2004  }
2005 
2006  StdMeshInstance::AnimationNode* node = Instance->GetAnimationNodeByNumber(iAnimationNumber);
2007  if (!node || node->GetType() != StdMeshInstance::AnimationNode::LeafNode) return C4Void();
2008  return fixtoi(node->GetPosition(), 1000);
2009 }
2010 
2011 static Nillable<int> FnGetAnimationWeight(C4Object *Obj, Nillable<int> iAnimationNumber, Nillable<int> iAttachNumber)
2012 {
2013  if (!Obj) return C4Void();
2014  if (!Obj->pMeshInstance) return C4Void();
2015  if (iAnimationNumber.IsNil()) return C4Void(); // distinguish nil from 0
2016 
2017  StdMeshInstance* Instance = Obj->pMeshInstance;
2018  if (!iAttachNumber.IsNil())
2019  {
2020  const StdMeshInstance::AttachedMesh* Attached = Instance->GetAttachedMeshByNumber(iAttachNumber);
2021  // OwnChild is set if an object's instance is attached. In that case the animation should be set directly on that object.
2022  if (!Attached || !Attached->OwnChild) return C4Void();
2023  Instance = Attached->Child;
2024  }
2025 
2026  StdMeshInstance::AnimationNode* node = Instance->GetAnimationNodeByNumber(iAnimationNumber);
2028  return fixtoi(node->GetWeight(), 1000);
2029 }
2030 
2031 static bool FnSetAnimationPosition(C4Object *Obj, Nillable<int> iAnimationNumber, C4ValueArray* PositionProvider, Nillable<int> iAttachNumber)
2032 {
2033  if (!Obj) return false;
2034  if (!Obj->pMeshInstance) return false;
2035  if (iAnimationNumber.IsNil()) return false; // distinguish nil from 0
2036 
2037  StdMeshInstance* Instance = Obj->pMeshInstance;
2038  if (!iAttachNumber.IsNil())
2039  {
2040  const StdMeshInstance::AttachedMesh* Attached = Instance->GetAttachedMeshByNumber(iAttachNumber);
2041  // OwnChild is set if an object's instance is attached. In that case the animation should be set directly on that object.
2042  if (!Attached || !Attached->OwnChild) return false;
2043  Instance = Attached->Child;
2044  }
2045 
2046  StdMeshInstance::AnimationNode* node = Instance->GetAnimationNodeByNumber(iAnimationNumber);
2047  // slot 0 is reserved for ActMap animations
2048  if (!node || node->GetSlot() == 0 || node->GetType() != StdMeshInstance::AnimationNode::LeafNode) return false;
2049  StdMeshInstance::ValueProvider* p_provider = CreateValueProviderFromArray(Obj, *PositionProvider);
2050  if (!p_provider) return false;
2051  Instance->SetAnimationPosition(node, p_provider);
2052  return true;
2053 }
2054 
2055 static bool FnSetAnimationBoneTransform(C4Object *Obj, Nillable<int> iAnimationNumber, C4ValueArray* Transformation, Nillable<int> iAttachNumber)
2056 {
2057  if (!Obj) return false;
2058  if (!Obj->pMeshInstance) return false;
2059  if (iAnimationNumber.IsNil()) return false; // distinguish nil from 0
2060 
2061  StdMeshInstance* Instance = Obj->pMeshInstance;
2062  if (!iAttachNumber.IsNil())
2063  {
2064  const StdMeshInstance::AttachedMesh* Attached = Instance->GetAttachedMeshByNumber(iAttachNumber);
2065  // OwnChild is set if an object's instance is attached. In that case the animation should be set directly on that object.
2066  if (!Attached || !Attached->OwnChild) return false;
2067  Instance = Attached->Child;
2068  }
2069 
2070  StdMeshInstance::AnimationNode* node = Instance->GetAnimationNodeByNumber(iAnimationNumber);
2071  // slot 0 is reserved for ActMap animations
2072  if (!node || node->GetSlot() == 0 || node->GetType() != StdMeshInstance::AnimationNode::CustomNode) return false;
2073 
2074  StdMeshMatrix matrix;
2075  if (!C4ValueToMatrix(*Transformation, &matrix))
2076  throw C4AulExecError("TransformBone: Transformation is not a valid 3x4 matrix");
2077  // Here the same remark applies as in FnTransformBone
2078  StdMeshTransformation trans = matrix.Decompose();
2079 
2080  Instance->SetAnimationBoneTransform(node, trans);
2081  return true;
2082 }
2083 
2084 static bool FnSetAnimationWeight(C4Object *Obj, Nillable<int> iAnimationNumber, C4ValueArray* WeightProvider, Nillable<int> iAttachNumber)
2085 {
2086  if (!Obj) return false;
2087  if (!Obj->pMeshInstance) return false;
2088  if (iAnimationNumber.IsNil()) return false; // distinguish nil from 0
2089 
2090  StdMeshInstance* Instance = Obj->pMeshInstance;
2091  if (!iAttachNumber.IsNil())
2092  {
2093  const StdMeshInstance::AttachedMesh* Attached = Instance->GetAttachedMeshByNumber(iAttachNumber);
2094  // OwnChild is set if an object's instance is attached. In that case the animation should be set directly on that object.
2095  if (!Attached || !Attached->OwnChild) return false;
2096  Instance = Attached->Child;
2097  }
2098 
2099  StdMeshInstance::AnimationNode* node = Instance->GetAnimationNodeByNumber(iAnimationNumber);
2100  // slot 0 is reserved for ActMap animations
2101  if (!node || node->GetSlot() == 0 || node->GetType() != StdMeshInstance::AnimationNode::LinearInterpolationNode) return false;
2102  StdMeshInstance::ValueProvider* w_provider = CreateValueProviderFromArray(Obj, *WeightProvider);
2103  if (!w_provider) return false;
2104  Instance->SetAnimationWeight(node, w_provider);
2105  return true;
2106 }
2107 
2108 static Nillable<int> FnAttachMesh(C4Object *Obj, C4PropList* Mesh, C4String * szParentBone, C4String * szChildBone, C4ValueArray * Transformation, int Flags, int AttachNumber)
2109 {
2110  if (!Obj->pMeshInstance) return C4Void();
2111  if (!Mesh) return C4Void();
2112 
2113  StdMeshMatrix trans = StdMeshMatrix::Identity();
2114  if (Transformation)
2115  if (!C4ValueToMatrix(*Transformation, &trans))
2116  throw C4AulExecError("AttachMesh: Transformation is not a valid 3x4 matrix");
2117 
2119  C4Object* pObj = Mesh->GetObject();
2120  if (pObj)
2121  {
2122  if (!pObj->pMeshInstance) return C4Void();
2123  attach = Obj->pMeshInstance->AttachMesh(*pObj->pMeshInstance, new C4MeshDenumerator(pObj), szParentBone->GetData(), szChildBone->GetData(), trans, Flags, false, AttachNumber);
2124  }
2125  else
2126  {
2127  C4Def* pDef = Mesh->GetDef();
2128  if (!pDef) return C4Void();
2129  if (pDef->Graphics.Type != C4DefGraphics::TYPE_Mesh) return C4Void();
2130  attach = Obj->pMeshInstance->AttachMesh(*pDef->Graphics.Mesh, new C4MeshDenumerator(pDef), szParentBone->GetData(), szChildBone->GetData(), trans, Flags, AttachNumber);
2131  if(attach) attach->Child->SetFaceOrderingForClrModulation(Obj->ColorMod);
2132  }
2133 
2134  if (!attach) return C4Void();
2135  return attach->Number;
2136 }
2137 
2138 static bool FnDetachMesh(C4Object *Obj, long iAttachNumber)
2139 {
2140  if (!Obj || !Obj->pMeshInstance) return false;
2141  return Obj->pMeshInstance->DetachMesh(iAttachNumber);
2142 }
2143 
2144 static bool FnSetAttachBones(C4Object *Obj, long iAttachNumber, Nillable<C4String*> szParentBone, Nillable<C4String*> szChildBone)
2145 {
2146  if (!Obj || !Obj->pMeshInstance) return false;
2148  if (!attach) return false;
2149 
2150  if (!szParentBone.IsNil())
2151  {
2152  C4String* ParentBone = szParentBone;
2153  if (!attach->SetParentBone(ParentBone->GetData())) return false;
2154  }
2155 
2156  if (!szChildBone.IsNil())
2157  {
2158  C4String* ChildBone = szChildBone;
2159  if (!attach->SetChildBone(ChildBone->GetData())) return false;
2160  }
2161 
2162  return true;
2163 }
2164 
2165 static bool FnSetAttachTransform(C4Object *Obj, long iAttachNumber, C4ValueArray* Transformation)
2166 {
2167  if (!Obj || !Obj->pMeshInstance) return false;
2168  if (!Transformation) return false;
2170  if (!attach) return false;
2171 
2172  StdMeshMatrix trans;
2173  if (!C4ValueToMatrix(*Transformation, &trans))
2174  throw C4AulExecError("SetAttachTransform: Transformation is not a valid 3x4 matrix");
2175 
2176  attach->SetAttachTransformation(trans);
2177  return true;
2178 }
2179 
2180 static Nillable<C4String*> FnGetMeshMaterial(C4PropList * _this, int iSubMesh)
2181 {
2182  // Called in object or definition context?
2183  C4Object *Obj = Object(_this);
2184  if (!Obj)
2185  {
2186  if (!_this || !_this->GetDef()) throw NeedNonGlobalContext("GetMeshMaterial");
2187  // Called in definition context: Get definition default mesh material
2188  C4Def *def = _this->GetDef();
2189  if (!def->Graphics.IsMesh()) return C4Void();
2190  if (iSubMesh < 0 || (unsigned int)iSubMesh >= def->Graphics.Mesh->GetNumSubMeshes()) return C4Void();
2191  const StdSubMesh &submesh = def->Graphics.Mesh->GetSubMesh(iSubMesh);
2192  return String(submesh.GetMaterial().Name.getData());
2193  }
2194  else
2195  {
2196  // Called in object context: Get material of mesh instance
2197  if (!Obj->pMeshInstance) return C4Void();
2198  if (iSubMesh < 0 || (unsigned int)iSubMesh >= Obj->pMeshInstance->GetNumSubMeshes()) return C4Void();
2199  StdSubMeshInstance& submesh = Obj->pMeshInstance->GetSubMesh(iSubMesh);
2200  return String(submesh.GetMaterial().Name.getData());
2201  }
2202 }
2203 
2204 static bool FnSetMeshMaterial(C4Object *Obj, C4String* Material, int iSubMesh)
2205 {
2206  if (!Obj || !Obj->pMeshInstance) return false;
2207  if (iSubMesh < 0 || (unsigned int)iSubMesh >= Obj->pMeshInstance->GetNumSubMeshes()) return false;
2208  if (!Material) return false;
2209 
2210  const StdMeshMaterial* material = ::MeshMaterialManager.GetMaterial(Material->GetData().getData());
2211  if (!material) return false;
2212 
2213  Obj->pMeshInstance->SetMaterial(iSubMesh, *material);
2214  return true;
2215 }
2216 
2217 
2218 static bool FnCreateParticleAtBone(C4Object* Obj, C4String* szName, C4String* szBoneName, C4ValueArray* Pos, C4ValueArray* Dir, C4Value lifetime, C4PropList *properties, int amount)
2219 {
2220  // safety
2221  if(!Obj || !Obj->Status) return false;
2222  // Get bone
2223  if(!Obj->pMeshInstance) return false;
2224  const StdMesh& mesh = Obj->pMeshInstance->GetMesh();
2225  const StdMeshBone* bone = mesh.GetSkeleton().GetBoneByName(szBoneName->GetData());
2226  if(!bone) return false;
2227  // get particle
2228  C4ParticleDef *pDef=::Particles.definitions.GetDef(FnStringPar(szName));
2229  if (!pDef) return false;
2230 #ifndef USE_CONSOLE
2231  // Get transform
2233  const StdMeshMatrix transform = Obj->pMeshInstance->GetBoneTransform(bone->Index) * StdMeshMatrix::Transform(bone->Transformation);
2234  // Get offset and direction
2235  StdMeshVector x, dir;
2236  if(Pos)
2237  {
2238  if(Pos->GetSize() != 3)
2239  throw C4AulExecError("CreateParticleAtBone: Pos is not a three-vector");
2240  x.x = (*Pos).GetItem(0).getInt();
2241  x.y = (*Pos).GetItem(1).getInt();
2242  x.z = (*Pos).GetItem(2).getInt();
2243  }
2244  else { x.x = x.y = x.z = 0.0f; }
2245 
2246  if(Dir)
2247  {
2248  if(Dir->GetSize() != 3)
2249  throw C4AulExecError("CreateParticleAtBone: Dir is not a three-vector");
2250  dir.x = (*Dir).GetItem(0).getInt() / 10.0f;
2251  dir.y = (*Dir).GetItem(1).getInt() / 10.0f;
2252  dir.z = (*Dir).GetItem(2).getInt() / 10.0f;
2253  }
2254  else { dir.x = dir.y = dir.z = 0.0f; }
2255  // Apply the bone transformation to them, to go from bone coordinates
2256  // to mesh coordinates.
2257  // This is a good example why we should have different types for
2258  // position vectors and displacement vectors. TODO.
2259  StdMeshVector transformed_x = transform * x;
2260  transformed_x.x += transform(0,3);
2261  transformed_x.y += transform(1,3);
2262  transformed_x.z += transform(2,3);
2263  x = transformed_x;
2264  dir = transform * dir;
2265  // Apply MeshTransformation in the mesh reference frame
2266  C4Value value;
2267  Obj->GetProperty(P_MeshTransformation, &value);
2268  StdMeshMatrix MeshTransform;
2269  if (!C4ValueToMatrix(value, &MeshTransform))
2270  MeshTransform = StdMeshMatrix::Identity();
2271  x = MeshTransform * x;
2272  dir = MeshTransform * dir;
2273  x.x += MeshTransform(0,3);
2274  x.y += MeshTransform(1,3);
2275  x.z += MeshTransform(2,3);
2276  // Now go to world coordinates -- this code is copied from and needs to
2277  // stay in sync with C4DrawGL::PerformMesh, so the particles are
2278  // created at the correct position.
2279  // TODO: This should be moved into a common function.
2280  const StdMeshBox& box = mesh.GetBoundingBox();
2281  StdMeshVector v1, v2;
2282  v1.x = box.x1; v1.y = box.y1; v1.z = box.z1;
2283  v2.x = box.x2; v2.y = box.y2; v2.z = box.z2;
2284  const float tx = fixtof(Obj->fix_x) + Obj->Def->Shape.GetX();
2285  const float ty = fixtof(Obj->fix_y) + Obj->Def->Shape.GetY();
2286  const float twdt = Obj->Def->Shape.Wdt;
2287  const float thgt = Obj->Def->Shape.Hgt;
2288  const float rx = -std::min(v1.x,v2.x) / fabs(v2.x - v1.x);
2289  const float ry = -std::min(v1.y,v2.y) / fabs(v2.y - v1.y);
2290  const float dx = tx + rx*twdt;
2291  const float dy = ty + ry*thgt;
2292  x.x += dx;
2293  x.y += dy;
2294  // This was added in the block before and could also just be removed from tx/ty.
2295  // However, the block would no longer be equal to where it came from.
2296  x.x -= fixtof(Obj->fix_x);
2297  x.y -= fixtof(Obj->fix_y);
2298  // Finally, apply DrawTransform to the world coordinates,
2299  // and incorporate object rotation into the transformation
2300  C4DrawTransform draw_transform;
2301  if(Obj->pDrawTransform)
2302  {
2303  draw_transform.SetTransformAt(*Obj->pDrawTransform, fixtof(Obj->fix_x), fixtof(Obj->fix_y));
2304  draw_transform.Rotate(fixtof(Obj->fix_r), 0.0f, 0.0f);
2305  }
2306  else
2307  {
2308  draw_transform.SetRotate(fixtof(Obj->fix_r), 0.0f, 0.0f);
2309  }
2310 
2311  StdMeshMatrix DrawTransform;
2312  DrawTransform(0, 0) = draw_transform.mat[0];
2313  DrawTransform(0, 1) = draw_transform.mat[1];
2314  DrawTransform(0, 2) = 0.0f;
2315  DrawTransform(0, 3) = draw_transform.mat[2];
2316  DrawTransform(1, 0) = draw_transform.mat[3];
2317  DrawTransform(1, 1) = draw_transform.mat[4];
2318  DrawTransform(1, 2) = 0.0f;
2319  DrawTransform(1, 3) = draw_transform.mat[5];
2320  DrawTransform(2, 0) = 0.0f;
2321  DrawTransform(2, 1) = 0.0f;
2322  DrawTransform(2, 2) = 1.0f;
2323  DrawTransform(2, 3) = 0.0f;
2324 
2325  x = DrawTransform * x;
2326  dir = DrawTransform * dir;
2327  x.x += DrawTransform(0,3);
2328  x.y += DrawTransform(1,3);
2329  x.z += DrawTransform(2,3);
2330 
2331  // construct data
2332  C4ParticleValueProvider valueX, valueY, valueSpeedX, valueSpeedY, valueLifetime;
2333  valueX.Set(x.x);
2334  valueY.Set(x.y);
2335  valueSpeedX.Set(dir.x);
2336  valueSpeedY.Set(dir.y);
2337  valueLifetime.Set(lifetime);
2338 
2339  // cast
2340  if (amount < 1) amount = 1;
2341  ::Particles.Create(pDef, valueX, valueY, valueSpeedX, valueSpeedY, valueLifetime, properties, amount, Obj);
2342 #endif
2343  // success, even if not created
2344  return true;
2345 
2346 }
2347 
2348 static Nillable<long> FnGetDefWidth(C4PropList * _this)
2349 {
2350  if (!_this) return C4Void();
2351  C4Def *def = _this->GetDef();
2352  if (!def) return C4Void();
2353  return def->Shape.Wdt;
2354 }
2355 
2356 static Nillable<long> FnGetDefHeight(C4PropList * _this)
2357 {
2358  if (!_this) return C4Void();
2359  C4Def *def = _this->GetDef();
2360  if (!def) return C4Void();
2361  return def->Shape.Hgt;
2362 }
2363 
2364 //=========================== C4Script Function Map ===================================
2365 
2367 {
2368  { "C4D_None" ,C4V_Int, C4D_None},
2369  { "C4D_All" ,C4V_Int, C4D_All},
2370  { "C4D_StaticBack" ,C4V_Int, C4D_StaticBack},
2371  { "C4D_Structure" ,C4V_Int, C4D_Structure},
2372  { "C4D_Vehicle" ,C4V_Int, C4D_Vehicle},
2373  { "C4D_Living" ,C4V_Int, C4D_Living},
2374  { "C4D_Object" ,C4V_Int, C4D_Object},
2375  { "C4D_Goal" ,C4V_Int, C4D_Goal},
2376  { "C4D_Environment" ,C4V_Int, C4D_Environment},
2377  { "C4D_Rule" ,C4V_Int, C4D_Rule},
2378  { "C4D_Background" ,C4V_Int, C4D_Background},
2379  { "C4D_Parallax" ,C4V_Int, C4D_Parallax},
2380  { "C4D_MouseSelect" ,C4V_Int, C4D_MouseSelect},
2381  { "C4D_Foreground" ,C4V_Int, C4D_Foreground},
2382  { "C4D_MouseIgnore" ,C4V_Int, C4D_MouseIgnore},
2383  { "C4D_IgnoreFoW" ,C4V_Int, C4D_IgnoreFoW},
2384 
2385  { "C4D_GrabGet" ,C4V_Int, C4D_Grab_Get},
2386  { "C4D_GrabPut" ,C4V_Int, C4D_Grab_Put},
2387 
2388  { "C4D_Border_Sides" ,C4V_Int, C4D_Border_Sides},
2389  { "C4D_Border_Top" ,C4V_Int, C4D_Border_Top},
2390  { "C4D_Border_Bottom" ,C4V_Int, C4D_Border_Bottom},
2391  { "C4D_Border_Layer" ,C4V_Int, C4D_Border_Layer},
2392 
2393  { "COMD_None" ,C4V_Int, COMD_None},
2394  { "COMD_Stop" ,C4V_Int, COMD_Stop},
2395  { "COMD_Up" ,C4V_Int, COMD_Up},
2396  { "COMD_UpRight" ,C4V_Int, COMD_UpRight},
2397  { "COMD_Right" ,C4V_Int, COMD_Right},
2398  { "COMD_DownRight" ,C4V_Int, COMD_DownRight},
2399  { "COMD_Down" ,C4V_Int, COMD_Down},
2400  { "COMD_DownLeft" ,C4V_Int, COMD_DownLeft},
2401  { "COMD_Left" ,C4V_Int, COMD_Left},
2402  { "COMD_UpLeft" ,C4V_Int, COMD_UpLeft},
2403 
2404  { "DIR_Left" ,C4V_Int, DIR_Left},
2405  { "DIR_Right" ,C4V_Int, DIR_Right},
2406 
2407  { "OCF_Construct" ,C4V_Int, OCF_Construct},
2408  { "OCF_Grab" ,C4V_Int, OCF_Grab},
2409  { "OCF_Collectible" ,C4V_Int, OCF_Carryable},
2410  { "OCF_OnFire" ,C4V_Int, OCF_OnFire},
2411  { "OCF_HitSpeed1" ,C4V_Int, OCF_HitSpeed1},
2412  { "OCF_Fullcon" ,C4V_Int, OCF_FullCon},
2413  { "OCF_Inflammable" ,C4V_Int, OCF_Inflammable},
2414  { "OCF_Rotate" ,C4V_Int, OCF_Rotate},
2415  { "OCF_Exclusive" ,C4V_Int, OCF_Exclusive},
2416  { "OCF_Entrance" ,C4V_Int, OCF_Entrance},
2417  { "OCF_HitSpeed2" ,C4V_Int, OCF_HitSpeed2},
2418  { "OCF_HitSpeed3" ,C4V_Int, OCF_HitSpeed3},
2419  { "OCF_Collection" ,C4V_Int, OCF_Collection},
2420  { "OCF_HitSpeed4" ,C4V_Int, OCF_HitSpeed4},
2421  { "OCF_NotContained" ,C4V_Int, OCF_NotContained},
2422  { "OCF_CrewMember" ,C4V_Int, OCF_CrewMember},
2423  { "OCF_InLiquid" ,C4V_Int, OCF_InLiquid},
2424  { "OCF_InSolid" ,C4V_Int, OCF_InSolid},
2425  { "OCF_InFree" ,C4V_Int, OCF_InFree},
2426  { "OCF_Available" ,C4V_Int, OCF_Available},
2427  { "OCF_Container" ,C4V_Int, OCF_Container},
2428  { "OCF_Alive" ,C4V_Int, (int) OCF_Alive},
2429 
2430  { "VIS_All" ,C4V_Int, VIS_All},
2431  { "VIS_None" ,C4V_Int, VIS_None},
2432  { "VIS_Owner" ,C4V_Int, VIS_Owner},
2433  { "VIS_Allies" ,C4V_Int, VIS_Allies},
2434  { "VIS_Enemies" ,C4V_Int, VIS_Enemies},
2435  { "VIS_Select" ,C4V_Int, VIS_Select},
2436  { "VIS_God" ,C4V_Int, VIS_God},
2437  { "VIS_LayerToggle" ,C4V_Int, VIS_LayerToggle},
2438  { "VIS_OverlayOnly" ,C4V_Int, VIS_OverlayOnly},
2439  { "VIS_Editor" ,C4V_Int, VIS_Editor},
2440 
2441  { "C4MN_Style_Normal" ,C4V_Int, C4MN_Style_Normal},
2442  { "C4MN_Style_Context" ,C4V_Int, C4MN_Style_Context},
2443  { "C4MN_Style_Info" ,C4V_Int, C4MN_Style_Info},
2444  { "C4MN_Style_Dialog" ,C4V_Int, C4MN_Style_Dialog},
2445  { "C4MN_Style_EqualItemHeight",C4V_Int, C4MN_Style_EqualItemHeight},
2446 
2447  { "C4MN_Extra_None" ,C4V_Int, C4MN_Extra_None},
2448  { "C4MN_Extra_Value" ,C4V_Int, C4MN_Extra_Value},
2449  { "C4MN_Extra_Info" ,C4V_Int, C4MN_Extra_Info},
2450 
2451  { "C4MN_Add_ImgRank" ,C4V_Int, C4MN_Add_ImgRank},
2452  { "C4MN_Add_ImgIndexed" ,C4V_Int, C4MN_Add_ImgIndexed},
2453  { "C4MN_Add_ImgObjRank" ,C4V_Int, C4MN_Add_ImgObjRank},
2454  { "C4MN_Add_ImgObject" ,C4V_Int, C4MN_Add_ImgObject},
2455  { "C4MN_Add_ImgTextSpec" ,C4V_Int, C4MN_Add_ImgTextSpec},
2456  { "C4MN_Add_ImgPropListSpec",C4V_Int, C4MN_Add_ImgPropListSpec},
2457  { "C4MN_Add_ImgColor" ,C4V_Int, C4MN_Add_ImgColor},
2458  { "C4MN_Add_PassValue" ,C4V_Int, C4MN_Add_PassValue},
2459  { "C4MN_Add_ForceCount" ,C4V_Int, C4MN_Add_ForceCount},
2460  { "C4MN_Add_ForceNoDesc" ,C4V_Int, C4MN_Add_ForceNoDesc},
2461 
2462  { "GFXOV_MODE_None" ,C4V_Int, C4GraphicsOverlay::MODE_None }, // gfx overlay modes
2463  { "GFXOV_MODE_Base" ,C4V_Int, C4GraphicsOverlay::MODE_Base }, //
2464  { "GFXOV_MODE_Action" ,C4V_Int, C4GraphicsOverlay::MODE_Action }, //
2465  { "GFXOV_MODE_Picture" ,C4V_Int, C4GraphicsOverlay::MODE_Picture }, //
2466  { "GFXOV_MODE_IngamePicture" ,C4V_Int, C4GraphicsOverlay::MODE_IngamePicture }, //
2467  { "GFXOV_MODE_Object" ,C4V_Int, C4GraphicsOverlay::MODE_Object }, //
2468  { "GFXOV_MODE_ExtraGraphics" ,C4V_Int, C4GraphicsOverlay::MODE_ExtraGraphics }, //
2469  { "GFXOV_MODE_Rank" ,C4V_Int, C4GraphicsOverlay::MODE_Rank}, //
2470  { "GFXOV_MODE_ObjectPicture" ,C4V_Int, C4GraphicsOverlay::MODE_ObjectPicture}, //
2471  { "GFX_Overlay" ,C4V_Int, 1}, // default overlay index
2472  { "GFXOV_Clothing" ,C4V_Int, 1000}, // overlay indices for clothes on Clonks, etc.
2473  { "GFXOV_Tools" ,C4V_Int, 2000}, // overlay indices for tools, weapons, etc.
2474  { "GFXOV_ProcessTarget" ,C4V_Int, 3000}, // overlay indices for objects processed by a Clonk
2475  { "GFXOV_Misc" ,C4V_Int, 5000}, // overlay indices for other stuff
2476  { "GFXOV_UI" ,C4V_Int, 6000}, // overlay indices for user interface
2477  { "GFX_BLIT_Additive" ,C4V_Int, C4GFXBLIT_ADDITIVE}, // blit modes
2478  { "GFX_BLIT_Mod2" ,C4V_Int, C4GFXBLIT_MOD2}, //
2479  { "GFX_BLIT_ClrSfc_OwnClr" ,C4V_Int, C4GFXBLIT_CLRSFC_OWNCLR}, //
2480  { "GFX_BLIT_ClrSfc_Mod2" ,C4V_Int, C4GFXBLIT_CLRSFC_MOD2}, //
2481  { "GFX_BLIT_Wireframe" ,C4V_Int, C4GFXBLIT_WIREFRAME}, //
2482  { "GFX_BLIT_Custom" ,C4V_Int, C4GFXBLIT_CUSTOM}, //
2483  { "GFX_BLIT_Parent" ,C4V_Int, C4GFXBLIT_PARENT}, //
2484 
2485  // contact attachment
2486  { "CNAT_None" ,C4V_Int, CNAT_None },
2487  { "CNAT_Left" ,C4V_Int, CNAT_Left },
2488  { "CNAT_Right" ,C4V_Int, CNAT_Right },
2489  { "CNAT_Top" ,C4V_Int, CNAT_Top },
2490  { "CNAT_Bottom" ,C4V_Int, CNAT_Bottom },
2491  { "CNAT_Center" ,C4V_Int, CNAT_Center },
2492  { "CNAT_MultiAttach" ,C4V_Int, CNAT_MultiAttach },
2493  { "CNAT_NoCollision" ,C4V_Int, CNAT_NoCollision },
2494  { "CNAT_PhaseHalfVehicle" ,C4V_Int, CNAT_PhaseHalfVehicle },
2495 
2496  // vertex data
2497  { "VTX_X" ,C4V_Int, VTX_X },
2498  { "VTX_Y" ,C4V_Int, VTX_Y },
2499  { "VTX_CNAT" ,C4V_Int, VTX_CNAT },
2500  { "VTX_Friction" ,C4V_Int, VTX_Friction },
2501 
2502  // vertex set mode
2503  { "VTX_SetPermanent" ,C4V_Int, VTX_SetPermanent },
2504  { "VTX_SetPermanentUpd" ,C4V_Int, VTX_SetPermanentUpd },
2505 
2506  { "C4OS_DELETED" ,C4V_Int, C4OS_DELETED },
2507  { "C4OS_NORMAL" ,C4V_Int, C4OS_NORMAL },
2508  { "C4OS_INACTIVE" ,C4V_Int, C4OS_INACTIVE },
2509 
2510  { "C4CMD_Base" ,C4V_Int, C4CMD_Mode_Base },
2511  { "C4CMD_SilentBase" ,C4V_Int, C4CMD_Mode_SilentBase },
2512  { "C4CMD_Sub" ,C4V_Int, C4CMD_Mode_Sub },
2513  { "C4CMD_SilentSub" ,C4V_Int, C4CMD_Mode_SilentSub },
2514 
2515  { "C4CMD_MoveTo_NoPosAdjust" ,C4V_Int, C4CMD_MoveTo_NoPosAdjust },
2516  { "C4CMD_MoveTo_PushTarget" ,C4V_Int, C4CMD_MoveTo_PushTarget },
2517  { "C4CMD_Enter_PushTarget" ,C4V_Int, C4CMD_Enter_PushTarget },
2518 
2519  { "C4AVP_Const" ,C4V_Int, C4AVP_Const },
2520  { "C4AVP_Linear" ,C4V_Int, C4AVP_Linear },
2521  { "C4AVP_X" ,C4V_Int, C4AVP_X },
2522  { "C4AVP_Y" ,C4V_Int, C4AVP_Y },
2523  { "C4AVP_R" ,C4V_Int, C4AVP_R },
2524  { "C4AVP_AbsX" ,C4V_Int, C4AVP_AbsX },
2525  { "C4AVP_AbsY" ,C4V_Int, C4AVP_AbsY },
2526  { "C4AVP_Dist" ,C4V_Int, C4AVP_Dist },
2527  { "C4AVP_XDir" ,C4V_Int, C4AVP_XDir },
2528  { "C4AVP_YDir" ,C4V_Int, C4AVP_YDir },
2529  { "C4AVP_RDir" ,C4V_Int, C4AVP_RDir },
2530  { "C4AVP_AbsRDir" ,C4V_Int, C4AVP_AbsRDir },
2531  { "C4AVP_CosR" ,C4V_Int, C4AVP_CosR },
2532  { "C4AVP_SinR" ,C4V_Int, C4AVP_SinR },
2533  { "C4AVP_CosV" ,C4V_Int, C4AVP_CosV },
2534  { "C4AVP_SinV" ,C4V_Int, C4AVP_SinV },
2535  { "C4AVP_Action" ,C4V_Int, C4AVP_Action },
2536 
2537  { "ANIM_Loop" ,C4V_Int, ANIM_Loop },
2538  { "ANIM_Hold" ,C4V_Int, ANIM_Hold },
2539  { "ANIM_Remove" ,C4V_Int, ANIM_Remove },
2540 
2541  { "AM_None" ,C4V_Int, StdMeshInstance::AM_None },
2542  { "AM_DrawBefore" ,C4V_Int, StdMeshInstance::AM_DrawBefore },
2543  { "AM_MatchSkeleton" ,C4V_Int, StdMeshInstance::AM_MatchSkeleton },
2544 
2545  { nullptr, C4V_Nil, 0}
2546 };
2547 
2548 
2550 {
2551  // add all def constants (all Int)
2552  for (C4ScriptConstDef *pCDef = &C4ScriptObjectConstMap[0]; pCDef->Identifier; pCDef++)
2553  {
2554  assert(pCDef->ValType == C4V_Int); // only int supported currently
2555  pEngine->RegisterGlobalConstant(pCDef->Identifier, C4VInt(pCDef->Data));
2556  }
2557  C4PropListStatic * p = pEngine->GetPropList();
2558 #define F(f) ::AddFunc(p, #f, Fn##f)
2559 
2560  F(DoCon);
2561  F(GetCon);
2562  F(DoDamage);
2563  F(DoEnergy);
2564  F(DoBreath);
2565  F(GetEnergy);
2566  F(OnFire);
2567  F(Stuck);
2568  F(InLiquid);
2569  F(SetAction);
2570  F(SetActionData);
2571 
2572  F(SetBridgeActionData);
2573  F(GetAction);
2574  F(GetActTime);
2575  F(GetOwner);
2576  F(GetMass);
2577  F(GetBreath);
2578  F(GetMenu);
2579  F(GetVertexNum);
2580  F(GetVertex);
2581  F(SetVertex);
2582  F(AddVertex);
2583  F(InsertVertex);
2584  F(RemoveVertex);
2585  ::AddFunc(p, "SetContactDensity", FnSetContactDensity, false);
2586  F(GetController);
2587  F(SetController);
2588  F(SetName);
2589  F(GetKiller);
2590  F(SetKiller);
2591  F(GetPhase);
2592  F(SetPhase);
2593  F(GetCategory);
2594  F(GetOCF);
2595  F(SetAlive);
2596  F(GetAlive);
2597  F(GetDamage);
2598  F(SetComDir);
2599  F(GetComDir);
2600  F(SetDir);
2601  F(GetDir);
2602  F(SetEntrance);
2603  F(GetEntrance);
2604  F(SetCategory);
2605  F(FinishCommand);
2606  F(ActIdle);
2607  F(SetRDir);
2608  F(GetRDir);
2609  F(GetXDir);
2610  F(GetYDir);
2611  F(GetR);
2612  F(SetXDir);
2613  F(SetYDir);
2614  F(SetR);
2615  F(SetOwner);
2616  F(MakeCrewMember);
2617  F(GrabObjectInfo);
2618  F(CreateContents);
2619  F(ShiftContents);
2620  F(GetID);
2621  F(Contents);
2622  F(ScrollContents);
2623  F(Contained);
2624  F(ContentsCount);
2625  ::AddFunc(p, "FindContents", FnFindContents, false);
2626  ::AddFunc(p, "FindOtherContents", FnFindOtherContents, false);
2627  F(RemoveObject);
2628  F(GetActionTarget);
2629  F(SetActionTargets);
2630  ::AddFunc(p, "SetCrewStatus", FnSetCrewStatus, false);
2631  F(SetPosition);
2632  F(CreateMenu);
2633  F(AddMenuItem);
2634  F(SelectMenuItem);
2635  F(SetMenuDecoration);
2636  F(SetMenuTextProgress);
2637  F(ObjectDistance);
2638  F(GetValue);
2639  F(GetRank);
2640  F(SetTransferZone);
2641  F(SetMass);
2642  F(GetColor);
2643  F(SetColor);
2644  F(SetLightRange);
2645  F(GetLightColor);
2646  F(SetLightColor);
2647  F(SetPicture);
2648  F(GetProcedure);
2649  F(CanConcatPictureWith);
2650  F(SetGraphics);
2651  F(ObjectNumber);
2652  F(ShowInfo);
2653  F(CheckVisibility);
2654  F(SetClrModulation);
2656  F(CloseMenu);
2657  F(GetMenuSelection);
2658  F(GetDefBottom);
2659  F(SetMenuSize);
2660  F(GetCrewEnabled);
2661  F(SetCrewEnabled);
2662  F(DoCrewExp);
2663  F(ClearMenuItems);
2664  F(GetObjectLayer);
2665  F(SetObjectLayer);
2666  F(SetShape);
2667  F(SetObjDrawTransform);
2668  ::AddFunc(p, "SetObjDrawTransform2", FnSetObjDrawTransform2, false);
2669  ::AddFunc(p, "SetObjectStatus", FnSetObjectStatus, false);
2670  ::AddFunc(p, "GetObjectStatus", FnGetObjectStatus, false);
2671  ::AddFunc(p, "AdjustWalkRotation", FnAdjustWalkRotation, false);
2672  F(GetContact);
2673  F(SetObjectBlitMode);
2674  F(GetObjectBlitMode);
2675  ::AddFunc(p, "GetUnusedOverlayID", FnGetUnusedOverlayID, false);
2676  F(ExecuteCommand);
2677 
2678  F(PlayAnimation);
2679  F(TransformBone);
2680  F(StopAnimation);
2681  F(GetRootAnimation);
2682  F(GetAnimationList);
2683  F(GetAnimationLength);
2684  F(GetAnimationName);
2685  F(GetAnimationPosition);
2686  F(GetAnimationWeight);
2687  F(SetAnimationPosition);
2688  F(SetAnimationBoneTransform);
2689  F(SetAnimationWeight);
2690  F(AttachMesh);
2691  F(DetachMesh);
2692  F(SetAttachBones);
2693  F(SetAttachTransform);
2694  F(GetMeshMaterial);
2695  F(SetMeshMaterial);
2696  F(CreateParticleAtBone);
2697  F(ChangeDef);
2698  F(GrabContents);
2699  F(Punch);
2700  F(Kill);
2701  F(Fling);
2702  ::AddFunc(p, "Jump", FnJump, false);
2703  F(Enter);
2704  F(DeathAnnounce);
2705  F(SetSolidMask);
2706  F(SetHalfVehicleSolidMask);
2707  F(Exit);
2708  F(Collect);
2709 
2710  F(SetCommand);
2711  F(AddCommand);
2712  F(AppendCommand);
2713  F(GetCommand);
2714  F(SetCrewExtraData);
2715  F(GetCrewExtraData);
2716  F(GetDefWidth);
2717  F(GetDefHeight);
2718 #undef F
2719 }
const char * getData() const
Definition: StdBuf.h:442
const int32_t C4MaxPhysical
Definition: C4InfoCore.h:28
float y2
Definition: StdMesh.h:147
C4PropertyName GetPropertyP(C4PropertyName k) const
Definition: C4PropList.cpp:855
int32_t GetY() const
Definition: C4Object.h:287
const uint32_t OCF_HitSpeed1
Definition: C4Constants.h:84
const int C4MN_Add_ImgRank
int32_t GetItemHeight()
Definition: C4Menu.h:166
#define VIS_God
Definition: C4Object.h:68
int32_t CommandByName(const char *szCommand)
Definition: C4Command.cpp:127
bool IsContextMenu()
Definition: C4Menu.h:164
const StdMeshMaterial & GetMaterial() const
Definition: StdMesh.h:170
const int C4MN_Add_ImgPropListSpec
StdStrBuf GetData() const
Definition: C4StringTable.h:50
const int C4MN_Add_ForceNoDesc
void RegisterGlobalConstant(const char *szName, const C4Value &rValue)
bool IsValid(const C4Object *pForObj) const
bool SetLightColor(uint32_t iValue)
Definition: C4Object.cpp:4017
#define COMD_UpRight
Definition: C4Object.h:52
bool SetSelection(int32_t iSelection, bool fAdjustPosition, bool fDoCalls)
Definition: C4Menu.cpp:544
#define VIS_OverlayOnly
Definition: C4Object.h:70
C4ID id
Definition: C4Def.h:101
void GrabContents(C4Object *pFrom)
Definition: C4Object.cpp:4741
C4DrawTransform * pDrawTransform
Definition: C4Object.h:137
DWORD GetClrModulation(DWORD dwSrcClr, DWORD dwDstClr, DWORD &dwBack)
Definition: StdColors.h:112
bool Add(const char *szCaption, C4FacetSurface &fctSymbol, const char *szCommand, int32_t iCount=C4MN_Item_NoCount, C4Object *pObject=nullptr, const char *szInfoCaption=nullptr, C4ID idID=C4ID::None, const char *szCommand2=nullptr, bool fOwnValue=false, int32_t iValue=0, bool fIsSelectable=true)
Definition: C4Menu.cpp:350
void SetTransformAt(C4DrawTransform &rCopy, float iOffX, float iOffY)
Definition: C4Facet.cpp:541
void SetAlive(bool Alive)
Definition: C4Object.h:304
int32_t iNumRankSymbols
Definition: C4Def.h:190
const uint32_t OCF_Alive
Definition: C4Constants.h:103
const int32_t C4D_Environment
Definition: C4Def.h:48
const char * CommandName(int32_t iCommand)
Definition: C4Command.cpp:47
bool Enter(C4Object *pTarget, bool fCalls=true, bool fCopyMotion=true, bool *pfRejectCollect=nullptr)
Definition: C4Object.cpp:1260
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:152
#define C4GFXBLIT_MOD2
Definition: C4Surface.h:27
void SAppendChar(char cChar, char *szStr)
Definition: Standard.cpp:265
const uint32_t OCF_Entrance
Definition: C4Constants.h:90
const size_t C4MaxTitle
Definition: C4Constants.h:25
const uint32_t OCF_Collection
Definition: C4Constants.h:93
void ForcePosition(C4Real tx, C4Real ty)
Definition: C4Movement.cpp:515
int32_t GetCon() const
Definition: C4Object.h:272
const int32_t C4D_Vehicle
Definition: C4Def.h:42
C4ObjectPtr Cursor
Definition: C4Player.h:130
void SetSize(int32_t iToWdt, int32_t iToHgt)
Definition: C4Menu.cpp:617
virtual bool Add(C4Object *nObj, SortType eSort, C4ObjectList *pLstSorted=nullptr)
void SetHalfVehicleSolidMask(bool set)
Definition: C4Object.cpp:2468
void SetAsPicture(C4DefGraphics *pBaseGfx, DWORD dwBMode)
int32_t Time
Definition: C4Object.h:83
const int C4MN_Add_ImgColor
#define COMD_Down
Definition: C4Object.h:55
void SetAsObject(C4Object *pOverlayObj, DWORD dwBMode)
C4PropListStatic * GetPropList()
Definition: C4Aul.h:151
bool MakeCrewMember(C4Object *pObj, bool fForceInfo=true, bool fDoCalls=true)
Definition: C4Player.cpp:1008
const int32_t C4CMD_Mode_Base
Definition: C4Command.h:60
const C4Real Fix1
Definition: C4Real.h:313
C4String * getStr() const
Definition: C4Value.h:117
int32_t AttachMat
Definition: C4Shape.h:50
#define PSF_CrewEnabled
Definition: C4GameScript.h:148
int32_t ViewMode
Definition: C4Player.h:105
bool GetProperty(C4PropertyName k, C4Value *pResult) const
Definition: C4PropList.h:101
C4Game Game
Definition: C4Globals.cpp:52
const StdMeshMaterial & GetMaterial() const
Definition: StdMesh.h:270
int32_t GetY() const
Definition: C4Shape.h:63
bool ObjectComCancelAttach(C4Object *cObj)
NodeType GetType() const
Definition: StdMesh.h:347
#define COMD_DownRight
Definition: C4Object.h:54
C4Command * Next
Definition: C4Command.h:90
void SetDir(int32_t tdir)
Definition: C4Object.cpp:2840
C4String * String(const char *str)
Definition: C4AulDefFunc.h:30
int32_t GetValue(C4Object *pInBase, int32_t iForPlayer)
Definition: C4Object.cpp:1687
void InitObjectFunctionMap(C4AulScriptEngine *pEngine)
uint32_t UnsyncedRandom()
Definition: C4Random.cpp:58
bool StatusDeactivate(bool fClearPointers)
Definition: C4Object.cpp:4549
C4Scenario C4S
Definition: C4Game.h:74
const BYTE CNAT_PhaseHalfVehicle
Definition: C4Constants.h:117
C4ParticleSystem Particles
#define sprintf
Definition: Standard.h:164
const uint32_t OCF_NotContained
Definition: C4Constants.h:96
int GetBottom()
Definition: C4Shape.cpp:468
int32_t Mass
Definition: C4Object.h:115
void SetFaceOrderingForClrModulation(uint32_t clrmod)
Definition: StdMesh.cpp:1133
C4Rect PictureRect
Definition: C4Object.h:151
bool SetGraphics(const char *szGraphicsName=nullptr, C4Def *pSourceDef=nullptr)
Definition: C4Object.cpp:4446
void AssignDeath(bool fForced)
Definition: C4Object.cpp:989
bool DebugLog(const char *strMessage)
Definition: C4Log.cpp:280
const char * SSearch(const char *szString, const char *szIndex)
Definition: Standard.cpp:363
void DoBreath(int32_t iChange)
Definition: C4Object.cpp:1143
bool Init(C4FacetSurface &fctSymbol, const char *szEmpty, C4Object *pObject, int32_t iExtra=C4MN_Extra_None, int32_t iExtraData=0, int32_t iId=0, int32_t iStyle=C4MN_Style_Normal, bool fUserMenu=false)
void MakeValidName(char *sName)
const int32_t C4CMD_Mode_SilentBase
Definition: C4Command.h:61
C4PropList * GetAction() const
Definition: C4Object.cpp:2674
#define DIR_Right
Definition: C4Object.h:42
AttachedMesh * GetAttachedMeshByNumber(unsigned int number) const
Definition: StdMesh.cpp:1417
C4Command * Command
Definition: C4Object.h:166
#define C4OS_NORMAL
Definition: C4Object.h:35
const char * GetCStr() const
Definition: C4StringTable.h:49
int32_t OwnMass
Definition: C4Object.h:115
#define VIS_Enemies
Definition: C4Object.h:66
C4Real rdir
Definition: C4Object.h:126
float x2
Definition: StdMesh.h:147
int32_t ContactDensity
Definition: C4Shape.h:47
C4Value C4VInt(int32_t i)
Definition: C4Value.h:242
bool SetActionByName(C4String *ActName, C4Object *pTarget=nullptr, C4Object *pTarget2=nullptr, int32_t iCalls=SAC_StartCall|SAC_AbortCall, bool fForce=false)
Definition: C4Object.cpp:2814
StdCopyStrBuf Name
Definition: StdMesh.h:97
#define C4GFXBLIT_ADDITIVE
Definition: C4Surface.h:26
float z1
Definition: StdMesh.h:146
bool ShiftContents(bool fShiftBack, bool fDoCalls)
Definition: C4Object.cpp:4219
StdMeshTransformation Transformation
Definition: StdMesh.h:37
int32_t Ty
Definition: C4Command.h:83
const int32_t C4D_Border_Sides
Definition: C4Def.h:65
const uint32_t OCF_Container
Definition: C4Constants.h:102
#define C4FxCall_EngScript
Definition: C4Effect.h:55
bool AddCommand(int32_t iCommand, C4Object *pTarget, C4Value iTx, int32_t iTy=0, int32_t iUpdateInterval=0, C4Object *pTarget2=nullptr, bool fInitEvaluation=true, C4Value iData=C4VNull, bool fAppend=false, int32_t iRetries=0, C4String *szText=nullptr, int32_t iBaseMode=0)
Definition: C4Object.cpp:2562
void UpdateInLiquid()
Definition: C4Object.cpp:4694
const uint32_t OCF_InSolid
Definition: C4Constants.h:99
int32_t FlipDir
Definition: C4Facet.h:50
const uint32_t OCF_CrewMember
Definition: C4Constants.h:97
AnimationNode * GetRootAnimationForSlot(int slot)
Definition: StdMesh.cpp:1251
bool SetByDef(C4Def *pSrcDef)
char DeathMessage[C4MaxDeathMsg+1]
Definition: C4InfoCore.h:48
Definition: C4Menu.h:122
const BYTE CNAT_NoCollision
Definition: C4Constants.h:116
bool AddVertex(int32_t iX, int32_t iY)
Definition: C4Shape.cpp:28
const StdMeshSkeleton & GetSkeleton() const
Definition: StdMesh.h:203
int32_t Finished
Definition: C4Command.h:87
const int C4MN_Add_ImgTextSpec
AnimationNode * GetAnimationNodeByNumber(unsigned int number)
Definition: StdMesh.cpp:1245
float z2
Definition: StdMesh.h:147
int GetSymbolSize()
Definition: C4Menu.h:165
bool SetChildBone(const StdStrBuf &bone)
Definition: StdMesh.cpp:999
bool getBool() const
Definition: C4Value.h:113
const int C4MN_Add_PassValue
StdMeshInstance * Child
Definition: StdMesh.h:511
bool SetTextProgress(int32_t iToProgress, bool fAdd)
Definition: C4Menu.cpp:958
C4Value Tx
Definition: C4Command.h:82
int32_t Breath
Definition: C4Object.h:118
size_t SLen(const char *sptr)
Definition: Standard.h:74
C4GraphicsResource GraphicsResource
const int32_t C4D_Border_Top
Definition: C4Def.h:66
void DirectComContents(C4Object *pTarget, bool fDoCalls)
Definition: C4Object.cpp:4243
void UpdatLastEnergyLossCause(int32_t iNewCausePlr)
Definition: C4Object.cpp:1132
bool SEqual(const char *szStr1, const char *szStr2)
Definition: Standard.h:93
C4ObjectPtr Target2
Definition: C4Object.h:87
int32_t Mass
Definition: C4Def.h:114
#define VIS_Select
Definition: C4Object.h:67
void Set(float fA, float fB, float fC, float fD, float fE, float fF, float fG, float fH, float fI)
Definition: C4Facet.h:76
C4ObjectPtr Layer
Definition: C4Object.h:136
void SetSolidMask(int32_t iX, int32_t iY, int32_t iWdt, int32_t iHgt, int32_t iTX, int32_t iTY)
Definition: C4Object.cpp:2458
void SetAsRank(DWORD dwBMode, C4Object *rank_obj)
C4Value C4VObj(C4Object *pObj)
Definition: C4Value.cpp:88
size_t GetNumSubMeshes() const
Definition: StdMesh.h:588
void Set(const C4Facet &cpy)
Definition: C4FacetEx.h:46
void UpdateGraphics(bool fGraphicsChanged, bool fTemp=false)
Definition: C4Object.cpp:404
virtual C4Object * GetObject()
Definition: C4PropList.cpp:667
const int C4MN_Add_ImgObject
StdSubMeshInstance & GetSubMesh(size_t i)
Definition: StdMesh.h:589
const int32_t C4D_Grab_Get
Definition: C4Def.h:63
const uint32_t OCF_FullCon
Definition: C4Constants.h:85
C4ObjectInfo * Info
Definition: C4Object.h:145
#define C4OS_DELETED
Definition: C4Object.h:34
const int32_t C4CMD_Mode_SilentSub
Definition: C4Command.h:59
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
const char * GetName() const override
Definition: C4PropList.cpp:267
Definition: C4Real.h:58
ALWAYS_INLINE bool CheckConversion(C4V_Type vtToType) const
Definition: C4Value.h:189
const int C4MN_Add_MaxImage
virtual C4Def const * GetDef() const
Definition: C4PropList.cpp:685
bool Mobile
Definition: C4Object.h:128
const int32_t FullCon
Definition: C4Constants.h:181
int32_t Distance(int32_t iX1, int32_t iY1, int32_t iX2, int32_t iY2)
Definition: Standard.cpp:25
int32_t Energy
Definition: C4Object.h:117
void UpdatePos()
Definition: C4Object.cpp:370
int32_t Rotateable
Definition: C4Def.h:119
int32_t VtxFriction[C4D_MaxVertex]
Definition: C4Shape.h:46
int32_t AddName(const char *pnName)
Definition: C4ValueMap.cpp:429
int32_t Wdt
Definition: C4Rect.h:30
C4DefGraphics * Get(const char *szGrpName)
const int32_t C4D_IgnoreFoW
Definition: C4Def.h:55
const uint32_t OCF_Inflammable
Definition: C4Constants.h:86
const int32_t C4D_MouseSelect
Definition: C4Def.h:52
bool InLiquid
Definition: C4Object.h:131
void SetAsIngamePicture(C4DefGraphics *pBaseGfx, DWORD dwBMode)
C4Player * Get(int iPlayer) const
const StdMeshMatrix & GetBoneTransform(size_t i) const
Definition: StdMesh.cpp:1444
class C4ObjectMenu * Menu
Definition: C4Object.h:140
bool Set(int32_t iX, int32_t iY, int32_t iWdt, int32_t iHgt, C4Object *pObj)
const uint32_t OCF_HitSpeed2
Definition: C4Constants.h:91
int iResult
Definition: C4GroupMain.cpp:39
bool CloseMenu(bool fForce)
Definition: C4Object.cpp:1570
const int32_t C4D_Grab_Put
Definition: C4Def.h:62
const int32_t C4D_Border_Bottom
Definition: C4Def.h:67
const int32_t C4D_Object
Definition: C4Def.h:44
void Set(float fA, float fB, float fC, float fD, float fE, float fF, float fG, float fH, float fI)
const int32_t MNone
Definition: C4Constants.h:177
void CreateOwnOriginalCopy(C4Shape &rFrom)
Definition: C4Shape.cpp:508
const BYTE CNAT_MultiAttach
Definition: C4Constants.h:115
C4NotifyingObjectList Contents
Definition: C4Object.h:152
bool DebugLogF(const char *strMessage...)
Definition: C4Log.cpp:288
C4Shape Shape
Definition: C4Def.h:104
unsigned int GetNumber() const
Definition: StdMesh.h:346
bool IsNil() const
Definition: C4AulDefFunc.h:57
C4Def * Def
Definition: C4Object.h:143
#define VIS_Owner
Definition: C4Object.h:64
int32_t t_attach
Definition: C4Object.h:86
C4String * Text
Definition: C4Command.h:89
bool StatusActivate()
Definition: C4Object.cpp:4533
bool CrewDisabled
Definition: C4Object.h:163
void SetAsExtraGraphics(C4DefGraphics *pGfx, DWORD dwBMode)
#define C4D_VertexCpyPos
Definition: C4Rect.h:23
AnimationNode * PlayAnimation(const StdStrBuf &animation_name, int slot, AnimationNode *sibling, ValueProvider *position, ValueProvider *weight, bool stop_previous_animation)
Definition: StdMesh.cpp:1165
void UpdateShape(bool bUpdateVertices=true)
Definition: C4Object.cpp:343
const int C4MN_Add_ForceCount
#define DIR_Left
Definition: C4Object.h:41
int32_t y
Definition: C4Rect.h:30
void SetAsBase(C4DefGraphics *pBaseGfx, DWORD dwBMode)
C4V_Type GetType() const
Definition: C4Value.h:161
bool ObjectComPunch(C4Object *cObj, C4Object *pTarget, int32_t punch)
C4Real GetWeight() const
Definition: StdMesh.h:357
bool IsMesh() const
Definition: C4DefGraphics.h:73
const char * GetTypeName() const
Definition: C4Value.h:164
bool GetOnFire() const
Definition: C4Object.h:303
int32_t GetR() const
Definition: C4Object.h:288
const int32_t C4CMD_MoveTo_NoPosAdjust
Definition: C4Command.h:65
static bool DrawRankSymbol(C4FacetSurface *fctSymbol, int32_t iRank, C4Facet *pfctRankSymbols, int32_t iRankSymbolCount, bool fOwnSurface, int32_t iXOff=0, C4Facet *cgoDrawDirect=nullptr)
#define COMD_DownLeft
Definition: C4Object.h:56
void SetViewMode(int32_t iMode, C4Object *pTarget=nullptr, bool immediate_position=false)
Definition: C4Player.cpp:767
void StopAnimation(AnimationNode *node)
Definition: StdMesh.cpp:1188
#define COMD_None
Definition: C4Object.h:49
void ClearItems()
Definition: C4Menu.cpp:895
virtual const char * GetName() const
Definition: C4PropList.cpp:649
int32_t Failures
Definition: C4Command.h:88
C4ValueMapNames * pNames
Definition: C4ValueMap.h:44
int32_t Command
Definition: C4Command.h:81
C4PropList * GetPrototype() const
Definition: C4PropList.h:81
#define C4GFXBLIT_CLRSFC_OWNCLR
Definition: C4Surface.h:28
bool ObjectComJump(C4Object *cObj)
uint32_t GetBlitMode() const
static const C4ID None
Definition: C4Id.h:39
int32_t GetVertexContact(int32_t iVtx, DWORD dwCheckMask, int32_t tx, int32_t ty, const C4DensityProvider &rDensityProvider=DefaultDensityProvider)
Definition: C4Shape.cpp:488
StdMeshInstance::ValueProvider * CreateValueProviderFromArray(C4Object *pForObj, C4ValueArray &Data, const StdMeshAnimation *pos_for_animation)
float y1
Definition: StdMesh.h:146
#define C4Fx_AnyFire
Definition: C4Effect.h:151
int32_t Owner
Definition: C4Object.h:110
C4PlayerList Players
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:1224
int32_t GetX() const
Definition: C4Shape.h:62
uint32_t Color
Definition: C4Object.h:120
C4ValueMapData ExtraData
Definition: C4InfoCore.h:49
const int32_t C4CMD_MoveTo_PushTarget
Definition: C4Command.h:66
int32_t VtxNum
Definition: C4Shape.h:42
const StdMeshAnimation * GetAnimationByName(const StdStrBuf &name) const
Definition: StdMesh.cpp:396
void Draw(C4Facet &cgo, bool fSelected=false, DWORD iColor=0, C4Object *pObj=nullptr, int32_t iPhaseX=0, int32_t iPhaseY=0, C4DrawTransform *trans=nullptr, const char *graphicsName=nullptr)
Definition: C4Def.cpp:597
#define C4GFXBLIT_WIREFRAME
Definition: C4Surface.h:30
int32_t GetX() const
Definition: C4Object.h:286
bool EntranceStatus
Definition: C4Object.h:132
const int32_t C4D_All
Definition: C4Def.h:39
#define L2F(l)
void AssignRemoval(bool fExitContents=false)
Definition: C4Object.cpp:254
int32_t VtxX[C4D_MaxVertex]
Definition: C4Shape.h:43
Definition: C4Def.h:98
C4TransferZones TransferZones
Definition: C4Game.h:85
const unsigned int C4MaxName
const int NO_OWNER
Definition: C4Constants.h:137
C4Fixed itofix(int32_t x)
Definition: C4Real.h:261
const int32_t C4D_Background
Definition: C4Def.h:50
const uint32_t OCF_InLiquid
Definition: C4Constants.h:98
bool SetObjectCrewStatus(C4Object *pCrew, bool fNewStatus)
Definition: C4Player.cpp:1556
char Name[C4MaxName+1]
Definition: C4InfoCore.h:37
bool SetOwner(int32_t iOwner)
Definition: C4Object.cpp:3980
bool RemoveVertex(int32_t iPos)
Definition: C4Shape.cpp:326
C4Object * GetObject(int Index=0) const
int32_t Status
Definition: C4PropList.h:168
void UpdateMass()
Definition: C4Object.cpp:639
C4ValueArray * getArray() const
Definition: C4Value.h:118
void SetBlitMode(uint32_t dwToMode)
void SetCommand(int32_t iCommand, C4Object *pTarget, C4Value iTx, int32_t iTy=0, C4Object *pTarget2=nullptr, bool fControl=false, C4Value iData=C4VNull, int32_t iRetries=0, C4String *szText=nullptr)
Definition: C4Object.cpp:2595
const uint32_t OCF_Rotate
Definition: C4Constants.h:88
const int32_t C4D_StaticBack
Definition: C4Def.h:40
bool Collect(C4Object *pObj)
Definition: C4Object.cpp:4167
const char * GetC4VName(const C4V_Type Type)
Definition: C4Value.cpp:32
int32_t GetSelection()
Definition: C4Menu.cpp:599
C4Fixed ftofix(float x)
Definition: C4Real.h:258
const int32_t C4D_Rule
Definition: C4Def.h:47
bool AddMenuItem(C4ConsoleGUI *console, HMENU hMenu, DWORD dwID, const char *szString, bool fEnabled)
void SetAttachTransformation(const StdMeshMatrix &transformation)
Definition: StdMesh.cpp:1009
Definition: C4Id.h:25
bool NameExists(const char *szName)
int32_t GetIdentification()
Definition: C4Menu.cpp:612
int32_t GetSize() const
Definition: C4ValueArray.h:36
#define COMD_Right
Definition: C4Object.h:53
void BoundsCheck(C4Real &ctcox, C4Real &ctcoy)
Definition: C4Object.h:331
C4ObjectPtr Target
Definition: C4Command.h:84
int32_t Damage
Definition: C4Object.h:116
void UpdateFace(bool bUpdateShape, bool fTemp=false)
Definition: C4Object.cpp:378
const int C4MN_Add_ImgObjRank
const uint32_t OCF_Exclusive
Definition: C4Constants.h:89
C4ParticleSystemDefinitionList definitions
Definition: C4Particles.h:510
#define COMD_Stop
Definition: C4Object.h:50
int32_t Category
Definition: C4Object.h:113
bool IsActive()
Definition: C4Menu.cpp:480
void DoCon(int32_t iChange, bool grow_from_center)
Definition: C4Object.cpp:1152
C4Effect * Get(const char *szName, int32_t iIndex=0, int32_t iMaxPriority=0)
Definition: C4Effect.cpp:210
const int C4D_MaxVertex
Definition: C4Constants.h:55
int32_t getInt() const
Definition: C4Value.h:112
void Rotate(float Angle, float fOffX, float fOffY)
#define VIS_Allies
Definition: C4Object.h:65
void ClearCommands()
Definition: C4Object.cpp:2531
bool GetAlive() const
Definition: C4Object.h:305
int32_t GetItemNr(const char *strName) const
Definition: C4ValueMap.cpp:459
C4Object * FindOther(C4ID id, int iOwner=ANY_OWNER)
bool DetachMesh(unsigned int number)
Definition: StdMesh.cpp:1393
int32_t x
Definition: C4Rect.h:30
void Set(int32_t iX, int32_t iY, int32_t iWdt, int32_t iHgt)
Definition: C4Rect.cpp:86
#define F(f)
const StdMeshBone * GetBoneByName(const StdStrBuf &name) const
Definition: StdMesh.cpp:386
C4FacetSurface * pRankSymbols
Definition: C4Def.h:189
#define VIS_Editor
Definition: C4Object.h:71
const int32_t C4D_Structure
Definition: C4Def.h:41
#define C4OS_INACTIVE
Definition: C4Object.h:36
int32_t GetValue(C4Object *pInBase, int32_t iBuyPlayer)
Definition: C4Def.cpp:611
int ObjectCount(C4ID id=C4ID::None) const
C4Object * Object(C4PropList *_this)
Definition: C4AulDefFunc.h:34
void SetAsObjectPicture(C4Object *pOverlayObj, DWORD dwBMode)
const C4Value C4VNull
Definition: C4Value.cpp:30
C4ObjectPtr Target
Definition: C4Object.h:87
void Set(const C4Value &value)
const BYTE CNAT_None
Definition: C4Constants.h:108
#define C4GFXBLIT_CLRSFC_MOD2
Definition: C4Surface.h:29
C4Object * CreateContents(C4PropList *)
Definition: C4Object.cpp:1436
uint32_t GetClrModulation() const
C4Def * C4Id2Def(C4ID id)
Definition: C4DefList.h:84
#define C4GFXBLIT_CUSTOM
Definition: C4Surface.h:35
uint32_t GetLightColor() const
Definition: C4Object.h:300
int32_t Data
Definition: C4Object.h:84
void SetAsAction(C4DefGraphics *pBaseGfx, const char *szAction, DWORD dwBMode)
bool UpdateBoneTransforms()
Definition: StdMesh.cpp:1469
C4Object * Find(C4Def *def, int iOwner=ANY_OWNER, DWORD dwOCF=OCF_All)
C4ObjectPtr Target2
Definition: C4Command.h:84
const char * Identifier
Definition: C4AulDefFunc.h:268
C4Real fix_r
Definition: C4Object.h:125
#define PSF_NameChange
Definition: C4GameScript.h:150
int32_t Phase
Definition: C4Object.h:85
C4Real fix_x
Definition: C4Object.h:125
const BYTE CNAT_Top
Definition: C4Constants.h:111
const int C4SymbolSize
Definition: C4Constants.h:58
#define COMD_Up
Definition: C4Object.h:51
bool AdjustWalkRotation(int32_t iRangeX, int32_t iRangeY, int32_t iSpeed)
Definition: C4Object.cpp:4586
void Create(C4ParticleDef *of_def, C4ParticleValueProvider &x, C4ParticleValueProvider &y, C4ParticleValueProvider &speedX, C4ParticleValueProvider &speedY, C4ParticleValueProvider &lifetime, C4PropList *properties, int amount=1, C4Object *object=nullptr)
const uint32_t OCF_Grab
Definition: C4Constants.h:81
void DoExperience(int32_t change)
Definition: C4Object.cpp:1210
uint32_t ColorMod
Definition: C4Object.h:161
const int32_t C4D_Border_Layer
Definition: C4Def.h:68
float Hgt
Definition: C4Facet.h:118
std::vector< const StdMeshAnimation * > GetAnimations() const
Definition: StdMesh.cpp:404
const char * ToString() const
Definition: C4Id.h:59
#define COMD_Left
Definition: C4Object.h:57
C4ValueMapNames * CreateTempNameList()
Definition: C4ValueMap.cpp:146
const int32_t C4D_MouseIgnore
Definition: C4Def.h:54
GraphicsType Type
Definition: C4DefGraphics.h:48
bool InsertVertex(int32_t iPos, int32_t tx, int32_t ty)
Definition: C4Shape.cpp:314
void SetRotate(float iAngle, float fOffX, float fOffY)
const uint32_t OCF_OnFire
Definition: C4Constants.h:83
AttachedMesh * AttachMesh(const StdMesh &mesh, AttachedMesh::Denumerator *denumerator, const StdStrBuf &parent_bone, const StdStrBuf &child_bone, const StdMeshMatrix &transformation=StdMeshMatrix::Identity(), uint32_t flags=AM_None, unsigned int attach_number=0)
Definition: StdMesh.cpp:1331
const int32_t C4D_Living
Definition: C4Def.h:43
VertexUpdateMode
int32_t ValidPlr(int32_t plr)
const BYTE CNAT_Right
Definition: C4Constants.h:110
bool IsIdentifier(char cChar)
Definition: Standard.cpp:90
int32_t Dir
Definition: C4Object.h:80
bool Create(int iWdt, int iHgt, int iWdt2=C4FCT_Full, int iHgt2=C4FCT_Full)
Definition: C4FacetEx.cpp:54
void SetMaterial(size_t i, const StdMeshMaterial &material)
Definition: StdMesh.cpp:1435
#define VIS_None
Definition: C4Object.h:63
void SetName(const char *NewName=nullptr) override
Definition: C4Object.cpp:1679
bool SetLightRange(int32_t iToRange, int32_t iToFadeoutRange)
Definition: C4Object.cpp:4005
void SetAnimationPosition(AnimationNode *node, ValueProvider *position)
Definition: StdMesh.cpp:1258
int32_t GetProcedure() const
Definition: C4Object.cpp:2860
bool CheckContact(int32_t cx, int32_t cy)
Definition: C4Shape.cpp:335
bool ActivateMenu(int32_t iMenu, int32_t iMenuSelect=0, int32_t iMenuData=0, int32_t iMenuPosition=0, C4Object *pTarget=nullptr)
Definition: C4Object.cpp:1476
void DoEnergy(int32_t iChange, bool fExact, int32_t iCause, int32_t iCausedByPlr)
Definition: C4Object.cpp:1106
const uint32_t OCF_Carryable
Definition: C4Constants.h:82
bool C4ValueToMatrix(C4Value &value, StdMeshMatrix *matrix)
const uint32_t OCF_Construct
Definition: C4Constants.h:80
void SetAnimationWeight(AnimationNode *node, ValueProvider *weight)
Definition: StdMesh.cpp:1276
bool Log(const char *szMessage)
Definition: C4Log.cpp:202
float x1
Definition: StdMesh.h:146
float fixtof(const C4Fixed &x)
Definition: C4Real.h:257
int32_t Category
Definition: C4Def.h:117
C4ObjectInfoList CrewInfoList
Definition: C4Player.h:124
bool GrabInfo(C4Object *pFrom)
Definition: C4Object.cpp:4187
const uint32_t OCF_HitSpeed3
Definition: C4Constants.h:92
unsigned int Index
Definition: StdMesh.h:32
StdCopyStrBuf Name
C4Value C4VString(C4String *pStr)
Definition: C4Value.h:246
int32_t BlitMode
Definition: C4Def.h:141
#define C4GFXBLIT_PARENT
Definition: C4Surface.h:36
bool CanConcatPictureWith(C4Object *pOtherObject) const
Definition: C4Object.cpp:4751
const int32_t C4D_Goal
Definition: C4Def.h:46
void SetPermanent(bool fPermanent)
Definition: C4Menu.cpp:862
C4Real GetPosition() const
Definition: StdMesh.h:352
void AdjustCursorCommand()
Definition: C4Player.cpp:1059
const int32_t C4PVM_Target
Definition: C4Player.h:32
const StdMeshAnimation * GetAnimation() const
Definition: StdMesh.h:350
uint32_t BlitMode
Definition: C4Object.h:162
const int32_t C4D_Parallax
Definition: C4Def.h:51
void SetRotation(int32_t nr)
Definition: C4Object.cpp:4106
const int32_t C4CMD_Enter_PushTarget
Definition: C4Command.h:68
C4Effect * pEffects
Definition: C4Object.h:156
C4Real fix_y
Definition: C4Object.h:125
const int32_t C4PVM_Cursor
Definition: C4Player.h:31
C4ObjectPtr Contained
Definition: C4Object.h:144
bool ChangeDef(C4ID idNew)
Definition: C4Object.cpp:1040
const StdMeshMaterial * GetMaterial(const char *material_name) const
class C4GraphicsOverlay * GetGraphicsOverlay(int32_t iForID) const
Definition: C4Object.cpp:4473
const uint32_t OCF_Available
Definition: C4Constants.h:101
int32_t Hgt
Definition: C4Rect.h:30
C4SHead Head
Definition: C4Scenario.h:230
#define VIS_LayerToggle
Definition: C4Object.h:69
void SetCategory(int32_t Category)
Definition: C4Object.h:257
const StdMesh & GetMesh() const
Definition: StdMesh.h:622
C4Action Action
Definition: C4Object.h:147
C4Shape Shape
Definition: C4Object.h:148
C4ObjectPtr ViewCursor
Definition: C4Player.h:130
const int32_t C4D_None
Definition: C4Def.h:38
VertexDataIndex
bool SetParentBone(const StdStrBuf &bone)
Definition: StdMesh.cpp:989
uint32_t OCF
Definition: C4Object.h:134
bool RemoveGraphicsOverlay(int32_t iOverlayID)
Definition: C4Object.cpp:4501
void SetBridgeData(int32_t iBridgeTime, bool fMoveClonk, bool fWall, int32_t iBridgeMaterial)
Definition: C4Object.cpp:64
const uint32_t OCF_HitSpeed4
Definition: C4Constants.h:95
void Fling(C4Real txdir, C4Real tydir, bool fAddSpeed)
Definition: C4Object.cpp:1336
const int32_t C4CMD_Mode_Sub
Definition: C4Command.h:62
uint32_t DWORD
bool DrawPropListSpecImage(C4Facet &fctTarget, C4PropList *pSpec)
Definition: C4Game.cpp:3789
float Length
Definition: StdMesh.h:98
#define VIS_All
Definition: C4Object.h:62
C4ParticleDef * GetDef(const char *name, C4ParticleDef *exclude=nullptr)
int fixtoi(const C4Fixed &x)
Definition: C4Real.h:259
bool fOwnVertices
Definition: C4Object.h:149
const int C4MN_Add_ImgIndexed
C4Real xdir
Definition: C4Object.h:126
int32_t Controller
Definition: C4Object.h:111
void AddFunc(C4PropListStatic *Parent, const char *Name, RType(*pFunc)(ThisType *, ParTypes...), bool Public=true)
Definition: C4AulDefFunc.h:260
float Wdt
Definition: C4Facet.h:118
const StdMeshBox & GetBoundingBox() const
Definition: StdMesh.h:206
C4DrawTransform * GetTransform()
StdMeshMatManager MeshMaterialManager
C4String * GetPropertyStr(C4PropertyName k) const
Definition: C4PropList.cpp:775
#define s
C4DefGraphics Graphics
Definition: C4Def.h:191
StdMeshInstance * pMeshInstance
Definition: C4Object.h:155
float X
Definition: C4Facet.h:118
void SetFrameDeco(FrameDecoration *pNewDeco)
Definition: C4Gui.h:2193
const BYTE CNAT_Left
Definition: C4Constants.h:109
void SetAnimationBoneTransform(AnimationNode *node, const StdMeshTransformation &trans)
Definition: StdMesh.cpp:1269
#define C4FxCall_DmgScript
Definition: C4Effect.h:49
C4Object * getObj() const
Definition: C4Value.cpp:68
const BYTE CNAT_Bottom
Definition: C4Constants.h:112
C4Real ydir
Definition: C4Object.h:126
const int32_t C4D_Foreground
Definition: C4Def.h:53
void GameMsgObject(const char *szText, C4Object *pTarget)
bool IsVisible(int32_t iForPlr, bool fAsOverlay) const
Definition: C4Object.cpp:4047
int32_t VtxCNAT[C4D_MaxVertex]
Definition: C4Shape.h:45
C4ScriptConstDef C4ScriptObjectConstMap[]
int32_t LastEnergyLossCausePlayer
Definition: C4Object.h:112
const uint32_t OCF_InFree
Definition: C4Constants.h:100
int32_t VtxY[C4D_MaxVertex]
Definition: C4Shape.h:44
void DoDamage(int32_t iLevel, int32_t iCausedByPlr, int32_t iCause)
Definition: C4Object.cpp:1092
int32_t Film
Definition: C4Scenario.h:73
virtual bool Remove(C4Object *pObj)
bool ExecuteCommand()
Definition: C4Object.cpp:2653
#define COMD_UpLeft
Definition: C4Object.h:58
int32_t ComDir
Definition: C4Object.h:82
void SetClrModulation(uint32_t dwToMod)
bool DrawTextSpecImage(C4Facet &fctTarget, const char *szSpec, class C4DrawTransform *pTransform, uint32_t dwClr=0xff)
Definition: C4Game.cpp:3735
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:270
C4Value Call(C4PropertyName k, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
Definition: C4PropList.h:110
bool SetPhase(int32_t iPhase)
Definition: C4Object.cpp:1775
C4PropList * getPropList() const
Definition: C4Value.h:116
const BYTE CNAT_Center
Definition: C4Constants.h:113
#define PSF_CrewDisabled
Definition: C4GameScript.h:149
virtual void SetName(const char *NewName=nullptr)
Definition: C4PropList.cpp:656