1 |
james |
36 |
//////////////////////////////////////////////////////////////////////////////// |
2 |
|
|
// logpositiondata.cs |
3 |
|
|
//////////////////////////////////////////////////////////////////////////////// |
4 |
|
|
|
5 |
|
|
// all global variable and functions are prefixed logpos_ |
6 |
|
|
|
7 |
|
|
new fileObject("logpos_file"); |
8 |
|
|
|
9 |
|
|
package t2matchlog { |
10 |
|
|
|
11 |
|
|
//////////////////////////////////////////////////////////////////////////////// |
12 |
|
|
|
13 |
|
|
function DefaultGame::startMatch(%game) |
14 |
|
|
{ |
15 |
|
|
$logpos_flag_count = 0; |
16 |
|
|
|
17 |
|
|
%file = "positiondata/" @ $missionSequence @ "_" @ $CurrentMissionType @ |
18 |
|
|
"_" @ $currentMission @ "_"; |
19 |
|
|
%i = 0; |
20 |
|
|
while (isFile(%file @ %i)) |
21 |
|
|
%i++; |
22 |
|
|
logpos_file.openForWrite(%file @ %i); |
23 |
|
|
|
24 |
|
|
logpos_file.writeLine($CurrentMission); |
25 |
|
|
logpos_file.writeLine($CurrentMissionType); |
26 |
|
|
logpos_file.writeLine($MissionDisplayName); |
27 |
|
|
logpos_file.writeLine($MissionTypeDisplayName); |
28 |
|
|
logpos_file.writeLine(MissionArea.area); |
29 |
|
|
logpos_dump_landmarks(MissionGroup); |
30 |
|
|
logpos_file.writeLine(""); |
31 |
|
|
|
32 |
|
|
for (%ci = 0; %ci != ClientGroup.getCount(); %ci++) { |
33 |
|
|
%client = ClientGroup.getObject(%ci); |
34 |
|
|
if (%client.player) { |
35 |
|
|
%name = stripChars(detag(getTaggedString(%client.name)), |
36 |
|
|
"\cp\co\c6\c7\c8\c9"); |
37 |
|
|
logpos_file.writeLine("S " @ %client SPC |
38 |
|
|
%client.player.team SPC %name); |
39 |
|
|
} |
40 |
|
|
} |
41 |
|
|
|
42 |
|
|
$logpos_vehicle_count = 0; |
43 |
|
|
$logpos_gameover = false; |
44 |
|
|
schedule(1000, 0, logpos_write_position_data); |
45 |
|
|
|
46 |
|
|
Parent::startMatch(%game); |
47 |
|
|
} |
48 |
|
|
|
49 |
|
|
//////////////////////////////////////////////////////////////////////////////// |
50 |
|
|
|
51 |
|
|
function DefaultGame::gameOver(%game) |
52 |
|
|
{ |
53 |
|
|
for (%ci = 0; %ci != ClientGroup.getCount(); %ci++) { |
54 |
|
|
%client = ClientGroup.getObject(%ci); |
55 |
|
|
logpos_file.writeLine("L " @ %client SPC %client.score); |
56 |
|
|
} |
57 |
|
|
for (%team = 1; %team <= %game.numTeams; %team++) |
58 |
james |
37 |
logpos_file.writeLine("Z " @ %team SPC $TeamScore[%team] SPC |
59 |
|
|
getTaggedString(%game.getTeamName(%team))); |
60 |
james |
36 |
logpos_file.close(); |
61 |
|
|
$logpos_gameover = true; |
62 |
|
|
|
63 |
|
|
Parent::gameOver(%game); |
64 |
|
|
} |
65 |
|
|
|
66 |
|
|
//////////////////////////////////////////////////////////////////////////////// |
67 |
|
|
|
68 |
|
|
function logpos_write_position_data() |
69 |
|
|
{ |
70 |
|
|
if ($logpos_gameover) |
71 |
|
|
return; |
72 |
|
|
|
73 |
|
|
// flags |
74 |
|
|
for (%i = 0; %i != $logpos_flag_count; %i++) |
75 |
|
|
{ |
76 |
|
|
%flag = $logpos_flag[%i]; |
77 |
|
|
if (%flag.carrier $= "") |
78 |
|
|
logpos_file.writeLine("F " @ %flag.team SPC %flag.position); |
79 |
|
|
else |
80 |
|
|
logpos_file.writeLine("F " @ %flag.team SPC %flag.carrier.client); |
81 |
|
|
} |
82 |
|
|
|
83 |
|
|
// players |
84 |
|
|
for (%ci = 0; %ci != ClientGroup.getCount(); %ci++) |
85 |
|
|
{ |
86 |
|
|
%client = ClientGroup.getObject(%ci); |
87 |
|
|
if (!%client.player) |
88 |
|
|
continue; |
89 |
|
|
%vehicle = %client.player.getObjectMount(); |
90 |
|
|
%seat = ""; |
91 |
|
|
if (%client.player.isPilot()) { %seat = "p"; } |
92 |
|
|
if (%client.player.isWeaponOperator()) { %seat = "w"; } |
93 |
|
|
%data = %client.player.position SPC %vehicle SPC %seat; |
94 |
|
|
logpos_file.writeLine(%client SPC %data); |
95 |
|
|
} |
96 |
|
|
|
97 |
|
|
// vehicles |
98 |
|
|
for (%i = 0; %i != $logpos_vehicle_count; %i++) { |
99 |
|
|
%vehicle = $logpos_vehicle[%i]; |
100 |
|
|
if (%vehicle) |
101 |
|
|
logpos_file.writeLine(%vehicle SPC %vehicle.position); |
102 |
|
|
} |
103 |
|
|
|
104 |
|
|
// terminate each set of position coordinates with a blank line |
105 |
|
|
logpos_file.writeLine(""); |
106 |
|
|
|
107 |
|
|
schedule(1000, 0, logpos_write_position_data); |
108 |
|
|
} |
109 |
|
|
|
110 |
|
|
//////////////////////////////////////////////////////////////////////////////// |
111 |
|
|
|
112 |
|
|
function logpos_dump_landmarks(%group) |
113 |
|
|
{ |
114 |
|
|
for (%i = 0; %i < %group.getCount(); %i++) |
115 |
|
|
{ |
116 |
|
|
%obj = %group.getObject(%i); |
117 |
|
|
%type = %obj.getClassName(); |
118 |
|
|
|
119 |
|
|
if (%type $= "SimGroup") |
120 |
|
|
{ |
121 |
|
|
logpos_dump_landmarks(%obj); |
122 |
|
|
} |
123 |
|
|
else if (%type $= "Item" && %obj.dataBlock $= "Flag") |
124 |
|
|
{ |
125 |
|
|
$logpos_flag[$logpos_flag_count] = %obj; |
126 |
|
|
$logpos_flag_count++; |
127 |
|
|
} |
128 |
|
|
else if (%obj.team !$= "") |
129 |
|
|
{ |
130 |
|
|
%data = %type SPC %obj.dataBlock SPC %obj.getName(); |
131 |
|
|
%data = %data SPC %obj.position SPC %obj.name; |
132 |
|
|
logpos_file.writeLine(%obj.team SPC %data); |
133 |
|
|
} |
134 |
|
|
} |
135 |
|
|
} |
136 |
|
|
|
137 |
|
|
//////////////////////////////////////////////////////////////////////////////// |
138 |
|
|
|
139 |
|
|
function serverCmdSuicide(%client) |
140 |
|
|
{ |
141 |
|
|
logpos_file.writeLine("serverCmdSuicide " @ %client); |
142 |
|
|
Parent::serverCmdSuicide(%client); |
143 |
|
|
} |
144 |
|
|
|
145 |
|
|
function vehicleListAdd(%blockName, %obj) |
146 |
|
|
{ |
147 |
|
|
logpos_file.writeLine("V " @ %obj SPC %obj.team SPC %blockName); |
148 |
|
|
$logpos_vehicle[$logpos_vehicle_count] = %obj; |
149 |
|
|
$logpos_vehicle_count++; |
150 |
|
|
Parent::vehicleListAdd(%blockName, %obj); |
151 |
|
|
} |
152 |
|
|
|
153 |
|
|
function vehicleListRemove(%data, %obj) |
154 |
|
|
{ |
155 |
|
|
logpos_file.writeLine("W " @ %obj); |
156 |
|
|
for (%i = 0; %i != $logpos_vehicle_count; %i++) |
157 |
|
|
if ($logpos_vehicle[%i] == %obj) |
158 |
|
|
$logpos_vehicle[%i] = 0; |
159 |
|
|
Parent::vehicleListRemove(%data, %obj); |
160 |
|
|
} |
161 |
|
|
|
162 |
|
|
function DefaultGame::playerSpawned(%game, %player) |
163 |
|
|
{ |
164 |
|
|
%name = stripChars(detag(getTaggedString(%player.client.name)), |
165 |
|
|
"\cp\co\c6\c7\c8\c9"); |
166 |
|
|
logpos_file.writeLine("S " @ %player.client SPC %player.team SPC %name); |
167 |
|
|
Parent::playerSpawned(%game, %player); |
168 |
|
|
} |
169 |
|
|
|
170 |
|
|
function DefaultGame::onClientKilled(%game, %clVictim, %clKiller, %damageType, |
171 |
|
|
%implement, %damageLocation) |
172 |
|
|
{ |
173 |
james |
37 |
if (%damageType == $DamageType::Impact || |
174 |
|
|
(isObject(%implement) && (%implement.getClassName() $= "Turret" || |
175 |
|
|
%implement.getClassName() $= "VehicleTurret" || |
176 |
|
|
%implement.getClassName() $= "FlyingVehicle"))) |
177 |
|
|
if (%controller = %implement.getControllingClient()) |
178 |
|
|
%clKiller = %controller; |
179 |
james |
36 |
logpos_file.writeLine("K " @ %clVictim SPC %clKiller SPC %damageType); |
180 |
|
|
Parent::onClientKilled(%game, %clVictim, %clKiller, %damageType, |
181 |
|
|
%implement, %damageLocation); |
182 |
|
|
} |
183 |
|
|
|
184 |
|
|
function DefaultGame::onClientDamaged(%game, %clVictim, %clAttacker, |
185 |
|
|
%damageType, %sourceObject) |
186 |
|
|
{ |
187 |
|
|
logpos_file.writeLine("D " @ %clVictim SPC %clAttacker SPC %damageType); |
188 |
|
|
Parent::onClientDamaged(%game, %clVictim, %clAttacker, %damageType, |
189 |
|
|
%sourceObject); |
190 |
|
|
} |
191 |
|
|
|
192 |
|
|
function DefaultGame::onClientLeaveGame(%game, %client) |
193 |
|
|
{ |
194 |
|
|
logpos_file.writeLine("L " @ %client SPC %client.score); |
195 |
|
|
Parent::onClientLeaveGame(%game, %client); |
196 |
|
|
} |
197 |
|
|
|
198 |
|
|
function Player::setArmor(%this, %size) |
199 |
|
|
{ |
200 |
|
|
logpos_file.writeLine("A " @ %this.client SPC %size); |
201 |
|
|
Parent::setArmor(%this, %size); |
202 |
|
|
} |
203 |
|
|
|
204 |
|
|
function ShapeBase::setInventory(%this, %data, %value, %force) |
205 |
|
|
{ |
206 |
|
|
logpos_file.writeLine("I " @ %this.client SPC %data.getName() SPC %value); |
207 |
|
|
Parent::setInventory(%this, %data, %value, %force); |
208 |
|
|
} |
209 |
|
|
|
210 |
|
|
function AIDeployObject(%client, %object) |
211 |
|
|
{ |
212 |
|
|
logpos_file.writeLine("O " @ %object SPC %client SPC |
213 |
|
|
%object.getDataBlock().getName() SPC %object.position); |
214 |
|
|
Parent::AIDeployObject(%client, %object); |
215 |
|
|
} |
216 |
|
|
|
217 |
|
|
function ShapeBaseData::onDestroyed(%data, %obj, %prevstate) |
218 |
|
|
{ |
219 |
|
|
logpos_file.writeLine("P " @ %obj SPC %obj.lastDamagedBy); |
220 |
|
|
Parent::onDestroyed(%data, %obj, %prevstate); |
221 |
|
|
} |
222 |
|
|
|
223 |
|
|
}; |
224 |
|
|
|
225 |
|
|
activatePackage(t2matchlog); |
226 |
|
|
|
227 |
|
|
//////////////////////////////////////////////////////////////////////////////// |
228 |
|
|
|