comparison src/dutil.c @ 15:d28f3d01043c

Add code to make nebulous terrain increase penetration of sheilds.
author darius
date Sat, 06 Dec 1997 15:21:57 +0000
parents cafa94d86546
children 65de6eb6861a
comparison
equal deleted inserted replaced
14:b7fe2e0e4b86 15:d28f3d01043c
194 return 0; 194 return 0;
195 } 195 }
196 196
197 if (victim->p_flags & PFSHIELD) 197 if (victim->p_flags & PFSHIELD)
198 { /* shields up? */ 198 { /* shields up? */
199 int penetrated; 199 int penetrated, factor;
200 /* 200 /*
201 * if the server is configured for damage penetration then the shields 201 * if the server is configured for damage penetration then the shields
202 * will not absorb all the damage 202 * will not absorb all the damage
203 */ 203 */
204 penetrated = damage * configvals->penetration 204
205 /* Holds the initial penetration factor */
206 factor = configvals->penetration;
207
208 /* Are we in nebulous terrain? */
209 if ((terrain_grid[(int) (j->t_x) / TGRID_GRANULARITY * TGRID_SIZE +
210 (int) (j->t_y) / TGRID_GRANULARITY].types
211 & T_NEBULA) && neb_effect[SS_SHIELD])
212 factor += drand48(); /* Yes - add something to the penetration factor */
213
214 if(factor > 1) /* Check for overflow */
215 factor = 1;
216
217 penetrated = damage * factor
205 * (victim->p_ship.s_maxshield - victim->p_shield) 218 * (victim->p_ship.s_maxshield - victim->p_shield)
206 / (victim->p_ship.s_maxshield); 219 / (victim->p_ship.s_maxshield);
207 damage -= penetrated; 220 damage -= penetrated;
208 221
209 victim->p_shield -= damage; /* damage shields */ 222 victim->p_shield -= damage; /* damage shields */
222 if (configvals->erosion > 0) 235 if (configvals->erosion > 0)
223 { 236 {
224 float chance = damage * configvals->erosion; 237 float chance = damage * configvals->erosion;
225 while (chance >= 0.5) 238 while (chance >= 0.5)
226 { /* no matter how much you suffer there's a 239 { /* no matter how much you suffer there's a
227 * chance you can avoid permanent damage */ 240 * chance you can avoid permanent damage */
228 if (lrand48() & 0x40) 241 if (lrand48() & 0x40)
229 { 242 {
230 victim->p_ship.s_maxdamage--; /* apply damage to maximum */ 243 victim->p_ship.s_maxdamage--; /* apply damage to maximum */
231 victim->p_damage--; /* instead of current */ 244 victim->p_damage--; /* instead of current */
232 } 245 }
233 chance -= 0.5; 246 chance -= 0.5;
234 } 247 }
235 if (drand48() < chance) 248 if (drand48() < chance)
236 { 249 {
237 victim->p_ship.s_maxdamage--; /* apply damage to maximum */ 250 victim->p_ship.s_maxdamage--; /* apply damage to maximum */
238 victim->p_damage--; /* instead of current */ 251 victim->p_damage--; /* instead of current */
239 } 252 }
240 } 253 }
241 } 254 }
242 255
243 if (victim->p_damage >= victim->p_ship.s_maxdamage) 256 if (victim->p_damage >= victim->p_ship.s_maxdamage)
244 { /* victim dead? */ 257 { /* victim dead? */
245 cause_kaboom(victim); /* make him explode */ 258 cause_kaboom(victim); /* make him explode */
246 if (sp) 259 if (sp)
247 { 260 {
248 victim->p_whydead = why; 261 victim->p_whydead = why;
249 if (!friendly(sp, victim) 262 if (!friendly(sp, victim)
250 && sp != victim /* hozers were getting credit for killing 263 && sp != victim /* hozers were getting credit for killing
251 * themselves because they were at war with 264 * themselves because they were at war with
252 their own race */ ) 265 their own race */ )
253 { 266 {
254 /* if a hostile player was responsible */ 267 /* if a hostile player was responsible */
255 tlog_plkill(victim, sp, op); 268 tlog_plkill(victim, sp, op);
256 if (victim->p_ship.s_type == PATROL) 269 if (victim->p_ship.s_type == PATROL)
257 sp->p_kills += .5 + ((float) victim->p_armies + victim->p_kills) / 10.0; 270 sp->p_kills += .5 + ((float) victim->p_armies + victim->p_kills) / 10.0;
258 else 271 else
259 sp->p_kills += 1.0 + ((float) victim->p_armies + victim->p_kills) / 10.0; 272 sp->p_kills += 1.0 + ((float) victim->p_armies + victim->p_kills) / 10.0;
260 killerstats(sp->p_no, victim); /* adjust everyones stats */ 273 killerstats(sp->p_no, victim); /* adjust everyones stats */
261 checkmaxkills(sp->p_no); 274 checkmaxkills(sp->p_no);
262 killmess(victim, sp); 275 killmess(victim, sp);
263 victim->p_whodead = sp->p_no; 276 victim->p_whodead = sp->p_no;
264 } 277 }
265 else if (op && !friendly(op, victim) && op != victim) 278 else if (op && !friendly(op, victim) && op != victim)
266 { 279 {
267 /* the primary assassin was friendly, check auxiliary killer */ 280 /* the primary assassin was friendly, check auxiliary killer */
268 tlog_plkill(victim, op, sp); 281 tlog_plkill(victim, op, sp);
269 282
270 if (victim->p_ship.s_type == PATROL) 283 if (victim->p_ship.s_type == PATROL)
271 op->p_kills += .5 + ((float) victim->p_armies + victim->p_kills) / 10.0; 284 op->p_kills += .5 + ((float) victim->p_armies + victim->p_kills) / 10.0;
272 else 285 else
273 op->p_kills += 1.0 + ((float) victim->p_armies + victim->p_kills) / 10.0; 286 op->p_kills += 1.0 + ((float) victim->p_armies + victim->p_kills) / 10.0;
274 killerstats(op->p_no, victim); /* adjust everyones stats */ 287 killerstats(op->p_no, victim); /* adjust everyones stats */
275 checkmaxkills(op->p_no); 288 checkmaxkills(op->p_no);
276 killmess(victim, op); 289 killmess(victim, op);
277 victim->p_whodead = op->p_no; 290 victim->p_whodead = op->p_no;
278 } 291 }
279 else 292 else
280 { 293 {
281 /* 294 /*
282 * give no credit since it was friendly and the auxiliary murderer 295 * give no credit since it was friendly and the auxiliary murderer
283 * was friendly too 296 * was friendly too
284 */ 297 */
285 tlog_plkill(victim, sp, (struct player *) 0); 298 tlog_plkill(victim, sp, (struct player *) 0);
286 killmess(victim, sp); 299 killmess(victim, sp);
287 victim->p_whodead = sp->p_no; 300 victim->p_whodead = sp->p_no;
288 } 301 }
289 } 302 }
290 loserstats(victim->p_no); 303 loserstats(victim->p_no);
291 return 1; /* victim died */ 304 return 1; /* victim died */
292 } 305 }