| 1 | ///////////////////////////////////////////////cxx . . $ `<file>/src/ai.cpp`/ |
| 2 | // |
| 3 | // Snipe2d ludum dare 48h compo entry |
| 4 | // |
| 5 | // Jari Komppa aka Sol |
| 6 | // http://iki.fi/sol |
| 7 | // |
| 8 | /////////////////////////////////////////////// |
| 9 | // License |
| 10 | /////////////////////////////////////////////// |
| 11 | // |
| 12 | // This software is provided 'as-is', without any express or implied |
| 13 | // warranty. In no event will the authors be held liable for any damages |
| 14 | // arising from the use of this software. |
| 15 | // |
| 16 | // Permission is granted to anyone to use this software for any purpose, |
| 17 | // including commercial applications, and to alter it and redistribute it |
| 18 | // freely, subject to the following restrictions: |
| 19 | // |
| 20 | // 1. The origin of this software must not be misrepresented; you must not |
| 21 | // claim that you wrote the original software. If you use this software |
| 22 | // in a product, an acknowledgment in the product documentation would be |
| 23 | // appreciated but is not required. |
| 24 | // 2. Altered source versions must be plainly marked as such, and must not be |
| 25 | // misrepresented as being the original software. |
| 26 | // 3. This notice may not be removed or altered from any source distribution. |
| 27 | // |
| 28 | // (eg. same as ZLIB license) |
| 29 | // |
| 30 | /////////////////////////////////////////////// |
| 31 | // |
| 32 | // Houses are taken from a satellite picture of glasgow. |
| 33 | // |
| 34 | // The sources are a mess, as I didn't even try to do anything |
| 35 | // really organized here.. and hey, it's a 48h compo =) |
| 36 | // |
| 37 | #include "snipe2d.h"cxx . . $ `<file>/src/snipe2d.h`/ |
| 38 | //#define DRAW_DEBUGLINES |
| 39 | |
| 40 | int routecxx . . $ route(d4c1ccc1fe1a56c0).(int x1,int y1,int x2, int y2) |
| 41 | { |
| 42 | if ( SDL_LockSurface(Gamecxx . . $ Game..AIMapcxx . . $ orbitalsniper_t#AIMap.) < 0 ) |
| 43 | return 0; |
| 44 | |
| 45 | char *t = (char*)Gamecxx . . $ Game..AIMapcxx . . $ orbitalsniper_t#AIMap.->pixels; |
| 46 | |
| 47 | int x, y; |
| 48 | int xinc; |
| 49 | int yinc; |
| 50 | int len,i; |
| 51 | |
| 52 | len = abscxx . . $ abs(a1851578aea3f541).(x2 - x1); |
| 53 | i = abscxx . . $ abs(a1851578aea3f541).(y2 - y1); |
| 54 | if (i > len) len = i; |
| 55 | if (len == 0) return 0; |
| 56 | |
| 57 | xinc = ((x2 - x1) << SHIFT_AMOUNTcxx . . $ `src/snipe2d.h:68:9`!) / len; |
| 58 | yinc = ((y2 - y1) << SHIFT_AMOUNTcxx . . $ `src/snipe2d.h:68:9`!) / len; |
| 59 | |
| 60 | x = (x1 << SHIFT_AMOUNTcxx . . $ `src/snipe2d.h:68:9`!) + ((1 << SHIFT_AMOUNTcxx . . $ `src/snipe2d.h:68:9`!) / 2); |
| 61 | y = (y1 << SHIFT_AMOUNTcxx . . $ `src/snipe2d.h:68:9`!) + ((1 << SHIFT_AMOUNTcxx . . $ `src/snipe2d.h:68:9`!) / 2); |
| 62 | |
| 63 | for (i = 1; i <= len; i++) |
| 64 | { |
| 65 | if ((t[(x >> SHIFT_AMOUNTcxx . . $ `src/snipe2d.h:68:9`!) + |
| 66 | (y >> SHIFT_AMOUNTcxx . . $ `src/snipe2d.h:68:9`!) * |
| 67 | (Gamecxx . . $ Game..AIMapcxx . . $ orbitalsniper_t#AIMap.->pitch)] & 0xff) == 1) |
| 68 | return 0; |
| 69 | x = x + xinc; |
| 70 | y = y + yinc; |
| 71 | } |
| 72 | |
| 73 | SDL_UnlockSurface(Gamecxx . . $ Game..AIMapcxx . . $ orbitalsniper_t#AIMap.); |
| 74 | return len; |
| 75 | } |
| 76 | |
| 77 | void drawLinecxx . . $ drawLine(fa5faf37b232239e).(SDL_Surface * aTarget, int x1,int y1,int x2, int y2, int clr) |
| 78 | { |
| 79 | if ( SDL_LockSurface(aTarget) < 0 ) |
| 80 | return; |
| 81 | |
| 82 | short *t = (short*)aTarget->pixels; |
| 83 | |
| 84 | int x, y; |
| 85 | int xinc; |
| 86 | int yinc; |
| 87 | int len,i; |
| 88 | |
| 89 | len = abscxx . . $ abs(a1851578aea3f541).(x2 - x1); |
| 90 | i = abscxx . . $ abs(a1851578aea3f541).(y2 - y1); |
| 91 | if (i > len) len = i; |
| 92 | if (len == 0) return; |
| 93 | |
| 94 | xinc = ((x2 - x1) << SHIFT_AMOUNTcxx . . $ `src/snipe2d.h:68:9`!) / len; |
| 95 | yinc = ((y2 - y1) << SHIFT_AMOUNTcxx . . $ `src/snipe2d.h:68:9`!) / len; |
| 96 | |
| 97 | x = (x1 << SHIFT_AMOUNTcxx . . $ `src/snipe2d.h:68:9`!) + ((1 << SHIFT_AMOUNTcxx . . $ `src/snipe2d.h:68:9`!) / 2); |
| 98 | y = (y1 << SHIFT_AMOUNTcxx . . $ `src/snipe2d.h:68:9`!) + ((1 << SHIFT_AMOUNTcxx . . $ `src/snipe2d.h:68:9`!) / 2); |
| 99 | |
| 100 | for (i = 1; i <= len; i++) |
| 101 | { |
| 102 | t[(x >> SHIFT_AMOUNTcxx . . $ `src/snipe2d.h:68:9`!) + |
| 103 | (y >> SHIFT_AMOUNTcxx . . $ `src/snipe2d.h:68:9`!) * |
| 104 | (aTarget->pitch / 2)] = clr; |
| 105 | |
| 106 | x = x + xinc; |
| 107 | y = y + yinc; |
| 108 | } |
| 109 | |
| 110 | SDL_UnlockSurface(aTarget); |
| 111 | } |
| 112 | |
| 113 | |
| 114 | |
| 115 | void precalc_aicxx . . $ precalc_ai(49f6e7a06ebc5aa8).() |
| 116 | { |
| 117 | if ( SDL_LockSurface(Gamecxx . . $ Game..AIMapcxx . . $ orbitalsniper_t#AIMap.) < 0 ) |
| 118 | return; |
| 119 | // Count waypoints |
| 120 | |
| 121 | Gamecxx . . $ Game..num_waypointscxx . . $ orbitalsniper_t#num_waypoints. = 0; |
| 122 | Gamecxx . . $ Game..num_spawnpointscxx . . $ orbitalsniper_t#num_spawnpoints. = 0; |
| 123 | int i,j; |
| 124 | for (j = 0; j < 600; j++) |
| 125 | { |
| 126 | int ofs = j * Gamecxx . . $ Game..AIMapcxx . . $ orbitalsniper_t#AIMap.->pitch; |
| 127 | for (i = 0; i < 800; i++) |
| 128 | { |
| 129 | switch (*((char*)Gamecxx . . $ Game..AIMapcxx . . $ orbitalsniper_t#AIMap.->pixels + ofs) & 0xff) |
| 130 | { |
| 131 | case 0: // street |
| 132 | break; |
| 133 | case 1: // house |
| 134 | break; |
| 135 | case 2: // bad guys spawn points |
| 136 | Gamecxx . . $ Game..num_spawnpointscxx . . $ orbitalsniper_t#num_spawnpoints.++; |
| 137 | Gamecxx . . $ Game..baddycxx . . $ orbitalsniper_t#baddy..spawncxx . . $ charcount_t#spawn.++; |
| 138 | break; |
| 139 | case 3: // VIP spawn points |
| 140 | Gamecxx . . $ Game..num_spawnpointscxx . . $ orbitalsniper_t#num_spawnpoints.++; |
| 141 | Gamecxx . . $ Game..vipcxx . . $ orbitalsniper_t#vip..spawncxx . . $ charcount_t#spawn.++; |
| 142 | break; |
| 143 | case 4: // waypoints |
| 144 | Gamecxx . . $ Game..num_waypointscxx . . $ orbitalsniper_t#num_waypoints.++; |
| 145 | break; |
| 146 | case 5: // neutral spawn points |
| 147 | Gamecxx . . $ Game..num_spawnpointscxx . . $ orbitalsniper_t#num_spawnpoints.++; |
| 148 | Gamecxx . . $ Game..pedestriancxx . . $ orbitalsniper_t#pedestrian..spawncxx . . $ charcount_t#spawn.++; |
| 149 | break; |
| 150 | } |
| 151 | ofs++; |
| 152 | } |
| 153 | } |
| 154 | Gamecxx . . $ Game..spawnpointscxx . . $ orbitalsniper_t#spawnpoints.= (SPAWNPOINTcxx . . $ SPAWNPOINT#*)calloc(Gamecxx . . $ Game..num_spawnpointscxx . . $ orbitalsniper_t#num_spawnpoints., sizeof(SPAWNPOINTcxx . . $ SPAWNPOINT#)); |
| 155 | Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints. = (WAYPOINTcxx . . $ WAYPOINT#*)calloc(Gamecxx . . $ Game..num_waypointscxx . . $ orbitalsniper_t#num_waypoints., sizeof(WAYPOINTcxx . . $ WAYPOINT#)); |
| 156 | int waypoint = 0; |
| 157 | int spawnpoint = 0; |
| 158 | for (j = 0; j < 600; j++) |
| 159 | { |
| 160 | int ofs = j * Gamecxx . . $ Game..AIMapcxx . . $ orbitalsniper_t#AIMap.->pitch; |
| 161 | for (i = 0; i < 800; i++) |
| 162 | { |
| 163 | switch (*((char*)Gamecxx . . $ Game..AIMapcxx . . $ orbitalsniper_t#AIMap.->pixels + ofs) & 0xff) |
| 164 | { |
| 165 | case 0: // street |
| 166 | break; |
| 167 | case 1: // house |
| 168 | break; |
| 169 | case 2: // bad guys spawn points |
| 170 | Gamecxx . . $ Game..spawnpointscxx . . $ orbitalsniper_t#spawnpoints.[spawnpoint].mXcxx . . $ spawnpointstruc#mX. = i; |
| 171 | Gamecxx . . $ Game..spawnpointscxx . . $ orbitalsniper_t#spawnpoints.[spawnpoint].mYcxx . . $ spawnpointstruc#mY. = j; |
| 172 | Gamecxx . . $ Game..spawnpointscxx . . $ orbitalsniper_t#spawnpoints.[spawnpoint].mTypecxx . . $ spawnpointstruc#mType. = CHAR_BADGUYcxx . . $ CHAR_BADGUY.; |
| 173 | spawnpoint++; |
| 174 | break; |
| 175 | case 3: // VIP spawn points |
| 176 | Gamecxx . . $ Game..spawnpointscxx . . $ orbitalsniper_t#spawnpoints.[spawnpoint].mXcxx . . $ spawnpointstruc#mX. = i; |
| 177 | Gamecxx . . $ Game..spawnpointscxx . . $ orbitalsniper_t#spawnpoints.[spawnpoint].mYcxx . . $ spawnpointstruc#mY. = j; |
| 178 | Gamecxx . . $ Game..spawnpointscxx . . $ orbitalsniper_t#spawnpoints.[spawnpoint].mTypecxx . . $ spawnpointstruc#mType. = CHAR_VIPcxx . . $ CHAR_VIP.; |
| 179 | spawnpoint++; |
| 180 | break; |
| 181 | case 4: // waypoints |
| 182 | Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[waypoint].mXcxx . . $ waypointstruc#mX. = i; |
| 183 | Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[waypoint].mYcxx . . $ waypointstruc#mY. = j; |
| 184 | waypoint++; |
| 185 | break; |
| 186 | case 5: // neutral spawn points |
| 187 | Gamecxx . . $ Game..spawnpointscxx . . $ orbitalsniper_t#spawnpoints.[spawnpoint].mXcxx . . $ spawnpointstruc#mX. = i; |
| 188 | Gamecxx . . $ Game..spawnpointscxx . . $ orbitalsniper_t#spawnpoints.[spawnpoint].mYcxx . . $ spawnpointstruc#mY. = j; |
| 189 | Gamecxx . . $ Game..spawnpointscxx . . $ orbitalsniper_t#spawnpoints.[spawnpoint].mTypecxx . . $ spawnpointstruc#mType. = 2; |
| 190 | spawnpoint++; |
| 191 | break; |
| 192 | } |
| 193 | ofs++; |
| 194 | } |
| 195 | } |
| 196 | |
| 197 | // Find and store connections |
| 198 | |
| 199 | for (i = 0; i < Gamecxx . . $ Game..num_waypointscxx . . $ orbitalsniper_t#num_waypoints.; i++) |
| 200 | { |
| 201 | waypoint = 0; |
| 202 | for (j = 0; j < Gamecxx . . $ Game..num_waypointscxx . . $ orbitalsniper_t#num_waypoints.; j++) |
| 203 | if (routecxx . . $ route(d4c1ccc1fe1a56c0).(Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[i].mXcxx . . $ waypointstruc#mX., Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[i].mYcxx . . $ waypointstruc#mY., Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[j].mXcxx . . $ waypointstruc#mX., Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[j].mYcxx . . $ waypointstruc#mY.)) |
| 204 | waypoint++; |
| 205 | |
| 206 | Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[i].mConnectionscxx . . $ waypointstruc#mConnections. = waypoint; |
| 207 | Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[i].mConnectioncxx . . $ waypointstruc#mConnection. = (int*)calloc(waypoint, sizeof(int)); |
| 208 | |
| 209 | waypoint = 0; |
| 210 | for (j = 0; j < Gamecxx . . $ Game..num_waypointscxx . . $ orbitalsniper_t#num_waypoints.; j++) |
| 211 | if (routecxx . . $ route(d4c1ccc1fe1a56c0).(Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[i].mXcxx . . $ waypointstruc#mX., Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[i].mYcxx . . $ waypointstruc#mY., Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[j].mXcxx . . $ waypointstruc#mX., Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[j].mYcxx . . $ waypointstruc#mY.)) |
| 212 | { |
| 213 | #ifdef DRAW_DEBUGLINES |
| 214 | drawLine(Game.Map, Game.waypoints[i].mX, Game.waypoints[i].mY, Game.waypoints[j].mX, Game.waypoints[j].mY, 0xffff); |
| 215 | #endif |
| 216 | Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[i].mConnectioncxx . . $ waypointstruc#mConnection.[waypoint] = j; |
| 217 | waypoint++; |
| 218 | } |
| 219 | } |
| 220 | |
| 221 | for (i = 0; i < Gamecxx . . $ Game..num_spawnpointscxx . . $ orbitalsniper_t#num_spawnpoints.; i++) |
| 222 | { |
| 223 | int spawndist = 10000; |
| 224 | for (j = 0; j < Gamecxx . . $ Game..num_waypointscxx . . $ orbitalsniper_t#num_waypoints.; j++) |
| 225 | { |
| 226 | int newdist = routecxx . . $ route(d4c1ccc1fe1a56c0).(Gamecxx . . $ Game..spawnpointscxx . . $ orbitalsniper_t#spawnpoints.[i].mXcxx . . $ spawnpointstruc#mX., Gamecxx . . $ Game..spawnpointscxx . . $ orbitalsniper_t#spawnpoints.[i].mYcxx . . $ spawnpointstruc#mY., Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[j].mXcxx . . $ waypointstruc#mX., Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[j].mYcxx . . $ waypointstruc#mY.); |
| 227 | if (newdist && newdist < spawndist) |
| 228 | { |
| 229 | spawndist = newdist; |
| 230 | Gamecxx . . $ Game..spawnpointscxx . . $ orbitalsniper_t#spawnpoints.[i].mClosestWaypointcxx . . $ spawnpointstruc#mClosestWaypoint. = j; |
| 231 | } |
| 232 | } |
| 233 | } |
| 234 | #ifdef DRAW_DEBUGLINES |
| 235 | for (i = 0; i < Game.num_spawnpoints; i++) |
| 236 | drawLine(Game.Map, Game.spawnpoints[i].mX, Game.spawnpoints[i].mY, Game.waypoints[Game.spawnpoints[i].mClosestWaypoint].mX, Game.waypoints[Game.spawnpoints[i].mClosestWaypoint].mY, 0xf << (Game.spawnpoints[i].mType * 6)); |
| 237 | #endif |
| 238 | |
| 239 | SDL_UnlockSurface(Gamecxx . . $ Game..AIMapcxx . . $ orbitalsniper_t#AIMap.); |
| 240 | } |
| 241 | |
| 242 | float distancecxx . . $ distance(95d5df56d1097f86).(float aX1, float aY1, float aX2, float aY2) |
| 243 | { |
| 244 | return (float)sqrtcxx . . $ sqrt(fbcf3211dfe1bfd1).((aX2 - aX1) * (aX2 - aX1) + (aY2 - aY1) * (aY2 - aY1)); |
| 245 | } |
| 246 | |
| 247 | float distance_wpcxx . . $ distance_wp(862d6589e008f424).(int aWaypoint, float aX, float aY) |
| 248 | { |
| 249 | return distancecxx . . $ distance(95d5df56d1097f86).((float)Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[aWaypoint].mXcxx . . $ waypointstruc#mX., (float)Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[aWaypoint].mYcxx . . $ waypointstruc#mY., aX, aY); |
| 250 | } |
| 251 | |
| 252 | float distance_wpwpcxx . . $ distance_wpwp(ac70f22789a9917c).(int aWaypoint1, int aWaypoint2) |
| 253 | { |
| 254 | return distancecxx . . $ distance(95d5df56d1097f86).((float)Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[aWaypoint1].mXcxx . . $ waypointstruc#mX., (float)Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[aWaypoint1].mYcxx . . $ waypointstruc#mY., (float)Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[aWaypoint2].mXcxx . . $ waypointstruc#mX., (float)Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[aWaypoint2].mYcxx . . $ waypointstruc#mY.); |
| 255 | } |
| 256 | |
| 257 | void validateWaypointcxx . . $ validateWaypoint(77709a69c44eec2e).(CHARACTERcxx . . $ CHARACTER# &c, int &next) |
| 258 | { |
| 259 | int valid = 0; |
| 260 | int candidate = next; |
| 261 | while (!valid) |
| 262 | { |
| 263 | valid = 1; |
| 264 | int i; |
| 265 | for (i = 0; i < 7; i++) |
| 266 | if (c.mLastWaypointscxx . . $ character_#mLastWaypoints.[i] == Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[c.mNextWaypointcxx . . $ character_#mNextWaypoint.].mConnectioncxx . . $ waypointstruc#mConnection.[candidate]) |
| 267 | valid = 0; |
| 268 | if (!valid) |
| 269 | { |
| 270 | candidate++; |
| 271 | if (candidate >= Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[c.mNextWaypointcxx . . $ character_#mNextWaypoint.].mConnectionscxx . . $ waypointstruc#mConnections.) |
| 272 | candidate = 0; |
| 273 | if (candidate == next) // no valid waypoints |
| 274 | return; |
| 275 | } |
| 276 | } |
| 277 | next = candidate; |
| 278 | } |
| 279 | |
| 280 | void handle_aicxx . . $ handle_ai(538e78ad5df5d635).(CHARACTERcxx . . $ CHARACTER# &c) |
| 281 | { |
| 282 | // is this AI inactive? |
| 283 | if (c.mTypecxx . . $ character_#mType. == -1) |
| 284 | return; |
| 285 | |
| 286 | // Kludge: hit position sign |
| 287 | if (c.mTypecxx . . $ character_#mType. == 3 || c.mTypecxx . . $ character_#mType. == 4) |
| 288 | { |
| 289 | |
| 290 | c.mTTLcxx . . $ character_#mTTL.--; |
| 291 | if (c.mTTLcxx . . $ character_#mTTL. < 0) |
| 292 | c.mTypecxx . . $ character_#mType. = -1; |
| 293 | return; |
| 294 | } |
| 295 | |
| 296 | // Pedestrian AI |
| 297 | // Pedestrians just walk around, and try not to walk |
| 298 | // in circles. |
| 299 | if (c.mTypecxx . . $ character_#mType. == 2) |
| 300 | { |
| 301 | float dist = distance_wpcxx . . $ distance_wp(862d6589e008f424).(c.mNextWaypointcxx . . $ character_#mNextWaypoint., c.mXcxx . . $ character_#mX., c.mYcxx . . $ character_#mY.); |
| 302 | // Have we arrived at waypoint? |
| 303 | if (dist < 4) |
| 304 | { |
| 305 | |
| 306 | #ifdef RECYCLE_PEDESTRIANS |
| 307 | // Reduce time to live.. |
| 308 | c.mTTL--; |
| 309 | if (c.mTTL <= 0) |
| 310 | { |
| 311 | // Wipe and recycle.. |
| 312 | spa(2); |
| 313 | c.mType = -1; |
| 314 | return; |
| 315 | } |
| 316 | #endif |
| 317 | // Store current waypoint in old waypoints list.. |
| 318 | c.mLastWaypointscxx . . $ character_#mLastWaypoints.[c.mLastWaypointcxx . . $ character_#mLastWaypoint.] = c.mNextWaypointcxx . . $ character_#mNextWaypoint.; |
| 319 | c.mLastWaypointcxx . . $ character_#mLastWaypoint.++; |
| 320 | if (c.mLastWaypointcxx . . $ character_#mLastWaypoint. >= 7) |
| 321 | c.mLastWaypointcxx . . $ character_#mLastWaypoint. = 0; |
| 322 | // Find a new waypoint |
| 323 | |
| 324 | int next = rand() % Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[c.mNextWaypointcxx . . $ character_#mNextWaypoint.].mConnectionscxx . . $ waypointstruc#mConnections.; |
| 325 | validateWaypointcxx . . $ validateWaypoint(77709a69c44eec2e).(c, next); |
| 326 | c.mNextWaypointcxx . . $ character_#mNextWaypoint. = Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[c.mNextWaypointcxx . . $ character_#mNextWaypoint.].mConnectioncxx . . $ waypointstruc#mConnection.[next]; |
| 327 | // Calculate vector.. |
| 328 | dist = distance_wpcxx . . $ distance_wp(862d6589e008f424).(c.mNextWaypointcxx . . $ character_#mNextWaypoint., c.mXcxx . . $ character_#mX., c.mYcxx . . $ character_#mY.); |
| 329 | c.mXicxx . . $ character_#mXi. = ((Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[c.mNextWaypointcxx . . $ character_#mNextWaypoint.].mXcxx . . $ waypointstruc#mX. - c.mXcxx . . $ character_#mX.) / dist) * c.mSpeedcxx . . $ character_#mSpeed.; |
| 330 | c.mYicxx . . $ character_#mYi. = ((Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[c.mNextWaypointcxx . . $ character_#mNextWaypoint.].mYcxx . . $ waypointstruc#mY. - c.mYcxx . . $ character_#mY.) / dist) * c.mSpeedcxx . . $ character_#mSpeed.; |
| 331 | |
| 332 | } |
| 333 | } |
| 334 | |
| 335 | // VIP AI |
| 336 | // VIPs try to find their way to their exit point. |
| 337 | if (c.mTypecxx . . $ character_#mType. == CHAR_VIPcxx . . $ CHAR_VIP.) |
| 338 | { |
| 339 | if (c.mNextWaypointcxx . . $ character_#mNextWaypoint. == -1) |
| 340 | { |
| 341 | // Have we arrived home? |
| 342 | float dist = distancecxx . . $ distance(95d5df56d1097f86).((float)Gamecxx . . $ Game..spawnpointscxx . . $ orbitalsniper_t#spawnpoints.[c.mTargetcxx . . $ character_#mTarget.].mXcxx . . $ spawnpointstruc#mX., (float)Gamecxx . . $ Game..spawnpointscxx . . $ orbitalsniper_t#spawnpoints.[c.mTargetcxx . . $ character_#mTarget.].mYcxx . . $ spawnpointstruc#mY., c.mXcxx . . $ character_#mX., c.mYcxx . . $ character_#mY.); |
| 343 | if (dist < 4) |
| 344 | { |
| 345 | // arrived safely. |
| 346 | c.mTypecxx . . $ character_#mType. = -1; |
| 347 | Gamecxx . . $ Game..Scorecxx . . $ orbitalsniper_t#Score. += (int)((float)5000*Gamecxx . . $ Game..ScoreModcxx . . $ orbitalsniper_t#ScoreMod.); |
| 348 | Gamecxx . . $ Game..vipcxx . . $ orbitalsniper_t#vip..countcxx . . $ charcount_t#count.--; |
| 349 | Gamecxx . . $ Game..vipcxx . . $ orbitalsniper_t#vip..goalcxx . . $ charcount_t#goal.++; |
| 350 | } |
| 351 | } |
| 352 | else |
| 353 | { |
| 354 | float dist = distance_wpcxx . . $ distance_wp(862d6589e008f424).(c.mNextWaypointcxx . . $ character_#mNextWaypoint., c.mXcxx . . $ character_#mX., c.mYcxx . . $ character_#mY.); |
| 355 | // Have we arrived at waypoint? |
| 356 | if (dist < 4) |
| 357 | { |
| 358 | // Store current waypoint in old waypoints list.. |
| 359 | c.mLastWaypointscxx . . $ character_#mLastWaypoints.[c.mLastWaypointcxx . . $ character_#mLastWaypoint.] = c.mNextWaypointcxx . . $ character_#mNextWaypoint.; |
| 360 | c.mLastWaypointcxx . . $ character_#mLastWaypoint.++; |
| 361 | if (c.mLastWaypointcxx . . $ character_#mLastWaypoint. >= 7) |
| 362 | c.mLastWaypointcxx . . $ character_#mLastWaypoint. = 0; |
| 363 | // Find a new waypoint |
| 364 | |
| 365 | // Can we get to the final destination from here? |
| 366 | if (routecxx . . $ route(d4c1ccc1fe1a56c0).((int)c.mXcxx . . $ character_#mX., (int)c.mYcxx . . $ character_#mY., Gamecxx . . $ Game..spawnpointscxx . . $ orbitalsniper_t#spawnpoints.[c.mTargetcxx . . $ character_#mTarget.].mXcxx . . $ spawnpointstruc#mX., Gamecxx . . $ Game..spawnpointscxx . . $ orbitalsniper_t#spawnpoints.[c.mTargetcxx . . $ character_#mTarget.].mYcxx . . $ spawnpointstruc#mY.)) |
| 367 | { |
| 368 | // Yep, calculate vector to home |
| 369 | c.mNextWaypointcxx . . $ character_#mNextWaypoint. = -1; |
| 370 | dist = distancecxx . . $ distance(95d5df56d1097f86).((float)Gamecxx . . $ Game..spawnpointscxx . . $ orbitalsniper_t#spawnpoints.[c.mTargetcxx . . $ character_#mTarget.].mXcxx . . $ spawnpointstruc#mX., (float)Gamecxx . . $ Game..spawnpointscxx . . $ orbitalsniper_t#spawnpoints.[c.mTargetcxx . . $ character_#mTarget.].mYcxx . . $ spawnpointstruc#mY., c.mXcxx . . $ character_#mX., c.mYcxx . . $ character_#mY.); |
| 371 | c.mXicxx . . $ character_#mXi. = ((Gamecxx . . $ Game..spawnpointscxx . . $ orbitalsniper_t#spawnpoints.[c.mTargetcxx . . $ character_#mTarget.].mXcxx . . $ spawnpointstruc#mX. - c.mXcxx . . $ character_#mX.) / dist) * c.mSpeedcxx . . $ character_#mSpeed.; |
| 372 | c.mYicxx . . $ character_#mYi. = ((Gamecxx . . $ Game..spawnpointscxx . . $ orbitalsniper_t#spawnpoints.[c.mTargetcxx . . $ character_#mTarget.].mYcxx . . $ spawnpointstruc#mY. - c.mYcxx . . $ character_#mY.) / dist) * c.mSpeedcxx . . $ character_#mSpeed.; |
| 373 | } |
| 374 | else |
| 375 | { |
| 376 | // Nope, try to figure out the closest waypoint to target that's connected from here |
| 377 | int next = 0; |
| 378 | dist = distance_wpcxx . . $ distance_wp(862d6589e008f424).(Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[c.mNextWaypointcxx . . $ character_#mNextWaypoint.].mConnectioncxx . . $ waypointstruc#mConnection.[0], (float)Gamecxx . . $ Game..spawnpointscxx . . $ orbitalsniper_t#spawnpoints.[c.mTargetcxx . . $ character_#mTarget.].mXcxx . . $ spawnpointstruc#mX., (float)Gamecxx . . $ Game..spawnpointscxx . . $ orbitalsniper_t#spawnpoints.[c.mTargetcxx . . $ character_#mTarget.].mYcxx . . $ spawnpointstruc#mY.); |
| 379 | int i; |
| 380 | for (i = 1; i < Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[c.mNextWaypointcxx . . $ character_#mNextWaypoint.].mConnectionscxx . . $ waypointstruc#mConnections.; i++) |
| 381 | { |
| 382 | float newdist = distance_wpcxx . . $ distance_wp(862d6589e008f424).(Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[c.mNextWaypointcxx . . $ character_#mNextWaypoint.].mConnectioncxx . . $ waypointstruc#mConnection.[i], (float)Gamecxx . . $ Game..spawnpointscxx . . $ orbitalsniper_t#spawnpoints.[c.mTargetcxx . . $ character_#mTarget.].mXcxx . . $ spawnpointstruc#mX., (float)Gamecxx . . $ Game..spawnpointscxx . . $ orbitalsniper_t#spawnpoints.[c.mTargetcxx . . $ character_#mTarget.].mYcxx . . $ spawnpointstruc#mY.); |
| 383 | if (newdist < dist) |
| 384 | { |
| 385 | dist = newdist; |
| 386 | next = i; |
| 387 | } |
| 388 | } |
| 389 | // Make sure we're not walking in circles: |
| 390 | validateWaypointcxx . . $ validateWaypoint(77709a69c44eec2e).(c, next); |
| 391 | c.mNextWaypointcxx . . $ character_#mNextWaypoint. = Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[c.mNextWaypointcxx . . $ character_#mNextWaypoint.].mConnectioncxx . . $ waypointstruc#mConnection.[next]; |
| 392 | // Calculate vector.. |
| 393 | dist = distance_wpcxx . . $ distance_wp(862d6589e008f424).(c.mNextWaypointcxx . . $ character_#mNextWaypoint., c.mXcxx . . $ character_#mX., c.mYcxx . . $ character_#mY.); |
| 394 | c.mXicxx . . $ character_#mXi. = ((Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[c.mNextWaypointcxx . . $ character_#mNextWaypoint.].mXcxx . . $ waypointstruc#mX. - c.mXcxx . . $ character_#mX.) / dist) * c.mSpeedcxx . . $ character_#mSpeed.; |
| 395 | c.mYicxx . . $ character_#mYi. = ((Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[c.mNextWaypointcxx . . $ character_#mNextWaypoint.].mYcxx . . $ waypointstruc#mY. - c.mYcxx . . $ character_#mY.) / dist) * c.mSpeedcxx . . $ character_#mSpeed.; |
| 396 | } |
| 397 | |
| 398 | } |
| 399 | } |
| 400 | } |
| 401 | |
| 402 | // Bad guy AI |
| 403 | // Bad guys try to find their way to a VIP. |
| 404 | if (c.mTypecxx . . $ character_#mType. == CHAR_BADGUYcxx . . $ CHAR_BADGUY.) |
| 405 | { |
| 406 | if (c.mTargetcxx . . $ character_#mTarget. != -1 && Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[c.mTargetcxx . . $ character_#mTarget.].mTypecxx . . $ character_#mType. != 1) |
| 407 | { |
| 408 | // Lost target |
| 409 | c.mTargetcxx . . $ character_#mTarget. = -1; |
| 410 | } |
| 411 | |
| 412 | if (c.mTargetcxx . . $ character_#mTarget. == -1) // Bad guy without a target |
| 413 | { |
| 414 | if (Gamecxx . . $ Game..vipcxx . . $ orbitalsniper_t#vip..countcxx . . $ charcount_t#count. == 0) |
| 415 | { |
| 416 | // No VIPs to pester, walk around randomly |
| 417 | |
| 418 | if (c.mNextWaypointcxx . . $ character_#mNextWaypoint. == -1) |
| 419 | { |
| 420 | // We were walking towards a VIP last time, so |
| 421 | // we'll need to find the closest waypoint and walk to that. |
| 422 | c.mNextWaypointcxx . . $ character_#mNextWaypoint. = 0; |
| 423 | int i; |
| 424 | float dist = distance_wpcxx . . $ distance_wp(862d6589e008f424).(0, c.mXcxx . . $ character_#mX., c.mYcxx . . $ character_#mY.); |
| 425 | for (i = 1; i < Gamecxx . . $ Game..num_waypointscxx . . $ orbitalsniper_t#num_waypoints.; i++) |
| 426 | { |
| 427 | float newdist = distance_wpcxx . . $ distance_wp(862d6589e008f424).(i, c.mXcxx . . $ character_#mX., c.mYcxx . . $ character_#mY.); |
| 428 | if (newdist < dist && routecxx . . $ route(d4c1ccc1fe1a56c0).(Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[i].mXcxx . . $ waypointstruc#mX., Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[i].mYcxx . . $ waypointstruc#mY., (int)c.mXcxx . . $ character_#mX., (int)c.mYcxx . . $ character_#mY.)) |
| 429 | { |
| 430 | dist = newdist; |
| 431 | c.mNextWaypointcxx . . $ character_#mNextWaypoint. = i; |
| 432 | } |
| 433 | } |
| 434 | // Calculate vector towards the closest waypoint |
| 435 | c.mXicxx . . $ character_#mXi. = ((Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[c.mNextWaypointcxx . . $ character_#mNextWaypoint.].mXcxx . . $ waypointstruc#mX. - c.mXcxx . . $ character_#mX.) / dist) * c.mSpeedcxx . . $ character_#mSpeed.; |
| 436 | c.mYicxx . . $ character_#mYi. = ((Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[c.mNextWaypointcxx . . $ character_#mNextWaypoint.].mYcxx . . $ waypointstruc#mY. - c.mYcxx . . $ character_#mY.) / dist) * c.mSpeedcxx . . $ character_#mSpeed.; |
| 437 | } |
| 438 | else // just walk towards the next waypoint normally |
| 439 | { |
| 440 | float dist = distance_wpcxx . . $ distance_wp(862d6589e008f424).(c.mNextWaypointcxx . . $ character_#mNextWaypoint., c.mXcxx . . $ character_#mX., c.mYcxx . . $ character_#mY.); |
| 441 | // Have we arrived at waypoint? |
| 442 | if (dist < 4) |
| 443 | { |
| 444 | int next = rand() % Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[c.mNextWaypointcxx . . $ character_#mNextWaypoint.].mConnectionscxx . . $ waypointstruc#mConnections.; |
| 445 | // Bad guys have nowhere to go, so they might |
| 446 | // as well walk in circles.. (hence, no validatewaypoint) |
| 447 | c.mNextWaypointcxx . . $ character_#mNextWaypoint. = Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[c.mNextWaypointcxx . . $ character_#mNextWaypoint.].mConnectioncxx . . $ waypointstruc#mConnection.[next]; |
| 448 | // Calculate vector.. |
| 449 | dist = distance_wpcxx . . $ distance_wp(862d6589e008f424).(c.mNextWaypointcxx . . $ character_#mNextWaypoint., c.mXcxx . . $ character_#mX., c.mYcxx . . $ character_#mY.); |
| 450 | c.mXicxx . . $ character_#mXi. = ((Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[c.mNextWaypointcxx . . $ character_#mNextWaypoint.].mXcxx . . $ waypointstruc#mX. - c.mXcxx . . $ character_#mX.) / dist) * c.mSpeedcxx . . $ character_#mSpeed.; |
| 451 | c.mYicxx . . $ character_#mYi. = ((Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[c.mNextWaypointcxx . . $ character_#mNextWaypoint.].mYcxx . . $ waypointstruc#mY. - c.mYcxx . . $ character_#mY.) / dist) * c.mSpeedcxx . . $ character_#mSpeed.; |
| 452 | } |
| 453 | } |
| 454 | } |
| 455 | else // target a VIP |
| 456 | { |
| 457 | int t = rand() % Gamecxx . . $ Game..vipcxx . . $ orbitalsniper_t#vip..countcxx . . $ charcount_t#count.; |
| 458 | int i = 0; |
| 459 | while (t > 0 || Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[i].mTypecxx . . $ character_#mType. != CHAR_VIPcxx . . $ CHAR_VIP.) |
| 460 | { |
| 461 | if (Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[i].mTypecxx . . $ character_#mType. == CHAR_VIPcxx . . $ CHAR_VIP.) |
| 462 | t--; |
| 463 | i++; |
| 464 | } |
| 465 | c.mTargetcxx . . $ character_#mTarget. = i; |
| 466 | // Avoid sudden death: |
| 467 | if (distancecxx . . $ distance(95d5df56d1097f86).(c.mXcxx . . $ character_#mX., c.mYcxx . . $ character_#mY., Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[c.mTargetcxx . . $ character_#mTarget.].mXcxx . . $ character_#mX., Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[c.mTargetcxx . . $ character_#mTarget.].mYcxx . . $ character_#mY.) < 20) |
| 468 | { |
| 469 | c.mTargetcxx . . $ character_#mTarget. = -1; |
| 470 | if (c.mNextWaypointcxx . . $ character_#mNextWaypoint. == -1) |
| 471 | { |
| 472 | c.mXicxx . . $ character_#mXi. = 0; |
| 473 | c.mYicxx . . $ character_#mYi. = 0; |
| 474 | } |
| 475 | } |
| 476 | } |
| 477 | } |
| 478 | |
| 479 | int nolineofsight = 1; |
| 480 | |
| 481 | // Do we have line of sight to the VIP? |
| 482 | if (c.mTargetcxx . . $ character_#mTarget. != -1 && routecxx . . $ route(d4c1ccc1fe1a56c0).((int)c.mXcxx . . $ character_#mX., (int)c.mYcxx . . $ character_#mY., (int)Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[c.mTargetcxx . . $ character_#mTarget.].mXcxx . . $ character_#mX., (int)Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[c.mTargetcxx . . $ character_#mTarget.].mYcxx . . $ character_#mY.)) |
| 483 | { |
| 484 | nolineofsight = 0; |
| 485 | // Calculate new vector to it |
| 486 | float dist = distancecxx . . $ distance(95d5df56d1097f86).(Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[c.mTargetcxx . . $ character_#mTarget.].mXcxx . . $ character_#mX., Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[c.mTargetcxx . . $ character_#mTarget.].mYcxx . . $ character_#mY., c.mXcxx . . $ character_#mX., c.mYcxx . . $ character_#mY.); |
| 487 | c.mXicxx . . $ character_#mXi. = ((Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[c.mTargetcxx . . $ character_#mTarget.].mXcxx . . $ character_#mX. - c.mXcxx . . $ character_#mX.) / dist) * c.mSpeedcxx . . $ character_#mSpeed.; |
| 488 | c.mYicxx . . $ character_#mYi. = ((Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[c.mTargetcxx . . $ character_#mTarget.].mYcxx . . $ character_#mY. - c.mYcxx . . $ character_#mY.) / dist) * c.mSpeedcxx . . $ character_#mSpeed.; |
| 489 | c.mNextWaypointcxx . . $ character_#mNextWaypoint. = -1; |
| 490 | } |
| 491 | |
| 492 | |
| 493 | if (c.mNextWaypointcxx . . $ character_#mNextWaypoint. == -1) |
| 494 | { |
| 495 | // Caught up with the VIP? |
| 496 | float dist = distancecxx . . $ distance(95d5df56d1097f86).((float)Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[c.mTargetcxx . . $ character_#mTarget.].mXcxx . . $ character_#mX., (float)Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[c.mTargetcxx . . $ character_#mTarget.].mYcxx . . $ character_#mY., c.mXcxx . . $ character_#mX., c.mYcxx . . $ character_#mY.); |
| 497 | if (dist < 3) |
| 498 | { |
| 499 | // arrived safely. |
| 500 | c.mTypecxx . . $ character_#mType. = -1; |
| 501 | Gamecxx . . $ Game..Scorecxx . . $ orbitalsniper_t#Score. -= (int)((float)10000*Gamecxx . . $ Game..ScoreModcxx . . $ orbitalsniper_t#ScoreMod.); // +game over |
| 502 | Gamecxx . . $ Game..vipcxx . . $ orbitalsniper_t#vip..countcxx . . $ charcount_t#count.--; |
| 503 | Gamecxx . . $ Game..baddycxx . . $ orbitalsniper_t#baddy..countcxx . . $ charcount_t#count.--; |
| 504 | Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[c.mTargetcxx . . $ character_#mTarget.].mTypecxx . . $ character_#mType. = -1; |
| 505 | #ifdef DISPLAY_GAMEOVER_SCREENcxx . . $ `src/snipe2d.h:73:9`! |
| 506 | // gameoverscreen(2); |
| 507 | Gamecxx . . $ Game..GameOverReasoncxx . . $ orbitalsniper_t#GameOverReason. = OESREASON_NEGLIGENTcxx . . $ OESREASON_NEGLIGENT.; |
| 508 | // draw_gameoverscreen(Game.Screen); |
| 509 | return; |
| 510 | #endif |
| 511 | } |
| 512 | else |
| 513 | { |
| 514 | if (nolineofsight) |
| 515 | { |
| 516 | // Lost the VIP. Find closest accessible waypoint. |
| 517 | c.mNextWaypointcxx . . $ character_#mNextWaypoint. = 0; |
| 518 | int i; |
| 519 | float dist = distance_wpcxx . . $ distance_wp(862d6589e008f424).(0, Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[c.mTargetcxx . . $ character_#mTarget.].mXcxx . . $ character_#mX., Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[c.mTargetcxx . . $ character_#mTarget.].mYcxx . . $ character_#mY.); |
| 520 | for (i = 1; i < Gamecxx . . $ Game..num_waypointscxx . . $ orbitalsniper_t#num_waypoints.; i++) |
| 521 | { |
| 522 | float newdist = distance_wpcxx . . $ distance_wp(862d6589e008f424).(i, Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[c.mTargetcxx . . $ character_#mTarget.].mXcxx . . $ character_#mX., Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[c.mTargetcxx . . $ character_#mTarget.].mYcxx . . $ character_#mY.); |
| 523 | if (newdist < dist && routecxx . . $ route(d4c1ccc1fe1a56c0).(Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[i].mXcxx . . $ waypointstruc#mX., Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[i].mYcxx . . $ waypointstruc#mY., (int)c.mXcxx . . $ character_#mX., (int)c.mYcxx . . $ character_#mY.)) |
| 524 | { |
| 525 | dist = newdist; |
| 526 | c.mNextWaypointcxx . . $ character_#mNextWaypoint. = i; |
| 527 | } |
| 528 | } |
| 529 | // Calculate vector towards the closest waypoint |
| 530 | dist = distance_wpcxx . . $ distance_wp(862d6589e008f424).(c.mNextWaypointcxx . . $ character_#mNextWaypoint., c.mXcxx . . $ character_#mX., c.mYcxx . . $ character_#mY.); |
| 531 | c.mXicxx . . $ character_#mXi. = ((Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[c.mNextWaypointcxx . . $ character_#mNextWaypoint.].mXcxx . . $ waypointstruc#mX. - c.mXcxx . . $ character_#mX.) / dist) * c.mSpeedcxx . . $ character_#mSpeed.; |
| 532 | c.mYicxx . . $ character_#mYi. = ((Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[c.mNextWaypointcxx . . $ character_#mNextWaypoint.].mYcxx . . $ waypointstruc#mY. - c.mYcxx . . $ character_#mY.) / dist) * c.mSpeedcxx . . $ character_#mSpeed.; |
| 533 | } |
| 534 | } |
| 535 | } |
| 536 | else |
| 537 | { |
| 538 | float dist = distance_wpcxx . . $ distance_wp(862d6589e008f424).(c.mNextWaypointcxx . . $ character_#mNextWaypoint., c.mXcxx . . $ character_#mX., c.mYcxx . . $ character_#mY.); |
| 539 | // Have we arrived at waypoint? |
| 540 | if (dist < 4) |
| 541 | { |
| 542 | // Find a new waypoint |
| 543 | |
| 544 | if (c.mTargetcxx . . $ character_#mTarget. == -1) |
| 545 | { |
| 546 | int oldWaypoint = c.mNextWaypointcxx . . $ character_#mNextWaypoint.; |
| 547 | |
| 548 | // just choose the next-closest waypoint in the area (I know: we'll cycle). |
| 549 | c.mNextWaypointcxx . . $ character_#mNextWaypoint. = 0; |
| 550 | int i; |
| 551 | float dist = distance_wpcxx . . $ distance_wp(862d6589e008f424).(0, c.mXcxx . . $ character_#mX., c.mYcxx . . $ character_#mY.); |
| 552 | for (i = 1; i < Gamecxx . . $ Game..num_waypointscxx . . $ orbitalsniper_t#num_waypoints.; i++) |
| 553 | { |
| 554 | if (i != oldWaypoint) { |
| 555 | float newdist = distance_wpcxx . . $ distance_wp(862d6589e008f424).(i, c.mXcxx . . $ character_#mX., c.mYcxx . . $ character_#mY.); |
| 556 | if (newdist < dist && routecxx . . $ route(d4c1ccc1fe1a56c0).(Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[i].mXcxx . . $ waypointstruc#mX., Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[i].mYcxx . . $ waypointstruc#mY., (int)c.mXcxx . . $ character_#mX., (int)c.mYcxx . . $ character_#mY.)) |
| 557 | { |
| 558 | dist = newdist; |
| 559 | c.mNextWaypointcxx . . $ character_#mNextWaypoint. = i; |
| 560 | } |
| 561 | } |
| 562 | } |
| 563 | // Calculate vector towards the closest waypoint |
| 564 | c.mXicxx . . $ character_#mXi. = ((Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[c.mNextWaypointcxx . . $ character_#mNextWaypoint.].mXcxx . . $ waypointstruc#mX. - c.mXcxx . . $ character_#mX.) / dist) * c.mSpeedcxx . . $ character_#mSpeed.; |
| 565 | c.mYicxx . . $ character_#mYi. = ((Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[c.mNextWaypointcxx . . $ character_#mNextWaypoint.].mYcxx . . $ waypointstruc#mY. - c.mYcxx . . $ character_#mY.) / dist) * c.mSpeedcxx . . $ character_#mSpeed.; |
| 566 | } |
| 567 | else if (nolineofsight) |
| 568 | { |
| 569 | // Can't see the VIP, try to figure out the closest waypoint to target that's connected from here |
| 570 | int next = 0; |
| 571 | dist = distance_wpcxx . . $ distance_wp(862d6589e008f424).(Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[c.mNextWaypointcxx . . $ character_#mNextWaypoint.].mConnectioncxx . . $ waypointstruc#mConnection.[0], Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[c.mTargetcxx . . $ character_#mTarget.].mXcxx . . $ character_#mX., Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[c.mTargetcxx . . $ character_#mTarget.].mYcxx . . $ character_#mY.); |
| 572 | int i; |
| 573 | for (i = 1; i < Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[c.mNextWaypointcxx . . $ character_#mNextWaypoint.].mConnectionscxx . . $ waypointstruc#mConnections.; i++) |
| 574 | { |
| 575 | float newdist = distance_wpcxx . . $ distance_wp(862d6589e008f424).(Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[c.mNextWaypointcxx . . $ character_#mNextWaypoint.].mConnectioncxx . . $ waypointstruc#mConnection.[i], Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[c.mTargetcxx . . $ character_#mTarget.].mXcxx . . $ character_#mX., Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[c.mTargetcxx . . $ character_#mTarget.].mYcxx . . $ character_#mY.); |
| 576 | if (newdist < dist) |
| 577 | { |
| 578 | dist = newdist; |
| 579 | next = i; |
| 580 | } |
| 581 | } |
| 582 | // Note: bad guys MAY run in circles. |
| 583 | c.mNextWaypointcxx . . $ character_#mNextWaypoint. = Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[c.mNextWaypointcxx . . $ character_#mNextWaypoint.].mConnectioncxx . . $ waypointstruc#mConnection.[next]; |
| 584 | // Calculate vector.. |
| 585 | dist = distance_wpcxx . . $ distance_wp(862d6589e008f424).(c.mNextWaypointcxx . . $ character_#mNextWaypoint., c.mXcxx . . $ character_#mX., c.mYcxx . . $ character_#mY.); |
| 586 | c.mXicxx . . $ character_#mXi. = ((Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[c.mNextWaypointcxx . . $ character_#mNextWaypoint.].mXcxx . . $ waypointstruc#mX. - c.mXcxx . . $ character_#mX.) / dist) * c.mSpeedcxx . . $ character_#mSpeed.; |
| 587 | c.mYicxx . . $ character_#mYi. = ((Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[c.mNextWaypointcxx . . $ character_#mNextWaypoint.].mYcxx . . $ waypointstruc#mY. - c.mYcxx . . $ character_#mY.) / dist) * c.mSpeedcxx . . $ character_#mSpeed.; |
| 588 | } |
| 589 | |
| 590 | } |
| 591 | } |
| 592 | } |
| 593 | |
| 594 | |
| 595 | // Make 'em walk |
| 596 | c.mXcxx . . $ character_#mX. += c.mXicxx . . $ character_#mXi.; |
| 597 | c.mYcxx . . $ character_#mY. += c.mYicxx . . $ character_#mYi.; |
| 598 | } |
| 599 | |
| 600 | int findspawnpointcxx . . $ findspawnpoint(9b79fb6aee4c0440).(int aIndex, int aType) |
| 601 | { |
| 602 | int i, j; |
| 603 | j = 0; |
| 604 | i = 0; |
| 605 | while (i < Gamecxx . . $ Game..num_spawnpointscxx . . $ orbitalsniper_t#num_spawnpoints.) |
| 606 | { |
| 607 | if (Gamecxx . . $ Game..spawnpointscxx . . $ orbitalsniper_t#spawnpoints.[i].mTypecxx . . $ spawnpointstruc#mType. == aType) |
| 608 | j++; |
| 609 | if (j > aIndex) |
| 610 | return i; |
| 611 | i++; |
| 612 | } |
| 613 | return i; |
| 614 | } |
| 615 | |
| 616 | int spawn_aicxx . . $ spawn_ai(7864480464b09eea).(int aType) |
| 617 | { |
| 618 | |
| 619 | // find empty slot |
| 620 | int slot = 0; |
| 621 | while (slot < Gamecxx . . $ Game..num_characterscxx . . $ orbitalsniper_t#num_characters. && Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[slot].mTypecxx . . $ character_#mType. != -1) slot++; |
| 622 | Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[slot].mTypecxx . . $ character_#mType. = -1; // Overwrite the last slot if all slots were in use |
| 623 | Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[slot].mLastWaypointcxx . . $ character_#mLastWaypoint. = 0; |
| 624 | int i; |
| 625 | for (i = 0; i < 7; i++) |
| 626 | Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[slot].mLastWaypointscxx . . $ character_#mLastWaypoints.[i] = -1; |
| 627 | |
| 628 | if (aType == CHAR_BADGUYcxx . . $ CHAR_BADGUY.) |
| 629 | { |
| 630 | Gamecxx . . $ Game..baddycxx . . $ orbitalsniper_t#baddy..countcxx . . $ charcount_t#count.++; |
| 631 | // spawn a bad guy |
| 632 | int spawnpoint = 0; |
| 633 | int i = rand() % Gamecxx . . $ Game..baddycxx . . $ orbitalsniper_t#baddy..spawncxx . . $ charcount_t#spawn.; |
| 634 | spawnpoint = findspawnpointcxx . . $ findspawnpoint(9b79fb6aee4c0440).(i, CHAR_BADGUYcxx . . $ CHAR_BADGUY.); |
| 635 | |
| 636 | Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[slot].mTypecxx . . $ character_#mType. = CHAR_BADGUYcxx . . $ CHAR_BADGUY.; |
| 637 | Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[slot].mXcxx . . $ character_#mX. = (float)Gamecxx . . $ Game..spawnpointscxx . . $ orbitalsniper_t#spawnpoints.[spawnpoint].mXcxx . . $ spawnpointstruc#mX.; |
| 638 | Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[slot].mYcxx . . $ character_#mY. = (float)Gamecxx . . $ Game..spawnpointscxx . . $ orbitalsniper_t#spawnpoints.[spawnpoint].mYcxx . . $ spawnpointstruc#mY.; |
| 639 | Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[slot].mTargetcxx . . $ character_#mTarget. = -1; // find target at next handle_ai pass |
| 640 | Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[slot].mNextWaypointcxx . . $ character_#mNextWaypoint. = Gamecxx . . $ Game..spawnpointscxx . . $ orbitalsniper_t#spawnpoints.[spawnpoint].mClosestWaypointcxx . . $ spawnpointstruc#mClosestWaypoint.; |
| 641 | } |
| 642 | |
| 643 | if (aType == CHAR_VIPcxx . . $ CHAR_VIP.) |
| 644 | { |
| 645 | if (Gamecxx . . $ Game..vipcxx . . $ orbitalsniper_t#vip..countcxx . . $ charcount_t#count. >= 3) |
| 646 | return 0; // 3 vips at a time, thanks |
| 647 | Gamecxx . . $ Game..vipcxx . . $ orbitalsniper_t#vip..countcxx . . $ charcount_t#count.++; |
| 648 | // spawn a VIP |
| 649 | int spawnpoint = 0; |
| 650 | int i = rand() % Gamecxx . . $ Game..vipcxx . . $ orbitalsniper_t#vip..spawncxx . . $ charcount_t#spawn.; |
| 651 | spawnpoint = findspawnpointcxx . . $ findspawnpoint(9b79fb6aee4c0440).(i, CHAR_VIPcxx . . $ CHAR_VIP.); |
| 652 | |
| 653 | Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[slot].mTypecxx . . $ character_#mType. = CHAR_VIPcxx . . $ CHAR_VIP.; |
| 654 | Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[slot].mXcxx . . $ character_#mX. = (float)Gamecxx . . $ Game..spawnpointscxx . . $ orbitalsniper_t#spawnpoints.[spawnpoint].mXcxx . . $ spawnpointstruc#mX.; |
| 655 | Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[slot].mYcxx . . $ character_#mY. = (float)Gamecxx . . $ Game..spawnpointscxx . . $ orbitalsniper_t#spawnpoints.[spawnpoint].mYcxx . . $ spawnpointstruc#mY.; |
| 656 | Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[slot].mNextWaypointcxx . . $ character_#mNextWaypoint. = Gamecxx . . $ Game..spawnpointscxx . . $ orbitalsniper_t#spawnpoints.[spawnpoint].mClosestWaypointcxx . . $ spawnpointstruc#mClosestWaypoint.; |
| 657 | |
| 658 | int targetspawnpoint = 0; |
| 659 | float dist = 0; |
| 660 | // find target waypont, avoiding free score |
| 661 | while (dist < 20) |
| 662 | { |
| 663 | i = rand() % Gamecxx . . $ Game..vipcxx . . $ orbitalsniper_t#vip..spawncxx . . $ charcount_t#spawn.; |
| 664 | targetspawnpoint = findspawnpointcxx . . $ findspawnpoint(9b79fb6aee4c0440).(i, 1); |
| 665 | dist = distancecxx . . $ distance(95d5df56d1097f86).(Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[slot].mXcxx . . $ character_#mX., Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[slot].mYcxx . . $ character_#mY., (float)Gamecxx . . $ Game..spawnpointscxx . . $ orbitalsniper_t#spawnpoints.[targetspawnpoint].mXcxx . . $ spawnpointstruc#mX., (float)Gamecxx . . $ Game..spawnpointscxx . . $ orbitalsniper_t#spawnpoints.[targetspawnpoint].mYcxx . . $ spawnpointstruc#mY.); |
| 666 | } |
| 667 | Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[slot].mTargetcxx . . $ character_#mTarget. = targetspawnpoint; |
| 668 | } |
| 669 | |
| 670 | if (aType == CHAR_PEDESTRIANcxx . . $ CHAR_PEDESTRIAN.) |
| 671 | { |
| 672 | // spawn a pedestrian |
| 673 | int spawnpoint = 0; |
| 674 | int i = rand() % Gamecxx . . $ Game..pedestriancxx . . $ orbitalsniper_t#pedestrian..spawncxx . . $ charcount_t#spawn.; |
| 675 | spawnpoint = findspawnpointcxx . . $ findspawnpoint(9b79fb6aee4c0440).(i, CHAR_PEDESTRIANcxx . . $ CHAR_PEDESTRIAN.); |
| 676 | Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[slot].mTypecxx . . $ character_#mType. = CHAR_PEDESTRIANcxx . . $ CHAR_PEDESTRIAN.; |
| 677 | Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[slot].mXcxx . . $ character_#mX. = (float)Gamecxx . . $ Game..spawnpointscxx . . $ orbitalsniper_t#spawnpoints.[spawnpoint].mXcxx . . $ spawnpointstruc#mX.; |
| 678 | Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[slot].mYcxx . . $ character_#mY. = (float)Gamecxx . . $ Game..spawnpointscxx . . $ orbitalsniper_t#spawnpoints.[spawnpoint].mYcxx . . $ spawnpointstruc#mY.; |
| 679 | Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[slot].mTTLcxx . . $ character_#mTTL. = rand() % 10 + 5; |
| 680 | Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[slot].mNextWaypointcxx . . $ character_#mNextWaypoint. = Gamecxx . . $ Game..spawnpointscxx . . $ orbitalsniper_t#spawnpoints.[spawnpoint].mClosestWaypointcxx . . $ spawnpointstruc#mClosestWaypoint.; |
| 681 | } |
| 682 | float dist = distance_wpcxx . . $ distance_wp(862d6589e008f424).(Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[slot].mNextWaypointcxx . . $ character_#mNextWaypoint., Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[slot].mXcxx . . $ character_#mX., Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[slot].mYcxx . . $ character_#mY.); |
| 683 | Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[slot].mSpeedcxx . . $ character_#mSpeed. = (((((rand()%32768)/32768.0)) + 0.5f) * 0.5f) / |
| 684 | 5.0f; |
| 685 | // slow down pedestrians, they're not in a hurry.. |
| 686 | if (aType == CHAR_PEDESTRIANcxx . . $ CHAR_PEDESTRIAN.) Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[slot].mSpeedcxx . . $ character_#mSpeed. *= 0.5f; |
| 687 | Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[slot].mXicxx . . $ character_#mXi. = ((Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[slot].mNextWaypointcxx . . $ character_#mNextWaypoint.].mXcxx . . $ waypointstruc#mX. - Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[slot].mXcxx . . $ character_#mX.) / dist) * Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[slot].mSpeedcxx . . $ character_#mSpeed.; |
| 688 | Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[slot].mYicxx . . $ character_#mYi. = ((Gamecxx . . $ Game..waypointscxx . . $ orbitalsniper_t#waypoints.[Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[slot].mNextWaypointcxx . . $ character_#mNextWaypoint.].mYcxx . . $ waypointstruc#mY. - Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[slot].mYcxx . . $ character_#mY.) / dist) * Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[slot].mSpeedcxx . . $ character_#mSpeed.; |
| 689 | return slot; |
| 690 | } |
| 691 | |
| 692 | |
| 693 | |
| 694 | void shootcxx . . $ shoot(49f6e7a06ebc5aa8).() |
| 695 | { |
| 696 | Gamecxx . . $ Game..WobbleIndexcxx . . $ orbitalsniper_t#WobbleIndex. += 2048; |
| 697 | Gamecxx . . $ Game..Reloadingcxx . . $ orbitalsniper_t#Reloading. = Gamecxx . . $ Game..ReloadTimecxx . . $ orbitalsniper_t#ReloadTime.; |
| 698 | #ifdef CAMERA_RECOIL |
| 699 | if (Game.MouseZ < 0.25f) Game.MouseZ = 0.25f; |
| 700 | #ifndef CAMERA_STEPS |
| 701 | Game.CoordScale = Game.MouseZ; |
| 702 | #else |
| 703 | Game.CoordScale = ((int)(Game.MouseZ * 4)) / 4.0f; |
| 704 | if (Game.CoordScale < 0.05f) Game.CoordScale = 0.05f; |
| 705 | #endif |
| 706 | #endif |
| 707 | int slot = 0; |
| 708 | while (Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[slot].mTypecxx . . $ character_#mType. != -1) slot++; |
| 709 | Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[slot].mLastWaypointcxx . . $ character_#mLastWaypoint. = 0; |
| 710 | |
| 711 | float worldx = Gamecxx . . $ Game..MouseXcxx . . $ orbitalsniper_t#MouseX. + Gamecxx . . $ Game..WobbleXcxx . . $ orbitalsniper_t#WobbleX. + Gamecxx . . $ Game..CenterXcxx . . $ orbitalsniper_t#CenterX. + 320 * Gamecxx . . $ Game..CoordScalecxx . . $ orbitalsniper_t#CoordScale.; |
| 712 | float worldy = Gamecxx . . $ Game..MouseYcxx . . $ orbitalsniper_t#MouseY. + Gamecxx . . $ Game..WobbleYcxx . . $ orbitalsniper_t#WobbleY. + Gamecxx . . $ Game..CenterYcxx . . $ orbitalsniper_t#CenterY. + 240 * Gamecxx . . $ Game..CoordScalecxx . . $ orbitalsniper_t#CoordScale.; |
| 713 | |
| 714 | int hit = 0; |
| 715 | int gameover = 0; |
| 716 | int i; |
| 717 | for (i = 0; i < Gamecxx . . $ Game..num_characterscxx . . $ orbitalsniper_t#num_characters.; i++) |
| 718 | { |
| 719 | if (Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[i].mTypecxx . . $ character_#mType. != -1) |
| 720 | { |
| 721 | if (Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[i].mXcxx . . $ character_#mX. > worldx - 1 && |
| 722 | Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[i].mXcxx . . $ character_#mX. < worldx + 1 && |
| 723 | Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[i].mYcxx . . $ character_#mY. > worldy - 1 && |
| 724 | Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[i].mYcxx . . $ character_#mY. < worldy + 1) |
| 725 | { |
| 726 | if (Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[i].mTypecxx . . $ character_#mType. == CHAR_BADGUYcxx . . $ CHAR_BADGUY.) |
| 727 | { |
| 728 | Gamecxx . . $ Game..Scorecxx . . $ orbitalsniper_t#Score. += (int)((float)1000*Gamecxx . . $ Game..ScoreModcxx . . $ orbitalsniper_t#ScoreMod.); |
| 729 | Gamecxx . . $ Game..baddycxx . . $ orbitalsniper_t#baddy..countcxx . . $ charcount_t#count.--; |
| 730 | Gamecxx . . $ Game..baddycxx . . $ orbitalsniper_t#baddy..deadcxx . . $ charcount_t#dead.++; |
| 731 | } |
| 732 | if (Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[i].mTypecxx . . $ character_#mType. == CHAR_VIPcxx . . $ CHAR_VIP.) |
| 733 | { |
| 734 | Gamecxx . . $ Game..Scorecxx . . $ orbitalsniper_t#Score. -= (int)((float)100000*Gamecxx . . $ Game..ScoreModcxx . . $ orbitalsniper_t#ScoreMod.); // +game over |
| 735 | gameover = 1; |
| 736 | Gamecxx . . $ Game..vipcxx . . $ orbitalsniper_t#vip..countcxx . . $ charcount_t#count.--; |
| 737 | } |
| 738 | if (Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[i].mTypecxx . . $ character_#mType. == CHAR_PEDESTRIANcxx . . $ CHAR_PEDESTRIAN.) |
| 739 | { |
| 740 | Gamecxx . . $ Game..pedestriancxx . . $ orbitalsniper_t#pedestrian..deadcxx . . $ charcount_t#dead.++; |
| 741 | Gamecxx . . $ Game..Scorecxx . . $ orbitalsniper_t#Score. -= (int)((float)100*Gamecxx . . $ Game..ScoreModcxx . . $ orbitalsniper_t#ScoreMod.); |
| 742 | #ifdef RECYCLE_PEDESTRIANS |
| 743 | spawn_ai(2); // spawn a new pedestrian |
| 744 | #endif |
| 745 | } |
| 746 | Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[i].mTypecxx . . $ character_#mType. = -1; |
| 747 | hit = 1; |
| 748 | } |
| 749 | } |
| 750 | } |
| 751 | #ifdef DISPLAY_GAMEOVER_SCREENcxx . . $ `src/snipe2d.h:73:9`! |
| 752 | if (gameover) |
| 753 | { |
| 754 | // gameoverscreen(1); |
| 755 | Gamecxx . . $ Game..GameOverReasoncxx . . $ orbitalsniper_t#GameOverReason. = OESREASON_FRAGcxx . . $ OESREASON_FRAG.; |
| 756 | // draw_gameoverscreen(Game.Screen); |
| 757 | } |
| 758 | #endif |
| 759 | |
| 760 | Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[slot].mTypecxx . . $ character_#mType. = hit?3:4; // hit marker |
| 761 | Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[slot].mXcxx . . $ character_#mX. = worldx; |
| 762 | Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[slot].mYcxx . . $ character_#mY. = worldy; |
| 763 | Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[slot].mTTLcxx . . $ character_#mTTL. = 100; |
| 764 | } |