Tiberian Technologies Scripts Reference Revision: 9000
Loading...
Searching...
No Matches
JmgDeathMatch.h
1
2#pragma once
3#define PI 3.14159265f
4#define PI180 PI/180
5#define FORCELOOKATLOCATIONCUSTOM 6531234
6
7class JMG_DeathMatch_Game_Control : public ScriptImpClass {
8 void Created(GameObject *obj);
9 void Timer_Expired(GameObject *obj,int number);
10 void EnableSpawners(const char *name);
11};
12
13class JMG_DeathMatch_Spawn_Character : public ScriptImpClass {
14 void Created(GameObject *obj);
15 void Timer_Expired(GameObject *obj,int number);
16};
17
18class JMG_DeathMatch_Player : public ScriptImpClass {
19 int playerId;
20 void Created(GameObject *obj);
21 void Enemy_Seen(GameObject *obj,GameObject *seen);
22 void Custom(GameObject *obj,int message,int param,GameObject *sender);
23};
24
25class RP2DeathMatchSpawnSystem
26{
27public:
28 struct RP2DeathMatchSpawnNode
29 {
30 int id;
31 unsigned long lastSeen;
32 GameObject *obj;
33 Vector3 pos;
34 struct RP2DeathMatchSpawnNode *next;
35 RP2DeathMatchSpawnNode(GameObject *obj)
36 {
37 this->id = Commands->Get_ID(obj);
38 this->obj = obj;
39 this->pos = Commands->Get_Position(obj);
40 Vector3 temppos = this->pos;
41 temppos.Z += 1.9f;
42 Commands->Set_Position(this->obj,temppos);
43 this->lastSeen = Commands->Get_Random_Int(0,10);
44 this->next = NULL;
45 }
46 };
47private:
48 struct RP2DeathMatchSpawnNode *RP2DeathMatchSpawnNodeList;
49 float FindNearestPlayer(const Vector3 &pos,int ignorePlayer)
50 {
51 float nearest = -1.0f;
52 for (int x = 1;x < 128;x++)
53 {
54 if (x == ignorePlayer)
55 continue;
56 GameObject *player = Get_GameObj(x);
57 if (!player)
58 continue;
59 float tempDist = JmgUtility::SimpleDistance(pos,Commands->Get_Position(player));
60 if (nearest < 0 || tempDist < nearest)
61 nearest = tempDist;
62 }
63 return nearest;
64 }
65public:
66 RP2DeathMatchSpawnSystem()
67 {
68 RP2DeathMatchSpawnNodeList = NULL;
69 }
70 RP2DeathMatchSpawnNode *AddNode(GameObject *obj)
71 {
72 int id = Commands->Get_ID(obj);
73 RP2DeathMatchSpawnNode *Current = RP2DeathMatchSpawnNodeList;
74 if (!RP2DeathMatchSpawnNodeList)
75 return (RP2DeathMatchSpawnNodeList = new RP2DeathMatchSpawnNode(obj));
76 while (Current)
77 {
78 if (Current->id == id)
79 return Current;
80 if (!Current->next)
81 {
82 Current->next = new RP2DeathMatchSpawnNode(obj);
83 return Current->next;
84 }
85 Current = Current->next;
86 }
87 return NULL;
88 }
89 RP2DeathMatchSpawnSystem &operator -= (GameObject *obj)
90 {
91 int id = Commands->Get_ID(obj);
92 if (!RP2DeathMatchSpawnNodeList)
93 return *this;
94 RP2DeathMatchSpawnNode *Current = RP2DeathMatchSpawnNodeList, *Prev = NULL;
95 while (Current)
96 {
97 if (Current->id == id)
98 {
99 if (!Prev)
100 RP2DeathMatchSpawnNodeList = Current->next;
101 else
102 Prev->next = Current->next;
103 RP2DeathMatchSpawnNode *temp = Current;
104 Current = Current->next;
105 delete temp;
106 continue;
107 }
108 Prev = Current;
109 Current = Current->next;
110 }
111 return *this;
112 }
113 void emptyList()
114 {
115 RP2DeathMatchSpawnNode *temp,*die;
116 temp = RP2DeathMatchSpawnNodeList;
117 while (temp)
118 {
119 die = temp;
120 temp = temp->next;
121 delete die;
122 }
123 RP2DeathMatchSpawnNodeList = NULL;
124 }
125 void update()
126 {
127 RP2DeathMatchSpawnNode *Current = RP2DeathMatchSpawnNodeList;
128 while (Current)
129 {
130 Current->lastSeen++;
131 Current = Current->next;
132 }
133 }
134 void seePoint(int pointId)
135 {
136 RP2DeathMatchSpawnNode *Current = RP2DeathMatchSpawnNodeList;
137 while (Current)
138 {
139 if (Current->id == pointId)
140 {
141 Current->lastSeen = 0;
142 return;
143 }
144 Current = Current->next;
145 }
146 }
147 RP2DeathMatchSpawnNode *findSpawnPoint(int playerId)
148 {
149 float bestDistance = 0;
150 unsigned long bestTime = 0;
151 RP2DeathMatchSpawnNode *Current = RP2DeathMatchSpawnNodeList,*best = NULL;
152 while (Current)
153 {
154 float tempDist = FindNearestPlayer(Current->pos,playerId);
155 if ((tempDist > 25.0f || tempDist == -1) && (!bestTime || (Current->lastSeen > 1 && bestTime < Current->lastSeen) || (bestTime == Current->lastSeen && tempDist > bestDistance)))
156 {
157 bestDistance = tempDist;
158 bestTime = Current->lastSeen;
159 best = Current;
160 }
161 Current = Current->next;
162 }
163 if (best)
164 {
165 best->lastSeen = 0;
166 return best;
167 }
168 Current = RP2DeathMatchSpawnNodeList;
169 while (Current)
170 {
171 float tempDist = FindNearestPlayer(Current->pos,playerId);
172 if (!bestDistance || tempDist > bestDistance)
173 {
174 bestDistance = tempDist;
175 best = Current;
176 }
177 Current = Current->next;
178 }
179 if (best)
180 {
181 best->lastSeen = 0;
182 return best;
183 }
184 return NULL;
185 }
186 bool isEmpty()
187 {
188 if (!RP2DeathMatchSpawnNodeList)
189 return true;
190 return false;
191 }
192};
193RP2DeathMatchSpawnSystem RP2DeathMatchSpawnControl = RP2DeathMatchSpawnSystem();
194
195class JMG_DeathMatch_Random_Spawn_Point : public ScriptImpClass {
196 RP2DeathMatchSpawnSystem::RP2DeathMatchSpawnNode *myNode;
197 void Created(GameObject *obj);
198 void Enemy_Seen(GameObject *obj,GameObject *seen);
199 void Destroyed(GameObject *obj);
200};
201
202class JMG_DeathMatch_Teleport_Zone_Script : public ScriptImpClass {
203 Vector3 Teleport_Pos;
204 void Created(GameObject *obj);
205 void Timer_Expired(GameObject *obj,int number);
206 void Entered(GameObject *obj,GameObject *enter);
207};
208
209class JMG_DeathMatch_Teleport_Zone_Script_Attach : public ScriptImpClass {
210 int Set_Facing_ID;
211 int Movement_Object;
212 void Created(GameObject *obj);
213 void Timer_Expired(GameObject *obj, int number);
214};
215
216class JMG_DeathMatch_Damage_When_Outside_Of_Range : public ScriptImpClass {
217 float warnDistance;
218 float damageDistance;
219 float vehicleWarnDistance;
220 float vehicleDamageDistance;
221 float aircraftWarnDistance;
222 float aircraftDamageDistance;
223 float maxSurviveDistance;
224 Vector3 myPos;
225 int warnTime[128];
226 bool screenEffectOn[128];
227 void Created(GameObject *obj);
228 void Timer_Expired(GameObject *obj,int number);
229};
230
231
232class JMG_DeathMatch_Random_Weapon_Spawner : public ScriptImpClass {
233 int spawnLimit;
234 int powerupId;
235 bool enabled;
236 int enableId;
237 void Created(GameObject *obj);
238 void Custom(GameObject *obj,int message,int param,GameObject *sender);
239 int CreatePowerup(GameObject *obj);
240};
241
242class JMG_DeathMatch_Random_Weapon_Spawner_Attached : public ScriptImpClass {
243 void Destroyed(GameObject *obj);
244};