aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjacopo grandi <jak.sk8@hotmail.it>2021-02-22 19:51:09 +0100
committerjacopo grandi <jak.sk8@hotmail.it>2021-02-22 19:51:09 +0100
commit4842b67ab590250d95ad4be5fe61380a09b1e8ea (patch)
treeabb973efe013b3b0970b2f4434119f2c41644f65
parentbd372bf19eb79e0bfd3f3d9cb20b4c6a49a8a5ed (diff)
view levels and maxrange strat
-rw-r--r--build/army/best army ever.txtbin21560 -> 21560 bytes
-rw-r--r--build/army/range test.txtbin0 -> 21560 bytes
-rw-r--r--build/army/worst.txtbin21560 -> 21560 bytes
-rw-r--r--build/content/autolevel.py4
-rw-r--r--build/content/batteries.txt30
-rw-r--r--build/content/gf.bmpbin37978 -> 37978 bytes
-rw-r--r--build/content/templates/default.txt18
-rw-r--r--build/content/weapons.txt128
-rw-r--r--build/test.exebin785093 -> 786658 bytes
-rw-r--r--gst/info.c12
-rw-r--r--gst/info.h1
-rw-r--r--gst/units.c10
-rw-r--r--hud/hud.c5
-rw-r--r--hud/hud_views.c296
-rw-r--r--json/jsonparse.c2
-rw-r--r--render/render_text.c3
16 files changed, 257 insertions, 252 deletions
diff --git a/build/army/best army ever.txt b/build/army/best army ever.txt
index ba280ff..1ed86d2 100644
--- a/build/army/best army ever.txt
+++ b/build/army/best army ever.txt
Binary files differ
diff --git a/build/army/range test.txt b/build/army/range test.txt
new file mode 100644
index 0000000..44a5c2b
--- /dev/null
+++ b/build/army/range test.txt
Binary files differ
diff --git a/build/army/worst.txt b/build/army/worst.txt
index 2bd5a92..79686b5 100644
--- a/build/army/worst.txt
+++ b/build/army/worst.txt
Binary files differ
diff --git a/build/content/autolevel.py b/build/content/autolevel.py
index 345bccf..51d30f3 100644
--- a/build/content/autolevel.py
+++ b/build/content/autolevel.py
@@ -33,4 +33,6 @@ if __name__ == "__main__":
#comp("brains", ["name"])
#comp("brains", ["name"])
- #comp("armor", ["weight"], query, lambda x: [x[i]/5 for i in range(3)])
+ amt = .5
+ perc_inc = lambda x: [x[i]*(1.0+(i/2.0)*amt) for i in range(3)]
+ comp("weapons", ["damage"], query, perc_inc)
diff --git a/build/content/batteries.txt b/build/content/batteries.txt
index 18ae48e..baf7201 100644
--- a/build/content/batteries.txt
+++ b/build/content/batteries.txt
@@ -38,9 +38,9 @@
150.0
],
"recharge": [
- 1.0,
- 1.0,
- 1.0
+ 1,
+ 1,
+ 1
]
},
{
@@ -56,9 +56,9 @@
500.0
],
"recharge": [
- 1.0,
- 1.0,
- 1.0
+ 1,
+ 1,
+ 1
]
},
{
@@ -74,9 +74,9 @@
800.0
],
"recharge": [
- 1.0,
- 1.0,
- 1.0
+ 1,
+ 1,
+ 1
]
},
{
@@ -92,9 +92,9 @@
1500.0
],
"recharge": [
- 1.0,
- 1.0,
- 1.0
+ 1,
+ 1,
+ 1
]
},
{
@@ -110,9 +110,9 @@
2000.0
],
"recharge": [
- 1.0,
- 1.0,
- 1.0
+ 1,
+ 1,
+ 1
]
},
{
diff --git a/build/content/gf.bmp b/build/content/gf.bmp
index a3750be..b2f7aa5 100644
--- a/build/content/gf.bmp
+++ b/build/content/gf.bmp
Binary files differ
diff --git a/build/content/templates/default.txt b/build/content/templates/default.txt
index dece5bd..f99915c 100644
--- a/build/content/templates/default.txt
+++ b/build/content/templates/default.txt
@@ -6,7 +6,7 @@
"battery": "0",
"weapons": [ -1, -1, -1, -1, -1, -1, -1, -1 ],
"armor": [ -1, -1, -1, -1, -1, -1, -1, -1 ],
- "augs": [ -1, -1, -1, -1, -1, -1, -1, -1 ],
+ "augs": [ 4, -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 ]
},
{
@@ -21,12 +21,22 @@
},
{
"name": "well done",
- "chassis": "9",
+ "chassis": "10",
"brain": "2",
"battery": "2",
- "weapons": [ 2, 1, -1, -1, -1, -1, -1, -1 ],
+ "weapons": [ 27, -1, -1, -1, -1, -1, -1, -1 ],
"armor": [ 0, 0, -1, -1, -1, -1, -1, -1 ],
- "augs": [ 0, 0, 0, -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 ]
+ },
+ {
+ "name": "range tester",
+ "chassis": "12",
+ "brain": "0",
+ "battery": "1",
+ "weapons": [ 1, -1, -1, -1, -1, -1, -1, -1 ],
+ "armor": [ 0, 0, 0, 0, -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 ]
}
] \ No newline at end of file
diff --git a/build/content/weapons.txt b/build/content/weapons.txt
index 8d20804..324b66a 100644
--- a/build/content/weapons.txt
+++ b/build/content/weapons.txt
@@ -14,8 +14,8 @@
],
"damage": [
10.0,
- 10.0,
- 10.0
+ 12.5,
+ 15.0
],
"range": [
4.0,
@@ -38,8 +38,8 @@
],
"damage": [
15.0,
- 15.0,
- 15.0
+ 18.75,
+ 22.5
],
"range": [
5.0,
@@ -62,8 +62,8 @@
],
"damage": [
20.0,
- 20.0,
- 20.0
+ 25.0,
+ 30.0
],
"range": [
5.0,
@@ -86,8 +86,8 @@
],
"damage": [
32.0,
- 32.0,
- 32.0
+ 40.0,
+ 48.0
],
"range": [
6.0,
@@ -110,8 +110,8 @@
],
"damage": [
40.0,
- 40.0,
- 40.0
+ 50.0,
+ 60.0
],
"range": [
6.0,
@@ -134,8 +134,8 @@
],
"damage": [
250.0,
- 250.0,
- 250.0
+ 312.5,
+ 375.0
],
"range": [
7.0,
@@ -158,8 +158,8 @@
],
"damage": [
8.0,
- 8.0,
- 8.0
+ 10.0,
+ 12.0
],
"range": [
3.0,
@@ -182,8 +182,8 @@
],
"damage": [
25.0,
- 25.0,
- 25.0
+ 31.25,
+ 37.5
],
"range": [
4.0,
@@ -206,8 +206,8 @@
],
"damage": [
40.0,
- 40.0,
- 40.0
+ 50.0,
+ 60.0
],
"range": [
5.0,
@@ -230,8 +230,8 @@
],
"damage": [
400.0,
- 400.0,
- 400.0
+ 500.0,
+ 600.0
],
"range": [
1.0,
@@ -259,8 +259,8 @@
],
"damage": [
6.0,
- 6.0,
- 6.0
+ 7.5,
+ 9.0
],
"range": [
1.0,
@@ -283,8 +283,8 @@
],
"damage": [
60.0,
- 60.0,
- 60.0
+ 75.0,
+ 90.0
],
"range": [
1.0,
@@ -312,8 +312,8 @@
],
"damage": [
100.0,
- 100.0,
- 100.0
+ 125.0,
+ 150.0
],
"range": [
8.0,
@@ -336,8 +336,8 @@
],
"damage": [
60.0,
- 60.0,
- 60.0
+ 75.0,
+ 90.0
],
"range": [
7.0,
@@ -365,8 +365,8 @@
],
"damage": [
100.0,
- 100.0,
- 100.0
+ 125.0,
+ 150.0
],
"range": [
8.0,
@@ -394,8 +394,8 @@
],
"damage": [
300.0,
- 300.0,
- 300.0
+ 375.0,
+ 450.0
],
"range": [
9.0,
@@ -423,8 +423,8 @@
],
"damage": [
8.0,
- 8.0,
- 8.0
+ 10.0,
+ 12.0
],
"range": [
5.0,
@@ -447,8 +447,8 @@
],
"damage": [
20.0,
- 20.0,
- 20.0
+ 25.0,
+ 30.0
],
"range": [
6.0,
@@ -471,8 +471,8 @@
],
"damage": [
45.0,
- 45.0,
- 45.0
+ 56.25,
+ 67.5
],
"range": [
6.0,
@@ -495,8 +495,8 @@
],
"damage": [
150.0,
- 150.0,
- 150.0
+ 187.5,
+ 225.0
],
"range": [
7.0,
@@ -519,8 +519,8 @@
],
"damage": [
125.0,
- 125.0,
- 125.0
+ 156.25,
+ 187.5
],
"range": [
5.0,
@@ -543,8 +543,8 @@
],
"damage": [
110.0,
- 110.0,
- 110.0
+ 137.5,
+ 165.0
],
"range": [
5.0,
@@ -567,8 +567,8 @@
],
"damage": [
100.0,
- 100.0,
- 100.0
+ 125.0,
+ 150.0
],
"range": [
7.0,
@@ -596,8 +596,8 @@
],
"damage": [
15.0,
- 15.0,
- 15.0
+ 18.75,
+ 22.5
],
"range": [
1.0,
@@ -620,8 +620,8 @@
],
"damage": [
45.0,
- 45.0,
- 45.0
+ 56.25,
+ 67.5
],
"range": [
2.0,
@@ -644,8 +644,8 @@
],
"damage": [
90.0,
- 90.0,
- 90.0
+ 112.5,
+ 135.0
],
"range": [
6.0,
@@ -668,8 +668,8 @@
],
"damage": [
450.0,
- 450.0,
- 450.0
+ 562.5,
+ 675.0
],
"range": [
7.0,
@@ -692,8 +692,8 @@
],
"damage": [
1000.0,
- 1000.0,
- 1000.0
+ 1250.0,
+ 1500.0
],
"range": [
8.0,
@@ -740,8 +740,8 @@
],
"damage": [
80.0,
- 80.0,
- 80.0
+ 100.0,
+ 120.0
],
"damage_battery": [
5.0,
@@ -822,8 +822,8 @@
],
"damage": [
200.0,
- 200.0,
- 200.0
+ 250.0,
+ 300.0
],
"damage_battery": [
12.0,
@@ -933,8 +933,8 @@
],
"damage": [
100.0,
- 100.0,
- 100.0
+ 125.0,
+ 150.0
],
"range": [
0.0,
@@ -962,8 +962,8 @@
],
"damage": [
40.0,
- 40.0,
- 40.0
+ 50.0,
+ 60.0
],
"range": [
7.0,
diff --git a/build/test.exe b/build/test.exe
index 6fd06e7..d68d851 100644
--- a/build/test.exe
+++ b/build/test.exe
Binary files differ
diff --git a/gst/info.c b/gst/info.c
index eab41a2..2329baf 100644
--- a/gst/info.c
+++ b/gst/info.c
@@ -238,6 +238,17 @@ float info_unit_get_range(infos *info, info_unit *u, int w) {
return sum;
}
+float info_unit_get_maxrange(infos *info, info_unit *u) {
+ int lc = u->levels[LEVEL_CHASSIS];
+ float sum = 0;
+ for(int i=0; i<info->chassis[u->chassis].slot_weapon[lc]; i++) {
+ if (u->weapons[i] != -1) {
+ sum += info_unit_get_range(info, u, i);
+ }
+ }
+ return sum;
+}
+
float info_unit_get_charge_per_shot (infos *info, info_unit *u, int w) {
float sum = 0;
int lw = u->levels[LEVEL_WEAPONS+w];
@@ -311,6 +322,7 @@ float info_unit_get_cost (infos *info, info_unit *u) {
}
+
void weapon_init (info_weapon *w) {
strcpy(w->name, "nameless");
for (int l=0; l<MAXLEVEL; l++) {
diff --git a/gst/info.h b/gst/info.h
index 2fe0973..6417cda 100644
--- a/gst/info.h
+++ b/gst/info.h
@@ -115,6 +115,7 @@ float info_unit_get_damage_target(infos *info, info_unit *u, int w,
info_unit *t);
float info_unit_get_cooldown(infos *info, info_unit *u, int w);
float info_unit_get_range(infos *info, info_unit *u, int w);
+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);
diff --git a/gst/units.c b/gst/units.c
index b0ae2b0..409f9b1 100644
--- a/gst/units.c
+++ b/gst/units.c
@@ -116,11 +116,17 @@ int army_move_step (infos *info, army *ar, map *m) {
if (u->move_points <= 0) continue;
if (u->hp <= 0) continue;
if (u->charge <= 0) continue;
- // search target
+ // search target inside max range
unit *t[32];
+ float maxrange = info_unit_get_maxrange(info, &u->info);
+ unit_search(info, ar, m, u, t, maxrange);
+ // stop if found
+ if (t[0] != NULL) { continue; }
+
+ // search target
unit_search(info, ar, m, u, t, 100);
if (t[0] != NULL) {
- // in range to shoot
+ // in range to move
diff[0] = u->gridpos[0] - t[0]->gridpos[0];
diff[1] = u->gridpos[1] - t[0]->gridpos[1];
if (vec2_mag(diff) > /*info->units[u->who].range*/1) {
diff --git a/hud/hud.c b/hud/hud.c
index 70ce9b0..2f4eca4 100644
--- a/hud/hud.c
+++ b/hud/hud.c
@@ -167,12 +167,12 @@ void hud_map_sel (info_unit *u, infos *info, int sel, int ind,
if (sel == 2) {
*n = &u->armor[ind];
*bound = info->armorslen;
- size[0] = 150; size[1] = 250;
+ size[0] = 150; size[1] = 200;
}
if (sel == 3) {
*n = &u->weapons[ind];
*bound = info->weaponslen;
- size[0] = 200; size[1] = 110;
+ size[0] = 200; size[1] = 170;
}
if (sel == 4) {
*n = &u->augs[ind];
@@ -260,6 +260,7 @@ void hud_close_fnu (hud *h, infos *info) {
} else {
info->templates[h->og.temp_modify] = h->fnu.uinfo;
}
+ info_save_templates(info, "default");
h->state = 0;
}
diff --git a/hud/hud_views.c b/hud/hud_views.c
index a58e058..7b6d7f7 100644
--- a/hud/hud_views.c
+++ b/hud/hud_views.c
@@ -5,20 +5,33 @@
#include <hud_views.h>
+#define LABEL(x, y, s, d) {\
+ float p[2]={x,y};\
+ render_text_scaled(rend, s, p, t, d);\
+}
+
+#define LABEL_F3(x, y, s, q, v, d) {\
+ float p[2]={x,y}; char ss[64]; \
+ sprintf(ss, "%s: %."#q"f %."#q"f %."#q"f", s, v[0], v[1], v[2]);\
+ render_text_scaled(rend, ss, p, t, d);\
+}
+
+#define LABEL_I3(x, y, s, v, d) {\
+ float p[2]={x,y}; char ss[64]; \
+ sprintf(ss, "%s: %d %d %d", s, v[0], v[1], v[2]);\
+ render_text_scaled(rend, ss, p, t, 1);\
+}
+
void render_view_stats (SDL_Renderer* rend, txtd *t, int px, int py,
infos *info, info_unit *tm)
{
float h = 10;
- float pname[2] = { px+10, py+h };
- char sname[64]; sprintf(sname, "STATS");
- render_text_scaled(rend, sname, pname, t, 2);
- h += 35;
+ LABEL(px+10, py+h, "STATS", 2); h += 35;
- float cost = info_unit_get_cost(info, tm);
- float pcost[2] = { px+10, py+h };
- char scost[64]; sprintf(scost, "COST: %.2f", cost);
- render_text_scaled(rend, scost, pcost, t, 1);
- h += 20;
+ { 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[
@@ -65,22 +78,15 @@ void render_view_chassis (SDL_Renderer* rend, txtd *t, int px, int py,
infos *info, int chassis, int lvl, SDL_Texture *sprites)
{
if (chassis != -1) {
- float pname[2] = { px+10, py+10 };
- char sname[64]; sprintf(sname, "%s",
- info->chassis[chassis].name);
- render_text_scaled(rend, sname, pname, t, 2);
- float pweight[2] = { px+10, py+40 };
- char sweight[64]; sprintf(sweight, "MAX WEIGHT: %0.0f",
- info->chassis[chassis].weight_max[lvl]);
- render_text_scaled(rend, sweight, pweight, t, 1);
- float php[2] = { px+10, py+55 };
- char shp[64]; sprintf(shp, "HP: %0.1f",
- info->chassis[chassis].hp[lvl]);
- render_text_scaled(rend, shp, php, t, 1);
- float pspeed[2] = { px+10, py+70 };
- char sspeed[64]; sprintf(sspeed, "SPEED: %0.2f tiles/turn",
- info->chassis[chassis].speed[lvl]);
- render_text_scaled(rend, sspeed, pspeed, t, 1);
+ 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 += 15;
SDL_Rect srcRect = { chassis*32, 32, 32, 32 };
SDL_Rect dstRect = { px+300-32-10, py+10, 32, 32 };
@@ -95,25 +101,17 @@ void render_view_battery (SDL_Renderer* rend, txtd *t, int px, int py,
infos *info, int batt, int lvl)
{
if (batt != -1) {
- float pname[2] = { px+10, py+10 };
- char sname[64]; sprintf(sname, "%s",
- info->batteries[batt].name);
- render_text_scaled(rend, sname, pname, t, 1);
- float pweight[2] = { px+10, py+40 };
- char sweight[64]; sprintf(sweight, "WEIGHT: %0.0f",
- info->batteries[batt].weight[lvl]);
- render_text_scaled(rend, sweight, pweight, t, 1);
- float pcapacity[2] = { px+10, py+55 };
- char scapacity[64]; sprintf(scapacity, "CAPACITY: %0.1f",
- info->batteries[batt].capacity[lvl]);
- render_text_scaled(rend, scapacity, pcapacity, t, 1);
- float prech[2] = { px+10, py+70 };
- char srech[64];
+ 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");
- }
+ } else { strcpy(srech, "RECHARGEABLE"); }
render_text_scaled(rend, srech, prech, t, 1);
} else {
float pname[2] = { px+10, py+10 };
@@ -155,25 +153,21 @@ void render_view_armor_detail (SDL_Renderer* rend, txtd *t, int px, int py,
infos *info, int armor, int lvl)
{
if (armor != -1) {
- float pname[2] = { px+10, py+10 };
- char sname[64]; sprintf(sname, "%s", info->armors[armor].name);
- render_text_scaled(rend, sname, pname, t, 1);
- float pweight[2] = { px+10, py+40 };
- char sweight[64]; sprintf(sweight, "WEIGHT: %0.0f",
- info->armors[armor].weight[lvl]);
- render_text_scaled(rend, sweight, pweight, t, 1);
+ info_armor *arm = info->armors+armor;
+ int h = 10;
- float pred[2] = { px+10, py+60 };
- render_text_scaled(rend, "DAMAGE REDUCTION", pred, t, 1);
+ 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;
- int h=0;
for (int i=0; i<7; i++) {
- if (info->armors[armor].armor[i][lvl] < 0.001) continue;
- float pa[2] = { px+10, py+75+h*15 };
- char sa[64]; sprintf(sa, "%s: %.1f%",
- info->damage_types[i], info->armors[armor].armor[i][lvl]);
- render_text_scaled(rend, sa, pa, t, 1);
- h++;
+ 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;
}
} else {
render_view_weapon(rend, t, px, py, info, armor, lvl);
@@ -185,30 +179,19 @@ void render_view_weapon (SDL_Renderer* rend, txtd *t, int px, int py,
infos *info, int weapon, int lvl)
{
if (weapon != -1) {
- float pname[2] = { px+10, py+10 };
- char sname[64]; sprintf(sname, "%s",
- info->weapons[weapon].name);
- render_text_scaled(rend, sname, pname, t, 1);
- float pweight[2] = { px+10, py+30 };
- char sweight[64]; sprintf(sweight, "WEIGHT: %.0f",
- info->weapons[weapon].weight[lvl]);
- render_text_scaled(rend, sweight, pweight, t, 1);
- float ptype[2] = { px+10, py+45 };
- char stype[64]; sprintf(stype, "DAMAGE TYPE: %s",
+ 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]);
- render_text_scaled(rend, stype, ptype, t, 1);
- float pdamage[2] = { px+10, py+60 };
- char sdamage[64]; sprintf(sdamage, "DAMAGE: %.0f",
- info->weapons[weapon].damage[lvl]);
- render_text_scaled(rend, sdamage, pdamage, t, 1);
- float prange[2] = { px+10, py+75 };
- char srange[64]; sprintf(srange, "RANGE: %.0f",
- info->weapons[weapon].range[lvl]);
- render_text_scaled(rend, srange, prange, t, 1);
- float pcool[2] = { px+10, py+90 };
- char scool[64]; sprintf(scool, "COOLDOWN: %.0f",
- info->weapons[weapon].cooldown[lvl]);
- render_text_scaled(rend, scool, pcool, t, 1);
+
+ 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;
} else {
float pname[2] = { px+10, py+10 };
render_text_scaled(rend, "select a weapon...", pname, t, 1);
@@ -219,30 +202,34 @@ void render_view_weapon_detail (SDL_Renderer* rend, txtd *t,
int px, int py, infos *info, int weapon, int lvl)
{
if (weapon != -1) {
- float pname[2] = { px+10, py+10 };
- char sname[64]; sprintf(sname, "%s",
- info->weapons[weapon].name);
- render_text_scaled(rend, sname, pname, t, 1);
- float pweight[2] = { px+10, py+30 };
- char sweight[64]; sprintf(sweight, "WEIGHT: %.0f",
- info->weapons[weapon].weight[lvl]);
- render_text_scaled(rend, sweight, pweight, t, 1);
- float ptype[2] = { px+10, py+45 };
- char stype[64]; sprintf(stype, "DAMAGE TYPE: %s",
+ 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]);
- render_text_scaled(rend, stype, ptype, t, 1);
- float pdamage[2] = { px+10, py+60 };
- char sdamage[64]; sprintf(sdamage, "DAMAGE: %.0f",
- info->weapons[weapon].damage[lvl]);
- render_text_scaled(rend, sdamage, pdamage, t, 1);
- float prange[2] = { px+10, py+75 };
- char srange[64]; sprintf(srange, "RANGE: %.0f",
- info->weapons[weapon].range[lvl]);
- render_text_scaled(rend, srange, prange, t, 1);
- float pcool[2] = { px+10, py+90 };
- char scool[64]; sprintf(scool, "COOLDOWN: %.0f",
- info->weapons[weapon].cooldown[lvl]);
- render_text_scaled(rend, scool, pcool, t, 1);
+
+ 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;
+ }
} else {
render_view_weapon(rend, t, px, py, info, weapon, lvl);
}
@@ -253,14 +240,11 @@ void render_view_aug (SDL_Renderer* rend, txtd *t, int px, int py,
infos *info, int aug, int lvl)
{
if (aug != -1) {
- float pname[2] = { px+10, py+10 };
- char sname[64]; sprintf(sname, "%s",
- info->augs[aug].name);
- render_text_scaled(rend, sname, pname, t, 1);
- float pweight[2] = { px+10, py+30 };
- char sweight[64]; sprintf(sweight, "WEIGHT: %.0f",
- info->augs[aug].weight[lvl]);
- render_text_scaled(rend, sweight, pweight, t, 1);
+ 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;
} else {
float pname[2] = { px+10, py+10 };
render_text_scaled(rend, "select an augment...", pname, t, 1);
@@ -271,82 +255,68 @@ void render_view_aug_detail (SDL_Renderer* rend, txtd *t, int px, int py,
infos *info, int aug, int lvl)
{
if (aug != -1) {
- float h = 10;
- float pname[2] = { px+10, py+h };
- char sname[64]; sprintf(sname, "%s",
- info->augs[aug].name);
- render_text_scaled(rend, sname, pname, t, 1);
- h += 20;
+ info_aug *augm = info->augs+aug;
+ int h = 10;
- float pweight[2] = { px+10, py+h };
- char sweight[64]; sprintf(sweight, "WEIGHT: %.0f",
- info->augs[aug].weight[lvl]);
- render_text_scaled(rend, sweight, pweight, t, 1);
- h += 15;
+ LABEL(px+10, py+h, augm->name, 1); h += 20;
+ LABEL_F3(px+10, py+h, "WEIGHT", 0, augm->weight, 1); h += 15;
- float range = info->augs[aug].add_range[lvl];
- if (range != 0) {
- float p[2] = { px+10, py+h };
- char s[64]; sprintf(s, "RANGE: %.1f", range);
- render_text_scaled(rend, s, p, t, 1);
- h += 15;
+ 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 = info->augs[aug].add_cooldown[lvl];
+ float cooldown = 0; for(int i=0;i<MAXLEVEL;i++)
+ cooldown += fabs(augm->add_cooldown[i]);
if (cooldown != 0) {
- float p[2] = { px+10, py+h };
- char s[64]; sprintf(s, "COOLDOWN: %.2f", cooldown);
- render_text_scaled(rend, s, p, t, 1);
+ LABEL_F3(px+10, py+h, "COOLDOWN", 2, augm->add_cooldown, 1);
h += 15;
}
- float speed = info->augs[aug].add_speed[lvl];
+ float speed = 0; for(int i=0;i<MAXLEVEL;i++)
+ speed += fabs(augm->add_speed[i]);
if (speed != 0) {
- float p[2] = { px+10, py+h };
- char s[64]; sprintf(s, "SPEED: %.2f", speed);
- render_text_scaled(rend, s, p, t, 1);
- h += 15;
+ LABEL_F3(px+10, py+h, "SPEED", 2, augm->add_speed, 1); h += 15;
}
- float hp = info->augs[aug].add_hp[lvl];
+ float hp = 0; for(int i=0;i<MAXLEVEL;i++)
+ hp += fabs(augm->add_hp[i]);
if (hp != 0) {
- float p[2] = { px+10, py+h };
- char s[64]; sprintf(s, "HP: %.1f", hp);
- render_text_scaled(rend, s, p, t, 1);
- h += 15;
+ 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++) sum += fabs(info->augs[aug].add_armor[i][lvl]);
+ for (int i=0; i<7; i++)
+ for(int j=0;j<MAXLEVEL;j++)
+ sum += fabs(augm->add_armor[i][j]);
if (sum != 0) {
- float p[2] = { px+10, py+h };
- render_text_scaled(rend, "ARMOR: ", p, t, 1);
- h += 15;
for (int i=0; i<7; i++) {
- if (info->augs[aug].add_armor[i][lvl] == 0) continue;
- float pa[2] = { px+10, py+h };
- char sa[64]; sprintf(sa, "%s: %.1f%",
- info->damage_types[i], info->augs[aug].add_armor[i][lvl]);
- render_text_scaled(rend, sa, pa, t, 1);
- h += 15;
+ 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++) sum += fabs(info->augs[aug].add_damage[i][lvl]);
+ for (int i=0; i<7; i++)
+ for(int j=0;j<MAXLEVEL;j++)
+ sum += fabs(augm->add_damage[i][j]);
if (sum != 0) {
- float p[2] = { px+10, py+h };
- render_text_scaled(rend, "DAMAGE: ", p, t, 1);
- h += 15;
for (int i=0; i<7; i++) {
- if (info->augs[aug].add_damage[i][lvl] == 0) continue;
- float pa[2] = { px+10, py+h };
- char sa[64]; sprintf(sa, "%s: %.1f%",
- info->damage_types[i], info->augs[aug].add_damage[i][lvl]);
- render_text_scaled(rend, sa, pa, t, 1);
- h += 15;
+ 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;
+ }
}
}
} else {
diff --git a/json/jsonparse.c b/json/jsonparse.c
index 34587b5..9ac845c 100644
--- a/json/jsonparse.c
+++ b/json/jsonparse.c
@@ -23,7 +23,7 @@ void json_parse_array(char *json, void *temp, jsmntok_t *t, int r, char type) {
*p = atoi(val);
}
if (type == 'f') {
- float *p = (float*)(intptr_t)temp+sizeof(float)*i;
+ float *p = (float*)(intptr_t)temp+i;
*p = atof(val);
}
}
diff --git a/render/render_text.c b/render/render_text.c
index df9317c..6b801eb 100644
--- a/render/render_text.c
+++ b/render/render_text.c
@@ -4,6 +4,9 @@
void char_width_init (int *char_width) {
for (int i=0; i<128; char_width[i++]=5);
+ char_width['('] = 2; char_width[')'] = 2;
+ char_width['['] = 2; char_width[']'] = 2;
+ char_width['{'] = 3; char_width['}'] = 3;
char_width[','] = 1; char_width['-'] = 3; char_width['.'] = 1;
char_width['/'] = 4; char_width['!'] = 1;
char_width[':'] = 1; char_width[';'] = 1;