[Freeciv-Dev] (PR#13344) [Patch] Helicopter HP loss to unit_class struct
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=13344 >
There seemed to be no AI handling at all for this rule?
Applies on top of #13334
- ML
diff -Nurd -X.diff_ignore freeciv/common/unittype.c freeciv/common/unittype.c
--- freeciv/common/unittype.c 2005-06-26 17:28:46.062500000 +0300
+++ freeciv/common/unittype.c 2005-06-26 17:51:27.921875000 +0300
@@ -65,12 +65,12 @@
};
struct unit_class unit_classes[] = {
- { UCL_AIR, { FALSE, FALSE }},
- { UCL_HELICOPTER, { FALSE, FALSE }},
- { UCL_LAND, { TRUE, TRUE }},
- { UCL_MISSILE, { FALSE, FALSE }},
- { UCL_NUCLEAR, { FALSE, FALSE }},
- { UCL_SEA, { TRUE, TRUE }}
+ { UCL_AIR, { FALSE, FALSE }, 0},
+ { UCL_HELICOPTER, { FALSE, FALSE }, 10},
+ { UCL_LAND, { TRUE, TRUE }, 0},
+ { UCL_MISSILE, { FALSE, FALSE }, 0},
+ { UCL_NUCLEAR, { FALSE, FALSE }, 0},
+ { UCL_SEA, { TRUE, TRUE }, 0}
};
/**************************************************************************
diff -Nurd -X.diff_ignore freeciv/common/unittype.h freeciv/common/unittype.h
--- freeciv/common/unittype.h 2005-06-26 17:28:46.062500000 +0300
+++ freeciv/common/unittype.h 2005-06-26 17:41:37.968750000 +0300
@@ -55,6 +55,7 @@
struct unit_class {
Unit_Class_id id;
struct move_params move;
+ int hp_loss_pct; /* Percentage of hitpoints lost each turn not in
city or airbase */
};
/* Unit "special effects" flags:
diff -Nurd -X.diff_ignore freeciv/server/unittools.c freeciv/server/unittools.c
--- freeciv/server/unittools.c 2005-06-26 17:28:46.125000000 +0300
+++ freeciv/server/unittools.c 2005-06-26 17:57:30.921875000 +0300
@@ -470,6 +470,8 @@
static void unit_restore_hitpoints(struct unit *punit)
{
bool was_lower;
+ struct unit_class *class = get_unit_class(punit->type);
+ struct city *pcity = tile_get_city(punit->tile);
was_lower=(punit->hp < unit_type(punit)->hp);
@@ -480,12 +482,8 @@
/* Bonus recovery HP (traditionally from the United Nations) */
punit->hp += get_unit_bonus(punit, EFT_UNIT_RECOVER);
- if(is_heli_unit(punit)) {
- struct city *pcity = tile_get_city(punit->tile);
- if(!pcity) {
- if (!tile_has_special(punit->tile, S_AIRBASE))
- punit->hp-=unit_type(punit)->hp/10;
- }
+ if(!pcity && !tile_has_special(punit->tile, S_AIRBASE)) {
+ punit->hp -= unit_type(punit)->hp * class->hp_loss_pct / 100;
}
if(punit->hp>=unit_type(punit)->hp) {
@@ -534,6 +532,8 @@
{
int hp;
struct city *pcity;
+ struct unit_class *class = get_unit_class(punit->type);
+
if (unit_on_fortress(punit))
hp=unit_type(punit)->hp/4;
else
@@ -550,8 +550,9 @@
else
hp=unit_type(punit)->hp/3;
}
- else if (!is_heli_unit(punit))
+ else if (!class->hp_loss_pct) {
hp++;
+ }
if(punit->activity==ACTIVITY_FORTIFIED)
hp++;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#13344) [Patch] Helicopter HP loss to unit_class structure,
Marko Lindqvist <=
|
|