6
|
1 /*--------------------------------------------------------------------------
|
|
2 NETREK II -- Paradise
|
|
3
|
|
4 Permission to use, copy, modify, and distribute this software and its
|
|
5 documentation, or any derivative works thereof, for any NON-COMMERCIAL
|
|
6 purpose and without fee is hereby granted, provided that this copyright
|
|
7 notice appear in all copies. No representations are made about the
|
|
8 suitability of this software for any purpose. This software is provided
|
|
9 "as is" without express or implied warranty.
|
|
10
|
|
11 Xtrek Copyright 1986 Chris Guthrie
|
|
12 Netrek (Xtrek II) Copyright 1989 Kevin P. Smith
|
|
13 Scott Silvey
|
|
14 Paradise II (Netrek II) Copyright 1993 Larry Denys
|
|
15 Kurt Olsen
|
|
16 Brandon Gillespie
|
|
17 --------------------------------------------------------------------------*/
|
|
18
|
|
19 #include "config.h"
|
|
20 #include <stdio.h>
|
|
21 #include <sys/types.h>
|
|
22 #include <sys/ipc.h>
|
|
23 #include <sys/shm.h>
|
|
24 #include "defs.h"
|
|
25 #include "struct.h"
|
|
26 #include "data.h"
|
|
27 #include "shmem.h"
|
|
28
|
|
29
|
|
30
|
|
31
|
|
32
|
|
33 /*-----------------------------VISIBLE FUNCTIONS---------------------------*/
|
|
34
|
|
35 /*--------------------------------NPLASMATORP------------------------------*/
|
|
36 /*
|
|
37 * This function fires a plasma torp. It checks a number of conditions to
|
|
38 * see if it is allowable to fire a plasma torp. If so the the plasma if
|
|
39 * fire. The two styles of plasma torp are ones that fire in the direction
|
|
40 * the ship is going and ones that can fire independent of the ships
|
|
41 * direction.
|
|
42 */
|
|
43
|
|
44 void
|
|
45 nplasmatorp(course, type)
|
|
46 unsigned char course; /* direction plasma should go */
|
|
47 int type; /* type of plasma */
|
|
48 {
|
|
49 register int i; /* looping var */
|
|
50 register struct plasmatorp *k;/* to point to plasma torp */
|
|
51
|
|
52 if (weaponsallowed[WP_PLASMA] == 0)
|
|
53 { /* are plasmas enabled */
|
|
54 warning("Plasmas haven't been invented yet.");
|
|
55 return;
|
|
56 }
|
|
57 if (me->p_ship.s_plasma.cost <= 0)
|
|
58 { /* ship can have plasma */
|
|
59 warning("Weapon's Officer: Captain, this ship can't carry plasma torpedoes!");
|
|
60 return;
|
|
61 }
|
|
62 if (!(me->p_specweap & SFNPLASMAARMED))
|
|
63 { /* ship equiped with plasma */
|
|
64 warning("Weapon's Officer: Captain, this ship is not armed with plasma torpedoes!");
|
|
65 return;
|
|
66 }
|
|
67 if (me->p_flags & PFWEP)
|
|
68 { /* ship not w-temped */
|
|
69 warning("Plasma torpedo launch tube has exceeded the maximum safe temperature!");
|
|
70 return;
|
|
71 }
|
|
72 if (me->p_nplasmatorp == MAXPLASMA)
|
|
73 {
|
|
74 warning("Our fire control system limits us to 1 live torpedo at a time captain!");
|
|
75 return;
|
|
76 }
|
|
77 if (me->p_fuel < myship->s_plasma.cost)
|
|
78 { /* have enough fuel? */
|
|
79 warning("We don't have enough fuel to fire a plasma torpedo!");
|
|
80 return;
|
|
81 }
|
|
82 if (me->p_flags & PFREPAIR)
|
|
83 { /* not while in repair mode */
|
|
84 warning("We cannot fire while our vessel is undergoing repairs.");
|
|
85 return;
|
|
86 }
|
|
87 if ((me->p_cloakphase) && (me->p_ship.s_type != ATT))
|
|
88 {
|
|
89 warning("We are unable to fire while in cloak, captain!");
|
|
90 return; /* not while cloaked */
|
|
91 }
|
|
92
|
|
93 if (!check_fire_warp()
|
|
94 || !check_fire_warpprep()
|
|
95 || !check_fire_docked())
|
|
96 return;
|
|
97 me->p_nplasmatorp++; /* inc plasma torps fired */
|
|
98 me->p_fuel -= myship->s_plasma.cost; /* take off the fuel */
|
|
99 me->p_wtemp += myship->s_plasma.wtemp; /* do the w-temp */
|
|
100 for (i = me->p_no * MAXPLASMA, k = &plasmatorps[i];
|
|
101 i < (me->p_no + 1) * MAXPLASMA; i++, k++)
|
|
102 {
|
|
103 if (k->pt_status == PTFREE) /* find a free plasma to fire */
|
|
104 break;
|
|
105 }
|
|
106
|
|
107 k->pt_no = i; /* set plasmas number */
|
|
108 k->pt_status = type; /* set what type plasma is */
|
|
109 k->pt_owner = me->p_no; /* set the owner */
|
|
110 k->pt_team = me->p_team; /* set the team */
|
|
111 k->pt_x = me->p_x; /* set starting coords */
|
|
112 k->pt_y = me->p_y;
|
|
113 if (myship->s_nflags & SFNPLASMASTYLE) /* depending on type set */
|
|
114 k->pt_dir = course; /* any direction */
|
|
115 else
|
|
116 k->pt_dir = me->p_dir; /* or straight ahead of ship */
|
|
117 k->pt_damage = myship->s_plasma.damage; /* set the damage it will do */
|
|
118 k->pt_speed = myship->s_plasma.speed; /* set its speed */
|
|
119 k->pt_war = me->p_hostile | me->p_swar; /* who it doesn't like */
|
|
120 k->pt_fuse = myship->s_plasma.fuse; /* how long it will live */
|
|
121 k->pt_turns = myship->s_plasma.aux; /* how much will it track */
|
|
122 }
|
|
123
|
|
124 /*-------------------------------------------------------------------------*/
|
|
125
|
|
126
|
|
127
|
|
128
|
|
129
|
|
130 /*------END OF FILE-----*/
|