forked from github/server
Merge pull request #413 from ennorehling/master
fixed ships taking damage in a storm
This commit is contained in:
commit
0c7c67a7ab
16
src/move.c
16
src/move.c
|
@ -1779,6 +1779,9 @@ sail(unit * u, order * ord, bool move_on_land, region_list ** routep)
|
||||||
faction *f = u->faction;
|
faction *f = u->faction;
|
||||||
region *next_point = NULL;
|
region *next_point = NULL;
|
||||||
int error;
|
int error;
|
||||||
|
double damage_storm = get_param_flt(global.parameters, "rules.ship.damage_storm", 0.02);
|
||||||
|
bool storms_enabled = get_param_int(global.parameters, "rules.ship.storms", 1) != 0;
|
||||||
|
int lighthouse_div = get_param_int(global.parameters, "rules.storm.lighthouse.divisor", 0);
|
||||||
const char *token = getstrtoken();
|
const char *token = getstrtoken();
|
||||||
|
|
||||||
if (routep)
|
if (routep)
|
||||||
|
@ -1830,7 +1833,7 @@ sail(unit * u, order * ord, bool move_on_land, region_list ** routep)
|
||||||
if (!flying_ship(sh)) {
|
if (!flying_ship(sh)) {
|
||||||
int stormchance = 0;
|
int stormchance = 0;
|
||||||
int reason;
|
int reason;
|
||||||
bool storms_enabled = get_param_int(global.parameters, "rules.ship.storms", 1) != 0;
|
|
||||||
if (storms_enabled) {
|
if (storms_enabled) {
|
||||||
int stormyness;
|
int stormyness;
|
||||||
gamedate date;
|
gamedate date;
|
||||||
|
@ -1840,9 +1843,8 @@ sail(unit * u, order * ord, bool move_on_land, region_list ** routep)
|
||||||
/* storms should be the first thing we do. */
|
/* storms should be the first thing we do. */
|
||||||
stormchance = stormyness / shipspeed(sh, u);
|
stormchance = stormyness / shipspeed(sh, u);
|
||||||
if (check_leuchtturm(next_point, NULL)) {
|
if (check_leuchtturm(next_point, NULL)) {
|
||||||
int param = get_param_int(global.parameters, "rules.lighthous.stormchancedevisor", 0);
|
if (lighthouse_div > 0) {
|
||||||
if (param > 0) {
|
stormchance /= lighthouse_div;
|
||||||
stormchance /= param;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
stormchance = 0;
|
stormchance = 0;
|
||||||
|
@ -1875,6 +1877,12 @@ sail(unit * u, order * ord, bool move_on_land, region_list ** routep)
|
||||||
ADDMSG(&f->msgs, msg_message("storm", "ship region sink",
|
ADDMSG(&f->msgs, msg_message("storm", "ship region sink",
|
||||||
sh, current_point, sh->damage >= sh->size * DAMAGE_SCALE));
|
sh, current_point, sh->damage >= sh->size * DAMAGE_SCALE));
|
||||||
|
|
||||||
|
damage_ship(sh, damage_storm);
|
||||||
|
if (sh->damage >= sh->size * DAMAGE_SCALE) {
|
||||||
|
/* ship sinks, end journey here */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
next_point = rnext;
|
next_point = rnext;
|
||||||
/* these values need to be updated if next_point changes (due to storms): */
|
/* these values need to be updated if next_point changes (due to storms): */
|
||||||
tnext = next_point->terrain;
|
tnext = next_point->terrain;
|
||||||
|
|
Loading…
Reference in New Issue