diff options
-rw-r--r-- | build/army/balance 1000 the second.txt | bin | 21560 -> 0 bytes | |||
-rw-r--r-- | build/army/balance 1000.txt | bin | 21560 -> 0 bytes | |||
-rw-r--r-- | build/army/balance melee maul.txt | bin | 21560 -> 0 bytes | |||
-rw-r--r-- | build/army/best army ever.txt | bin | 21560 -> 0 bytes | |||
-rw-r--r-- | build/army/lotsa dudes.txt | bin | 21560 -> 0 bytes | |||
-rw-r--r-- | build/army/new army.txt (renamed from build/army/balance 1000 melee.txt) | bin | 21560 -> 25656 bytes | |||
-rw-r--r-- | build/army/range test.txt | bin | 21560 -> 0 bytes | |||
-rw-r--r-- | build/army/worst.txt | bin | 21560 -> 0 bytes | |||
-rw-r--r-- | build/content/armor.txt | 44 | ||||
-rw-r--r-- | build/content/templates/default.txt | 2 | ||||
-rw-r--r-- | build/test.exe | bin | 823970 -> 809746 bytes | |||
-rw-r--r-- | gst/gst.c | 21 | ||||
-rw-r--r-- | gst/gst.h | 4 | ||||
-rw-r--r-- | gst/info.c | 151 | ||||
-rw-r--r-- | gst/info.h | 12 | ||||
-rw-r--r-- | gst/units.c | 53 | ||||
-rw-r--r-- | gst/units.h | 13 | ||||
-rw-r--r-- | hud/hud.c | 83 | ||||
-rw-r--r-- | hud/hud_views.c | 282 |
19 files changed, 313 insertions, 352 deletions
diff --git a/build/army/balance 1000 the second.txt b/build/army/balance 1000 the second.txt Binary files differdeleted file mode 100644 index ef02fec..0000000 --- a/build/army/balance 1000 the second.txt +++ /dev/null diff --git a/build/army/balance 1000.txt b/build/army/balance 1000.txt Binary files differdeleted file mode 100644 index cecec84..0000000 --- a/build/army/balance 1000.txt +++ /dev/null diff --git a/build/army/balance melee maul.txt b/build/army/balance melee maul.txt Binary files differdeleted file mode 100644 index a3ababa..0000000 --- a/build/army/balance melee maul.txt +++ /dev/null diff --git a/build/army/best army ever.txt b/build/army/best army ever.txt Binary files differdeleted file mode 100644 index 5898346..0000000 --- a/build/army/best army ever.txt +++ /dev/null diff --git a/build/army/lotsa dudes.txt b/build/army/lotsa dudes.txt Binary files differdeleted file mode 100644 index 6314165..0000000 --- a/build/army/lotsa dudes.txt +++ /dev/null diff --git a/build/army/balance 1000 melee.txt b/build/army/new army.txt Binary files differindex 727e08a..e05c988 100644 --- a/build/army/balance 1000 melee.txt +++ b/build/army/new army.txt diff --git a/build/army/range test.txt b/build/army/range test.txt Binary files differdeleted file mode 100644 index 949cda9..0000000 --- a/build/army/range test.txt +++ /dev/null diff --git a/build/army/worst.txt b/build/army/worst.txt Binary files differdeleted file mode 100644 index aac287a..0000000 --- a/build/army/worst.txt +++ /dev/null diff --git a/build/content/armor.txt b/build/content/armor.txt index de31e24..c4f5486 100644 --- a/build/content/armor.txt +++ b/build/content/armor.txt @@ -6,12 +6,12 @@ 7.5, 5.0 ], - "base_pierce": [ + "base_armor_pierce": [ 5.0, 6.25, 7.5 ], - "base_spread": [ + "base_armor_spread": [ 8.0, 10.0, 12.0 @@ -24,17 +24,17 @@ 12.0, 8.0 ], - "base_pierce": [ + "base_armor_pierce": [ 7.0, 8.75, 10.5 ], - "base_spread": [ + "base_armor_spread": [ 10.0, 12.5, 15.0 ], - "base_impact": [ + "base_armor_impact": [ 5.0, 6.25, 7.5 @@ -47,7 +47,7 @@ 6.0, 4.0 ], - "base_laser": [ + "base_armor_laser": [ 10.0, 12.5, 15.0 @@ -60,7 +60,7 @@ 7.5, 5.0 ], - "base_fusion": [ + "base_armor_fusion": [ 8.0, 10.0, 12.0 @@ -73,12 +73,12 @@ 3.0, 2.0 ], - "base_spread": [ + "base_armor_spread": [ 5.0, 6.25, 7.5 ], - "base_impact": [ + "base_armor_impact": [ 8.0, 10.0, 12.0 @@ -91,7 +91,7 @@ 11.25, 7.5 ], - "base_explosive": [ + "base_armor_explosive": [ 12.0, 15.0, 18.0 @@ -104,27 +104,27 @@ 3.75, 2.5 ], - "base_pierce": [ + "base_armor_pierce": [ 3.0, 3.75, 4.5 ], - "base_spread": [ + "base_armor_spread": [ 3.0, 3.75, 4.5 ], - "base_fusion": [ + "base_armor_fusion": [ 3.0, 3.75, 4.5 ], - "base_explosive": [ + "base_armor_explosive": [ 3.0, 3.75, 4.5 ], - "base_laser": [ + "base_armor_laser": [ 3.0, 3.75, 4.5 @@ -137,17 +137,17 @@ 4.5, 3.0 ], - "base_pierce": [ + "base_armor_pierce": [ 6.0, 7.5, 9.0 ], - "base_spread": [ + "base_armor_spread": [ 4.0, 5.0, 6.0 ], - "base_impact": [ + "base_armor_impact": [ 3.0, 3.75, 4.5 @@ -160,7 +160,7 @@ 1.5, 1.0 ], - "base_pierce": [ + "base_armor_pierce": [ 4.0, 5.0, 6.0 @@ -173,12 +173,12 @@ 6.75, 4.5 ], - "base_pierce": [ + "base_armor_pierce": [ 10.0, 12.5, 15.0 ], - "base_spread": [ + "base_armor_spread": [ 8.0, 10.0, 12.0 @@ -191,7 +191,7 @@ 15.0, 10.0 ], - "base_explosive": [ + "base_armor_explosive": [ 25.0, 31.25, 37.5 diff --git a/build/content/templates/default.txt b/build/content/templates/default.txt index 88db0c8..775e7d3 100644 --- a/build/content/templates/default.txt +++ b/build/content/templates/default.txt @@ -84,7 +84,7 @@ "chassis": "5", "brain": "3", "battery": "0", - "weapons": [ 10, 10, -1, -1, -1, -1, -1, -1 ], + "weapons": [ 10, 1, -1, -1, -1, -1, -1, -1 ], "armor": [ 0, 0, 8, -1, -1, -1, -1, -1 ], "augs": [ -1, -1, -1, -1, -1, -1, -1, -1 ], "levels": [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] diff --git a/build/test.exe b/build/test.exe Binary files differindex 554180a..1b56cdf 100644 --- a/build/test.exe +++ b/build/test.exe @@ -39,7 +39,13 @@ void gst_lastpos (gamestate *gst) { } } -void gst_tobattle (gamestate *gst) { +void gst_compute_stats (gamestate *gst, infos *info) { + for (int i=0; i<gst->ar.uslen; i++) { + stats_unit_compute(info, &gst->ar.us[i].info, gst->ustats +i); + } +} + +void gst_tobattle (gamestate *gst, infos *info) { if (gst->playernum == 1) { //info_load_army(gst->army_bp+1, "army"); gst->army_bp[1] = gst->army_bp[0]; @@ -70,6 +76,7 @@ void gst_tobattle (gamestate *gst) { gst->ar.us[gst->ar.uslen].owner = i; } } + gst_compute_stats(gst, info); gst_lastpos(gst); gst->starttime = FLT_MAX; gst->turn = 0; @@ -153,11 +160,11 @@ void gst_process (gamestate *gst, infos *info, fxs *fx, float t) { gst->turn ++; map *m; army *ar; gst_get_maparmy(gst, &m, &ar); - int move = army_move(info, ar, m); + int move = army_move(info, ar, m, gst->ustats); a_dmg dmgs[1024*8]; - int fire = army_fire(info, ar, m, dmgs); - army_upkeep(info, ar, m); + int fire = army_fire(info, ar, m, dmgs, gst->ustats); + army_upkeep(info, ar, m, gst->ustats); if (move == 0 && fire == 0) { gst->turn_until_finish--; } else { gst->turn_until_finish = 5; } @@ -194,7 +201,7 @@ void gst_render (SDL_Renderer *rend, SDL_Texture *txsprites, txtd *textd, amt = (amt / gst->turnspeed) + 1; if (amt > 1) amt = 1; if (amt < 0) amt = 0; // clamping away fuzzyness - // render enemies + // render units for (int i=0; i<ar->uslen; i++) { if (ar->us[i].hp <= 0) continue; float present_x = ar->us[i].pos[0]; @@ -210,8 +217,8 @@ void gst_render (SDL_Renderer *rend, SDL_Texture *txsprites, txtd *textd, SDL_Rect dstRect = { (int)x-posx, (int)y-posy, ts, ts }; SDL_RenderCopy(rend, txsprites, &srcRect, &dstRect); - float amt = ar->us[i].hp - / info_unit_get_health(info, &ar->us[i].info); + stats_unit base; stats_unit_compute(info, &ar->us[i].info, &base); + float amt = ar->us[i].hp / base.frame.hp; SDL_Rect hprect = { (int)x-posx, (int)y-posy+ts-5, ts*amt, 6 }; @@ -19,6 +19,8 @@ typedef struct { map map_battle; army ar; float ar_lastpos[MAXUNITS][2]; + stats_unit ustats[MAXUNITS]; + int state; float cam[2]; float starttime; @@ -33,7 +35,7 @@ void gst_init (gamestate *gst); void gst_destroy (gamestate *gst); void gst_get_maparmy(gamestate *gst, map **m, army **ar); -void gst_tobattle (gamestate *gst); +void gst_tobattle (gamestate *gst, infos *info); void gst_toeditor (gamestate *gst); void gst_process (gamestate *gst, infos *info, fxs *fx, float t); @@ -775,6 +775,7 @@ void info_parse_json (infos *info, char *json, char *obj) { void stats_weapon_init (stats_weapon *weap) { LOOP(7) weap->damage[z] = 0; weap->cooldown = 0; + weap->range = 0; weap->aoe = 0; weap->knockback = 0; weap->damage_battery = 0; @@ -811,46 +812,83 @@ void stats_comp_init (stats_comp *comp) { } -#define PRINT_STRUCT(obj, attr, type) { \ +#define PRINT_STRUCT(obj, text, attr, type) { \ if (obj->attr != 0) {\ - printf(" "#attr": %"#type"\n", obj->attr); \ + sprintf(arr[i], "%s: %"#type, text, obj->attr); \ + i ++;\ }\ } -void stats_frame_printf (stats_frame *frame) { - PRINT_STRUCT(frame, hp, f); - PRINT_STRUCT(frame, weight, f); - PRINT_STRUCT(frame, weight_max, f); - PRINT_STRUCT(frame, slot_weapon, d); - PRINT_STRUCT(frame, slot_armor, d); - PRINT_STRUCT(frame, slot_aug, d); - PRINT_STRUCT(frame, speed, f); - PRINT_STRUCT(frame, upkeep, f); - PRINT_STRUCT(frame, capacity, f); - PRINT_STRUCT(frame, recharge, f); - LOOP(7) PRINT_STRUCT(frame, armor[z], f); -} - -void stats_weapon_printf (stats_weapon *weap) { - LOOP(7) PRINT_STRUCT(weap, damage[z], f); - PRINT_STRUCT(weap, cooldown, f); - PRINT_STRUCT(weap, aoe, f); - PRINT_STRUCT(weap, knockback, f); - PRINT_STRUCT(weap, damage_battery, f); - PRINT_STRUCT(weap, stun, f); - PRINT_STRUCT(weap, charge_per_shot, f); - LOOP(7) PRINT_STRUCT(weap, armor_reduce[z], f); -} - -void stats_comp_printf (stats_comp *comp) { +void printf_arr (char arr[][64], int n) { + for (int i=0; i<n; i++) printf("%s\n", arr[i]); +} + +int stats_frame_sprintf (infos *info, stats_frame *frame, char arr[][64]) { + int i = 0; + PRINT_STRUCT(frame, "hp", hp, .2f); + PRINT_STRUCT(frame, "weight", weight, .0f); + PRINT_STRUCT(frame, "weight max", weight_max, .0f); + PRINT_STRUCT(frame, "weapon slots", slot_weapon, d); + PRINT_STRUCT(frame, "armor slots", slot_armor, d); + PRINT_STRUCT(frame, "augment slots", slot_aug, d); + PRINT_STRUCT(frame, "speed", speed, .2f); + PRINT_STRUCT(frame, "upkeep", upkeep, .2f); + PRINT_STRUCT(frame, "capacity", capacity, .0f); + PRINT_STRUCT(frame, "recharge", recharge, .1f); + LOOP(7) { + char str[64]; sprintf(str, "%s armor", info->damage_types[i]); + PRINT_STRUCT(frame, str, armor[z], f); + } + return i; +} + +int stats_weapon_sprintf (infos *info, stats_weapon *weap, char arr[][64]) { + int i = 0; + LOOP(7) { + char str[64]; sprintf(str, "%s damage", info->damage_types[i]); + PRINT_STRUCT(weap, str, damage[z], .1f); + } + PRINT_STRUCT(weap, "cooldown", cooldown, .2f); + PRINT_STRUCT(weap, "aoe", aoe, .0f); + PRINT_STRUCT(weap, "range", range, .0f); + PRINT_STRUCT(weap, "knockback", knockback, .0f); + PRINT_STRUCT(weap, "drain charge", damage_battery, .1f); + PRINT_STRUCT(weap, "stun", stun, .0f); + PRINT_STRUCT(weap, "charge per shot", charge_per_shot, .2f); + LOOP(7) { + char str[64]; sprintf(str, "%s armor reduce", info->damage_types[i]); + PRINT_STRUCT(weap, str, armor_reduce[z], .1f); + } + return i; +} + +void stats_comp_printf (infos *info, stats_comp *comp) { printf("name: %s\n", comp->name); printf("description: %s\n", comp->description); + char arr[32][64]; LOOP(MAXLEVEL) { printf(" level %d ->\n", z); - stats_frame_printf(comp->base +z); - stats_frame_printf(comp->perc +z); - stats_weapon_printf(comp->base_weapon +z); - stats_weapon_printf(comp->perc_weapon +z); + { int n = stats_frame_sprintf(info, comp->base +z, arr); + printf_arr(arr, n); + } + { int n = stats_frame_sprintf(info, comp->perc +z, arr); + printf_arr(arr, n); + } + { int n = stats_weapon_sprintf(info, comp->base_weapon +z, arr); + printf_arr(arr, n); + } + { int n = stats_weapon_sprintf(info, comp->perc_weapon +z, arr); + printf_arr(arr, n); + } + } +} + +void stats_unit_printf (infos *info, stats_unit *u) { + char arr[32][64]; + { int n = stats_frame_sprintf (info, &u->frame, arr); printf_arr(arr, n); } + LOOP(8) { + int n = stats_weapon_sprintf(info, u->weapon +z, arr); + printf_arr(arr, n); } } @@ -881,6 +919,7 @@ void stats_frame_sum (stats_frame *a, stats_frame *b) { void stats_weapon_sum (stats_weapon *a, stats_weapon *b) { LOOP(7) a->damage[z] += b->damage[z]; a->cooldown += b->cooldown; + a->range += b->range; a->aoe += b->aoe; a->knockback += b->knockback; a->damage_battery += b->damage_battery; @@ -928,6 +967,7 @@ void stats_frame_mul (stats_frame *a, stats_frame *b) { void stats_weapon_mul (stats_weapon *a, stats_weapon *b) { LOOP(7) a->damage[z] *= PERC_NORM(b->damage[z]); a->cooldown *= PERC_NORM(b->cooldown); + a->range *= PERC_NORM(b->range); a->aoe *= PERC_NORM(b->aoe); a->knockback *= PERC_NORM(b->knockback); a->damage_battery *= PERC_NORM(b->damage_battery); @@ -965,19 +1005,6 @@ void stats_unit_compute (infos *info, info_unit *u, stats_unit *base) { stats_unit_comp_sum(base, &perc, comp, lvl); }; - int wn = 0; - for (int i=0; i<8; i++) { - if (u->weapons[i] != -1) { - stats_comp *comp = &info->stats[STATS_WEAPONS][u->weapons[i]]; - int lvl = u->levels[LEVEL_WEAPONS+i]; - stats_frame_sum (&base->frame, &comp->base[lvl]); - stats_frame_sum (&perc.frame, &comp->perc[lvl]); - stats_weapon_sum (&base->weapon[wn], &comp->base_weapon[lvl]); - stats_weapon_sum (&perc.weapon[wn], &comp->perc_weapon[lvl]); - wn ++; - } - } - for (int i=0; i<8; i++) { if (u->armor[i] != -1) { stats_comp *comp = &info->stats[STATS_ARMOR][u->armor[i]]; @@ -994,14 +1021,35 @@ void stats_unit_compute (infos *info, info_unit *u, stats_unit *base) { } } + int wn = 0; + for (int i=0; i<8; i++) { + if (u->weapons[i] != -1 && i<base->frame.slot_weapon) { + stats_comp *comp = &info->stats[STATS_WEAPONS][u->weapons[i]]; + int lvl = u->levels[LEVEL_WEAPONS+i]; + stats_frame_sum (&base->frame, &comp->base[lvl]); + stats_frame_sum (&perc.frame, &comp->perc[lvl]); + stats_weapon_sum (&base->weapon[wn], &comp->base_weapon[lvl]); + stats_weapon_sum (&perc.weapon[wn], &comp->perc_weapon[lvl]); + wn ++; + } + } + base->weaponlen = wn; + stats_unit_apply_perc(base, &perc); } -void stats_unit_printf (stats_unit *u) { - stats_frame_printf (&u->frame); - LOOP(8) stats_weapon_printf(u->weapon +z); +float stats_compute_damage (stats_weapon *weapon, stats_frame *frame, + float *red) +{ + /* TODO: red */ + float damage = 0; + for (int i=0; i<7; i++) { + damage += weapon->damage[i] * (1- frame->armor[i]*0.01); + } + return damage; } + #define MATCH(frame, attr, type) {\ if (strcmp(key, #frame"_"#attr) == 0) {\ int rt = json_parse_subtokens(json, t, r, i+1); \ @@ -1072,6 +1120,7 @@ void stats_comp_parse (char *json, stats_comp *comp, jsmntok_t *t, int r, } MATCH(base_weapon, cooldown, 'f'); + MATCH(base_weapon, range, 'f'); MATCH(base_weapon, aoe, 'f'); MATCH(base_weapon, knockback, 'f'); MATCH(base_weapon, damage_battery, 'f'); @@ -1087,6 +1136,7 @@ void stats_comp_parse (char *json, stats_comp *comp, jsmntok_t *t, int r, } MATCH(perc_weapon, cooldown, 'f'); + MATCH(perc_weapon, range, 'f'); MATCH(perc_weapon, aoe, 'f'); MATCH(perc_weapon, knockback, 'f'); MATCH(perc_weapon, damage_battery, 'f'); @@ -1118,7 +1168,7 @@ void info_stats_parse (infos *info, char *json, int stats_type) { info->statslen[stats_type] ++; i += rt-1; - //stats_comp_printf(comp); + //stats_comp_printf(info, comp); } } } @@ -1170,13 +1220,14 @@ void info_load (infos *info) { info->statslen[i] = 0; info_read_file(json, files[i], size); info_stats_parse(info, json, i); + printf("info->statslen[%d]: %d\n", i, info->statslen[i]); } else { printf("error: out of memory in allocating for stats"); } } info_unit *u = info->templates+0; stats_unit base; stats_unit_compute(info, u, &base); - stats_unit_printf(&base); + stats_unit_printf(info, &base); } @@ -24,6 +24,7 @@ typedef struct { float damage[7]; float cooldown; + float range; float aoe; float knockback; float damage_battery; @@ -152,8 +153,8 @@ typedef struct { info_brain brains[32]; int brainslen; - stats_comp *stats[5]; - int statslen[5]; + stats_comp *stats[6]; + int statslen[6]; } infos; void info_unit_init (info_unit *u); @@ -173,6 +174,13 @@ float info_unit_get_maxrange(infos *info, info_unit *u); float info_unit_get_armor(infos *info, info_unit *u, int d); float info_unit_get_cost(infos *info, info_unit *u); +int stats_frame_sprintf (infos *info, stats_frame *frame, char arr[][64]); +int stats_weapon_sprintf (infos *info, stats_weapon *weap, char arr[][64]); +void stats_unit_compute (infos *info, info_unit *u, stats_unit *base); + +float stats_compute_damage (stats_weapon *weapon, stats_frame *frame, + float *red); + void info_load (infos *info); void info_save_templates (infos *info, char *filename); diff --git a/gst/units.c b/gst/units.c index b699e26..785230e 100644 --- a/gst/units.c +++ b/gst/units.c @@ -31,14 +31,16 @@ void army_destory(army *ar) { void unit_init (infos *info, army *ar, map *m, int x, int y, info_unit *iu, int owner, unit *u) { + stats_unit base; stats_unit_compute(info, iu, &base); u->pos[0] = x*m->ts; u->pos[1] = y*m->ts; u->gridpos[0] = x; u->gridpos[1] = y; u->info = *iu; u->owner = owner; - u->hp = info_unit_get_health(info, iu); + u->hp = base.frame.hp; u->move_points = 0; - u->charge = info_unit_get_capacity(info, iu); + u->charge = base.frame.capacity; for (int i=0; i<8; u->cooldown[i] = 1, i++); + for (int i=0; i<7; u->reduced_armor[i] = 0, i++); } void army_spawn (army *ar, map *m, unit u) { @@ -102,7 +104,7 @@ void unit_search (infos *info, army *ar, map *m, unit *u, typedef struct { unit *u; int *dir; int done; } mcom; -int army_move_step (infos *info, army *ar, map *m) { +int army_move_step (infos *info, army *ar, map *m, stats_unit *ustats) { int dirs[4][2] = { {1, 0},{0, 1},{-1,0},{0,-1} }; mcom mcs[ar->uslen]; int mclen = 0; @@ -116,7 +118,11 @@ int army_move_step (infos *info, army *ar, map *m) { if (u->charge <= 0) continue; // search target inside max range unit *t[32]; - float maxrange = info_unit_get_maxrange(info, &u->info); + float maxrange = 0; + for (int w=0; w<ustats[i].weaponlen; w++) { + float range = ustats[i].weapon[w].range; + if (maxrange < range) maxrange = range; + } unit_search(info, ar, m, u, t, maxrange); // stop if found if (t[0] != NULL) { continue; } @@ -173,22 +179,24 @@ int army_move_step (infos *info, army *ar, map *m) { else return 1; } -int army_move (infos *info, army *ar, map *m) { +int army_move (infos *info, army *ar, map *m, stats_unit *ustats) { for (int i=0; i<ar->uslen; i++) { - ar->us[i].move_points += info_unit_get_speed(info, &ar->us[i].info); + ar->us[i].move_points += ustats[i].frame.speed; } - int iter = 0, finished = army_move_step(info, ar, m); + int iter = 0, finished = army_move_step(info, ar, m, ustats); for (; iter<5 && !finished; iter++) { - finished = army_move_step(info, ar, m); + finished = army_move_step(info, ar, m, ustats); } return iter; } -int army_fire (infos *info, army *ar, map *m, a_dmg dmgs[]) { +int army_fire (infos *info, army *ar, map *m, a_dmg dmgs[], + stats_unit *ustats) +{ for (int i=0; i<ar->uslen; i++) { unit *u = ar->us+i; int lw = u->info.levels[LEVEL_CHASSIS]; - for (int j=0; j<info->chassis[u->info.chassis].slot_weapon[lw]; j++) { + for (int j=0; j<ustats[i].weaponlen; j++) { u->cooldown[j] += 1; } } @@ -199,19 +207,26 @@ int army_fire (infos *info, army *ar, map *m, a_dmg dmgs[]) { if (u->hp <= 0) continue; if (u->charge <= 0) continue; int lw = u->info.levels[LEVEL_CHASSIS]; - for (int j=0; j<info->chassis[u->info.chassis].slot_weapon[lw]; j++) { - if (u->info.weapons[j] == -1) continue; + for (int j=0; j<ustats[i].weaponlen; j++) { if (u->cooldown[j] <= 0) continue; - float range = info_unit_get_range(info, &u->info, j); + float range = ustats[i].weapon[j].range; unit_search(info, ar, m, u, t, range); if (t[0]!=NULL) { dmgs[dmgslen].u = u; dmgs[dmgslen].t = t[0]; - dmgs[dmgslen].dam = info_unit_get_damage_target( - info, &u->info, j, &t[0]->info); + + int t_i = 0; + for (int k=0; k<ar->uslen; k++) { + if (ar->us+k == t[0]) { t_i = k; break; } + } + float dam = stats_compute_damage( + &ustats[i].weapon[j], + &ustats[t_i].frame, u->reduced_armor); + + dmgs[dmgslen].dam = dam; dmgslen++; - u->cooldown[j] -= info_unit_get_cooldown(info, &u->info, j); - u->charge -= info_unit_get_charge_per_shot(info, &u->info, j); + u->cooldown[j] -= ustats[i].weapon[j].cooldown; + u->charge -= ustats[i].weapon[j].charge_per_shot; if (u->charge < 0) u->charge = 0; } } @@ -225,12 +240,12 @@ int army_fire (infos *info, army *ar, map *m, a_dmg dmgs[]) { return dmgslen; } -void army_upkeep (infos *info, army *ar, map *m) { +void army_upkeep (infos *info, army *ar, map *m, stats_unit *ustats) { // battery drain or recharge for (int i=0; i<ar->uslen; i++) { unit *u = ar->us+i; if (u->hp <= 0) continue; - u->charge -= info_unit_get_upkeep(info, &u->info); + u->charge -= ustats[i].frame.upkeep; if (u->charge < 0) u->charge = 0; } }
\ No newline at end of file diff --git a/gst/units.h b/gst/units.h index c7cc575..2b401e9 100644 --- a/gst/units.h +++ b/gst/units.h @@ -15,6 +15,8 @@ typedef struct unit_ { float move_points; float cooldown[8]; float charge; + float reduced_armor[7]; + float stun; } unit; typedef struct army_ { @@ -32,14 +34,15 @@ void unit_init (infos *info, army *ar, map *m, int x, int y, info_unit *iu, int owner, unit *u); void unit_remove (army *ar, map *m, unit *u); -void army_grid_init(army *ar); +void army_grid_init (army *ar); void army_init (army *ar, map *m); -void army_destory(army *ar); +void army_destory (army *ar); void army_spawn (army *ar, map *m, unit u); -int army_move (infos *info, army *ar, map *m); +int army_move (infos *info, army *ar, map *m, stats_unit *ustats); typedef struct { unit *u, *t; float dam; } a_dmg; -int army_fire (infos *info, army *ar, map *m, a_dmg dmgs[]); -void army_upkeep (infos *info, army *ar, map *m); +int army_fire (infos *info, army *ar, map *m, a_dmg dmgs[], + stats_unit *ustats); +void army_upkeep (infos *info, army *ar, map *m, stats_unit *ustats); #endif
\ No newline at end of file @@ -144,45 +144,41 @@ int hud_fnu_check (info_unit *u, infos *info) { if (u->chassis == -1) return 1; if (u->battery == -1) return 2; if (u->brain == -1) return 3; - float curweight = info_unit_get_weight(info, u); int chassis_lvl = u->levels[LEVEL_CHASSIS]; - float maxweight = info->chassis[u->chassis].weight_max[chassis_lvl]; - if (curweight > maxweight) { return 4; } + + stats_unit base; + stats_unit_compute(info, u, &base); + if (base.frame.weight > base.frame.weight_max) { return 4; } return 0; } void hud_map_sel (info_unit *u, infos *info, int sel, int ind, int8_t **n, int *bound, int size[]) { + *bound = info->statslen[sel]; if (sel == 0) { *n = &u->chassis; - *bound = info->chassislen; size[0] = 300; size[1] = 300; } if (sel == 1) { - *n = &u->battery; - *bound = info->batterieslen; + *n = &u->brain; size[0] = 145; size[1] = 145; } if (sel == 2) { - *n = &u->armor[ind]; - *bound = info->armorslen; - size[0] = 150; size[1] = 200; + *n = &u->battery; + size[0] = 145; size[1] = 145; } if (sel == 3) { *n = &u->weapons[ind]; - *bound = info->weaponslen; size[0] = 200; size[1] = 170; } if (sel == 4) { - *n = &u->augs[ind]; - *bound = info->augslen; + *n = &u->armor[ind]; size[0] = 150; size[1] = 200; } if (sel == 5) { - *n = &u->brain; - *bound = info->brainslen; - size[0] = 145; size[1] = 145; + *n = &u->augs[ind]; + size[0] = 150; size[1] = 200; } } @@ -324,7 +320,7 @@ void hud_process_form_new_unit (graphic_settings *gs, hud *h, MKb *mkb, int lvl = hud_mouse_level(mousepos, possb, sizesb); if (lvl != -1) h->fnu.uinfo.levels[LEVEL_BATTERY] = lvl; else { - h->fnu.sel = 1; h->state = 2; + h->fnu.sel = 2; h->state = 2; hud_open_sel(gs, h, t, info, &h->fnu.rect_battery); } } @@ -334,15 +330,16 @@ void hud_process_form_new_unit (graphic_settings *gs, hud *h, MKb *mkb, int lvl = hud_mouse_level(mousepos, possbr, sizesbr); if (lvl != -1) h->fnu.uinfo.levels[LEVEL_BRAIN] = lvl; else { - h->fnu.sel = 5; h->state = 2; + h->fnu.sel = 1; h->state = 2; hud_open_sel(gs, h, t, info, &h->fnu.rect_brain); } } if (h->fnu.uinfo.chassis != -1) { int lc = h->fnu.uinfo.levels[LEVEL_CHASSIS]; - for (int i=0; - i<info->chassis[h->fnu.uinfo.chassis].slot_armor[lc]; i++) - { + stats_comp *comp = + info->stats[STATS_CHASSIS] +h->fnu.uinfo.chassis; + + for (int i=0; i<comp->base[lc].slot_armor; i++) { float possa[2] = { h->fnu.rect_armor[i].x, h->fnu.rect_armor[i].y }; float sizesa[2] = { @@ -351,14 +348,12 @@ void hud_process_form_new_unit (graphic_settings *gs, hud *h, MKb *mkb, int lvl = hud_mouse_level(mousepos, possa, sizesa); if (lvl != -1) h->fnu.uinfo.levels[LEVEL_ARMOR+i] = lvl; else { - h->fnu.sel = 2; h->fnu.ind = i; h->state = 2; + h->fnu.sel = 4; h->fnu.ind = i; h->state = 2; hud_open_sel(gs, h, t, info, &h->fnu.rect_armor[i]); } } } - for (int i=0; - i<info->chassis[h->fnu.uinfo.chassis].slot_weapon[lc]; i++) - { + for (int i=0; i<comp->base[lc].slot_weapon; i++) { float possa[2] = { h->fnu.rect_weapons[i].x, h->fnu.rect_weapons[i].y }; float sizesa[2] = { @@ -372,9 +367,7 @@ void hud_process_form_new_unit (graphic_settings *gs, hud *h, MKb *mkb, } } } - for (int i=0; - i<info->chassis[h->fnu.uinfo.chassis].slot_aug[lc]; i++) - { + for (int i=0; i<comp->base[lc].slot_armor; i++) { float possa[2] = { h->fnu.rect_augs[i].x, h->fnu.rect_augs[i].y }; float sizesa[2] = { @@ -383,7 +376,7 @@ void hud_process_form_new_unit (graphic_settings *gs, hud *h, MKb *mkb, int lvl = hud_mouse_level(mousepos, possa, sizesa); if (lvl != -1) h->fnu.uinfo.levels[LEVEL_AUGS+i] = lvl; else { - h->fnu.sel = 4; h->fnu.ind = i; h->state = 2; + h->fnu.sel = 5; h->fnu.ind = i; h->state = 2; hud_open_sel(gs, h, t, info, &h->fnu.rect_augs[i]); } } @@ -437,7 +430,7 @@ void hud_process_overlay_game (graphic_settings *gs, hud *h, MKb *mkb, memcpy(h->ob.oppo, buffer+arlen, 32); memcpy(gst->army_bp[1].name, buffer+arlen+32, 32); gst->playernum = 2; - gst_tobattle(gst); + gst_tobattle(gst, info); gst->cam[0] = -gs->resx/2+gst->map_battle.sx*gst->map_battle.ts/2; gst->cam[1] = -gs->resy/2+gst->map_battle.sy*gst->map_battle.ts/2; h->state = 3; @@ -458,7 +451,7 @@ void hud_process_overlay_game (graphic_settings *gs, hud *h, MKb *mkb, memcpy(h->ob.oppo, buffer+arlen, 32); memcpy(gst->army_bp[1].name, buffer+arlen+32, 32); gst->playernum = 2; - gst_tobattle(gst); + gst_tobattle(gst, info); gst->cam[0] = -gs->resx/2+gst->map_battle.sx*gst->map_battle.ts/2; gst->cam[1] = -gs->resy/2+gst->map_battle.sy*gst->map_battle.ts/2; h->state = 3; @@ -560,6 +553,7 @@ void hud_process_overlay_game (graphic_settings *gs, hud *h, MKb *mkb, unit u; unit_init(info, ar, m, x, y, info->templates+h->og.temp_place, 0, &u); + army_spawn(ar, m, u); } } else { @@ -605,12 +599,11 @@ void hud_process_overlay_game (graphic_settings *gs, hud *h, MKb *mkb, if (pt_rect(mousepos, posp, sizep)) { if (h->og.start_battle_flag == 1) { // start battle - printf("ahia\n"); h->og.start_battle_flag = 0; hud_edit_close(h, info); info_load_army(gst->army_bp+1, h->og.army_list[i]); gst->playernum = 2; - gst_tobattle(gst); + gst_tobattle(gst, info); gst->cam[0] = -gs->resx/2 +gst->map_battle.sx*gst->map_battle.ts/2; gst->cam[1] = -gs->resy/2 @@ -619,7 +612,6 @@ void hud_process_overlay_game (graphic_settings *gs, hud *h, MKb *mkb, h->state = 3; Mix_PlayChannel( -1, sounds[SOUND_SUCCESS], 0 ); } else { - printf("lol\n"); int cur = h->og.army_listcur; info_save_army(gst->army_bp+0, h->og.army_list[cur]); h->og.army_listcur = i; @@ -783,24 +775,24 @@ void hud_render_sel (hud_sel *sc, MKb *mkb, info_unit *u, render_view_chassis(rend, t, x, y, info, i, lvl, sprites); } if (sel==1) { - int lvl = u->levels[LEVEL_BATTERY]; - render_view_battery(rend, t, x, y, info, i, lvl); + int lvl = u->levels[LEVEL_BRAIN]; + render_view_brain(rend, t, x, y, info, i, lvl); } if (sel==2) { - int lvl = u->levels[LEVEL_ARMOR+ind]; - render_view_armor_detail(rend, t, x, y, info, i, lvl); + int lvl = u->levels[LEVEL_BATTERY]; + render_view_battery(rend, t, x, y, info, i, lvl); } if (sel==3) { int lvl = u->levels[LEVEL_WEAPONS+ind]; render_view_weapon_detail(rend, t, x, y, info, i, lvl); } if (sel==4) { - int lvl = u->levels[LEVEL_AUGS+ind]; - render_view_aug_detail(rend, t, x, y, info, i, lvl); + int lvl = u->levels[LEVEL_ARMOR+ind]; + render_view_armor_detail(rend, t, x, y, info, i, lvl); } if (sel==5) { - int lvl = u->levels[LEVEL_BRAIN]; - render_view_brain(rend, t, x, y, info, i, lvl); + int lvl = u->levels[LEVEL_AUGS+ind]; + render_view_aug_detail(rend, t, x, y, info, i, lvl); } } SDL_RenderSetClipRect(rend, NULL); @@ -832,7 +824,10 @@ void hud_render_form_new_unit (form_new_unit *fnu, MKb *mkb, int lc = fnu->uinfo.levels[LEVEL_CHASSIS]; if (fnu->uinfo.chassis != -1) { - for (int i=0; i<info->chassis[fnu->uinfo.chassis].slot_weapon[lc]; i++) { + stats_comp *comp = + info->stats[STATS_CHASSIS] +fnu->uinfo.chassis; + + for (int i=0; i<comp->base[lc].slot_weapon; i++) { SDL_SetRenderDrawColor(rend, 200, 100, 255, 255); SDL_RenderFillRect(rend, fnu->rect_weapons+i); SDL_SetRenderDrawColor(rend, 0, 0, 0, 255); @@ -842,7 +837,7 @@ void hud_render_form_new_unit (form_new_unit *fnu, MKb *mkb, fnu->rect_weapons[i].y, info, fnu->uinfo.weapons[i], fnu->uinfo.levels[LEVEL_WEAPONS+i]); } - for (int i=0; i<info->chassis[fnu->uinfo.chassis].slot_armor[lc]; i++) { + for (int i=0; i<comp->base[lc].slot_armor; i++) { SDL_SetRenderDrawColor(rend, 200, 200, 255, 255); SDL_RenderFillRect(rend, fnu->rect_armor+i); SDL_SetRenderDrawColor(rend, 0, 0, 0, 255); @@ -852,7 +847,7 @@ void hud_render_form_new_unit (form_new_unit *fnu, MKb *mkb, fnu->rect_armor[i].y, info, fnu->uinfo.armor[i], fnu->uinfo.levels[LEVEL_ARMOR+i]); } - for (int i=0; i<info->chassis[fnu->uinfo.chassis].slot_aug[lc]; i++) { + for (int i=0; i<comp->base[lc].slot_aug; i++) { SDL_SetRenderDrawColor(rend, 200, 200, 255, 255); SDL_RenderFillRect(rend, fnu->rect_augs+i); SDL_SetRenderDrawColor(rend, 0, 0, 0, 255); diff --git a/hud/hud_views.c b/hud/hud_views.c index c767e68..a669034 100644 --- a/hud/hud_views.c +++ b/hud/hud_views.c @@ -29,56 +29,62 @@ render_text_scaled(rend, ss, p, t, 1);\ } + +void render_view_comp (SDL_Renderer* rend, txtd *t, int px, int py, + infos *info, stats_comp *comp, int lvl) +{ + float pad = 0; + float h = 0; + + char arr[32][64]; + { + int n = stats_frame_sprintf(info, comp->base +lvl, arr); + for (int i=0; i<n; i++) { LABEL(px+pad, py+h, arr[i], 1); h += 15; } + } + { + int n = stats_frame_sprintf(info, comp->perc +lvl, arr); + for (int i=0; i<n; i++) { LABEL(px+pad, py+h, arr[i], 1); h += 15; } + } + { + int n = stats_weapon_sprintf(info, comp->base_weapon +lvl, arr); + for (int i=0; i<n; i++) { LABEL(px+pad, py+h, arr[i], 1); h += 15; } + } + { + int n = stats_weapon_sprintf(info, comp->perc_weapon +lvl, arr); + for (int i=0; i<n; i++) { LABEL(px+pad, py+h, arr[i], 1); h += 15; } + } +} + +void render_view_stats_unit (SDL_Renderer* rend, txtd *t, int px, int py, + infos *info, stats_unit *u) +{ + float pad = 0; + float h = 0; + + char arr[32][64]; + { + int n = stats_frame_sprintf(info, &u->frame, arr); + for (int i=0; i<n; i++) { LABEL(px+pad, py+h, arr[i], 1); h += 15; } + } + h += 10; + for (int i=0; i<u->weaponlen; i++) { + LABEL(px+pad, py+h, " WEAPON", 1); h += 15; + int n = stats_weapon_sprintf(info, u->weapon +i, arr); + for (int i=0; i<n; i++) { LABEL(px+pad, py+h, arr[i], 1); h += 15; } + } +} + + void render_view_stats (SDL_Renderer* rend, txtd *t, int px, int py, infos *info, info_unit *tm) { float h = 10; LABEL(px+10, py+h, "STATS", 2); h += 35; + LABEL(px+10, py+h, tm->name, 1); h += 15; - { float val = info_unit_get_cost(info, tm); - char s[64]; sprintf(s, "COST: %.2f", val); - LABEL(px+10, py+h, s, 1); - } h += 20; - - float calcweight = info_unit_get_weight(info, tm); - float maxweight = info->chassis[tm->chassis].weight_max[ - tm->levels[LEVEL_CHASSIS]]; - float pw[2] = { px+10, py+h }; - char sw[64]; sprintf(sw, "WEIGHT: %.0f/%.0f", - calcweight, maxweight); - render_text_scaled(rend, sw, pw, t, 1); - h += 15; - - float hp = info_unit_get_health(info, tm); - float php[2] = { px+10, py+h }; - char shp[64]; sprintf(shp, "HP: %.2f", hp); - render_text_scaled(rend, shp, php, t, 1); - h += 15; - - float speed = info_unit_get_speed(info, tm); - float pspeed[2] = { px+10, py+h }; - char sspeed[64]; sprintf(sspeed, "SPEED: %.2f", speed); - render_text_scaled(rend, sspeed, pspeed, t, 1); - h += 15; - - float dps = info_unit_get_dps(info, tm); - float pdps[2] = { px+10, py+h }; - char sdps[64]; sprintf(sdps, "DAMAGE PER TURN: %.2f", dps); - render_text_scaled(rend, sdps, pdps, t, 1); - h += 20; - - float part[2] = { px+10, py+h }; - render_text_scaled(rend, "ARMOR:", part, t, 1); - h += 15; - - for (int i=0; i<7; i++) { - float ar = info_unit_get_armor(info, tm, i); - float par[2] = { px+10, py+h }; - char sar[64]; sprintf(sar, "%s: %.1f%", info->damage_types[i], ar); - render_text_scaled(rend, sar, par, t, 1); - h += 15; - } - h += 5; + stats_unit base; + stats_unit_compute(info, tm, &base); + render_view_stats_unit(rend, t, px+10, py+h, info, &base); } @@ -112,21 +118,10 @@ void render_view_chassis (SDL_Renderer* rend, txtd *t, int px, int py, info_chassis *ch = info->chassis+chassis; int h = 10; - LABEL(px+10, py+h, info->chassis[chassis].name, 1); h += 30; - - LABEL_F3(px+10, py+h, "MAX WEIGHT", 0, ch->weight_max, 1); h += 15; - LABEL_F3(px+10, py+h, "HP", 0, ch->hp, 1); h += 15; - LABEL_F3(px+10, py+h, "SPEED", 2, ch->speed, 1); h += 15; - LABEL_F3(px+10, py+h, "UPKEEP", 2, ch->upkeep, 1); h += 20; - - LABEL_I3(px+10, py+h, "WEAPON SLOTS", ch->slot_weapon, 1); h += 15; - LABEL_I3(px+10, py+h, "ARMOR SLOTS", ch->slot_armor, 1); h += 15; - LABEL_I3(px+10, py+h, "AUGMENT SLOTS", ch->slot_aug, 1); h += 15; - - SDL_Rect srcRect = { chassis*32, 32, 32, 32 }; - SDL_Rect dstRect = { px+300-32-10, py+10, 32, 32 }; - SDL_RenderCopy(rend, sprites, &srcRect, &dstRect); - + stats_comp *comp = info->stats[STATS_CHASSIS]+chassis; + LABEL(px+10, py+h, comp->name, 2); h += 30; + render_view_comp(rend, t, px+10, py+h, info, comp, lvl); + info_unit u; int8_t *_; int __; int size[2]; hud_map_sel(&u, info, 0, 0, &_, &__, size); size[0] -= 5; size[1] -= 5; @@ -143,16 +138,10 @@ void render_view_battery (SDL_Renderer* rend, txtd *t, int px, int py, if (batt != -1) { info_battery *battery = info->batteries+batt; int h = 10; - LABEL(px+10, py+h, info->batteries[batt].name, 1); h += 30; - LABEL_F3(px+10, py+h, "MAX WEIGHT", 0, battery->weight, 1); h += 15; - LABEL_F3(px+10, py+h, "CAPACITY", 0, battery->capacity, 1); h += 15; - - float prech[2] = { px+10, py+h }; char srech[64]; - if (info->batteries[batt].recharge[lvl] == 0) { - strcpy(srech, "NOT RECHARGEABLE"); - } else { strcpy(srech, "RECHARGEABLE"); } - render_text_scaled(rend, srech, prech, t, 1); + stats_comp *comp = info->stats[STATS_BATTERY]+batt; + LABEL(px+10, py+h, comp->name, 1); h += 30; + render_view_comp(rend, t, px+10, py+h, info, comp, lvl); float size[2] = {145, 145}; size[0] -= 5; size[1] -= 5; render_view_level(rend, px+size[0], py+size[1], lvl); @@ -170,26 +159,9 @@ void render_view_armor (SDL_Renderer* rend, txtd *t, int px, int py, info_armor *arm = info->armors+armor; int h = 10; - LABEL(px+10, py+h, arm->name, 1); h += 20; - LABEL_F3(px+10, py+h, "WEIGHT", 0, arm->weight, 1); h += 20; + stats_comp *comp = info->stats[STATS_ARMOR]+armor; + LABEL(px+10, py+h, comp->name, 1); h += 20; - /*char sa[64]; int j=0; - char temp[16] = "red: "; - strcpy(sa+j, temp); - j += strlen(temp); - for (int i=0; i<7; i++) { - if (i<7-1) { - sprintf(temp, "%.0f, ", info->armors[armor].armor[i][lvl]); - } else { - sprintf(temp, "%.0f", info->armors[armor].armor[i][lvl]); - } - strcpy(sa+j, temp); - j += strlen(temp); - } - sa[j] = '\0'; - float pa[2] = { px+10, py+25 }; - render_text_scaled(rend, sa, pa, t, 1); - */ float size[2] = { 150, 50 }; size[0] -= 5; size[1] -= 5; render_view_level(rend, px+size[0], py+size[1], lvl); } else { @@ -204,20 +176,11 @@ void render_view_armor_detail (SDL_Renderer* rend, txtd *t, int px, int py, if (armor != -1) { info_armor *arm = info->armors+armor; int h = 10; + + stats_comp *comp = info->stats[STATS_ARMOR]+armor; + LABEL(px+10, py+h, comp->name, 1); h += 30; + render_view_comp(rend, t, px+10, py+h, info, comp, lvl); - LABEL(px+10, py+h, arm->name, 1); h += 30; - LABEL_F3(px+10, py+h, "WEIGHT", 0, arm->weight, 1); h += 20; - LABEL(px+10, py+h, "DAMAGE REDUCTION", 1); h += 15; - - for (int i=0; i<7; i++) { - float sum = 0; for(int j=0;j<MAXLEVEL;j++) - sum+=fabs(arm->armor[i][j]); - if (sum > 0) { - LABEL_F3(px+10, py+h, info->damage_types[i], - 1, arm->armor[i], 1); - } - h += 15; - } info_unit u; int8_t *_; int __; int size[2]; hud_map_sel(&u, info, 2, 0, &_, &__, size); size[0] -= 5; size[1] -= 5; @@ -234,17 +197,10 @@ void render_view_weapon (SDL_Renderer* rend, txtd *t, int px, int py, if (weapon != -1) { info_weapon *weap = info->weapons+weapon; int h = 10; - - char dt[32]; - sprintf(dt, "DAMAGE TYPE: %s", - info->damage_types[info->weapons[weapon].damage_type]); - - LABEL(px+10, py+h, weap->name, 1); h += 20; - LABEL_F3(px+10, py+h, "WEIGHT", 0, weap->weight, 1); h += 15; - LABEL(px+10, py+h, dt, 1); h += 15; - LABEL_F3(px+10, py+h, "DAMAGE", 0, weap->damage, 1); h += 15; - LABEL_F3(px+10, py+h, "RANGE", 0, weap->range, 1); h += 15; - LABEL_F3(px+10, py+h, "COOLDOWN", 0, weap->cooldown, 1); h += 15; + + stats_comp *comp = info->stats[STATS_WEAPONS]+weapon; + LABEL(px+10, py+h, comp->name, 1); h += 30; + render_view_comp(rend, t, px+10, py+h, info, comp, lvl); float size[2] = { 200, 110 }; size[0] -= 5; size[1] -= 5; render_view_level(rend, px+size[0], py+size[1], lvl); @@ -261,32 +217,11 @@ void render_view_weapon_detail (SDL_Renderer* rend, txtd *t, if (weapon != -1) { info_weapon *weap = info->weapons+weapon; int h = 10; + + stats_comp *comp = info->stats[STATS_WEAPONS]+weapon; + LABEL(px+10, py+h, comp->name, 1); h += 30; + render_view_comp(rend, t, px+10, py+h, info, comp, lvl); - char dt[32]; - sprintf(dt, "DAMAGE TYPE: %s", - info->damage_types[info->weapons[weapon].damage_type]); - - LABEL(px+10, py+h, weap->name, 1); h += 20; - LABEL_F3(px+10, py+h, "WEIGHT", 0, weap->weight, 1); h += 15; - LABEL(px+10, py+h, dt, 1); h += 15; - LABEL_F3(px+10, py+h, "DAMAGE", 0, weap->damage, 1); h += 15; - LABEL_F3(px+10, py+h, "RANGE", 0, weap->range, 1); h += 15; - LABEL_F3(px+10, py+h, "COOLDOWN", 0, weap->cooldown, 1); h += 15; - LABEL_F3(px+10, py+h, "UPKEEP", 0, weap->upkeep, 1); h += 15; - - float kb = 0; for(int i=0;i<MAXLEVEL;i++) - kb += fabs(weap->knockback[i]); - if (kb > 0) { - LABEL_I3(px+10, py+h, "KNOCKBACK", weap->knockback, 1); - h += 15; - } - - float cps = 0; for(int i=0;i<MAXLEVEL;i++) - cps += fabs(weap->charge_per_shot[i]); - if (cps > 0) { - LABEL_F3(px+10, py+h, "CHARGE PER SHOT",0,weap->charge_per_shot, 1); - h += 15; - } info_unit u; int8_t *_; int __; int size[2]; hud_map_sel(&u, info, 3, 0, &_, &__, size); size[0] -= 5; size[1] -= 5; @@ -304,8 +239,8 @@ void render_view_aug (SDL_Renderer* rend, txtd *t, int px, int py, info_aug *augm = info->augs+aug; int h = 10; - LABEL(px+10, py+h, augm->name, 1); h += 20; - LABEL_F3(px+10, py+h, "WEIGHT", 0, augm->weight, 1); h += 15; + stats_comp *comp = info->stats[STATS_AUGS]+aug; + LABEL(px+10, py+h, comp->name, 1); h += 20; float size[2] = { 150, 50 }; size[0] -= 5; size[1] -= 5; render_view_level(rend, px+size[0], py+size[1], lvl); @@ -322,67 +257,10 @@ void render_view_aug_detail (SDL_Renderer* rend, txtd *t, int px, int py, info_aug *augm = info->augs+aug; int h = 10; - LABEL(px+10, py+h, augm->name, 1); h += 20; - LABEL_F3(px+10, py+h, "WEIGHT", 0, augm->weight, 1); h += 15; + stats_comp *comp = info->stats[STATS_AUGS]+aug; + LABEL(px+10, py+h, comp->name, 1); h += 20; + render_view_comp(rend, t, px+10, py+h, info, comp, lvl); - float range = 0; for(int i=0;i<MAXLEVEL;i++) - range += fabs(augm->add_range[i]); - if (range > 0) { - LABEL_F3(px+10, py+h, "RANGE", 0, augm->add_range, 1); h += 15; - } - - float cooldown = 0; for(int i=0;i<MAXLEVEL;i++) - cooldown += fabs(augm->add_cooldown[i]); - if (cooldown != 0) { - LABEL_F3(px+10, py+h, "COOLDOWN", 2, augm->add_cooldown, 1); - h += 15; - } - - float speed = 0; for(int i=0;i<MAXLEVEL;i++) - speed += fabs(augm->add_speed[i]); - if (speed != 0) { - LABEL_F3(px+10, py+h, "SPEED", 2, augm->add_speed, 1); h += 15; - } - - float hp = 0; for(int i=0;i<MAXLEVEL;i++) - hp += fabs(augm->add_hp[i]); - if (hp != 0) { - LABEL_F3(px+10, py+h, "HP", 1, augm->add_hp, 1); h += 15; - } - - h += 5; - - float sum = 0; - for (int i=0; i<7; i++) - for(int j=0;j<MAXLEVEL;j++) - sum += fabs(augm->add_armor[i][j]); - if (sum != 0) { - for (int i=0; i<7; i++) { - float suml = 0; for(int j=0;j<MAXLEVEL;j++) - suml+=fabs(augm->add_armor[i][j]); - if (suml > 0) { - LABEL_F3(px+10, py+h, info->damage_types[i], - 1, augm->add_armor[i], 1); - h += 15; - } - } - } - - sum = 0; - for (int i=0; i<7; i++) - for(int j=0;j<MAXLEVEL;j++) - sum += fabs(augm->add_damage[i][j]); - if (sum != 0) { - for (int i=0; i<7; i++) { - float suml = 0; for(int j=0;j<MAXLEVEL;j++) - suml+=fabs(augm->add_damage[i][j]); - if (suml > 0) { - LABEL_F3(px+10, py+h, info->damage_types[i], - 1, augm->add_damage[i], 1); - h += 15; - } - } - } info_unit u; int8_t *_; int __; int size[2]; hud_map_sel(&u, info, 4, 0, &_, &__, size); size[0] -= 5; size[1] -= 5; @@ -398,9 +276,11 @@ void render_view_brain (SDL_Renderer* rend, txtd *t, int px, int py, { if (brain != -1) { float pname[2] = { px+10, py+10 }; - char sname[64]; sprintf(sname, "%s", - info->brains[brain].name); - render_text_scaled(rend, sname, pname, t, 1); + int h = 10; + + stats_comp *comp = info->stats[STATS_BRAIN]+brain; + LABEL(px+10, py+h, comp->name, 1); h += 20; + render_view_comp(rend, t, px+10, py+h, info, comp, lvl); float size[2] = { 145, 145 }; size[0] -= 5; size[1] -= 5; render_view_level(rend, px+size[0], py+size[1], lvl); |