# HG changeset patch # User darius # Date 881421717 0 # Node ID d28f3d01043c9c5f839097c2a263e7396ff73ea8 # Parent b7fe2e0e4b86ebcefe0b393991bc8a0dcde7083a Add code to make nebulous terrain increase penetration of sheilds. diff -r b7fe2e0e4b86 -r d28f3d01043c src/dutil.c --- a/src/dutil.c Sat Dec 06 06:27:50 1997 +0000 +++ b/src/dutil.c Sat Dec 06 15:21:57 1997 +0000 @@ -196,12 +196,25 @@ if (victim->p_flags & PFSHIELD) { /* shields up? */ - int penetrated; + int penetrated, factor; /* * if the server is configured for damage penetration then the shields * will not absorb all the damage */ - penetrated = damage * configvals->penetration + + /* Holds the initial penetration factor */ + factor = configvals->penetration; + + /* Are we in nebulous terrain? */ + if ((terrain_grid[(int) (j->t_x) / TGRID_GRANULARITY * TGRID_SIZE + + (int) (j->t_y) / TGRID_GRANULARITY].types + & T_NEBULA) && neb_effect[SS_SHIELD]) + factor += drand48(); /* Yes - add something to the penetration factor */ + + if(factor > 1) /* Check for overflow */ + factor = 1; + + penetrated = damage * factor * (victim->p_ship.s_maxshield - victim->p_shield) / (victim->p_ship.s_maxshield); damage -= penetrated; @@ -224,22 +237,22 @@ float chance = damage * configvals->erosion; while (chance >= 0.5) { /* no matter how much you suffer there's a - * chance you can avoid permanent damage */ - if (lrand48() & 0x40) - { - victim->p_ship.s_maxdamage--; /* apply damage to maximum */ - victim->p_damage--; /* instead of current */ - } - chance -= 0.5; + * chance you can avoid permanent damage */ + if (lrand48() & 0x40) + { + victim->p_ship.s_maxdamage--; /* apply damage to maximum */ + victim->p_damage--; /* instead of current */ + } + chance -= 0.5; } if (drand48() < chance) { - victim->p_ship.s_maxdamage--; /* apply damage to maximum */ - victim->p_damage--; /* instead of current */ + victim->p_ship.s_maxdamage--; /* apply damage to maximum */ + victim->p_damage--; /* instead of current */ } } } - + if (victim->p_damage >= victim->p_ship.s_maxdamage) { /* victim dead? */ cause_kaboom(victim); /* make him explode */ @@ -247,44 +260,44 @@ { victim->p_whydead = why; if (!friendly(sp, victim) - && sp != victim /* hozers were getting credit for killing - * themselves because they were at war with - their own race */ ) + && sp != victim /* hozers were getting credit for killing + * themselves because they were at war with + their own race */ ) { - /* if a hostile player was responsible */ - tlog_plkill(victim, sp, op); - if (victim->p_ship.s_type == PATROL) - sp->p_kills += .5 + ((float) victim->p_armies + victim->p_kills) / 10.0; - else - sp->p_kills += 1.0 + ((float) victim->p_armies + victim->p_kills) / 10.0; - killerstats(sp->p_no, victim); /* adjust everyones stats */ - checkmaxkills(sp->p_no); - killmess(victim, sp); - victim->p_whodead = sp->p_no; + /* if a hostile player was responsible */ + tlog_plkill(victim, sp, op); + if (victim->p_ship.s_type == PATROL) + sp->p_kills += .5 + ((float) victim->p_armies + victim->p_kills) / 10.0; + else + sp->p_kills += 1.0 + ((float) victim->p_armies + victim->p_kills) / 10.0; + killerstats(sp->p_no, victim); /* adjust everyones stats */ + checkmaxkills(sp->p_no); + killmess(victim, sp); + victim->p_whodead = sp->p_no; } else if (op && !friendly(op, victim) && op != victim) { - /* the primary assassin was friendly, check auxiliary killer */ - tlog_plkill(victim, op, sp); - - if (victim->p_ship.s_type == PATROL) - op->p_kills += .5 + ((float) victim->p_armies + victim->p_kills) / 10.0; - else - op->p_kills += 1.0 + ((float) victim->p_armies + victim->p_kills) / 10.0; - killerstats(op->p_no, victim); /* adjust everyones stats */ - checkmaxkills(op->p_no); - killmess(victim, op); - victim->p_whodead = op->p_no; + /* the primary assassin was friendly, check auxiliary killer */ + tlog_plkill(victim, op, sp); + + if (victim->p_ship.s_type == PATROL) + op->p_kills += .5 + ((float) victim->p_armies + victim->p_kills) / 10.0; + else + op->p_kills += 1.0 + ((float) victim->p_armies + victim->p_kills) / 10.0; + killerstats(op->p_no, victim); /* adjust everyones stats */ + checkmaxkills(op->p_no); + killmess(victim, op); + victim->p_whodead = op->p_no; } else { - /* - * give no credit since it was friendly and the auxiliary murderer - * was friendly too - */ - tlog_plkill(victim, sp, (struct player *) 0); - killmess(victim, sp); - victim->p_whodead = sp->p_no; + /* + * give no credit since it was friendly and the auxiliary murderer + * was friendly too + */ + tlog_plkill(victim, sp, (struct player *) 0); + killmess(victim, sp); + victim->p_whodead = sp->p_no; } } loserstats(victim->p_no);