| 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 |
|
|
logpos_file.writeLine("Z " @ %team SPC $TeamScore[%team]); |
| 59 |
|
|
logpos_file.close(); |
| 60 |
|
|
$logpos_gameover = true; |
| 61 |
|
|
|
| 62 |
|
|
Parent::gameOver(%game); |
| 63 |
|
|
} |
| 64 |
|
|
|
| 65 |
|
|
//////////////////////////////////////////////////////////////////////////////// |
| 66 |
|
|
|
| 67 |
|
|
function logpos_write_position_data() |
| 68 |
|
|
{ |
| 69 |
|
|
if ($logpos_gameover) |
| 70 |
|
|
return; |
| 71 |
|
|
|
| 72 |
|
|
// flags |
| 73 |
|
|
for (%i = 0; %i != $logpos_flag_count; %i++) |
| 74 |
|
|
{ |
| 75 |
|
|
%flag = $logpos_flag[%i]; |
| 76 |
|
|
if (%flag.carrier $= "") |
| 77 |
|
|
logpos_file.writeLine("F " @ %flag.team SPC %flag.position); |
| 78 |
|
|
else |
| 79 |
|
|
logpos_file.writeLine("F " @ %flag.team SPC %flag.carrier.client); |
| 80 |
|
|
} |
| 81 |
|
|
|
| 82 |
|
|
// players |
| 83 |
|
|
for (%ci = 0; %ci != ClientGroup.getCount(); %ci++) |
| 84 |
|
|
{ |
| 85 |
|
|
%client = ClientGroup.getObject(%ci); |
| 86 |
|
|
if (!%client.player) |
| 87 |
|
|
continue; |
| 88 |
|
|
%vehicle = %client.player.getObjectMount(); |
| 89 |
|
|
%seat = ""; |
| 90 |
|
|
if (%client.player.isPilot()) { %seat = "p"; } |
| 91 |
|
|
if (%client.player.isWeaponOperator()) { %seat = "w"; } |
| 92 |
|
|
%data = %client.player.position SPC %vehicle SPC %seat; |
| 93 |
|
|
logpos_file.writeLine(%client SPC %data); |
| 94 |
|
|
} |
| 95 |
|
|
|
| 96 |
|
|
// vehicles |
| 97 |
|
|
for (%i = 0; %i != $logpos_vehicle_count; %i++) { |
| 98 |
|
|
%vehicle = $logpos_vehicle[%i]; |
| 99 |
|
|
if (%vehicle) |
| 100 |
|
|
logpos_file.writeLine(%vehicle SPC %vehicle.position); |
| 101 |
|
|
} |
| 102 |
|
|
|
| 103 |
|
|
// terminate each set of position coordinates with a blank line |
| 104 |
|
|
logpos_file.writeLine(""); |
| 105 |
|
|
|
| 106 |
|
|
schedule(1000, 0, logpos_write_position_data); |
| 107 |
|
|
} |
| 108 |
|
|
|
| 109 |
|
|
//////////////////////////////////////////////////////////////////////////////// |
| 110 |
|
|
|
| 111 |
|
|
function logpos_dump_landmarks(%group) |
| 112 |
|
|
{ |
| 113 |
|
|
for (%i = 0; %i < %group.getCount(); %i++) |
| 114 |
|
|
{ |
| 115 |
|
|
%obj = %group.getObject(%i); |
| 116 |
|
|
%type = %obj.getClassName(); |
| 117 |
|
|
|
| 118 |
|
|
if (%type $= "SimGroup") |
| 119 |
|
|
{ |
| 120 |
|
|
logpos_dump_landmarks(%obj); |
| 121 |
|
|
} |
| 122 |
|
|
else if (%type $= "Item" && %obj.dataBlock $= "Flag") |
| 123 |
|
|
{ |
| 124 |
|
|
$logpos_flag[$logpos_flag_count] = %obj; |
| 125 |
|
|
$logpos_flag_count++; |
| 126 |
|
|
} |
| 127 |
|
|
else if (%obj.team !$= "") |
| 128 |
|
|
{ |
| 129 |
|
|
%data = %type SPC %obj.dataBlock SPC %obj.getName(); |
| 130 |
|
|
%data = %data SPC %obj.position SPC %obj.name; |
| 131 |
|
|
logpos_file.writeLine(%obj.team SPC %data); |
| 132 |
|
|
} |
| 133 |
|
|
} |
| 134 |
|
|
} |
| 135 |
|
|
|
| 136 |
|
|
//////////////////////////////////////////////////////////////////////////////// |
| 137 |
|
|
|
| 138 |
|
|
function serverCmdSuicide(%client) |
| 139 |
|
|
{ |
| 140 |
|
|
logpos_file.writeLine("serverCmdSuicide " @ %client); |
| 141 |
|
|
Parent::serverCmdSuicide(%client); |
| 142 |
|
|
} |
| 143 |
|
|
|
| 144 |
|
|
function vehicleListAdd(%blockName, %obj) |
| 145 |
|
|
{ |
| 146 |
|
|
logpos_file.writeLine("V " @ %obj SPC %obj.team SPC %blockName); |
| 147 |
|
|
$logpos_vehicle[$logpos_vehicle_count] = %obj; |
| 148 |
|
|
$logpos_vehicle_count++; |
| 149 |
|
|
Parent::vehicleListAdd(%blockName, %obj); |
| 150 |
|
|
} |
| 151 |
|
|
|
| 152 |
|
|
function vehicleListRemove(%data, %obj) |
| 153 |
|
|
{ |
| 154 |
|
|
logpos_file.writeLine("W " @ %obj); |
| 155 |
|
|
for (%i = 0; %i != $logpos_vehicle_count; %i++) |
| 156 |
|
|
if ($logpos_vehicle[%i] == %obj) |
| 157 |
|
|
$logpos_vehicle[%i] = 0; |
| 158 |
|
|
Parent::vehicleListRemove(%data, %obj); |
| 159 |
|
|
} |
| 160 |
|
|
|
| 161 |
|
|
function DefaultGame::playerSpawned(%game, %player) |
| 162 |
|
|
{ |
| 163 |
|
|
%name = stripChars(detag(getTaggedString(%player.client.name)), |
| 164 |
|
|
"\cp\co\c6\c7\c8\c9"); |
| 165 |
|
|
logpos_file.writeLine("S " @ %player.client SPC %player.team SPC %name); |
| 166 |
|
|
Parent::playerSpawned(%game, %player); |
| 167 |
|
|
} |
| 168 |
|
|
|
| 169 |
|
|
function DefaultGame::onClientKilled(%game, %clVictim, %clKiller, %damageType, |
| 170 |
|
|
%implement, %damageLocation) |
| 171 |
|
|
{ |
| 172 |
|
|
logpos_file.writeLine("K " @ %clVictim SPC %clKiller SPC %damageType); |
| 173 |
|
|
Parent::onClientKilled(%game, %clVictim, %clKiller, %damageType, |
| 174 |
|
|
%implement, %damageLocation); |
| 175 |
|
|
} |
| 176 |
|
|
|
| 177 |
|
|
function DefaultGame::onClientDamaged(%game, %clVictim, %clAttacker, |
| 178 |
|
|
%damageType, %sourceObject) |
| 179 |
|
|
{ |
| 180 |
|
|
logpos_file.writeLine("D " @ %clVictim SPC %clAttacker SPC %damageType); |
| 181 |
|
|
Parent::onClientDamaged(%game, %clVictim, %clAttacker, %damageType, |
| 182 |
|
|
%sourceObject); |
| 183 |
|
|
} |
| 184 |
|
|
|
| 185 |
|
|
function DefaultGame::onClientLeaveGame(%game, %client) |
| 186 |
|
|
{ |
| 187 |
|
|
logpos_file.writeLine("L " @ %client SPC %client.score); |
| 188 |
|
|
Parent::onClientLeaveGame(%game, %client); |
| 189 |
|
|
} |
| 190 |
|
|
|
| 191 |
|
|
function Player::setArmor(%this, %size) |
| 192 |
|
|
{ |
| 193 |
|
|
logpos_file.writeLine("A " @ %this.client SPC %size); |
| 194 |
|
|
Parent::setArmor(%this, %size); |
| 195 |
|
|
} |
| 196 |
|
|
|
| 197 |
|
|
function ShapeBase::setInventory(%this, %data, %value, %force) |
| 198 |
|
|
{ |
| 199 |
|
|
logpos_file.writeLine("I " @ %this.client SPC %data.getName() SPC %value); |
| 200 |
|
|
Parent::setInventory(%this, %data, %value, %force); |
| 201 |
|
|
} |
| 202 |
|
|
|
| 203 |
|
|
function AIDeployObject(%client, %object) |
| 204 |
|
|
{ |
| 205 |
|
|
logpos_file.writeLine("O " @ %object SPC %client SPC |
| 206 |
|
|
%object.getDataBlock().getName() SPC %object.position); |
| 207 |
|
|
Parent::AIDeployObject(%client, %object); |
| 208 |
|
|
} |
| 209 |
|
|
|
| 210 |
|
|
function ShapeBaseData::onDestroyed(%data, %obj, %prevstate) |
| 211 |
|
|
{ |
| 212 |
|
|
logpos_file.writeLine("P " @ %obj SPC %obj.lastDamagedBy); |
| 213 |
|
|
Parent::onDestroyed(%data, %obj, %prevstate); |
| 214 |
|
|
} |
| 215 |
|
|
|
| 216 |
|
|
}; |
| 217 |
|
|
|
| 218 |
|
|
activatePackage(t2matchlog); |
| 219 |
|
|
|
| 220 |
|
|
//////////////////////////////////////////////////////////////////////////////// |
| 221 |
|
|
|