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) 2010-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 /* Functions mapped by C4Script */
19 
20 #ifndef INC_C4GameScript
21 #define INC_C4GameScript
22 
23 #include "script/C4Value.h"
24 
25 // add functions to engine
26 void InitGameFunctionMap(C4AulScriptEngine *pEngine);
27 void InitObjectFunctionMap(C4AulScriptEngine *pEngine);
28 
29 bool C4ValueToMatrix(C4Value& value, StdMeshMatrix* matrix);
30 bool C4ValueToMatrix(const C4ValueArray& array, StdMeshMatrix* matrix);
31 
32 /* Engine-Calls */
33 
34 #define PSF_Initialize          "~Initialize"
35 #define PSF_InitializePlayers   "~InitializePlayers"
36 #define PSF_InitializeAmbience  "~InitializeAmbience"
37 #define PSF_Construction        "~Construction"
38 #define PSF_Destruction         "~Destruction"
39 #define PSF_ContentsDestruction "~ContentsDestruction" // C4Object *pContents
40 #define PSF_InitializePlayer    "~InitializePlayer" // iPlayer, iX, iY, pBase, iTeam, idExtra
41 #define PSF_InitializeScriptPlayer    "~InitializeScriptPlayer" // iPlayer, idTeam
42 #define PSF_PreInitializePlayer "~PreInitializePlayer" // iPlayer
43 #define PSF_InitializePlayerControl "~InitializePlayerControl" // iPlayer, szControlSet, hasKeyboard, hasMouse, hasGamepad
44 #define PSF_InitializeMap       "~InitializeMap" // map
45 #define PSF_InitializeObjects   "~InitializeObjects"
46 #define PSF_RemovePlayer        "~RemovePlayer" // iPlayer
47 #define PSF_RelaunchPlayer      "~RelaunchPlayer" // iPlayer, iKilledBy
48 #define PSF_Time1               "~Time1"
49 #define PSF_Hit                 "~Hit"
50 #define PSF_Hit2                "~Hit2"
51 #define PSF_Hit3                "~Hit3"
52 #define PSF_Grab                "~Grab" // pObject, fGrab
53 #define PSF_Grabbed             "~Grabbed"
54 #define PSF_Get                 "~Get"
55 #define PSF_Put                 "~Put"
56 #define PSF_Collection          "~Collection" // pObject, fPut
57 #define PSF_Collection2         "~Collection2" // pObject
58 #define PSF_Ejection            "~Ejection" // pObject
59 #define PSF_Entrance            "~Entrance" // pContainer
60 #define PSF_Departure           "~Departure" // pContainer
61 #define PSF_Purchase            "~Purchase" // iPlayer, pBuyObj
62 #define PSF_Sale                "~Sale" // iPlayer
63 #define PSF_Damage              "~Damage" // iChange, iCausedBy
64 #define PSF_Incineration        "~Incineration" // iCausedBy
65 #define PSF_IncinerationEx      "~IncinerationEx" // iCausedBy
66 #define PSF_Death               "~Death" // iCausedBy
67 #define PSF_ActivateEntrance    "~ActivateEntrance" // pByObject
68 #define PSF_LiftTop             "~LiftTop"
69 #define PSF_Contact             "~Contact%s"
70 #define PSF_ControlCommand      "~ControlCommand" // szCommand, pTarget, iTx, iTy
71 #define PSF_ControlCommandFinished "~ControlCommandFinished" // szCommand, pTarget, iTx, iTy, pTarget2, iData
72 #define PSF_CatchBlow           "~CatchBlow" // iLevel, pByObject
73 #define PSF_QueryCatchBlow      "~QueryCatchBlow" // pByObject
74 #define PSF_Stuck               "~Stuck"
75 #define PSF_GrabLost            "~GrabLost"
76 #define PSF_OnLineBreak         "~OnLineBreak" // iCause
77 #define PSF_OnLineChange        "~OnLineChange" // current_length
78 #define PSF_ControlTransfer     "~ControlTransfer" // C4Object* pObj, int iTx, int iTy
79 #define PSF_OnSynchronized       "~OnSynchronized"
80 #define PSF_CalcValue           "~CalcValue" // C4Object *pInBase, int iForPlayer
81 #define PSF_CalcDefValue        "~CalcDefValue" // C4Object *pInBase, int iForPlayer
82 #define PSF_InputCallback       "InputCallback" // const char *szText
83 #define PSF_MenuQueryCancel     "~MenuQueryCancel" // int iSelection
84 #define PSF_IsFulfilled         "~IsFulfilled" // int for_plr
85 #define PSF_AttachTargetLost    "~AttachTargetLost"
86 #define PSF_CrewSelection       "~CrewSelection" // bool fDeselect
87 #define PSF_GetObject2Drop      "~GetObject2Drop" // C4Object *pForCollectionOfObj
88 #define PSF_LeagueGetResult     "~LeagueGetResult" // int iForPlr
89 #define PSF_FireMode            "~FireMode"
90 #define PSF_FrameDecoration     "~FrameDecoration%s"
91 #define PSF_CalcBuyValue        "~CalcBuyValue" // C4ID idItem, int iDefValue
92 #define PSF_CalcSellValue       "~CalcSellValue" // C4Object *pObj, int iObjValue
93 #define PSF_OnJoinCrew          "~Recruitment" // int Player
94 #define PSF_OnRemoveCrew        "~DeRecruitment" // int Player
95 #define PSF_OnInIncendiaryMaterial "OnInIncendiaryMaterial"
96 #define PSF_EditCursorSelection   "~EditCursorSelection"
97 #define PSF_EditCursorDeselection "~EditCursorDeselection" // new_selection
98 #define PSF_EditCursorMoved     "~EditCursorMoved" // int old_x, int old_y
99 #define PSF_DigOutObject        "~DigOutObject" // C4Object *obj
100 #define PSF_OnDugOut            "~DugOut" //C4Object *by_obj
101 #define PSF_SaveScenarioObjects "~SaveScenarioObjects" // int file_handle, [array duplication_list]
102 #define PSF_CommandFailure      "~CommandFailure" // string command, pTarget, iTx, iTy, pTarget2, iData
103 #define PSF_OnCompletionChange  "~OnCompletionChange" // int old_con, int new_con
104 
105 #define PSF_CollectStatistics   "CollectStatistics"
106 
107 // Effect callbacks
108 
109 #define PSF_FxStart             "Fx%sStart" // C4Object *pTarget, int iEffectNumber, int iTemp, C4Value vVar1, C4Value vVar2, C4Value vVar3, C4Value vVar4
110 #define PSF_FxStop              "Fx%sStop" // C4Object *pTarget, int iEffectNumber, int iReason, bool fTemp
111 #define PSF_FxTimer             "Fx%sTimer" // C4Object *pTarget, int iEffectNumber, int iEffectTime
112 #define PSF_FxEffect            "Fx%sEffect" // C4String *szNewEffect, C4Object *pTarget, int iEffectNumber, int iNewEffectNumber, C4Value vNewEffectVar1, C4Value vNewEffectVar2, C4Value vNewEffectVar3, C4Value vNewEffectVar4
113 #define PSF_FxDamage            "Fx%sDamage" // C4Object *pTarget, int iEffectNumber, int iDamage, int iCause, int iCausePlayer
114 #define PSF_FxCustom            "Fx%s%s" // C4Object *pTarget, int iEffectNumber, C4Value vVar1, C4Value vVar2, C4Value vVar3, C4Value vVar4, C4Value vVar5, C4Value vVar6, C4Value vVar7
115 
116 // Controls
117 
118 #define PSF_PlayerControl            "PlayerControl" // int iPlr, int iControl, C4ID idControlExtraData, int x, int y, int iStrength, bool fRepeated, bool fReleased
119 #define PSF_MouseSelection           "~MouseSelection" // int iByPlr
120 #define PSF_MouseSelectionAlt        "~MouseSelectionAlt" // int iByPlr
121 #define PSF_MouseDragDrop            "~MouseDragDrop" // int iPlr, C4Object *source, C4Object *target
122 #define PSF_MouseHover               "~MouseHover" // int iPlr, C4Object* old, C4Object* new, C4Object* drag
123 
124 // Proplist
125 
126 #define PSF_Definition               "~Definition" // proplist definition
127 
128 // Reject* Callbacks
129 
130 #define PSF_RejectHostilityChange    "~RejectHostilityChange" // int iPlr1, int iPlr2, bool fNewHostility
131 #define PSF_RejectTeamSwitch         "~RejectTeamSwitch" // int iPlr, int idNewTeam
132 #define PSF_RejectEntrance           "~RejectEntrance" // C4Object *pIntoObj
133 #define PSF_RejectCollection         "~RejectCollect" // idObject, pObject
134 #define PSF_RejectContents           "~RejectContents" // blocks opening of activate/get/contents menus; no parameters
135 
136 // On* Callbacks
137 
138 #define PSF_OnGameOver               "~OnGameOver"
139 #define PSF_MenuSelection            "~OnMenuSelection" // int iItemIndex, C4Object *pMenuObject
140 #define PSF_OnActionJump             "~OnActionJump" // int iXDir100, iYDir100
141 #define PSF_OnOwnerChanged           "~OnOwnerChanged" // iNewOwner, iOldOwner
142 #define PSF_EnergyChange             "~OnEnergyChange" // int iChange, int iCause, int iCausedByPlayer
143 #define PSF_BreathChange             "~OnBreathChange" // int iChange
144 #define PSF_OnHostilityChange        "~OnHostilityChange" // int iPlr1, int iPlr2, bool fNewHostility, bool fOldHostility
145 #define PSF_OnTeamSwitch             "~OnTeamSwitch" // int iPlr1, int idNewTeam, int idOldTeam
146 #define PSF_OnOwnerRemoved           "~OnOwnerRemoved"
147 #define PSF_Promotion                "~OnPromotion"
148 #define PSF_CrewEnabled              "~OnCrewEnabled"
149 #define PSF_CrewDisabled             "~OnCrewDisabled"
150 #define PSF_NameChange               "~OnNameChanged" // bool inInfoSection
151 #define PSF_OnWealthChanged          "~OnWealthChanged" // int iPlr
152 #define PSF_OnActionChanged          "~OnActionChanged" // string oldaction
153 #define PSF_OnMaterialChanged        "~OnMaterialChanged" // int newmat, int oldmat
154 
155 // Fx%s is automatically prefixed
156 #define PSFS_FxAdd              "Add" // C4Object *pTarget, int iEffectNumber, C4String *szNewEffect, int iNewTimer, C4Value vNewEffectVar1, C4Value vNewEffectVar2, C4Value vNewEffectVar3, C4Value vNewEffectVar4
157 #define PSFS_FxInfo             "Info" // C4Object *pTarget, int iEffectNumber
158 
159 // Construction is used instead of Construct intentionally, because this callback
160 // is not performed in the beginning of the command; some checks are skipped.
161 // If there will ever be more generic ControlCommand*-callbacks, there should be
162 // an additional callback for Construct.
163 #define PSF_ControlCommandAcquire      "~ControlCommandAcquire" // C4Object *pTarget (unused), int iRangeX, int iRangeY, C4Object *pExcludeContainer, C4ID idAcquireDef
164 #define PSF_ControlCommandConstruction "~ControlCommandConstruction"  // C4Object *pTarget (unused), int iRangeX, int iRangeY, C4Object *pTarget2 (unused), C4ID idConstructDef
165 
166 #endif
167