void drown(region * r) { if (fval(r->terrain, SEA_REGION)) { unit **up = up = &r->units; while (*up) { unit *u = *up; int amphibian_level = 0; if (u->ship || u_race(u) == get_race(RC_SPELL) || u->number == 0) { up = &u->next; continue; } if (amphibian_level) { int dead = damage_unit(u, "5d1", false, false); if (dead) { ADDMSG(&u->faction->msgs, msg_message("drown_amphibian_dead", "amount unit region", dead, u, r)); } else { ADDMSG(&u->faction->msgs, msg_message("drown_amphibian_nodead", "unit region", u, r)); } } else if (!(canswim(u) || canfly(u))) { scale_number(u, 0); ADDMSG(&u->faction->msgs, msg_message("drown", "unit region", u, r)); } if (*up == u) up = &u->next; } remove_empty_units_in_region(r); } }
damage_unit load_damage_unit( JsonObject &curr ) { damage_type dt = dt_by_name( curr.get_string( "damage_type" ) ); if( dt == DT_NULL ) { curr.throw_error( "Invalid damage type" ); } float amount = curr.get_float( "amount" ); int arpen = curr.get_int( "armor_penetration", 0 ); float armor_mul = curr.get_float( "armor_multiplier", 1.0f ); float damage_mul = curr.get_float( "damage_multiplier", 1.0f ); return damage_unit( dt, amount, arpen, armor_mul, damage_mul ); }
static void volcano_destruction(region * volcano, region * r, region * rn, const char *damage) { attrib *a; unit **up; int percent = 25, time = 6 + rng_int() % 12; rsettrees(r, 2, 0); rsettrees(r, 1, 0); rsettrees(r, 0, 0); a = a_find(r->attribs, &at_reduceproduction); if (!a) { a = make_reduceproduction(percent, time); } else { /* Produktion vierteln ... */ a->data.sa[0] = (short)percent; /* Für 6-17 Runden */ a->data.sa[1] = (short)(a->data.sa[1] + time); } /* Personen bekommen 4W10 Punkte Schaden. */ for (up = &r->units; *up;) { unit *u = *up; if (u->number) { int dead = damage_unit(u, damage, true, false); if (dead) { ADDMSG(&u->faction->msgs, msg_message("volcano_dead", "unit region dead", u, volcano, dead)); } if (r == volcano && !fval(u->faction, FFL_SELECT)) { fset(u->faction, FFL_SELECT); if (rn) { ADDMSG(&u->faction->msgs, msg_message("volcanooutbreak", "regionv regionn", r, rn)); } else { ADDMSG(&u->faction->msgs, msg_message("volcanooutbreaknn", "region", r)); } } } if (u == *up) up = &u->next; } remove_empty_units_in_region(r); }