comparison src/weapons.c @ 20:9f180bf494bd default tip

Made torps and fighter wobbly. They have a chance of tracking randomly instead of staying straight or seeking if in nebulous terrain. Option is turned on when NEBULA_EFFECT contains PHOTON and/or FIGHTER.
author darius
date Wed, 24 Dec 1997 12:42:09 +0000
parents ed82a42ba89d
children
comparison
equal deleted inserted replaced
19:de685799a432 20:9f180bf494bd
65 */ 65 */
66 66
67 void 67 void
68 explode_damage(torp, radius, why) 68 explode_damage(torp, radius, why)
69 struct basetorp *torp; 69 struct basetorp *torp;
70 int radius; 70 int radius;
71 int why; 71 int why;
72 { 72 {
73 register int i; /* looping var */ 73 register int i; /* looping var */
74 int dx, dy, dist; /* to calc distance from torp to players */ 74 int dx, dy, dist; /* to calc distance from torp to players */
75 int damage; /* to hold damage inflicted */ 75 int damage; /* to hold damage inflicted */
76 register struct player *j; /* to point to players */ 76 register struct player *j; /* to point to players */
82 82
83 if (j->p_no == torp->bt_owner) /* General Vote, September, 1995. */ 83 if (j->p_no == torp->bt_owner) /* General Vote, September, 1995. */
84 continue; /* Torps no longer damage owner. */ 84 continue; /* Torps no longer damage owner. */
85 85
86 if ((torp->bt_status == TDET) /* if torp was detted then */ 86 if ((torp->bt_status == TDET) /* if torp was detted then */
87 && ((j->p_no == torp->bt_owner) || /* cannot damage firing 87 && ((j->p_no == torp->bt_owner) || /* cannot damage firing
88 * player */ 88 * player */
89 ((j->p_no != torp->bt_whodet) /* cannot damage players on 89 ((j->p_no != torp->bt_whodet) /* cannot damage players on
90 * same team */ 90 * same team */
91 && (j->p_team == players[torp->bt_whodet].p_team))) 91 && (j->p_team == players[torp->bt_whodet].p_team)))
92 ) /* except the detter */ 92 ) /* except the detter */
93 continue; 93 continue;
94 94
95 dx = torp->bt_x - j->p_x; /* calc delta x and y */ 95 dx = torp->bt_x - j->p_x; /* calc delta x and y */
96 dy = torp->bt_y - j->p_y; 96 dy = torp->bt_y - j->p_y;
100 dist = dx * dx + dy * dy; /* calc distnace squared */ 100 dist = dx * dx + dy * dy; /* calc distnace squared */
101 if (dist > radius * radius) /* if not within damage distance */ 101 if (dist > radius * radius) /* if not within damage distance */
102 continue; /* then continue */ 102 continue; /* then continue */
103 if (dist > EXPDIST * EXPDIST) /* if not direct hit */ 103 if (dist > EXPDIST * EXPDIST) /* if not direct hit */
104 damage = torp->bt_damage * (radius - sqrt((double) dist)) / 104 damage = torp->bt_damage * (radius - sqrt((double) dist)) /
105 (radius - EXPDIST); 105 (radius - EXPDIST);
106 else /* else if direct hit */ 106 else /* else if direct hit */
107 damage = torp->bt_damage; /* do torp damage */ 107 damage = torp->bt_damage; /* do torp damage */
108 108
109 if (damage > 0) 109 if (damage > 0)
110 { /* if damage was done then */ 110 { /* if damage was done then */
111 if (players[torp->bt_owner].p_hostile & j->p_team) /* start war if */ 111 if (players[torp->bt_owner].p_hostile & j->p_team) /* start war if */
112 players[torp->bt_owner].p_swar |= j->p_team; /* necessary */ 112 players[torp->bt_owner].p_swar |= j->p_team; /* necessary */
113 inflict_damage(&players[torp->bt_owner], &players[torp->bt_whodet], 113 inflict_damage(&players[torp->bt_owner], &players[torp->bt_whodet],
114 j, damage, why); 114 j, damage, why);
115 } 115 }
116 } 116 }
117 } 117 }
118 118
119 void 119 void
157 157
158 for (i = 0, j = &phasers[i]; i < MAXPLAYER; i++, j++) 158 for (i = 0, j = &phasers[i]; i < MAXPLAYER; i++, j++)
159 { /* all players */ 159 { /* all players */
160 switch (j->ph_status) 160 switch (j->ph_status)
161 { /* check player's phaser status */ 161 { /* check player's phaser status */
162 case PHFREE: /* if not beging fired */ 162 case PHFREE: /* if not beging fired */
163 continue; /* then continue */ 163 continue; /* then continue */
164 case PHMISS: /* if it missed */ 164 case PHMISS: /* if it missed */
165 case PHHIT2: /* or ????? */ 165 case PHHIT2: /* or ????? */
166 if (j->ph_fuse-- == 1) /* dec count of phaser */ 166 if (j->ph_fuse-- == 1) /* dec count of phaser */
167 j->ph_status = PHFREE; /* free it up if count done */ 167 j->ph_status = PHFREE; /* free it up if count done */
168 break; 168 break;
169 case PHHIT: /* if it hit someone then */ 169 case PHHIT: /* if it hit someone then */
170 if (j->ph_fuse-- == players[i].p_ship.s_phaser.fuse) 170 if (j->ph_fuse-- == players[i].p_ship.s_phaser.fuse)
171 { 171 {
172 victim = &players[j->ph_target]; /* get the victim */ 172 victim = &players[j->ph_target]; /* get the victim */
173 if (players[i].p_hostile & victim->p_team) /* start war if */ 173 if (players[i].p_hostile & victim->p_team) /* start war if */
174 players[i].p_swar |= victim->p_team; /* necessary */ 174 players[i].p_swar |= victim->p_team; /* necessary */
175 if (victim->p_status == PALIVE) /* only damage if alive */ 175 if (victim->p_status == PALIVE) /* only damage if alive */
176 inflict_damage(&players[i], 0, victim, j->ph_damage, KPHASER); 176 inflict_damage(&players[i], 0, victim, j->ph_damage, KPHASER);
177 } /* end of if phaser hit someone */ 177 } /* end of if phaser hit someone */
178 if (j->ph_fuse == 0) 178 if (j->ph_fuse == 0)
179 j->ph_status = PHFREE; 179 j->ph_status = PHFREE;
180 break; 180 break;
181 } /* end of switch */ 181 } /* end of switch */
182 } /* end of for loop through players */ 182 } /* end of for loop through players */
183 } 183 }
184 184
185 185
189 /* this function will use the space grid */ 189 /* this function will use the space grid */
190 190
191 int 191 int
192 weap_near_object(torp, type, dist) 192 weap_near_object(torp, type, dist)
193 struct basetorp *torp; 193 struct basetorp *torp;
194 int type; 194 int type;
195 int dist; 195 int dist;
196 { 196 {
197 register struct planet *pl; /* to point to the planets */ 197 register struct planet *pl; /* to point to the planets */
198 int dx, dy, i; 198 int dx, dy, i;
199 199
200 for (i = 0, pl = &planets[i]; i < NUMPLANETS; i++, pl = &planets[i]) 200 for (i = 0, pl = &planets[i]; i < NUMPLANETS; i++, pl = &planets[i])
213 } 213 }
214 214
215 int 215 int
216 near_player(torp, dist) 216 near_player(torp, dist)
217 struct basetorp *torp; /* the torp to check for */ 217 struct basetorp *torp; /* the torp to check for */
218 int dist; 218 int dist;
219 { 219 {
220 register int i; /* looping var */ 220 register int i; /* looping var */
221 int dx, dy; /* to calc torp-player distance */ 221 int dx, dy; /* to calc torp-player distance */
222 register struct player *j; /* to point to players */ 222 register struct player *j; /* to point to players */
223 223
322 if ((terrain_grid[(int) (j->t_x) / TGRID_GRANULARITY * TGRID_SIZE + 322 if ((terrain_grid[(int) (j->t_x) / TGRID_GRANULARITY * TGRID_SIZE +
323 (int) (j->t_y) / TGRID_GRANULARITY].types 323 (int) (j->t_y) / TGRID_GRANULARITY].types
324 & T_NEBULA) && neb_effect[SS_PHOTON]) 324 & T_NEBULA) && neb_effect[SS_PHOTON])
325 if(TORP_NEB_EFF > (lrand48() % 100)) /* Is torp affected? */ 325 if(TORP_NEB_EFF > (lrand48() % 100)) /* Is torp affected? */
326 turn = (lrand48() % 2); /* Yes */ 326 turn = (lrand48() % 2); /* Yes */
327 327
328 if (turn < 0) 328 if (turn < 0)
329 { /* we will go left */ 329 { /* we will go left */
330 heading = ((int) j->t_dir) - j->t_turns; /* turn left */ 330 heading = ((int) j->t_dir) - j->t_turns; /* turn left */
331 if (heading < 0) 331 if (heading < 0)
332 j->t_dir = heading + 256; 332 j->t_dir = heading + 256;
359 move_torp(i, -1, -1, 1); 359 move_torp(i, -1, -1, 1);
360 players[j->t_owner].p_ntorp--; /* let player fire another */ 360 players[j->t_owner].p_ntorp--; /* let player fire another */
361 break; /* no more torp processing */ 361 break; /* no more torp processing */
362 } 362 }
363 if ((sun_effect[SS_PHOTON] && weap_near_object(&j->t_base, PLSTAR, ORBDIST)) 363 if ((sun_effect[SS_PHOTON] && weap_near_object(&j->t_base, PLSTAR, ORBDIST))
364 || 364 ||(wh_effect[SS_PHOTON] && weap_near_object(&j->t_base, PLWHOLE, ORBDIST)))
365 (wh_effect[SS_PHOTON] && weap_near_object(&j->t_base, PLWHOLE, ORBDIST)))
366 { 365 {
367 /* did it hit a star or wormhole? */ 366 /* did it hit a star or wormhole? */
368 j->t_whodet = j->t_owner; 367 j->t_whodet = j->t_owner;
369 explode(&j->t_base); 368 explode(&j->t_base);
370 break; 369 break;