comparison src/weapons.c @ 13:ed82a42ba89d

Added code to cause missiles, fighters and plasmas to get confused in nebulous terrain. If it gets confused then it picks a random direction to go.
author darius
date Sat, 06 Dec 1997 06:27:03 +0000
parents 331055a97a9d
children 9f180bf494bd
comparison
equal deleted inserted replaced
12:8f2256d473fb 13:ed82a42ba89d
124 torp->bt_status = TEXPLODE; /* set the torp to explode */ 124 torp->bt_status = TEXPLODE; /* set the torp to explode */
125 torp->bt_fuse = 10 / TORPFUSE; 125 torp->bt_fuse = 10 / TORPFUSE;
126 } 126 }
127 127
128 128
129
130
131 /*---------------------------------PEXPLODE-------------------------------*/ 129 /*---------------------------------PEXPLODE-------------------------------*/
132 /* 130 /*
133 * This function does the explosion of a plasma torp. It goes through all 131 * This function does the explosion of a plasma torp. It goes through all
134 * players and damages them if they are close enough to get damaged 132 * players and damages them if they are close enough to get damaged
135 */ 133 */
140 { 138 {
141 explode_damage(&plasmatorp->pt_base, PLASDAMDIST, KPLASMA); 139 explode_damage(&plasmatorp->pt_base, PLASDAMDIST, KPLASMA);
142 plasmatorp->pt_status = PTEXPLODE; /* set the plasma to explode */ 140 plasmatorp->pt_status = PTEXPLODE; /* set the plasma to explode */
143 plasmatorp->pt_fuse = 10 / PLASMAFUSE; 141 plasmatorp->pt_fuse = 10 / PLASMAFUSE;
144 } 142 }
145
146
147 143
148 144
149 /*-------------------------------UDPHASER----------------------------------*/ 145 /*-------------------------------UDPHASER----------------------------------*/
150 /* 146 /*
151 * This function goes through all players and calcs the damage from a phaser 147 * This function goes through all players and calcs the damage from a phaser
214 return 1; /* yep, it hit. return a 1. */ 210 return 1; /* yep, it hit. return a 1. */
215 } 211 }
216 return 0; /* return that it should continue */ 212 return 0; /* return that it should continue */
217 } 213 }
218 214
219
220 #if 0 /* I think this is now unused */
221 /*----------------------------------NEAR----------------------------------*/
222 /*
223 * This function checks to see if a player is close enough to a torp for the
224 * torp to explode on. This function returns a 1 if the torp should explode
225 * and a zero if not.
226 */
227
228 int
229 near(torp)
230 struct torp *torp; /* the torp to check for */
231 {
232 #if 1
233 return near_player(&torp->t_base, EXPDIST);
234 #else
235 register int i; /* looping var */
236 int dx, dy; /* to calc torp-player distance */
237 register struct player *j; /* to point to players */
238
239 for (i = 0, j = &players[i]; i < MAXPLAYER; i++, j++)
240 {
241 if (j->p_status != PALIVE)
242 continue; /* don't check players not alive */
243 if (j->p_no == torp->t_owner)
244 continue; /* no exploding on self */
245 if (!hostile_to(torp->t_war, torp->t_team, j))
246 continue; /* disregard if both teams not at war */
247 dx = torp->t_x - j->p_x; /* calc delta coords */
248 dy = torp->t_y - j->p_y;
249 if (ABS(dx) > EXPDIST || ABS(dy) > EXPDIST)
250 continue; /* disregard if obviously too far */
251 if (dx * dx + dy * dy < EXPDIST * EXPDIST)
252 return 1; /* if close enough to explode then return 1 */
253 }
254 return 0; /* return that torp should continue */
255 #endif
256 }
257 #endif
258
259 int 215 int
260 near_player(torp, dist) 216 near_player(torp, dist)
261 struct basetorp *torp; /* the torp to check for */ 217 struct basetorp *torp; /* the torp to check for */
262 int dist; 218 int dist;
263 { 219 {
319 275
320 int 276 int
321 pnear(plasmatorp) 277 pnear(plasmatorp)
322 struct plasmatorp *plasmatorp;/* the plasma torp to check for */ 278 struct plasmatorp *plasmatorp;/* the plasma torp to check for */
323 { 279 {
324 #if 1
325 return near_player(&plasmatorp->pt_base, EXPDIST); 280 return near_player(&plasmatorp->pt_base, EXPDIST);
326 #else
327 register int i; /* looping var */
328 int dx, dy; /* to calc distances with */
329 register struct player *j; /* to point to players */
330 /* fprintf(stderr, "ENTERING PNEAR\n"); */
331 for (i = 0, j = &players[i]; i < MAXPLAYER; i++, j++)
332 {
333 if (!(j->p_status == PALIVE))
334 continue; /* don't check players not alive */
335 if (plasmatorp->pt_owner == j->p_no)
336 continue; /* no exploding on self */
337 if (!hostile_to(plasmatorp->pt_war, plasmatorp->pt_team, j))
338 continue; /* disregard if both teams not at war */
339 dx = plasmatorp->pt_x - j->p_x; /* calc delta coords */
340 dy = plasmatorp->pt_y - j->p_y;
341 /* fprintf(stderr, "ENTERING UDORPS #1\n"); */
342 if (ABS(dx) > EXPDIST || ABS(dy) > EXPDIST)
343 continue; /* disregard if obviously too far */
344 /* fprintf(stderr, "ENTERING UDORPS #2\n"); */
345 if (dx * dx + dy * dy < EXPDIST * EXPDIST)
346 return 1; /* if close enough to explode then return 1 */
347 /* fprintf(stderr, "ENTERING UDORPS #3\n"); */
348 }
349 return 0; /* return that plasma torp should continue */
350 #endif
351 } 281 }
352 282
353 283
354 int 284 int
355 outofbounds(x, y) 285 outofbounds(x, y)
376 306
377 for (i = 0, j = &torps[i]; i < MAXPLAYER * MAXTORP; i++, j++) 307 for (i = 0, j = &torps[i]; i < MAXPLAYER * MAXTORP; i++, j++)
378 { 308 {
379 switch (j->t_status) 309 switch (j->t_status)
380 { /* check status of torp */ 310 { /* check status of torp */
381 case TFREE: /* if torp not active then */ 311 case TFREE: /* if torp not active then */
382 continue; /* go on to next torp */ 312 continue; /* go on to next torp */
383 case TMOVE: 313 case TMOVE:
384 case TSTRAIGHT: /* if torp moving then */ 314 case TSTRAIGHT: /* if torp moving then */
385 if (j->t_turns > 0) 315 if (j->t_turns > 0)
386 { /* if torp can turn then */ 316 { /* if torp can turn then */
387 turn = torp_track_opportunity 317 turn = torp_track_opportunity
388 (&j->t_base, j->t_turns, 318 (&j->t_base, j->t_turns,
389 configvals->improved_tracking[SS_PHOTON]); 319 configvals->improved_tracking[SS_PHOTON]);
390 /* should we go right or left */ 320 /* should we go right or left */
391 if (turn < 0) 321
392 { /* we will go left */ 322 if ((terrain_grid[(int) (j->t_x) / TGRID_GRANULARITY * TGRID_SIZE +
393 heading = ((int) j->t_dir) - j->t_turns; /* turn left */ 323 (int) (j->t_y) / TGRID_GRANULARITY].types
394 if (heading < 0) 324 & T_NEBULA) && neb_effect[SS_PHOTON])
395 j->t_dir = heading + 256; 325 if(TORP_NEB_EFF > (lrand48() % 100)) /* Is torp affected? */
396 /* 326 turn = (lrand48() % 2); /* Yes */
397 * j->t_dir = ((heading < 0) ? ((unsigned char) (256 + heading)) : 327
398 * ((unsigned char) heading)); * no underflow 328 if (turn < 0)
399 */ 329 { /* we will go left */
400 } 330 heading = ((int) j->t_dir) - j->t_turns; /* turn left */
401 else if (turn > 0) 331 if (heading < 0)
402 { /* we will go right */ 332 j->t_dir = heading + 256;
403 heading = ((int) j->t_dir) + j->t_turns; /* turn right */ 333 /*
404 if (heading > 255) 334 * j->t_dir = ((heading < 0) ? ((unsigned char) (256 + heading)) :
405 j->t_dir = heading - 256; 335 * ((unsigned char) heading)); * no underflow
406 /* 336 */
407 * j->t_dir = ((heading > 255) ? ((unsigned char) (heading - 256)) 337 }
408 * : ((unsigned char) heading)); * no overflow 338 else if (turn > 0)
409 */ 339 { /* we will go right */
410 } 340 heading = ((int) j->t_dir) + j->t_turns; /* turn right */
411 } 341 if (heading > 255)
412 j->t_x += (double) j->t_speed * Cos[j->t_dir] * WARP1; 342 j->t_dir = heading - 256;
413 j->t_y += (double) j->t_speed * Sin[j->t_dir] * WARP1; 343 /*
414 344 * j->t_dir = ((heading > 255) ? ((unsigned char) (heading - 256))
415 #if 0 345 * : ((unsigned char) heading)); * no overflow
416 if (outofbounds(j->t_x, j->t_y)) 346 */
417 { /* hit top wall? */ 347 }
418 j->t_status = TEXPLODE; /* so you cannot wall kill */ 348 }
419 j->t_whodet = j->t_owner; 349 j->t_x += (double) j->t_speed * Cos[j->t_dir] * WARP1;
420 /* explode(&j->t_base); eliminate self wallkills */ 350 j->t_y += (double) j->t_speed * Sin[j->t_dir] * WARP1;
421 break; /* done with this torp */ 351
422 } 352 move_torp(i, j->t_x, j->t_y, 1);
423 #endif 353
424 354 if (j->t_status == TMOVE) /* if a TMOVE torp then */
425 move_torp(i, j->t_x, j->t_y, 1); 355 j->t_dir += (lrand48() % 3) - 1; /* make the torp wobble */
426 356 if (j->t_fuse-- <= 0)
427 if (j->t_status == TMOVE) /* if a TMOVE torp then */ 357 { /* dec torp's life and see if dead */
428 j->t_dir += (lrand48() % 3) - 1; /* make the torp wobble */ 358 j->t_status = TFREE; /* dead, free the torp */
429 if (j->t_fuse-- <= 0) 359 move_torp(i, -1, -1, 1);
430 { /* dec torp's life and see if dead */ 360 players[j->t_owner].p_ntorp--; /* let player fire another */
431 j->t_status = TFREE; /* dead, free the torp */ 361 break; /* no more torp processing */
432 move_torp(i, -1, -1, 1); 362 }
433 players[j->t_owner].p_ntorp--; /* let player fire another */ 363 if ((sun_effect[SS_PHOTON] && weap_near_object(&j->t_base, PLSTAR, ORBDIST))
434 break; /* no more torp processing */ 364 ||
435 } 365 (wh_effect[SS_PHOTON] && weap_near_object(&j->t_base, PLWHOLE, ORBDIST)))
436 if ((sun_effect[SS_PHOTON] && weap_near_object(&j->t_base, PLSTAR, ORBDIST)) 366 {
437 || 367 /* did it hit a star or wormhole? */
438 (wh_effect[SS_PHOTON] && weap_near_object(&j->t_base, PLWHOLE, ORBDIST))) 368 j->t_whodet = j->t_owner;
439 { 369 explode(&j->t_base);
440 /* did it hit a star or wormhole? */ 370 break;
441 j->t_whodet = j->t_owner; 371 }
442 explode(&j->t_base); 372
443 break; 373 if ((terrain_grid[(int) (j->t_x) / TGRID_GRANULARITY * TGRID_SIZE +
444 } 374 (int) (j->t_y) / TGRID_GRANULARITY].types
445 375 & T_ASTEROIDS) && ast_effect[SS_PHOTON])
446 if ((terrain_grid[(int) (j->t_x) / TGRID_GRANULARITY * TGRID_SIZE + 376 if (TORP_HIT_AST > (lrand48() % 100))
447 (int) (j->t_y) / TGRID_GRANULARITY].types 377 {
448 & T_ASTEROIDS) && 378 explode(&j->t_base);
449 ast_effect[SS_PHOTON]) 379 break;
450 if (TORP_HIT_AST > (lrand48() % 100)) 380 }
451 { 381
452 explode(&j->t_base); 382 if (near_player(&j->t_base, EXPDIST))
453 break; 383 {
454 } 384 /* if torp near enough to hit */
455 385 explode(&j->t_base); /* let torp explode on player */
456 if (near_player(&j->t_base, EXPDIST)) 386 }
457 { 387
458 /* if torp near enough to hit */ 388 break;
459 explode(&j->t_base); /* let torp explode on player */ 389 case TDET: /* if torp was detted */
460 } 390 explode(&j->t_base); /* make it explode */
461 391 break; /* on to next torp */
462 break; 392 case TEXPLODE: /* if torp exploding */
463 case TDET: /* if torp was detted */ 393 if (j->t_fuse-- <= 0)
464 explode(&j->t_base); /* make it explode */ 394 { /* dec explosion timer */
465 break; /* on to next torp */ 395 j->t_status = TFREE; /* if torp done, free it up */
466 case TEXPLODE: /* if torp exploding */ 396 move_torp(i, -1, -1, 1);
467 if (j->t_fuse-- <= 0) 397 players[j->t_owner].p_ntorp--; /* let player fire another */
468 { /* dec explosion timer */ 398 }
469 j->t_status = TFREE; /* if torp done, free it up */ 399 break; /* on to next torp */
470 move_torp(i, -1, -1, 1); 400 case TOFF:
471 players[j->t_owner].p_ntorp--; /* let player fire another */ 401 j->t_status = TFREE;
472 } 402 move_torp(i, -1, -1, 1);
473 break; /* on to next torp */ 403 players[j->t_owner].p_ntorp--;
474 case TOFF: 404 break;
475 j->t_status = TFREE; 405 default: /* Shouldn't happen */
476 move_torp(i, -1, -1, 1); 406 j->t_status = TFREE;
477 players[j->t_owner].p_ntorp--; 407 break;
478 break;
479 default: /* Shouldn't happen */
480 j->t_status = TFREE;
481 break;
482 } /* end of switch */ 408 } /* end of switch */
483 } /* end of for */ 409 } /* end of for */
484 } 410 }
485 411
486 void 412 void
494 for (i = 0; i < MAXPLAYER * NPTHINGIES; i++) 420 for (i = 0; i < MAXPLAYER * NPTHINGIES; i++)
495 { 421 {
496 mis = &missiles[i]; 422 mis = &missiles[i];
497 switch (mis->ms_status) 423 switch (mis->ms_status)
498 { 424 {
499 case TFREE: 425 case TFREE:
500 break; 426 break;
501 case TLAND: 427 case TLAND:
502 j = &players[mis->ms_owner]; 428 j = &players[mis->ms_owner];
503 j->p_ship.s_missilestored++; 429 j->p_ship.s_missilestored++;
504 j->p_armies = (int) (j->p_ship.s_missilestored / FAE_RATE); 430 j->p_armies = (int) (j->p_ship.s_missilestored / FAE_RATE);
505 mis->ms_status = TFREE; 431 mis->ms_status = TFREE;
506 j->p_nthingys--; 432 j->p_nthingys--;
507 break; 433 break;
508 #if 0 434 case TRETURN:
509 case TRETURN: 435 case TMOVE:
510 j = &players[mis->ms_owner]; 436 case TSTRAIGHT:
511 if (!(j->p_ship.s_nflags & SFNHASFIGHTERS)) 437
512 { 438 if (mis->ms_fuse-- <= 0)
513 mis->ms_type = MISSILETHINGY; /* If the player no longer has em, */ 439 {
514 mis->ms_status = TMOVE; /* make his fighters kamikazes */ 440 mis->ms_status = TFREE;
515 mis->fi_hasfired = 0; 441 move_missile(i, -1, -1, 1);
516 break; 442 break;
517 } 443 }
518 444
519 445 if (terrain_grid[(int) (mis->ms_x) / TGRID_GRANULARITY * TGRID_SIZE +
520 if (mis->ms_fuse-- <= 0) 446 (int) (mis->ms_y) / TGRID_GRANULARITY].types
521 { 447 & T_ASTEROIDS)
522 mis->ms_status = TFREE; 448 if ((mis->ms_type == FIGHTERTHINGY) &&
523 move_missile(i, -1, -1, 1); 449 ast_effect[SS_FIGHTER] &&
524 break; 450 (FIGHTER_HIT_AST > (lrand48() % 100)))
525 } 451 {
526 452 mis->ms_whodet = mis->ms_owner;
527 if (((sun_effect[SS_MISSILE] && mis->ms_type == MISSILETHINGY 453 explode(&mis->ms_base);
528 || sun_effect[SS_FIGHTER] && mis->ms_type == FIGHTERTHINGY) 454 break;
529 && weap_near_object(&mis->ms_base, PLSTAR, ORBDIST)) || 455 }
530 ((wh_effect[SS_MISSILE] && mis->ms_type == MISSILETHINGY 456 else if ((MISSILE_HIT_AST > (lrand48() % 100)) &&
531 || wh_effect[SS_FIGHTER] && mis->ms_type == FIGHTERTHINGY) 457 ast_effect[SS_MISSILE])
532 && weap_near_object(&mis->ms_base, PLWHOLE, ORBDIST))) 458 {
533 { 459 mis->ms_whodet = mis->ms_owner;
534 /* did it hit a star or wormhole? */ 460 explode(&mis->ms_base);
535 explode(&mis->ms_base); 461 break;
536 break; 462 }
537 } 463
538 if (mis->ms_turns > 0) 464 if ((((sun_effect[SS_MISSILE] && mis->ms_type == MISSILETHINGY)
539 { 465 || (sun_effect[SS_FIGHTER] && mis->ms_type == FIGHTERTHINGY))
540 turn = fighter_track_target(&mis->ms_base, mis->ms_turns); 466 && weap_near_object(&mis->ms_base, PLSTAR, ORBDIST))
541 mis->ms_dir = (unsigned char) (mis->ms_dir + turn * mis->ms_turns); 467 ||
542 } 468 (((wh_effect[SS_MISSILE] && mis->ms_type == MISSILETHINGY)
543 x = mis->ms_x + mis->ms_speed * Cos[mis->ms_dir] * WARP1; 469 || (wh_effect[SS_FIGHTER] && mis->ms_type == FIGHTERTHINGY))
544 y = mis->ms_y + mis->ms_speed * Sin[mis->ms_dir] * WARP1; 470 && weap_near_object(&mis->ms_base, PLWHOLE, ORBDIST)))
545 move_missile(i, x, y, 1); 471 {
546 472 /* did it hit a star? */
547 if (mis->ms_fuse-- <= 0) 473 explode(&mis->ms_base);
548 { 474 break;
549 mis->ms_status = TFREE; 475 }
550 move_missile(i, -1, -1, 1); 476
551 } 477 j = &players[mis->ms_owner];
552 else if (f_land(mis)) 478
553 { 479 if (mis->ms_type == FIGHTERTHINGY &&
554 mis->ms_status = TLAND; 480 !(j->p_ship.s_nflags & SFNHASFIGHTERS))
555 move_missile(i, -1, -1, 1); 481 {
556 } 482 mis->ms_type = MISSILETHINGY; /* If the player no longer has em, */
557 break; 483 mis->ms_status = TMOVE; /* make his fighters kamikazes */
558 #endif 484 mis->fi_hasfired = 0;
559 case TRETURN: 485 break;
560 case TMOVE: 486 }
561 case TSTRAIGHT: 487
562 488 if ((mis->ms_type == FIGHTERTHINGY)
563 if (mis->ms_fuse-- <= 0) 489 && ((mis->ms_fuse < .6 * j->p_ship.s_missile.fuse)
564 { 490 || (mis->fi_hasfired))
565 mis->ms_status = TFREE; 491 && mis->ms_status != TRETURN)
566 move_missile(i, -1, -1, 1); 492 mis->ms_status = TRETURN;
567 break; 493
568 } 494 if (mis->ms_turns > 0)
569 495 {
570 if (terrain_grid[(int) (mis->ms_x) / TGRID_GRANULARITY * TGRID_SIZE + 496 if (mis->ms_type == FIGHTERTHINGY)
571 (int) (mis->ms_y) / TGRID_GRANULARITY].types 497 {
572 & T_ASTEROIDS) 498 turn = fighter_track_target(&mis->ms_base, mis->ms_turns);
573 if ((mis->ms_type == FIGHTERTHINGY) && 499 }
574 ast_effect[SS_FIGHTER] && 500 else
575 (FIGHTER_HIT_AST > (lrand48() % 100))) 501 {
576 { 502 turn = torp_track_opportunity
577 mis->ms_whodet = mis->ms_owner; 503 (&mis->ms_base, mis->ms_turns,
578 explode(&mis->ms_base); 504 configvals->improved_tracking[SS_MISSILE]);
579 break; 505 }
580 } 506
581 else if ((MISSILE_HIT_AST > (lrand48() % 100)) && 507 if ((terrain_grid[(int) (mis->ms_x) / TGRID_GRANULARITY * TGRID_SIZE +
582 ast_effect[SS_MISSILE]) 508 (int) (mis->ms_y) / TGRID_GRANULARITY].types
583 { 509 & T_NEBULA))
584 mis->ms_whodet = mis->ms_owner; 510
585 explode(&mis->ms_base); 511 if((mis->ms_type == FIGHTERTHINGY) && neb_effect[SS_FIGHTER])
586 break; 512 {
587 } 513 if(FIGHTER_NEB_EFF > (lrand48() % 100)) /* Is fighter affected? */
588 514 turn = (lrand48() % 2); /* Yes */
589 if ((((sun_effect[SS_MISSILE] && mis->ms_type == MISSILETHINGY) 515 }
590 || (sun_effect[SS_FIGHTER] && mis->ms_type == FIGHTERTHINGY)) 516 else
591 && weap_near_object(&mis->ms_base, PLSTAR, ORBDIST)) 517 if(neb_effect[SS_MISSILE])
592 || 518 if(MISSILE_NEB_EFF > (lrand48() % 100)) /* Is missile affected? */
593 (((wh_effect[SS_MISSILE] && mis->ms_type == MISSILETHINGY) 519 turn = (lrand48() % 2); /* Yes */
594 || (wh_effect[SS_FIGHTER] && mis->ms_type == FIGHTERTHINGY)) 520
595 && weap_near_object(&mis->ms_base, PLWHOLE, ORBDIST))) 521
596 { 522 mis->ms_dir = (unsigned char) (mis->ms_dir + turn * mis->ms_turns);
597 /* did it hit a star? */ 523 }
598 explode(&mis->ms_base); 524 x = mis->ms_x + mis->ms_speed * Cos[mis->ms_dir] * WARP1;
599 break; 525 y = mis->ms_y + mis->ms_speed * Sin[mis->ms_dir] * WARP1;
600 } 526
601 527 move_missile(i, x, y, 1);
602 j = &players[mis->ms_owner]; 528
603 529 if (mis->ms_status != TSTRAIGHT)
604 if (mis->ms_type == FIGHTERTHINGY && 530 mis->ms_dir += (lrand48() % 3) - 1;
605 !(j->p_ship.s_nflags & SFNHASFIGHTERS)) 531
606 { 532 if (mis->ms_type == MISSILETHINGY
607 mis->ms_type = MISSILETHINGY; /* If the player no longer has em, */ 533 && near_player(&mis->ms_base, EXPDIST))
608 mis->ms_status = TMOVE; /* make his fighters kamikazes */ 534 {
609 mis->fi_hasfired = 0; 535 explode(&mis->ms_base);
610 break; 536 }
611 } 537 else if (mis->ms_type == FIGHTERTHINGY
612 538 && near_player(&mis->ms_base, FSTRIKEDIST)
613 if ((mis->ms_type == FIGHTERTHINGY) 539 && !mis->fi_hasfired)
614 && ((mis->ms_fuse < .6 * j->p_ship.s_missile.fuse) 540 {
615 || (mis->fi_hasfired)) 541 if (f_torp(mis))
616 && mis->ms_status != TRETURN) 542 mis->fi_hasfired = 1; /* if within strike range, fire a torp */
617 mis->ms_status = TRETURN; 543 }
618 544
619 if (mis->ms_turns > 0) 545 if (mis->ms_status == TRETURN &&
620 { 546 f_land(mis))
621 if (mis->ms_type == FIGHTERTHINGY) 547 {
622 { 548 mis->ms_status = TLAND;
623 turn = fighter_track_target(&mis->ms_base, mis->ms_turns); 549 move_missile(i, -1, -1, 1);
624 } 550 }
625 else 551
626 { 552 break;
627 turn = torp_track_opportunity 553
628 (&mis->ms_base, mis->ms_turns, 554 case TDET:
629 configvals->improved_tracking[SS_MISSILE]); 555 explode(&mis->ms_base);
630 } 556 break;
631 mis->ms_dir = (unsigned char) (mis->ms_dir + turn * mis->ms_turns); 557
632 } 558 case TEXPLODE:
633 x = mis->ms_x + mis->ms_speed * Cos[mis->ms_dir] * WARP1; 559 if (mis->ms_fuse-- <= 0)
634 y = mis->ms_y + mis->ms_speed * Sin[mis->ms_dir] * WARP1; 560 {
635 561 mis->ms_status = TFREE;
636 #if 0 562 players[mis->ms_owner].p_nthingys--;
637 if (outofbounds(x, y)) 563 move_missile(i, -1, -1, 1);
638 { 564 }
639 explode(&mis->ms_base); 565 break;
640 break; 566 default:
641 } 567 mis->ms_status = TFREE;
642 #endif 568 break;
643
644 move_missile(i, x, y, 1);
645
646 if (mis->ms_status != TSTRAIGHT)
647 mis->ms_dir += (lrand48() % 3) - 1;
648
649 if (mis->ms_type == MISSILETHINGY
650 && near_player(&mis->ms_base, EXPDIST))
651 {
652 explode(&mis->ms_base);
653 }
654 else if (mis->ms_type == FIGHTERTHINGY
655 && near_player(&mis->ms_base, FSTRIKEDIST)
656 && !mis->fi_hasfired)
657 {
658 if (f_torp(mis))
659 mis->fi_hasfired = 1; /* if within strike range, fire a torp */
660 }
661
662 if (mis->ms_status == TRETURN &&
663 f_land(mis))
664 {
665 mis->ms_status = TLAND;
666 move_missile(i, -1, -1, 1);
667 }
668
669 break;
670
671 case TDET:
672 explode(&mis->ms_base);
673 break;
674
675 case TEXPLODE:
676 if (mis->ms_fuse-- <= 0)
677 {
678 mis->ms_status = TFREE;
679 players[mis->ms_owner].p_nthingys--;
680 move_missile(i, -1, -1, 1);
681 }
682 break;
683 default:
684 mis->ms_status = TFREE;
685 break;
686 } 569 }
687 } 570 }
688 } 571 }
689 572
690 int 573 int
697 float a, b, c, d; 580 float a, b, c, d;
698 float t; 581 float t;
699 float tdx, tdy; 582 float tdx, tdy;
700 float theta; 583 float theta;
701 584
702 #if 1 /* mathematically, these affect t, but not 585 /* mathematically, these affect t, but not
703 * the return value */ 586 * the return value */
704 s *= WARP1 * TICKSPERSEC; 587 s *= WARP1 * TICKSPERSEC;
705 w *= WARP1 * TICKSPERSEC; 588 w *= WARP1 * TICKSPERSEC;
706 #endif
707 589
708 sdx = s * Cos[dir]; 590 sdx = s * Cos[dir];
709 sdy = s * Sin[dir]; 591 sdy = s * Sin[dir];
710 592
711 a = s * (float) s - w * (float) w; 593 a = s * (float) s - w * (float) w;
857 739
858 for (i = 0, j = &plasmatorps[i]; i < MAXPLAYER * MAXPLASMA; i++, j++) 740 for (i = 0, j = &plasmatorps[i]; i < MAXPLAYER * MAXPLASMA; i++, j++)
859 { 741 {
860 switch (j->pt_status) 742 switch (j->pt_status)
861 { /* check torp's status */ 743 { /* check torp's status */
862 case PTFREE: /* if plasma not being fired */ 744 case PTFREE: /* if plasma not being fired */
863 continue; /* go to next plasma */ 745 continue; /* go to next plasma */
864 case PTMOVE: /* if plasma moving */ 746 case PTMOVE: /* if plasma moving */
865 turn = torp_track_opportunity 747 turn = torp_track_opportunity
866 (&j->pt_base, j->pt_turns, 748 (&j->pt_base, j->pt_turns,
867 configvals->improved_tracking[SS_PLASMA]); 749 configvals->improved_tracking[SS_PLASMA]);
868 /* should we go right or left */ 750
869 if (turn < 0) 751 if ((terrain_grid[(int) (j->pt_x) / TGRID_GRANULARITY * TGRID_SIZE +
870 { /* if left then */ 752 (int) (j->pt_y) / TGRID_GRANULARITY].types
871 heading = ((int) j->pt_dir) - j->pt_turns; 753 & T_NEBULA) && neb_effect[SS_PLASMA])
872 j->pt_dir = ((heading < 0) ? ((unsigned char) (256 + heading)) : 754 if(PLASMA_NEB_EFF > (lrand48() % 100)) /* Is plasma affected? */
873 ((unsigned char) heading)); /* no rollunder */ 755 turn = (lrand48() % 2); /* Yes */
874 } 756
875 else if (turn > 0) 757 /* should we go right or left */
876 { /* else if right */ 758 if (turn < 0)
877 heading = ((int) j->pt_dir) + j->pt_turns; 759 { /* if left then */
878 j->pt_dir = ((heading > 255) ? ((unsigned char) (heading - 256)) : 760 heading = ((int) j->pt_dir) - j->pt_turns;
879 ((unsigned char) heading)); /* no rollover */ 761 j->pt_dir = ((heading < 0) ? ((unsigned char) (256 + heading)) :
880 } 762 ((unsigned char) heading)); /* no rollunder */
881 j->pt_x += (double) j->pt_speed * Cos[j->pt_dir] * WARP1; 763 }
882 764 else if (turn > 0)
883 #if 0 765 { /* else if right */
884 if (j->pt_x < 0) 766 heading = ((int) j->pt_dir) + j->pt_turns;
885 { /* if torp at left edge */ 767 j->pt_dir = ((heading > 255) ? ((unsigned char) (heading - 256)) :
886 j->pt_x = 0; /* set x to left edge */ 768 ((unsigned char) heading)); /* no rollover */
887 pexplode(j); /* make torp explode */ 769 }
888 break; /* go to next torp */ 770 j->pt_x += (double) j->pt_speed * Cos[j->pt_dir] * WARP1;
889 } 771
890 else if (j->pt_x > GWIDTH) 772 j->pt_y += (double) j->pt_speed * Sin[j->pt_dir] * WARP1;
891 { /* if torp is at right edge */ 773 if (j->pt_fuse-- <= 0)
892 j->pt_x = GWIDTH; /* set x to right edge */ 774 { /* dec the torp fuse. if torp done */
893 pexplode(j); /* make torp explode */ 775 j->pt_status = PTFREE; /* free it up */
894 break; /* on to next torp */ 776 players[j->pt_owner].p_nplasmatorp--; /* dec p-torps fired */
895 } 777 break;
896 #endif 778 }
897 j->pt_y += (double) j->pt_speed * Sin[j->pt_dir] * WARP1; 779
898 #if 0 780 if ((terrain_grid[(int) (j->pt_x) / TGRID_GRANULARITY * TGRID_SIZE +
899 if (j->pt_y < 0) 781 (int) (j->pt_y) / TGRID_GRANULARITY].types
900 { /* if torp at top */ 782 & T_ASTEROIDS) &&
901 j->pt_y = 0; /* set torp to top edge */ 783 ast_effect[SS_PLASMA])
902 pexplode(j); /* make torp explode */ 784 if (PLASMA_HIT_AST > (lrand48() % 100))
903 break; /* on to next torp */ 785 {
904 } 786 pexplode(j);
905 else if (j->pt_y > GWIDTH) 787 break;
906 { /* if torp is at bottom */ 788 }
907 j->pt_y = GWIDTH; /* set y to bottom */ 789
908 pexplode(j); /* make torp explode */ 790 if ((sun_effect[SS_PLASMA] && weap_near_object(&j->pt_base, PLSTAR, ORBDIST))
909 break; /* on to next torp */ 791 ||
910 } 792 (sun_effect[SS_PLASMA] && weap_near_object(&j->pt_base, PLWHOLE, ORBDIST))
911 #endif 793 /* did it hit a star? */
912 794 || pnear(j) /* or a player */ )
913 if (j->pt_fuse-- <= 0) 795 {
914 { /* dec the torp fuse. if torp done */ 796 pexplode(j);
915 j->pt_status = PTFREE; /* free it up */ 797 }
916 players[j->pt_owner].p_nplasmatorp--; /* dec p-torps fired */ 798 break; /* on to next torp */
917 break; 799 case PTDET: /* if torp was detted */
918 } 800 pexplode(j); /* make it explode */
919 801 break; /* on to next torp */
920 if ((terrain_grid[(int) (j->pt_x) / TGRID_GRANULARITY * TGRID_SIZE + 802 case PTEXPLODE: /* if torp is exploding */
921 (int) (j->pt_y) / TGRID_GRANULARITY].types 803 if (j->pt_fuse-- <= 0)
922 & T_ASTEROIDS) && 804 { /* dec the timer until torp dead */
923 ast_effect[SS_PLASMA]) 805 j->pt_status = PTFREE; /* set the torp free is timer zero */
924 if (PLASMA_HIT_AST > (lrand48() % 100)) 806 players[j->pt_owner].p_nplasmatorp--; /* dec ptorps fired by player */
925 { 807 }
926 pexplode(j); 808 break;
927 break; 809 default: /* Shouldn't happen */
928 } 810 j->pt_status = PTFREE; /* free torp if it got screwed */
929 811 break; /* on to next torp */
930 if ((sun_effect[SS_PLASMA] && weap_near_object(&j->pt_base, PLSTAR, ORBDIST))
931 ||
932 (sun_effect[SS_PLASMA] && weap_near_object(&j->pt_base, PLWHOLE, ORBDIST))
933 /* did it hit a star? */
934 || pnear(j) /* or a player */ )
935 {
936 pexplode(j);
937 }
938 break; /* on to next torp */
939 case PTDET: /* if torp was detted */
940 pexplode(j); /* make it explode */
941 break; /* on to next torp */
942 case PTEXPLODE: /* if torp is exploding */
943 if (j->pt_fuse-- <= 0)
944 { /* dec the timer until torp dead */
945 j->pt_status = PTFREE; /* set the torp free is timer zero */
946 players[j->pt_owner].p_nplasmatorp--; /* dec ptorps fired by player */
947 }
948 break;
949 default: /* Shouldn't happen */
950 j->pt_status = PTFREE; /* free torp if it got screwed */
951 break; /* on to next torp */
952 } 812 }
953 } 813 }
954 } 814 }
955 815
956 816