Mercurial > ~darius > hgwebdir.cgi > paradise_server
diff 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 |
line wrap: on
line diff
--- 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);