diff options
author | jacopo grandi <jak.sk8@hotmail.it> | 2021-02-20 00:11:23 +0100 |
---|---|---|
committer | jacopo grandi <jak.sk8@hotmail.it> | 2021-02-20 00:11:23 +0100 |
commit | 2eef87c8970db643c4ef09e0fd9e8110c8193043 (patch) | |
tree | 78a9bcc7932ab8edb8669ded755ee2c81afc0912 /gst/info.c | |
parent | c135f85fcdc1eeedd04e0c9e9f626b907500f20a (diff) |
finish condition and bad cost function
Diffstat (limited to 'gst/info.c')
-rw-r--r-- | gst/info.c | 86 |
1 files changed, 84 insertions, 2 deletions
@@ -130,8 +130,10 @@ float info_unit_get_health(infos *info, info_unit *u) { sum += info->augs[u->augs[i]].add_hp[lvl]; } } - sum += info->chassis[u->chassis].hp[lc]; - return sum; + float mult = (1 + sum/100.0f); + if (mult < 0) mult = 0; + float ret = info->chassis[u->chassis].hp[lc] * mult; + return ret; } float info_unit_get_speed(infos *info, info_unit *u) { @@ -175,6 +177,39 @@ float info_unit_get_damage_target (infos *info, info_unit *u, int w, return damage * mult; } +float info_unit_get_aoe (infos *info, info_unit *u, int w) { + int lc = u->levels[LEVEL_CHASSIS]; + float sum = 0; + for(int i=0; i<16; i++) { + if (u->augs[i] != -1 && info->chassis[u->chassis].slot_aug[lc]) { + int lvl = u->levels[LEVEL_AUGS+i]; + //sum += info->augs[u->augs[i]].add_aoe[lvl]; + } + } + int lw = u->levels[LEVEL_WEAPONS+w]; + float dam = info->weapons[u->weapons[w]].aoe[lw] + sum; + return dam; +} + +float info_unit_get_knockback (infos *info, info_unit *u, int w) { + int lc = u->levels[LEVEL_CHASSIS]; + float sum = 0; + for(int i=0; i<16; i++) { + if (u->augs[i] != -1 && info->chassis[u->chassis].slot_aug[lc]) { + int lvl = u->levels[LEVEL_AUGS+i]; + //sum += info->augs[u->augs[i]].add_knockback[lvl]; + } + } + int lw = u->levels[LEVEL_WEAPONS+w]; + float dam = info->weapons[u->weapons[w]].knockback[lw] + sum; + return dam; +} + +float info_unit_get_stun (infos *info, info_unit *u, int w) { + // TODO + return 0; +} + float info_unit_get_cooldown(infos *info, info_unit *u, int w) { int lc = u->levels[LEVEL_CHASSIS]; float sum = 0; @@ -228,6 +263,53 @@ float info_unit_get_armor(infos *info, info_unit *u, int d) { return sum; } +float info_unit_get_cost (infos *info, info_unit *u) { + // see design/notes.txt:implement cost function + float sum = 0; + int lc = u->levels[LEVEL_CHASSIS]; + info_chassis *chassis = info->chassis+u->chassis; + float sumchassis = 0; + sumchassis += powf(2, chassis->slot_weapon[lc])*20; + sumchassis += powf(2, chassis->slot_armor[lc])*10; + sumchassis += powf(2, chassis->slot_aug[lc])*5; + sumchassis += chassis->weight_max[lc]/5; + sumchassis += chassis->hp[lc]/20; + sumchassis += chassis->speed[lc]*32; + sum += sumchassis; + if (u->battery != -1) { + int lb = u->levels[LEVEL_BATTERY]; + info_battery *battery = info->batteries+u->battery; + float sumbattery = 0; + sumbattery += battery->capacity[lb]; + sum += sumbattery; + } + for(int i=0; i<8; i++) { + int lw = u->levels[LEVEL_WEAPONS+i]; + int la = u->levels[LEVEL_ARMOR+i]; + if (u->weapons[i] != -1 && i<chassis->slot_weapon[lc]) { + info_weapon *weapon = info->weapons+u->weapons[i]; + float sumweap = 0; + float dam = info_unit_get_damage(info, u, i); + float cool = info_unit_get_cooldown(info, u, i); + float damtot = dam / cool; + float aoe = info_unit_get_aoe(info, u, i); + float knockback = info_unit_get_knockback(info, u, i); + float stun = info_unit_get_stun(info, u, i); + float mult = 1+aoe*5 + 10; + damtot = damtot*mult; + damtot += knockback * 20 + stun * 50; + sumweap = damtot; + sum += sumweap; + } + } + for(int t=0; t<7; t++) { + float armortot = info_unit_get_armor(info, u, t) * 3; + sum += armortot; + } + + return sum; +} + void weapon_init (info_weapon *w) { strcpy(w->name, "nameless"); |