diff options
author | jacopo grandi <jak.sk8@hotmail.it> | 2021-02-19 18:30:53 +0100 |
---|---|---|
committer | jacopo grandi <jak.sk8@hotmail.it> | 2021-02-19 18:30:53 +0100 |
commit | 5126638d46398579c26d3c7bd908fe17b8508b13 (patch) | |
tree | fbb9e981187f32bf78dc521ff538ea31de9c0019 | |
parent | 5f0fce4191309e9526b7109a0d87c092ce6a4193 (diff) |
battery calc and unstable levels
-rw-r--r-- | build/army/army2.txt | bin | 21528 -> 0 bytes | |||
-rw-r--r-- | build/content/armor.txt | 189 | ||||
-rw-r--r-- | build/content/augments.txt | 264 | ||||
-rw-r--r-- | build/content/autolevel.py | 28 | ||||
-rw-r--r-- | build/content/batteries.txt | 113 | ||||
-rw-r--r-- | build/content/brains.txt | 50 | ||||
-rw-r--r-- | build/content/chassis.txt | 731 | ||||
-rw-r--r-- | build/content/gf.bmp | bin | 37978 -> 37978 bytes | |||
-rw-r--r-- | build/content/gfsmall.bmp (renamed from build/army/army.txt) | bin | 21528 -> 18826 bytes | |||
-rw-r--r-- | build/content/weapons.txt | 934 | ||||
-rw-r--r-- | build/test.exe | bin | 746614 -> 751250 bytes | |||
-rw-r--r-- | design/notes.txt | 86 | ||||
-rw-r--r-- | gst/gst.c | 1 | ||||
-rw-r--r-- | gst/info.c | 487 | ||||
-rw-r--r-- | gst/info.h | 76 | ||||
-rw-r--r-- | gst/units.c | 21 | ||||
-rw-r--r-- | gst/units.h | 1 | ||||
-rw-r--r-- | hud/hud.c | 49 | ||||
-rw-r--r-- | hud/hud_views.c | 79 | ||||
-rw-r--r-- | hud/hud_views.h | 20 | ||||
-rw-r--r-- | json/jsonparse.c | 122 | ||||
-rw-r--r-- | json/jsonparse.h | 19 | ||||
-rw-r--r-- | main.c | 16 | ||||
-rw-r--r-- | render/render_text.c | 17 | ||||
-rw-r--r-- | render/render_text.h | 3 |
25 files changed, 2546 insertions, 760 deletions
diff --git a/build/army/army2.txt b/build/army/army2.txt Binary files differdeleted file mode 100644 index ae1c3b5..0000000 --- a/build/army/army2.txt +++ /dev/null diff --git a/build/content/armor.txt b/build/content/armor.txt index f418779..5182a0c 100644 --- a/build/content/armor.txt +++ b/build/content/armor.txt @@ -1,57 +1,200 @@ [ { "name": "metal plating", - "weight": "50", - "pierce": "5", "spread": "8" + "weight": [ + 50.0, + 50.0, + 50.0 + ], + "pierce": [ + 5.0, + 5.0, + 5.0 + ], + "spread": [ + 8.0, + 8.0, + 8.0 + ] }, { "name": "heavy metal plating", - "weight": "80", - "pierce": "7", "spread": "10", "impact": "5" + "weight": [ + 80.0, + 80.0, + 80.0 + ], + "pierce": [ + 7.0, + 7.0, + 7.0 + ], + "spread": [ + 10.0, + 10.0, + 10.0 + ], + "impact": [ + 5.0, + 5.0, + 5.0 + ] }, { "name": "reflective plating", - "weight": "40", - "laser": "10" + "weight": [ + 40.0, + 40.0, + 40.0 + ], + "laser": [ + 10.0, + 10.0, + 10.0 + ] }, { "name": "heat resistent plating", - "weight": "50", - "fusion": "8" + "weight": [ + 50.0, + 50.0, + 50.0 + ], + "fusion": [ + 8.0, + 8.0, + 8.0 + ] }, { "name": "padding", - "weight": "20", - "spread": "5", "impact": "8" + "weight": [ + 20.0, + 20.0, + 20.0 + ], + "spread": [ + 5.0, + 5.0, + 5.0 + ], + "impact": [ + 8.0, + 8.0, + 8.0 + ] }, { "name": "reactive armor", - "weight": "75", - "explosive": "12" + "weight": [ + 75.0, + 75.0, + 75.0 + ], + "explosive": [ + 12.0, + 12.0, + 12.0 + ] }, { "name": "energy shields", - "weight": "25", - "pierce": "3", "spread": "3", "fusion": "3", "explosive": "3", "laser": "3" + "weight": [ + 25.0, + 25.0, + 25.0 + ], + "pierce": [ + 3.0, + 3.0, + 3.0 + ], + "spread": [ + 3.0, + 3.0, + 3.0 + ], + "fusion": [ + 3.0, + 3.0, + 3.0 + ], + "explosive": [ + 3.0, + 3.0, + 3.0 + ], + "laser": [ + 3.0, + 3.0, + 3.0 + ] }, { "name": "composite armor", - "weight": "30", - "pierce": "6", "spread": "4", "impact": "3" + "weight": [ + 30.0, + 30.0, + 30.0 + ], + "pierce": [ + 6.0, + 6.0, + 6.0 + ], + "spread": [ + 4.0, + 4.0, + 4.0 + ], + "impact": [ + 3.0, + 3.0, + 3.0 + ] }, { "name": "plastic armor", - "weight": "10", - "pierce": "4" + "weight": [ + 10.0, + 10.0, + 10.0 + ], + "pierce": [ + 4.0, + 4.0, + 4.0 + ] }, { "name": "sloped steel armor", - "weight": "45", - "pierce": "10", "spread": "8" + "weight": [ + 45.0, + 45.0, + 45.0 + ], + "pierce": [ + 10.0, + 10.0, + 10.0 + ], + "spread": [ + 8.0, + 8.0, + 8.0 + ] }, { "name": "charged armor", - "weight": "100", - "explosive": "25" - }, + "weight": [ + 100.0, + 100.0, + 100.0 + ], + "explosive": [ + 25.0, + 25.0, + 25.0 + ] + } ]
\ No newline at end of file diff --git a/build/content/augments.txt b/build/content/augments.txt index c98e1d1..6582a7e 100644 --- a/build/content/augments.txt +++ b/build/content/augments.txt @@ -1,97 +1,273 @@ [ { "name": "charged ammo", - "weight": "10", - "damage_emp": "5" + "weight": [ + 10.0, + 10.0, + 10.0 + ], + "damage_emp": [ + 5.0, + 5.0, + 5.0 + ] }, { "name": "fusion ammo", - "weight": "10", - "damage_fusion": "4" + "weight": [ + 10.0, + 10.0, + 10.0 + ], + "damage_fusion": [ + 4.0, + 4.0, + 4.0 + ] }, { "name": "explosive ammo", - "weight": "30", - "armor_explosive": "8" + "weight": [ + 30.0, + 30.0, + 30.0 + ], + "armor_explosive": [ + 8.0, + 8.0, + 8.0 + ] }, { "name": "radiator", - "weight": "10", - "armor_fusion": "2" + "weight": [ + 10.0, + 10.0, + 10.0 + ], + "armor_fusion": [ + 2.0, + 2.0, + 2.0 + ] }, { "name": "priority module", - "weight": "0" + "weight": [ + 0.0, + 0.0, + 0.0 + ] }, { "name": "communication array", - "weight": "50", - "armor_pierce": "1", - "armor_impact": "1", - "armor_fusion": "1", - "aoe": "2" + "weight": [ + 50.0, + 50.0, + 50.0 + ], + "armor_pierce": [ + 1.0, + 1.0, + 1.0 + ], + "armor_impact": [ + 1.0, + 1.0, + 1.0 + ], + "armor_fusion": [ + 1.0, + 1.0, + 1.0 + ], + "aoe": [ + 2.0, + 2.0, + 2.0 + ] }, { "name": "long range targeting", - "weight": "0", - "add_range": "1" + "weight": [ + 0.0, + 0.0, + 0.0 + ], + "add_range": [ + 1.0, + 1.0, + 1.0 + ] }, { "name": "long range targeting", - "weight": "0", - "range": "1" + "weight": [ + 0.0, + 0.0, + 0.0 + ], + "range": [ + 1.0, + 1.0, + 1.0 + ] }, { "name": "fast target acquisition", - "weight": "5", - "add_cooldown": "-0.1" + "weight": [ + 5.0, + 5.0, + 5.0 + ], + "add_cooldown": [ + -0.1, + -0.1, + -0.1 + ] }, { "name": "overcharger", - "weight": "10", - "damage_laser": "8", - "recharge": "-5" + "weight": [ + 10.0, + 10.0, + 10.0 + ], + "damage_laser": [ + 8.0, + 8.0, + 8.0 + ], + "recharge": [ + -5.0, + -5.0, + -5.0 + ] }, { "name": "focus lens", - "weight": "3", - "damage_laser": "3" + "weight": [ + 3.0, + 3.0, + 3.0 + ], + "damage_laser": [ + 3.0, + 3.0, + 3.0 + ] }, { "name": "amplifier", - "weight": "30", - "damage_laser": "3", - "damage_fusion": "5" + "weight": [ + 30.0, + 30.0, + 30.0 + ], + "damage_laser": [ + 3.0, + 3.0, + 3.0 + ], + "damage_fusion": [ + 5.0, + 5.0, + 5.0 + ] }, { "name": "shrapnel", - "weight": "5", - "damage_explosive": "5" + "weight": [ + 5.0, + 5.0, + 5.0 + ], + "damage_explosive": [ + 5.0, + 5.0, + 5.0 + ] }, { "name": "reloader", - "weight": "40", - "add_cooldown": "-0.1" + "weight": [ + 40.0, + 40.0, + 40.0 + ], + "add_cooldown": [ + -0.1, + -0.1, + -0.1 + ] }, { "name": "anti jamming device", - "weight": "2", - "armor_emp": "5" + "weight": [ + 2.0, + 2.0, + 2.0 + ], + "armor_emp": [ + 5.0, + 5.0, + 5.0 + ] }, { "name": "weight stripping", - "weight": "-10", - "add_hp": "-10" + "weight": [ + -10.0, + -10.0, + -10.0 + ], + "add_hp": [ + -10.0, + -10.0, + -10.0 + ] }, { "name": "barebone weapon setup", - "weight": "-30", - "damage_pierce": "-25", - "damage_laser": "-25", - "damage_impact": "-25", - "damage_fusion": "-25", - "damage_explosive": "-25", - "damage_emp": "-25", - "damage_spread": "-25" + "weight": [ + -30.0, + -30.0, + -30.0 + ], + "damage_pierce": [ + -25.0, + -25.0, + -25.0 + ], + "damage_laser": [ + -25.0, + -25.0, + -25.0 + ], + "damage_impact": [ + -25.0, + -25.0, + -25.0 + ], + "damage_fusion": [ + -25.0, + -25.0, + -25.0 + ], + "damage_explosive": [ + -25.0, + -25.0, + -25.0 + ], + "damage_emp": [ + -25.0, + -25.0, + -25.0 + ], + "damage_spread": [ + -25.0, + -25.0, + -25.0 + ] } ]
\ No newline at end of file diff --git a/build/content/autolevel.py b/build/content/autolevel.py new file mode 100644 index 0000000..eac6e09 --- /dev/null +++ b/build/content/autolevel.py @@ -0,0 +1,28 @@ +import json + +def vectorize (obj, forbidlist): + for c in obj: + for key in c: + if not(key in forbidlist): + val = c[key] + try: val = int(val); + except: pass + try: val = float(val); + except: pass + c[key] = [val for i in range(3)] + return obj + + +def comp(filename, forbidlist): + with open(filename+".txt", "r") as f: obj = json.loads(f.read()) + obj = vectorize(obj, forbidlist) + with open(filename+".txt", "w") as f: + f.write(json.dumps(obj, indent=4)) + +if __name__ == "__main__": + #comp("weapons", ["name", "damage_type"]) + #comp("augments", ["name"]) + #comp("batteries", ["name"]) + #comp("armor", ["name"]) + #comp("chassis", ["name"]) + comp("brains", ["name"]) diff --git a/build/content/batteries.txt b/build/content/batteries.txt index fe5da27..18ae48e 100644 --- a/build/content/batteries.txt +++ b/build/content/batteries.txt @@ -1,34 +1,131 @@ [ { "name": "small alkaline pack", - "weight": "0", "capacity": "50" + "weight": [ + 0.0, + 0.0, + 0.0 + ], + "capacity": [ + 50.0, + 50.0, + 50.0 + ] }, { "name": "big alkaline pack", - "weight": "2", "capacity": "200" + "weight": [ + 2.0, + 2.0, + 2.0 + ], + "capacity": [ + 200.0, + 200.0, + 200.0 + ] }, { "name": "small lithium pack", - "weight": "5", "capacity": "150", "recharge": "1" + "weight": [ + 5.0, + 5.0, + 5.0 + ], + "capacity": [ + 150.0, + 150.0, + 150.0 + ], + "recharge": [ + 1.0, + 1.0, + 1.0 + ] }, { "name": "big lithium pack", - "weight": "15", "capacity": "500", "recharge": "1" + "weight": [ + 15.0, + 15.0, + 15.0 + ], + "capacity": [ + 500.0, + 500.0, + 500.0 + ], + "recharge": [ + 1.0, + 1.0, + 1.0 + ] }, { "name": "lead battery", - "weight": "20", "capacity": "800", "recharge": "1" + "weight": [ + 20.0, + 20.0, + 20.0 + ], + "capacity": [ + 800.0, + 800.0, + 800.0 + ], + "recharge": [ + 1.0, + 1.0, + 1.0 + ] }, { "name": "small molten salt battery", - "weight": "40", "capacity": "1500", "recharge": "1" + "weight": [ + 40.0, + 40.0, + 40.0 + ], + "capacity": [ + 1500.0, + 1500.0, + 1500.0 + ], + "recharge": [ + 1.0, + 1.0, + 1.0 + ] }, { "name": "big molten salt battery", - "weight": "70", "capacity": "2000", "recharge": "1" + "weight": [ + 70.0, + 70.0, + 70.0 + ], + "capacity": [ + 2000.0, + 2000.0, + 2000.0 + ], + "recharge": [ + 1.0, + 1.0, + 1.0 + ] }, { "name": "atomic battery", - "weight": "150", "capacity": "10000" + "weight": [ + 150.0, + 150.0, + 150.0 + ], + "capacity": [ + 10000.0, + 10000.0, + 10000.0 + ] } ]
\ No newline at end of file diff --git a/build/content/brains.txt b/build/content/brains.txt index c9bb4b5..87d8d10 100644 --- a/build/content/brains.txt +++ b/build/content/brains.txt @@ -1,20 +1,50 @@ [ { - "name": "search and destroy" + "name": "search and destroy", + "upkeep": [ + 1.0, + 1.0, + 1.0 + ] }, - { - "name": "follower" + { + "name": "follower", + "upkeep": [ + 1.0, + 1.0, + 1.0 + ] }, - { - "name": "defensive" + { + "name": "defensive", + "upkeep": [ + 1.0, + 1.0, + 1.0 + ] }, - { - "name": "kamikaze" + { + "name": "kamikaze", + "upkeep": [ + 1.0, + 1.0, + 1.0 + ] }, - { - "name": "run and gun" + { + "name": "run and gun", + "upkeep": [ + 1.0, + 1.0, + 1.0 + ] }, { - "name": "flank" + "name": "flank", + "upkeep": [ + 1.0, + 1.0, + 1.0 + ] } ]
\ No newline at end of file diff --git a/build/content/chassis.txt b/build/content/chassis.txt index e4643c2..5d8db88 100644 --- a/build/content/chassis.txt +++ b/build/content/chassis.txt @@ -1,180 +1,669 @@ [ { "name": "light two legged bot", - "slot_weapon": "1", - "slot_armor": "0", - "slot_aug": "1", - "weight_max": "20", - "hp": "100", - "speed": "1.5" + "slot_weapon": [ + 1.0, + 1.0, + 1.0 + ], + "slot_armor": [ + 0.0, + 0.0, + 0.0 + ], + "slot_aug": [ + 1.0, + 1.0, + 1.0 + ], + "weight_max": [ + 20.0, + 20.0, + 20.0 + ], + "hp": [ + 100.0, + 100.0, + 100.0 + ], + "speed": [ + 1.5, + 1.5, + 1.5 + ], + "upkeep": [ + 1.0, + 1.0, + 1.0 + ] }, { "name": "heavy two legged bot", - "slot_weapon": "1", - "slot_armor": "1", - "slot_aug": "3", - "weight_max": "45", - "hp": "350", - "speed": "1" + "slot_weapon": [ + 1.0, + 1.0, + 1.0 + ], + "slot_armor": [ + 1.0, + 1.0, + 1.0 + ], + "slot_aug": [ + 3.0, + 3.0, + 3.0 + ], + "weight_max": [ + 45.0, + 45.0, + 45.0 + ], + "hp": [ + 350.0, + 350.0, + 350.0 + ], + "speed": [ + 1.0, + 1.0, + 1.0 + ] }, { "name": "light four legged bot", - "slot_weapon": "2", - "slot_armor": "1", - "slot_aug": "2", - "weight_max": "50", - "hp": "400", - "speed": "1" + "slot_weapon": [ + 2.0, + 2.0, + 2.0 + ], + "slot_armor": [ + 1.0, + 1.0, + 1.0 + ], + "slot_aug": [ + 2.0, + 2.0, + 2.0 + ], + "weight_max": [ + 50.0, + 50.0, + 50.0 + ], + "hp": [ + 400.0, + 400.0, + 400.0 + ], + "speed": [ + 1.0, + 1.0, + 1.0 + ] }, { "name": "heavy four legged bot", - "slot_weapon": "2", - "slot_armor": "2", - "slot_aug": "5", - "weight_max": "150", - "hp": "1200", - "speed": "0.67" + "slot_weapon": [ + 2.0, + 2.0, + 2.0 + ], + "slot_armor": [ + 2.0, + 2.0, + 2.0 + ], + "slot_aug": [ + 5.0, + 5.0, + 5.0 + ], + "weight_max": [ + 150.0, + 150.0, + 150.0 + ], + "hp": [ + 1200.0, + 1200.0, + 1200.0 + ], + "speed": [ + 0.67, + 0.67, + 0.67 + ] }, { "name": "light six legged bot", - "slot_weapon": "2", - "slot_armor": "2", - "slot_aug": "3", - "weight_max": "210", - "hp": "640", - "speed": "1" + "slot_weapon": [ + 2.0, + 2.0, + 2.0 + ], + "slot_armor": [ + 2.0, + 2.0, + 2.0 + ], + "slot_aug": [ + 3.0, + 3.0, + 3.0 + ], + "weight_max": [ + 210.0, + 210.0, + 210.0 + ], + "hp": [ + 640.0, + 640.0, + 640.0 + ], + "speed": [ + 1.0, + 1.0, + 1.0 + ] }, { "name": "heavy six legged bot", - "slot_weapon": "2", - "slot_armor": "4", - "slot_aug": "6", - "weight_max": "300", - "hp": "1500", - "speed": "1" + "slot_weapon": [ + 2.0, + 2.0, + 2.0 + ], + "slot_armor": [ + 4.0, + 4.0, + 4.0 + ], + "slot_aug": [ + 6.0, + 6.0, + 6.0 + ], + "weight_max": [ + 300.0, + 300.0, + 300.0 + ], + "hp": [ + 1500.0, + 1500.0, + 1500.0 + ], + "speed": [ + 1.0, + 1.0, + 1.0 + ] }, { "name": "light buggy", - "slot_weapon": "1", - "slot_armor": "1", - "slot_aug": "1", - "weight_max": "50", - "hp": "200", - "speed": "1" + "slot_weapon": [ + 1.0, + 1.0, + 1.0 + ], + "slot_armor": [ + 1.0, + 1.0, + 1.0 + ], + "slot_aug": [ + 1.0, + 1.0, + 1.0 + ], + "weight_max": [ + 50.0, + 50.0, + 50.0 + ], + "hp": [ + 200.0, + 200.0, + 200.0 + ], + "speed": [ + 1.0, + 1.0, + 1.0 + ] }, { "name": "buggy", - "slot_weapon": "2", - "slot_armor": "2", - "slot_aug": "2", - "weight_max": "150", - "hp": "400", - "speed": "1" + "slot_weapon": [ + 2.0, + 2.0, + 2.0 + ], + "slot_armor": [ + 2.0, + 2.0, + 2.0 + ], + "slot_aug": [ + 2.0, + 2.0, + 2.0 + ], + "weight_max": [ + 150.0, + 150.0, + 150.0 + ], + "hp": [ + 400.0, + 400.0, + 400.0 + ], + "speed": [ + 1.0, + 1.0, + 1.0 + ] }, { "name": "light wheeled vehicle", - "slot_weapon": "1", - "slot_armor": "0", - "slot_aug": "2", - "weight_max": "60", - "hp": "320", - "speed": "1", - "recharge": "0.3" + "slot_weapon": [ + 1.0, + 1.0, + 1.0 + ], + "slot_armor": [ + 0.0, + 0.0, + 0.0 + ], + "slot_aug": [ + 2.0, + 2.0, + 2.0 + ], + "weight_max": [ + 60.0, + 60.0, + 60.0 + ], + "hp": [ + 320.0, + 320.0, + 320.0 + ], + "speed": [ + 1.0, + 1.0, + 1.0 + ], + "recharge": [ + 0.3, + 0.3, + 0.3 + ] }, { "name": "medium wheeled vehicle", - "slot_weapon": "2", - "slot_armor": "2", - "slot_aug": "3", - "weight_max": "200", - "hp": "720", - "speed": "1", - "recharge": "0.2" + "slot_weapon": [ + 2.0, + 2.0, + 2.0 + ], + "slot_armor": [ + 2.0, + 2.0, + 2.0 + ], + "slot_aug": [ + 3.0, + 3.0, + 3.0 + ], + "weight_max": [ + 200.0, + 200.0, + 200.0 + ], + "hp": [ + 720.0, + 720.0, + 720.0 + ], + "speed": [ + 1.0, + 1.0, + 1.0 + ], + "recharge": [ + 0.2, + 0.2, + 0.2 + ] }, { "name": "heavy wheeled vehicle", - "slot_weapon": "2", - "slot_armor": "4", - "slot_aug": "4", - "weight_max": "270", - "hp": "950", - "speed": "1", - "recharge": "0.2" + "slot_weapon": [ + 2.0, + 2.0, + 2.0 + ], + "slot_armor": [ + 4.0, + 4.0, + 4.0 + ], + "slot_aug": [ + 4.0, + 4.0, + 4.0 + ], + "weight_max": [ + 270.0, + 270.0, + 270.0 + ], + "hp": [ + 950.0, + 950.0, + 950.0 + ], + "speed": [ + 1.0, + 1.0, + 1.0 + ], + "recharge": [ + 0.2, + 0.2, + 0.2 + ] }, { "name": "light tank", - "slot_weapon": "1", - "slot_armor": "3", - "slot_aug": "2", - "weight_max": "300", - "hp": "700", - "speed": "1", - "recharge": "0.4" + "slot_weapon": [ + 1.0, + 1.0, + 1.0 + ], + "slot_armor": [ + 3.0, + 3.0, + 3.0 + ], + "slot_aug": [ + 2.0, + 2.0, + 2.0 + ], + "weight_max": [ + 300.0, + 300.0, + 300.0 + ], + "hp": [ + 700.0, + 700.0, + 700.0 + ], + "speed": [ + 1.0, + 1.0, + 1.0 + ], + "recharge": [ + 0.4, + 0.4, + 0.4 + ] }, { "name": "medium tank", - "slot_weapon": "1", - "slot_armor": "4", - "slot_aug": "4", - "weight_max": "400", - "hp": "1250", - "speed": "1", - "recharge": "0.5" + "slot_weapon": [ + 1.0, + 1.0, + 1.0 + ], + "slot_armor": [ + 4.0, + 4.0, + 4.0 + ], + "slot_aug": [ + 4.0, + 4.0, + 4.0 + ], + "weight_max": [ + 400.0, + 400.0, + 400.0 + ], + "hp": [ + 1250.0, + 1250.0, + 1250.0 + ], + "speed": [ + 1.0, + 1.0, + 1.0 + ], + "recharge": [ + 0.5, + 0.5, + 0.5 + ] }, { "name": "heavy tank", - "slot_weapon": "2", - "slot_armor": "5", - "slot_aug": "5", - "weight_max": "450", - "hp": "1600", - "speed": "1" + "slot_weapon": [ + 2.0, + 2.0, + 2.0 + ], + "slot_armor": [ + 5.0, + 5.0, + 5.0 + ], + "slot_aug": [ + 5.0, + 5.0, + 5.0 + ], + "weight_max": [ + 450.0, + 450.0, + 450.0 + ], + "hp": [ + 1600.0, + 1600.0, + 1600.0 + ], + "speed": [ + 1.0, + 1.0, + 1.0 + ] }, { "name": "super heavy tank", - "slot_weapon": "3", - "slot_armor": "6", - "slot_aug": "6", - "weight_max": "500", - "hp": "2000", - "speed": "1" + "slot_weapon": [ + 3.0, + 3.0, + 3.0 + ], + "slot_armor": [ + 6.0, + 6.0, + 6.0 + ], + "slot_aug": [ + 6.0, + 6.0, + 6.0 + ], + "weight_max": [ + 500.0, + 500.0, + 500.0 + ], + "hp": [ + 2000.0, + 2000.0, + 2000.0 + ], + "speed": [ + 1.0, + 1.0, + 1.0 + ] }, { "name": "hovercraft", - "slot_weapon": "2", - "slot_armor": "0", - "slot_aug": "3", - "weight_max": "40", - "hp": "300", - "speed": "1", - "recharge": "-0.2" + "slot_weapon": [ + 2.0, + 2.0, + 2.0 + ], + "slot_armor": [ + 0.0, + 0.0, + 0.0 + ], + "slot_aug": [ + 3.0, + 3.0, + 3.0 + ], + "weight_max": [ + 40.0, + 40.0, + 40.0 + ], + "hp": [ + 300.0, + 300.0, + 300.0 + ], + "speed": [ + 1.0, + 1.0, + 1.0 + ], + "recharge": [ + -0.2, + -0.2, + -0.2 + ] }, { "name": "jet floater", - "slot_weapon": "1", - "slot_armor": "0", - "slot_aug": "2", - "weight_max": "30", - "hp": "60", - "speed": "1" + "slot_weapon": [ + 1.0, + 1.0, + 1.0 + ], + "slot_armor": [ + 0.0, + 0.0, + 0.0 + ], + "slot_aug": [ + 2.0, + 2.0, + 2.0 + ], + "weight_max": [ + 30.0, + 30.0, + 30.0 + ], + "hp": [ + 60.0, + 60.0, + 60.0 + ], + "speed": [ + 1.0, + 1.0, + 1.0 + ] }, { "name": "one wheeler", - "slot_weapon": "1", - "slot_armor": "0", - "slot_aug": "4", - "weight_max": "15", - "hp": "40", - "speed": "1" + "slot_weapon": [ + 1.0, + 1.0, + 1.0 + ], + "slot_armor": [ + 0.0, + 0.0, + 0.0 + ], + "slot_aug": [ + 4.0, + 4.0, + 4.0 + ], + "weight_max": [ + 15.0, + 15.0, + 15.0 + ], + "hp": [ + 40.0, + 40.0, + 40.0 + ], + "speed": [ + 1.0, + 1.0, + 1.0 + ] }, { "name": "armored crawler", - "slot_weapon": "1", - "slot_armor": "4", - "slot_aug": "2", - "weight_max": "200", - "hp": "750", - "speed": "1", - "recharge": "-0.4" + "slot_weapon": [ + 1.0, + 1.0, + 1.0 + ], + "slot_armor": [ + 4.0, + 4.0, + 4.0 + ], + "slot_aug": [ + 2.0, + 2.0, + 2.0 + ], + "weight_max": [ + 200.0, + 200.0, + 200.0 + ], + "hp": [ + 750.0, + 750.0, + 750.0 + ], + "speed": [ + 1.0, + 1.0, + 1.0 + ], + "upkeep": [ + 0.4, + 0.4, + 0.4 + ] } ]
\ No newline at end of file diff --git a/build/content/gf.bmp b/build/content/gf.bmp Binary files differindex 85cd3e2..a3750be 100644 --- a/build/content/gf.bmp +++ b/build/content/gf.bmp diff --git a/build/army/army.txt b/build/content/gfsmall.bmp Binary files differindex ae1c3b5..211c925 100644 --- a/build/army/army.txt +++ b/build/content/gfsmall.bmp diff --git a/build/content/weapons.txt b/build/content/weapons.txt index f4b3b2b..8d20804 100644 --- a/build/content/weapons.txt +++ b/build/content/weapons.txt @@ -1,192 +1,974 @@ [ { "name": "smg", - "damage_type": "pierce", "weight": "10", "cooldown": "1", - "damage": "10", "range": "4" + "damage_type": "pierce", + "weight": [ + 10.0, + 10.0, + 10.0 + ], + "cooldown": [ + 1.0, + 1.0, + 1.0 + ], + "damage": [ + 10.0, + 10.0, + 10.0 + ], + "range": [ + 4.0, + 4.0, + 4.0 + ] }, { "name": "machinegun", - "damage_type": "pierce", "weight": "25", "cooldown": "1", - "damage": "15", "range": "5" + "damage_type": "pierce", + "weight": [ + 25.0, + 25.0, + 25.0 + ], + "cooldown": [ + 1.0, + 1.0, + 1.0 + ], + "damage": [ + 15.0, + 15.0, + 15.0 + ], + "range": [ + 5.0, + 5.0, + 5.0 + ] }, { "name": "heavy machinegun", - "damage_type": "pierce", "weight": "40", "cooldown": "1", - "damage": "20", "range": "5" + "damage_type": "pierce", + "weight": [ + 40.0, + 40.0, + 40.0 + ], + "cooldown": [ + 1.0, + 1.0, + 1.0 + ], + "damage": [ + 20.0, + 20.0, + 20.0 + ], + "range": [ + 5.0, + 5.0, + 5.0 + ] }, { "name": "semi autocannon", - "damage_type": "pierce", "weight": "70", "cooldown": "2", - "damage": "32", "range": "6" + "damage_type": "pierce", + "weight": [ + 70.0, + 70.0, + 70.0 + ], + "cooldown": [ + 2.0, + 2.0, + 2.0 + ], + "damage": [ + 32.0, + 32.0, + 32.0 + ], + "range": [ + 6.0, + 6.0, + 6.0 + ] }, { "name": "autocannon", - "damage_type": "pierce", "weight": "100", "cooldown": "1", - "damage": "40", "range": "6" + "damage_type": "pierce", + "weight": [ + 100.0, + 100.0, + 100.0 + ], + "cooldown": [ + 1.0, + 1.0, + 1.0 + ], + "damage": [ + 40.0, + 40.0, + 40.0 + ], + "range": [ + 6.0, + 6.0, + 6.0 + ] }, { "name": "high velocity cannon", - "damage_type": "pierce", "weight": "120", "cooldown": "4", - "damage": "250", "range": "7" + "damage_type": "pierce", + "weight": [ + 120.0, + 120.0, + 120.0 + ], + "cooldown": [ + 4.0, + 4.0, + 4.0 + ], + "damage": [ + 250.0, + 250.0, + 250.0 + ], + "range": [ + 7.0, + 7.0, + 7.0 + ] }, { "name": "scrap gun", - "damage_type": "spread", "weight": "5", "cooldown": "2", - "damage": "8", "range": "3" + "damage_type": "spread", + "weight": [ + 5.0, + 5.0, + 5.0 + ], + "cooldown": [ + 2.0, + 2.0, + 2.0 + ], + "damage": [ + 8.0, + 8.0, + 8.0 + ], + "range": [ + 3.0, + 3.0, + 3.0 + ] }, { "name": "burst cannon", - "damage_type": "spread", "weight": "15", "cooldown": "2", - "damage": "25", "range": "4" + "damage_type": "spread", + "weight": [ + 15.0, + 15.0, + 15.0 + ], + "cooldown": [ + 2.0, + 2.0, + 2.0 + ], + "damage": [ + 25.0, + 25.0, + 25.0 + ], + "range": [ + 4.0, + 4.0, + 4.0 + ] }, { "name": "heavy burst cannon", - "damage_type": "spread", "weight": "30", "cooldown": "2", - "damage": "40", "range": "5" + "damage_type": "spread", + "weight": [ + 30.0, + 30.0, + 30.0 + ], + "cooldown": [ + 2.0, + 2.0, + 2.0 + ], + "damage": [ + 40.0, + 40.0, + 40.0 + ], + "range": [ + 5.0, + 5.0, + 5.0 + ] }, { "name": "maul", - "damage_type": "impact", "weight": "200", "cooldown": "3", - "damage": "400", "range": "1", "knockback": "2" + "damage_type": "impact", + "weight": [ + 200.0, + 200.0, + 200.0 + ], + "cooldown": [ + 3.0, + 3.0, + 3.0 + ], + "damage": [ + 400.0, + 400.0, + 400.0 + ], + "range": [ + 1.0, + 1.0, + 1.0 + ], + "knockback": [ + 2.0, + 2.0, + 2.0 + ] }, { "name": "slam", - "damage_type": "impact", "weight": "0", "cooldown": "1", - "damage": "6", "range": "1" + "damage_type": "impact", + "weight": [ + 0.0, + 0.0, + 0.0 + ], + "cooldown": [ + 1.0, + 1.0, + 1.0 + ], + "damage": [ + 6.0, + 6.0, + 6.0 + ], + "range": [ + 1.0, + 1.0, + 1.0 + ] }, { "name": "warhammer", - "damage_type": "impact", "weight": "40", "cooldown": "1", - "damage": "60", "range": "1", "knockback": "1" + "damage_type": "impact", + "weight": [ + 40.0, + 40.0, + 40.0 + ], + "cooldown": [ + 1.0, + 1.0, + 1.0 + ], + "damage": [ + 60.0, + 60.0, + 60.0 + ], + "range": [ + 1.0, + 1.0, + 1.0 + ], + "knockback": [ + 1.0, + 1.0, + 1.0 + ] }, { "name": "rocket", - "damage_type": "explosive", "weight": "60", "cooldown": "3", - "damage": "100", "range": "8" + "damage_type": "explosive", + "weight": [ + 60.0, + 60.0, + 60.0 + ], + "cooldown": [ + 3.0, + 3.0, + 3.0 + ], + "damage": [ + 100.0, + 100.0, + 100.0 + ], + "range": [ + 8.0, + 8.0, + 8.0 + ] }, { "name": "rocket swarm", - "damage_type": "explosive", "weight": "120", "cooldown": "3", - "damage": "60", "range": "7", "aoe": "2" + "damage_type": "explosive", + "weight": [ + 120.0, + 120.0, + 120.0 + ], + "cooldown": [ + 3.0, + 3.0, + 3.0 + ], + "damage": [ + 60.0, + 60.0, + 60.0 + ], + "range": [ + 7.0, + 7.0, + 7.0 + ], + "aoe": [ + 2.0, + 2.0, + 2.0 + ] }, { "name": "tactical rocket", - "damage_type": "explosive", "weight": "160", "cooldown": "1", - "damage": "100", "range": "8", "aoe": "1" + "damage_type": "explosive", + "weight": [ + 160.0, + 160.0, + 160.0 + ], + "cooldown": [ + 1.0, + 1.0, + 1.0 + ], + "damage": [ + 100.0, + 100.0, + 100.0 + ], + "range": [ + 8.0, + 8.0, + 8.0 + ], + "aoe": [ + 1.0, + 1.0, + 1.0 + ] }, { "name": "nuclear rocket", - "damage_type": "explosive", "weight": "200", "cooldown": "6", - "damage": "300", "range": "9", "aoe": "3" + "damage_type": "explosive", + "weight": [ + 200.0, + 200.0, + 200.0 + ], + "cooldown": [ + 6.0, + 6.0, + 6.0 + ], + "damage": [ + 300.0, + 300.0, + 300.0 + ], + "range": [ + 9.0, + 9.0, + 9.0 + ], + "aoe": [ + 3.0, + 3.0, + 3.0 + ] }, { "name": "light laser", - "damage_type": "laser", "weight": "20", "cooldown": "1", - "damage": "8", "range": "5" + "damage_type": "laser", + "weight": [ + 20.0, + 20.0, + 20.0 + ], + "cooldown": [ + 1.0, + 1.0, + 1.0 + ], + "damage": [ + 8.0, + 8.0, + 8.0 + ], + "range": [ + 5.0, + 5.0, + 5.0 + ] }, { "name": "combined light laser", - "damage_type": "laser", "weight": "50", "cooldown": "1", - "damage": "20", "range": "6" + "damage_type": "laser", + "weight": [ + 50.0, + 50.0, + 50.0 + ], + "cooldown": [ + 1.0, + 1.0, + 1.0 + ], + "damage": [ + 20.0, + 20.0, + 20.0 + ], + "range": [ + 6.0, + 6.0, + 6.0 + ] }, { "name": "heavy laser", - "damage_type": "laser", "weight": "130", "cooldown": "1", - "damage": "45", "range": "6" + "damage_type": "laser", + "weight": [ + 130.0, + 130.0, + 130.0 + ], + "cooldown": [ + 1.0, + 1.0, + 1.0 + ], + "damage": [ + 45.0, + 45.0, + 45.0 + ], + "range": [ + 6.0, + 6.0, + 6.0 + ] }, { "name": "combined heavy laser", - "damage_type": "laser", "weight": "300", "cooldown": "1", - "damage": "150", "range": "7" + "damage_type": "laser", + "weight": [ + 300.0, + 300.0, + 300.0 + ], + "cooldown": [ + 1.0, + 1.0, + 1.0 + ], + "damage": [ + 150.0, + 150.0, + 150.0 + ], + "range": [ + 7.0, + 7.0, + 7.0 + ] }, { "name": "plasma cannon", - "damage_type": "fusion", "weight": "80", "cooldown": "2", - "damage": "125", "range": "5" + "damage_type": "fusion", + "weight": [ + 80.0, + 80.0, + 80.0 + ], + "cooldown": [ + 2.0, + 2.0, + 2.0 + ], + "damage": [ + 125.0, + 125.0, + 125.0 + ], + "range": [ + 5.0, + 5.0, + 5.0 + ] }, { "name": "plasma autocannon", - "damage_type": "fusion", "weight": "170", "cooldown": "1", - "damage": "110", "range": "5" + "damage_type": "fusion", + "weight": [ + 170.0, + 170.0, + 170.0 + ], + "cooldown": [ + 1.0, + 1.0, + 1.0 + ], + "damage": [ + 110.0, + 110.0, + 110.0 + ], + "range": [ + 5.0, + 5.0, + 5.0 + ] }, { "name": "plasma artillery", - "damage_type": "fusion", "weight": "200", "cooldown": "3", - "damage": "100", "range": "7", "aoe": "2" + "damage_type": "fusion", + "weight": [ + 200.0, + 200.0, + 200.0 + ], + "cooldown": [ + 3.0, + 3.0, + 3.0 + ], + "damage": [ + 100.0, + 100.0, + 100.0 + ], + "range": [ + 7.0, + 7.0, + 7.0 + ], + "aoe": [ + 2.0, + 2.0, + 2.0 + ] }, { "name": "fusion blade", - "damage_type": "fusion", "weight": "15", "cooldown": "1", - "damage": "15", "range": "1" + "damage_type": "fusion", + "weight": [ + 15.0, + 15.0, + 15.0 + ], + "cooldown": [ + 1.0, + 1.0, + 1.0 + ], + "damage": [ + 15.0, + 15.0, + 15.0 + ], + "range": [ + 1.0, + 1.0, + 1.0 + ] }, { "name": "fusion lance", - "damage_type": "fusion", "weight": "50", "cooldown": "1", - "damage": "45", "range": "2" + "damage_type": "fusion", + "weight": [ + 50.0, + 50.0, + 50.0 + ], + "cooldown": [ + 1.0, + 1.0, + 1.0 + ], + "damage": [ + 45.0, + 45.0, + 45.0 + ], + "range": [ + 2.0, + 2.0, + 2.0 + ] }, { "name": "light railgun", - "damage_type": "impact", "weight": "50", "cooldown": "2", - "damage": "90", "range": "6" + "damage_type": "impact", + "weight": [ + 50.0, + 50.0, + 50.0 + ], + "cooldown": [ + 2.0, + 2.0, + 2.0 + ], + "damage": [ + 90.0, + 90.0, + 90.0 + ], + "range": [ + 6.0, + 6.0, + 6.0 + ] }, { "name": "heavy railgun", - "damage_type": "impact", "weight": "190", "cooldown": "3", - "damage": "450", "range": "7" + "damage_type": "impact", + "weight": [ + 190.0, + 190.0, + 190.0 + ], + "cooldown": [ + 3.0, + 3.0, + 3.0 + ], + "damage": [ + 450.0, + 450.0, + 450.0 + ], + "range": [ + 7.0, + 7.0, + 7.0 + ] }, { "name": "supercharged railgun", - "damage_type": "impact", "weight": "240", "cooldown": "4", - "damage": "1000", "range": "8" + "damage_type": "impact", + "weight": [ + 240.0, + 240.0, + 240.0 + ], + "cooldown": [ + 4.0, + 4.0, + 4.0 + ], + "damage": [ + 1000.0, + 1000.0, + 1000.0 + ], + "range": [ + 8.0, + 8.0, + 8.0 + ] }, { "name": "discharge beam", - "damage_type": "emp", "weight": "40", "cooldown": "2", - "damage_battery": "3", "range": "4" + "damage_type": "emp", + "weight": [ + 40.0, + 40.0, + 40.0 + ], + "cooldown": [ + 2.0, + 2.0, + 2.0 + ], + "damage_battery": [ + 3.0, + 3.0, + 3.0 + ], + "range": [ + 4.0, + 4.0, + 4.0 + ] }, { "name": "haywire beam", - "damage_type": "emp", "weight": "50", "cooldown": "5", - "damage": "80", "damage_battery": "5", "range": "6" + "damage_type": "emp", + "weight": [ + 50.0, + 50.0, + 50.0 + ], + "cooldown": [ + 5.0, + 5.0, + 5.0 + ], + "damage": [ + 80.0, + 80.0, + 80.0 + ], + "damage_battery": [ + 5.0, + 5.0, + 5.0 + ], + "range": [ + 6.0, + 6.0, + 6.0 + ] }, { "name": "stun beam", - "damage_type": "emp", "weight": "80", "cooldown": "5", - "stun": "1", "range": "4" + "damage_type": "emp", + "weight": [ + 80.0, + 80.0, + 80.0 + ], + "cooldown": [ + 5.0, + 5.0, + 5.0 + ], + "stun": [ + 1.0, + 1.0, + 1.0 + ], + "range": [ + 4.0, + 4.0, + 4.0 + ] }, { "name": "amplified discharge impulse", - "damage_type": "emp", "weight": "150", "cooldown": "3", - "damage_battery": "10", "range": "5", "aoe": "1" + "damage_type": "emp", + "weight": [ + 150.0, + 150.0, + 150.0 + ], + "cooldown": [ + 3.0, + 3.0, + 3.0 + ], + "damage_battery": [ + 10.0, + 10.0, + 10.0 + ], + "range": [ + 5.0, + 5.0, + 5.0 + ], + "aoe": [ + 1.0, + 1.0, + 1.0 + ] }, { "name": "amplified haywire beam", - "damage_type": "emp", "weight": "120", "cooldown": "5", - "damage": "200", "damage_battery": "12", "range": "6" + "damage_type": "emp", + "weight": [ + 120.0, + 120.0, + 120.0 + ], + "cooldown": [ + 5.0, + 5.0, + 5.0 + ], + "damage": [ + 200.0, + 200.0, + 200.0 + ], + "damage_battery": [ + 12.0, + 12.0, + 12.0 + ], + "range": [ + 6.0, + 6.0, + 6.0 + ] }, { "name": "amplified stun beam", - "damage_type": "emp", "weight": "200", "cooldown": "6", - "stun": "1", "range": "4" + "damage_type": "emp", + "weight": [ + 200.0, + 200.0, + 200.0 + ], + "cooldown": [ + 6.0, + 6.0, + 6.0 + ], + "stun": [ + 1.0, + 1.0, + 1.0 + ], + "range": [ + 4.0, + 4.0, + 4.0 + ] }, { "name": "ion cannon", - "damage_type": "emp", "weight": "75", "cooldown": "2", - "reduce_fusion": "1", "reduce_laser": "1", "range": "5" + "damage_type": "emp", + "weight": [ + 75.0, + 75.0, + 75.0 + ], + "cooldown": [ + 2.0, + 2.0, + 2.0 + ], + "reduce_fusion": [ + 1.0, + 1.0, + 1.0 + ], + "reduce_laser": [ + 1.0, + 1.0, + 1.0 + ], + "range": [ + 5.0, + 5.0, + 5.0 + ] }, { "name": "heavy ion cannon", - "damage_type": "emp", "weight": "150", "cooldown": "1", - "reduce_fusion": "1", "reduce_laser": "1", "range": "6" + "damage_type": "emp", + "weight": [ + 150.0, + 150.0, + 150.0 + ], + "cooldown": [ + 1.0, + 1.0, + 1.0 + ], + "reduce_fusion": [ + 1.0, + 1.0, + 1.0 + ], + "reduce_laser": [ + 1.0, + 1.0, + 1.0 + ], + "range": [ + 6.0, + 6.0, + 6.0 + ] }, { "name": "explosive charges", - "damage_type": "explosive", "weight": "5", "cooldown": "10", - "damage": "100", "range": "0", "aoe": "2" + "damage_type": "explosive", + "weight": [ + 5.0, + 5.0, + 5.0 + ], + "cooldown": [ + 10.0, + 10.0, + 10.0 + ], + "damage": [ + 100.0, + 100.0, + 100.0 + ], + "range": [ + 0.0, + 0.0, + 0.0 + ], + "aoe": [ + 2.0, + 2.0, + 2.0 + ] }, { "name": "javelin", - "damage_type": "explosive", "weight": "60", "cooldown": "2", - "damage": "40", "range": "7" + "damage_type": "explosive", + "weight": [ + 60.0, + 60.0, + 60.0 + ], + "cooldown": [ + 2.0, + 2.0, + 2.0 + ], + "damage": [ + 40.0, + 40.0, + 40.0 + ], + "range": [ + 7.0, + 7.0, + 7.0 + ] } ]
\ No newline at end of file diff --git a/build/test.exe b/build/test.exe Binary files differindex ebb5f5e..835c6e6 100644 --- a/build/test.exe +++ b/build/test.exe diff --git a/design/notes.txt b/design/notes.txt index bace25c..ef2bb25 100644 --- a/design/notes.txt +++ b/design/notes.txt @@ -1,47 +1,49 @@ -tasks: (commit number) - -[x] implement rm unit (issued on 6, done on 6) -[x] implement armor calculation (issued on 6, done on 6) -[x] implement augment calculations (issued on 6, done on 6) -[x] implement augment hud view (issued on 6, done on 6) -[ ] implement sound (issued on 6) -[ ] implement stats hud view (issued on 6) -[ ] implement battery calculation (issued on 6) -[ ] implement brain behaviour (issued on 6) -[ ] implement component levels (issued on 6) -[ ] implement persistent settings (issued on 6) -[ ] implement net hud and minilobby (issued on 6) -[ ] implement army hud view (issued on 6) -[ ] implement cost function (issued on 6) -[ ] implement lobby cost constraints (issued on 6) -[ ] implement edit unit directly (issued on 6) -[ ] implement naming template and army (issued on 6) -[ ] implement move animation (issued on 6) -[ ] implement fire animation (issued on 6) -[ ] implement explosions (issued on 6) -[ ] design 3d units (issued on 6) -[ ] design 3d map tiles (issued on 6) -[ ] implement 3d units (issued on 6) -[ ] design component sprites (issued on 6) +tasks: (date) + +[x] implement rm unit (issued on 18:02:21, done on 18:02:21) +[x] implement armor calculation (issued on 18:02:21, done on 18:02:21) +[x] implement augment calculations (issued on 18:02:21, done on 18:02:21) +[x] implement augment hud view (issued on 18:02:21, done on 18:02:21) +[ ] implement sound (issued on 18:02:21) +[ ] implement end of battle condition (issued on 19:02:21) +[ ] implement stats hud view (issued on 18:02:21) +[x] implement battery calculation (issued on 18:02:21, done on 19:02:21) +[ ] implement brain behaviour (issued on 18:02:21) +[ ] implement component levels (issued on 18:02:21) +[ ] implement persistent settings (issued on 18:02:21) +[ ] implement net hud and minilobby (issued on 18:02:21) +[ ] implement army hud view (issued on 18:02:21) +[ ] implement cost function (issued on 18:02:21) +[ ] implement lobby cost constraints (issued on 18:02:21) +[ ] implement edit unit directly (issued on 18:02:21) +[ ] implement naming template and army (issued on 18:02:21) +[ ] implement move animation (issued on 18:02:21) +[ ] implement fire animation (issued on 18:02:21) +[ ] implement explosions (issued on 18:02:21) +[ ] design 3d units (issued on 18:02:21) +[ ] design 3d map tiles (issued on 18:02:21) +[ ] implement 3d units (issued on 18:02:21) +[ ] design component sprites (issued on 18:02:21) bugs: -[ ] symmetric integration (found on 6) +[ ] symmetric integration (found on 18:02:21) (on army movement and fire, equal armies should fair equally) testing: -[ ] armor calculations (issued on 6) +[ ] write test suit (issued on 19:02:21) +[ ] armor calculations (issued on 18:02:21) balance: -[ ] balance components (issued on 6) +[ ] balance components (issued on 18:02:21) -view from 6 to the end: +view from 18:02:21 to the end: game is make templates, assemble for army, fight other army multiplayer up to 2 ppl armies, templates and settings are persistent @@ -50,6 +52,22 @@ view from 6 to the end: details: +implement components level: + could do it globally, every level is +5%atk and +10% cost + could set each weapon stat as a vector, v[level] is the stat + what is max level? 5? + work + global: just implement the function + local: that's #components * #attributes * #levels, n^3 operations + both: local weights, worst of both worlds + global is a quick solution, but i'm not here to do things quickly, i want to do them good. + so local is better, but requires to + . revolutionize every json parser + . write a lot of numbers + . design with a lot more variables in play + before writing 10000 numbers i should design, or autogenerate them + settled on 3 lvls, autogenerated with python + implement rm unit: -> done, paper note solution implement armor calculation: @@ -76,4 +94,12 @@ implement stats hud view: ! put them in stats later implement sound: - partially done, need sound design
\ No newline at end of file + partially done, need sound design + +implement battery calculations: + every component but the battery has an upkeep + upkeep gets paid at the end of the turn + if no charge: no shooting or moving + weapons that drain energy do so (wow, also what?) + yellow small text! yay! +-> done, tested briefely, testing is delayed until i write test suite @@ -78,5 +78,6 @@ void gst_process (gamestate *gst, infos *info, float t) { gst_get_maparmy(gst, &m, &ar); army_move(info, ar, m); army_fire(info, ar, m); + army_upkeep(info, ar, m); } }
\ No newline at end of file @@ -42,72 +42,125 @@ void info_unit_init (info_unit *u) { for(int i=0; i<34; u->levels[i] = 0, i++); } +float info_unit_get_capacity(infos *info, info_unit *u) { + float sum = 0; + int lc = u->levels[LEVEL_CHASSIS]; + 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_capacity[lvl]; + } + } + int lvl = u->levels[LEVEL_BATTERY]; + sum += info->batteries[u->battery].capacity[lvl]; + return sum; +} + +float info_unit_get_upkeep(infos *info, info_unit *u) { + float sum = 0; + int lc = u->levels[LEVEL_CHASSIS]; + int lbr = u->levels[LEVEL_BRAIN]; + for(int i=0; i<8; i++) { + if (u->weapons[i] != -1 && info->chassis[u->chassis].slot_weapon[lc]) { + int lvl = u->levels[LEVEL_WEAPONS+i]; + sum += info->weapons[u->weapons[i]].upkeep[lvl]; + } + if (u->armor[i] != -1 && info->chassis[u->chassis].slot_armor[lc]) { + int lvl = u->levels[LEVEL_ARMOR+i]; + sum += info->armors[u->armor[i]].upkeep[lvl]; + } + } + 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]].upkeep[lvl]; + } + } + sum += info->chassis[u->chassis].upkeep[lc]; + sum += info->brains[u->brain].upkeep[lbr]; + return sum; +} + float info_unit_get_weight (infos *info, info_unit *u) { float sum = 0; + int lc = u->levels[LEVEL_CHASSIS]; if (u->battery != -1) { - sum += info->batteries[u->battery].weight; + int lb = u->levels[LEVEL_BATTERY]; + sum += info->batteries[u->battery].weight[lb]; } for(int i=0; i<8; i++) { - if (u->weapons[i] != -1 && i<info->chassis[u->chassis].slot_weapon) { - sum += info->weapons[u->weapons[i]].weight; + if (u->weapons[i] != -1 && i<info->chassis[u->chassis].slot_weapon[lc]) { + int lvl = u->levels[LEVEL_WEAPONS+i]; + sum += info->weapons[u->weapons[i]].weight[lvl]; } - if (u->armor[i] != -1 && i<info->chassis[u->chassis].slot_armor) { - sum += info->armors[u->armor[i]].weight; + if (u->armor[i] != -1 && i<info->chassis[u->chassis].slot_armor[lc]) { + int lvl = u->levels[LEVEL_ARMOR+i]; + sum += info->armors[u->armor[i]].weight[lvl]; } } for(int i=0; i<16; i++) { if (u->augs[i] != -1 && info->chassis[u->chassis].slot_aug) { - sum += info->augs[u->augs[i]].weight; + int lvl = u->levels[LEVEL_AUGS+i]; + sum += info->augs[u->augs[i]].weight[lvl]; } } return sum; } float info_unit_get_dps (infos *info, info_unit *u) { + int lc = u->levels[LEVEL_CHASSIS]; float sum = 0; for(int i=0; i<8; i++) { - if (u->weapons[i] != -1 && i<info->chassis[u->chassis].slot_weapon) { + if (u->weapons[i] != -1 && i<info->chassis[u->chassis].slot_weapon[lc]) { info_weapon *w = info->weapons+u->weapons[i]; + int lw = u->levels[LEVEL_WEAPONS+i]; float damage = info_unit_get_damage(info, u, i); - sum += damage/w->cooldown; + sum += damage/w->cooldown[lw]; } } return sum; } float info_unit_get_health(infos *info, info_unit *u) { + 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) { - sum += info->augs[u->augs[i]].add_hp; + 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_hp[lvl]; } } - sum += info->chassis[u->chassis].hp; + sum += info->chassis[u->chassis].hp[lc]; return sum; } float info_unit_get_speed(infos *info, info_unit *u) { + 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) { - sum += info->augs[u->augs[i]].add_speed; + 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_speed[lvl]; } } - sum += info->chassis[u->chassis].speed; + sum += info->chassis[u->chassis].speed[lc]; return sum; } float info_unit_get_damage (infos *info, info_unit *u, int w) { + int lc = u->levels[LEVEL_CHASSIS]; int damage_type = info->weapons[u->weapons[w]].damage_type; float sum = 0; for(int i=0; i<16; i++) { - if (u->augs[i] != -1 && info->chassis[u->chassis].slot_aug) { - sum += info->augs[u->augs[i]].add_damage[damage_type]; + 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_damage[damage_type][lvl]; } } float mult = (1 + sum/100.0f); if (mult < 0) mult = 0; - float dam = info->weapons[u->weapons[w]].damage * mult; + int lw = u->levels[LEVEL_WEAPONS+w]; + float dam = info->weapons[u->weapons[w]].damage[lw] * mult; return dam; } @@ -123,37 +176,53 @@ float info_unit_get_damage_target (infos *info, info_unit *u, int w, } float info_unit_get_cooldown(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) { - sum += info->augs[u->augs[i]].add_cooldown; + 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_cooldown[lvl]; } } - sum += info->weapons[u->weapons[w]].cooldown; + int lw = u->levels[LEVEL_WEAPONS+w]; + sum += info->weapons[u->weapons[w]].cooldown[lw]; return sum; } float info_unit_get_range(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) { - sum += info->augs[u->augs[i]].add_range; + 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_range[lvl]; } } - sum += info->weapons[u->weapons[w]].range; + int lw = u->levels[LEVEL_WEAPONS+w]; + sum += info->weapons[u->weapons[w]].range[lw]; + 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]; + sum += info->weapons[u->weapons[w]].charge_per_shot[lw]; return sum; } float info_unit_get_armor(infos *info, info_unit *u, int d) { + int lc = u->levels[LEVEL_CHASSIS]; float sum = 0; for(int i=0; i<8; i++) { - if (u->armor[i] != -1 && i<info->chassis[u->chassis].slot_armor) { - sum += info->armors[u->armor[i]].armor[d]; + if (u->armor[i] != -1 && i<info->chassis[u->chassis].slot_armor[lc]) { + int lvl = u->levels[LEVEL_ARMOR+i]; + sum += info->armors[u->armor[i]].armor[d][lvl]; } } for(int i=0; i<16; i++) { - if (u->augs[i] != -1 && info->chassis[u->chassis].slot_aug) { - sum += info->augs[u->augs[i]].add_armor[d]; + 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_armor[d][lvl]; } } return sum; @@ -162,47 +231,77 @@ float info_unit_get_armor(infos *info, info_unit *u, int d) { void weapon_init (info_weapon *w) { strcpy(w->name, "nameless"); - w->damage_type = 0; - w->weight = 0; w->cooldown = 1; - w->damage = 0; w->range = 0; w->aoe = 0; - w->knockback = 0; w->stun = 0; - for (int i=0; i<7; i++) { w->reduce_armor[i]=0; } + for (int l=0; l<MAXLEVEL; l++) { + w->damage_type = 0; + w->weight[l] = 0; + w->cooldown[l] = 1; + w->damage[l] = 0; + w->range[l] = 0; + w->aoe[l] = 0; + w->knockback[l] = 0; + w->stun[l] = 0; + for (int i=0; i<7; i++) { w->reduce_armor[i][l]=0; } + w->upkeep[l] = 0; + w->charge_per_shot[l] = 0; + } } void chassis_init (info_chassis *c) { strcpy(c->name, "nameless"); - c->slot_weapon = 0; c->slot_armor = 0; c->slot_aug = 0; - c->weight_max = 0; c->hp = 0; + for (int l=0; l<MAXLEVEL; l++) { + c->slot_weapon[l] = 0; + c->slot_armor[l] = 0; + c->slot_aug[l] = 0; + c->weight_max[l] = 0; + c->hp[l] = 0; + c->upkeep[l] = 0; + } } void battery_init (info_battery *b) { strcpy(b->name, "nameless"); - b->weight = 0; b->capacity = 0; b->recharge = 0; + for (int l=0; l<MAXLEVEL; l++) { + b->weight[l] = 0; + b->capacity[l] = 0; + b->recharge[l] = 0; + } } void armor_init (info_armor *a) { strcpy(a->name, "nameless"); - a->weight = 0; - for (int i=0; i<7; i++) { a->armor[i]=0; } + for (int l=0; l<MAXLEVEL; l++) { + a->weight[l] = 0; + for (int i=0; i<7; i++) { a->armor[i][l]=0; } + a->upkeep[l] = 0; + } } void aug_init (info_aug *a) { strcpy(a->name, "nameless"); - a->weight = 0; - for (int i=0; i<7; i++) { a->add_damage[i]=0; } - for (int i=0; i<7; i++) { a->add_armor[i]=0; } - a->add_range = 0; - a->add_cooldown = 0; - a->add_speed = 0; - a->add_hp = 0; + for (int l=0; l<MAXLEVEL; l++) { + a->weight[l] = 0; + for (int i=0; i<7; i++) { a->add_damage[i][l]=0; } + for (int i=0; i<7; i++) { a->add_armor[i][l]=0; } + a->add_range[l] = 0; + a->add_cooldown [l]= 0; + a->add_speed[l] = 0; + a->add_hp[l] = 0; + a->add_capacity[l] = 0; + a->upkeep[l] = 0; + } } void brain_init (info_brain *a) { strcpy(a->name, "nameless"); + for (int l=0; l<MAXLEVEL; l++) { + a->upkeep[l] = 0; + } } -void info_unit_parse (char *json, info_unit *u, jsmntok_t *t, int r) { +void info_unit_parse (char *json, info_unit *u, jsmntok_t *t, int r, + infos *info) +{ info_unit_init(u); int obj_i = 0, dict_i = -1; for (int i=0; i<r; i+=2) { @@ -243,7 +342,9 @@ void info_unit_parse (char *json, info_unit *u, jsmntok_t *t, int r) { } } -void info_weapon_parse (char *json, info_weapon *w, jsmntok_t *t, int r) { +void info_weapon_parse (char *json, info_weapon *w, jsmntok_t *t, int r, + infos *info) +{ weapon_init(w); int obj_i = 0, dict_i = -1; for (int i=0; i<r; i+=2) { @@ -257,70 +358,57 @@ void info_weapon_parse (char *json, info_weapon *w, jsmntok_t *t, int r) { w->damage_type = damage_type_map(val); } if (strcmp(key, "weight") == 0) { - char val[32]; substr_token(json, val, t+i+1); - w->weight = atof(val); + int rt = json_parse_subtokens(json, t, r, i+1); + json_parse_array(json, w->weight, t+i+2, rt-1, 'f'); } if (strcmp(key, "cooldown") == 0) { - char val[32]; substr_token(json, val, t+i+1); - w->cooldown = atof(val); + int rt = json_parse_subtokens(json, t, r, i+1); + json_parse_array(json, w->cooldown, t+i+2, rt-1, 'f'); } if (strcmp(key, "damage") == 0) { - char val[32]; substr_token(json, val, t+i+1); - w->damage = atof(val); + int rt = json_parse_subtokens(json, t, r, i+1); + json_parse_array(json, w->damage, t+i+2, rt-1, 'f'); } if (strcmp(key, "range") == 0) { - char val[32]; substr_token(json, val, t+i+1); - w->range = atof(val); + int rt = json_parse_subtokens(json, t, r, i+1); + json_parse_array(json, w->range, t+i+2, rt-1, 'f'); } if (strcmp(key, "aoe") == 0) { - char val[32]; substr_token(json, val, t+i+1); - w->aoe = atof(val); + int rt = json_parse_subtokens(json, t, r, i+1); + json_parse_array(json, w->aoe, t+i+2, rt-1, 'f'); } if (strcmp(key, "knockback") == 0) { - char val[32]; substr_token(json, val, t+i+1); - w->knockback = atoi(val); + int rt = json_parse_subtokens(json, t, r, i+1); + json_parse_array(json, w->knockback, t+i+2, rt-1, 'i'); } if (strcmp(key, "damage_battery") == 0) { - char val[32]; substr_token(json, val, t+i+1); - w->damage_battery = atof(val); + int rt = json_parse_subtokens(json, t, r, i+1); + json_parse_array(json, w->damage_battery, t+i+2, rt-1, 'f'); } if (strcmp(key, "stun") == 0) { - char val[32]; substr_token(json, val, t+i+1); - w->stun = atoi(val); - } - if (strcmp(key, "reduce_pierce") == 0) { - char val[32]; substr_token(json, val, t+i+1); - w->reduce_armor[0] = atof(val); - } - if (strcmp(key, "reduce_laser") == 0) { - char val[32]; substr_token(json, val, t+i+1); - w->reduce_armor[1] = atof(val); - } - if (strcmp(key, "reduce_impact") == 0) { - char val[32]; substr_token(json, val, t+i+1); - w->reduce_armor[2] = atof(val); - } - if (strcmp(key, "reduce_fusion") == 0) { - char val[32]; substr_token(json, val, t+i+1); - w->reduce_armor[3] = atof(val); - } - if (strcmp(key, "reduce_explosive") == 0) { - char val[32]; substr_token(json, val, t+i+1); - w->reduce_armor[4] = atof(val); - } - if (strcmp(key, "reduce_emp") == 0) { - char val[32]; substr_token(json, val, t+i+1); - w->reduce_armor[5] = atof(val); - } - if (strcmp(key, "reduce_spread") == 0) { - char val[32]; substr_token(json, val, t+i+1); - w->reduce_armor[6] = atof(val); + int rt = json_parse_subtokens(json, t, r, i+1); + json_parse_array(json, w->stun, t+i+2, rt-1, 'i'); + } + for (int h=0; h<7; h++) { + char strkey[32]; sprintf(strkey, "reduce_%s", + info->damage_types[h]); + if (strcmp(key, strkey) == 0) { + int rt = json_parse_subtokens(json, t, r, i+1); + json_parse_array(json, w->reduce_armor[h], t+i+2, rt-1, 'f'); + break; + } + } + if (strcmp(key, "upkeep") == 0) { + int rt = json_parse_subtokens(json, t, r, i+1); + json_parse_array(json, w->upkeep, t+i+2, rt-1, 'f'); } } } } -void info_chassis_parse (char *json, info_chassis *c, jsmntok_t *t, int r) { +void info_chassis_parse (char *json, info_chassis *c, jsmntok_t *t, int r, + infos *info) +{ chassis_init(c); int obj_i = 0, dict_i = -1; for (int i=0; i<r; i+=2) { @@ -330,34 +418,40 @@ void info_chassis_parse (char *json, info_chassis *c, jsmntok_t *t, int r) { substr_token(json, c->name, t+i+1); } if (strcmp(key, "slot_weapon") == 0) { - char val[32]; substr_token(json, val, t+i+1); - c->slot_weapon = atoi(val); + int rt = json_parse_subtokens(json, t, r, i+1); + json_parse_array(json, c->slot_weapon, t+i+2, rt-1, 'i'); } if (strcmp(key, "slot_armor") == 0) { - char val[32]; substr_token(json, val, t+i+1); - c->slot_armor = atoi(val); + int rt = json_parse_subtokens(json, t, r, i+1); + json_parse_array(json, c->slot_armor, t+i+2, rt-1, 'i'); } if (strcmp(key, "slot_aug") == 0) { - char val[32]; substr_token(json, val, t+i+1); - c->slot_aug = atoi(val); + int rt = json_parse_subtokens(json, t, r, i+1); + json_parse_array(json, c->slot_aug, t+i+2, rt-1, 'i'); } if (strcmp(key, "weight_max") == 0) { - char val[32]; substr_token(json, val, t+i+1); - c->weight_max = atof(val); + int rt = json_parse_subtokens(json, t, r, i+1); + json_parse_array(json, c->weight_max, t+i+2, rt-1, 'f'); } if (strcmp(key, "hp") == 0) { - char val[32]; substr_token(json, val, t+i+1); - c->hp = atof(val); + int rt = json_parse_subtokens(json, t, r, i+1); + json_parse_array(json, c->hp, t+i+2, rt-1, 'f'); } if (strcmp(key, "speed") == 0) { - char val[32]; substr_token(json, val, t+i+1); - c->speed = atof(val); + int rt = json_parse_subtokens(json, t, r, i+1); + json_parse_array(json, c->speed, t+i+2, rt-1, 'f'); + } + if (strcmp(key, "upkeep") == 0) { + int rt = json_parse_subtokens(json, t, r, i+1); + json_parse_array(json, c->upkeep, t+i+2, rt-1, 'f'); } } } } -void info_battery_parse (char *json, info_battery *b, jsmntok_t *t, int r) { +void info_battery_parse (char *json, info_battery *b, jsmntok_t *t, int r, + infos *info) +{ battery_init(b); int obj_i = 0, dict_i = -1; for (int i=0; i<r; i+=2) { @@ -367,22 +461,24 @@ void info_battery_parse (char *json, info_battery *b, jsmntok_t *t, int r) { substr_token(json, b->name, t+i+1); } if (strcmp(key, "weight") == 0) { - char val[32]; substr_token(json, val, t+i+1); - b->weight = atof(val); + int rt = json_parse_subtokens(json, t, r, i+1); + json_parse_array(json, b->weight, t+i+2, rt-1, 'f'); } if (strcmp(key, "capacity") == 0) { - char val[32]; substr_token(json, val, t+i+1); - b->capacity = atof(val); + int rt = json_parse_subtokens(json, t, r, i+1); + json_parse_array(json, b->capacity, t+i+2, rt-1, 'f'); } if (strcmp(key, "recharge") == 0) { - char val[32]; substr_token(json, val, t+i+1); - b->recharge = atoi(val); + int rt = json_parse_subtokens(json, t, r, i+1); + json_parse_array(json, b->recharge, t+i+2, rt-1, 'i'); } } } } -void info_armor_parse (char *json, info_armor *a, jsmntok_t *t, int r) { +void info_armor_parse (char *json, info_armor *a, jsmntok_t *t, int r, + infos *info) +{ armor_init(a); int obj_i = 0, dict_i = -1; for (int i=0; i<r; i+=2) { @@ -392,42 +488,26 @@ void info_armor_parse (char *json, info_armor *a, jsmntok_t *t, int r) { substr_token(json, a->name, t+i+1); } if (strcmp(key, "weight") == 0) { - char val[32]; substr_token(json, val, t+i+1); - a->weight = atof(val); - } - if (strcmp(key, "pierce") == 0) { - char val[32]; substr_token(json, val, t+i+1); - a->armor[0] = atof(val); - } - if (strcmp(key, "laser") == 0) { - char val[32]; substr_token(json, val, t+i+1); - a->armor[1] = atof(val); - } - if (strcmp(key, "impact") == 0) { - char val[32]; substr_token(json, val, t+i+1); - a->armor[2] = atof(val); - } - if (strcmp(key, "fusion") == 0) { - char val[32]; substr_token(json, val, t+i+1); - a->armor[3] = atof(val); - } - if (strcmp(key, "explosive") == 0) { - char val[32]; substr_token(json, val, t+i+1); - a->armor[4] = atof(val); + int rt = json_parse_subtokens(json, t, r, i+1); + json_parse_array(json, a->weight, t+i+2, rt-1, 'f'); } - if (strcmp(key, "emp") == 0) { - char val[32]; substr_token(json, val, t+i+1); - a->armor[5] = atof(val); + for (int h=0; h<7; h++) { + if (strcmp(key, info->damage_types[h]) == 0) { + int rt = json_parse_subtokens(json, t, r, i+1); + json_parse_array(json, a->armor[h], t+i+2, rt-1, 'f'); + } } - if (strcmp(key, "spread") == 0) { - char val[32]; substr_token(json, val, t+i+1); - a->armor[6] = atof(val); + if (strcmp(key, "upkeep") == 0) { + int rt = json_parse_subtokens(json, t, r, i+1); + json_parse_array(json, a->upkeep, t+i+2, rt-1, 'f'); } } } } -void info_aug_parse (char *json, info_aug *a, jsmntok_t *t, int r) { +void info_aug_parse (char *json, info_aug *a, jsmntok_t *t, int r, + infos *info) +{ aug_init(a); int obj_i = 0, dict_i = -1; for (int i=0; i<r; i+=2) { @@ -437,82 +517,54 @@ void info_aug_parse (char *json, info_aug *a, jsmntok_t *t, int r) { substr_token(json, a->name, t+i+1); } if (strcmp(key, "weight") == 0) { - char val[32]; substr_token(json, val, t+i+1); - a->weight = atof(val); - } - if (strcmp(key, "damage_pierce") == 0) { - char val[32]; substr_token(json, val, t+i+1); - a->add_damage[0] = atof(val); - } - if (strcmp(key, "damage_laser") == 0) { - char val[32]; substr_token(json, val, t+i+1); - a->add_damage[1] = atof(val); - } - if (strcmp(key, "damage_impact") == 0) { - char val[32]; substr_token(json, val, t+i+1); - a->add_damage[2] = atof(val); - } - if (strcmp(key, "damage_fusion") == 0) { - char val[32]; substr_token(json, val, t+i+1); - a->add_damage[3] = atof(val); - } - if (strcmp(key, "damage_explosive") == 0) { - char val[32]; substr_token(json, val, t+i+1); - a->add_damage[4] = atof(val); - } - if (strcmp(key, "damage_emp") == 0) { - char val[32]; substr_token(json, val, t+i+1); - a->add_damage[5] = atof(val); - } - if (strcmp(key, "add_spread") == 0) { - char val[32]; substr_token(json, val, t+i+1); - a->add_damage[6] = atof(val); - } - if (strcmp(key, "armor_pierce") == 0) { - char val[32]; substr_token(json, val, t+i+1); - a->add_armor[0] = atof(val); - } - if (strcmp(key, "armor_laser") == 0) { - char val[32]; substr_token(json, val, t+i+1); - a->add_armor[1] = atof(val); - } - if (strcmp(key, "armor_impact") == 0) { - char val[32]; substr_token(json, val, t+i+1); - a->add_armor[2] = atof(val); - } - if (strcmp(key, "armor_fusion") == 0) { - char val[32]; substr_token(json, val, t+i+1); - a->add_armor[3] = atof(val); - } - if (strcmp(key, "armor_explosive") == 0) { - char val[32]; substr_token(json, val, t+i+1); - a->add_armor[4] = atof(val); - } - if (strcmp(key, "armor_emp") == 0) { - char val[32]; substr_token(json, val, t+i+1); - a->add_armor[5] = atof(val); - } - if (strcmp(key, "armor_spread") == 0) { - char val[32]; substr_token(json, val, t+i+1); - a->add_armor[6] = atof(val); + int rt = json_parse_subtokens(json, t, r, i+1); + json_parse_array(json, a->weight, t+i+2, rt-1, 'f'); + } + for (int h=0; h<7; h++) { + char strkey[32]; sprintf(strkey, "damage_%s", + info->damage_types[h]); + if (strcmp(key, strkey) == 0) { + int rt = json_parse_subtokens(json, t, r, i+1); + json_parse_array(json, a->add_damage[h], t+i+2, rt-1, 'f'); + break; + } + } + for (int h=0; h<7; h++) { + char strkey[32]; sprintf(strkey, "armor_%s", + info->damage_types[h]); + if (strcmp(key, strkey) == 0) { + int rt = json_parse_subtokens(json, t, r, i+1); + json_parse_array(json, a->add_armor[h], t+i+2, rt-1, 'f'); + break; + } } if (strcmp(key, "add_range") == 0) { - char val[32]; substr_token(json, val, t+i+1); - a->add_range = atof(val); + int rt = json_parse_subtokens(json, t, r, i+1); + json_parse_array(json, a->add_range, t+i+2, rt-1, 'f'); } if (strcmp(key, "add_cooldown") == 0) { - char val[32]; substr_token(json, val, t+i+1); - a->add_cooldown = atof(val); + int rt = json_parse_subtokens(json, t, r, i+1); + json_parse_array(json, a->add_cooldown, t+i+2, rt-1, 'f'); } if (strcmp(key, "add_hp") == 0) { - char val[32]; substr_token(json, val, t+i+1); - a->add_hp = atof(val); + int rt = json_parse_subtokens(json, t, r, i+1); + json_parse_array(json, a->add_hp, t+i+2, rt-1, 'f'); + } + if (strcmp(key, "add_capacity") == 0) { + int rt = json_parse_subtokens(json, t, r, i+1); + json_parse_array(json, a->add_capacity, t+i+2, rt-1, 'f'); + } + if (strcmp(key, "upkeep") == 0) { + int rt = json_parse_subtokens(json, t, r, i+1); + json_parse_array(json, a->upkeep, t+i+2, rt-1, 'f'); } } } } -void info_brain_parse (char *json, info_brain *a, jsmntok_t *t, int r) { +void info_brain_parse (char *json, info_brain *a, jsmntok_t *t, int r, + infos *info) +{ brain_init(a); int obj_i = 0, dict_i = -1; for (int i=0; i<r; i+=2) { @@ -521,6 +573,10 @@ void info_brain_parse (char *json, info_brain *a, jsmntok_t *t, int r) { if (strcmp(key, "name") == 0) { substr_token(json, a->name, t+i+1); } + if (strcmp(key, "upkeep") == 0) { + int rt = json_parse_subtokens(json, t, r, i+1); + json_parse_array(json, a->upkeep, t+i+2, rt-1, 'f'); + } } } } @@ -534,31 +590,38 @@ void info_parse_json (infos *info, char *json, char *obj) { if (t[i].type == JSMN_OBJECT) { int rt = json_parse_subtokens(json, t, r, i); if (strcmp(obj, "template") == 0) { - info_unit_parse(json, info->templates+index, t+i+1, rt); + info_unit_parse(json, + info->templates+index, t+i+1, rt, info); info->templateslen = index+1; } if (strcmp(obj, "weapon") == 0) { - info_weapon_parse(json, info->weapons+index, t+i+1, rt); + info_weapon_parse(json, + info->weapons+index, t+i+1, rt, info); info->weaponslen = index+1; } if (strcmp(obj, "chassis") == 0) { - info_chassis_parse(json, info->chassis+index, t+i+1, rt); + info_chassis_parse(json, + info->chassis+index, t+i+1, rt, info); info->chassislen = index+1; } if (strcmp(obj, "battery") == 0) { - info_battery_parse(json, info->batteries+index, t+i+1, rt); + info_battery_parse(json, + info->batteries+index, t+i+1, rt, info); info->batterieslen = index+1; } if (strcmp(obj, "armor") == 0) { - info_armor_parse(json, info->armors+index, t+i+1, rt); + info_armor_parse(json, + info->armors+index, t+i+1, rt, info); info->armorslen = index+1; } if (strcmp(obj, "aug") == 0) { - info_aug_parse(json, info->augs+index, t+i+1, rt); + info_aug_parse(json, + info->augs+index, t+i+1, rt, info); info->augslen = index+1; } if (strcmp(obj, "brain") == 0) { - info_brain_parse(json, info->brains+index, t+i+1, rt); + info_brain_parse(json, + info->brains+index, t+i+1, rt, info); info->brainslen = index+1; } index ++; @@ -2,71 +2,86 @@ #define INFO_H #define MAXTEMPLATES 128 +#define MAXLEVEL 3 #include <stdint.h> +#define LEVEL_CHASSIS 0 +#define LEVEL_BRAIN 1 +#define LEVEL_BATTERY 2 +#define LEVEL_WEAPONS 3 +#define LEVEL_ARMOR 11 +#define LEVEL_AUGS 19 + typedef struct { char name[32]; // indexes of info.* int8_t chassis; int8_t brain; + int8_t battery; int8_t weapons[8]; int8_t armor[8]; int8_t augs[16]; - int8_t battery; - int8_t levels[34]; + int8_t levels[35]; } info_unit; typedef struct { char name[32]; int damage_type; - float weight; - float cooldown; - float damage; - float range; - float aoe; - int knockback; - float damage_battery; - int stun; - float reduce_armor[7]; + float weight[MAXLEVEL]; + float cooldown[MAXLEVEL]; + float damage[MAXLEVEL]; + float range[MAXLEVEL]; + float aoe[MAXLEVEL]; + int knockback[MAXLEVEL]; + float damage_battery[MAXLEVEL]; + int stun[MAXLEVEL]; + float reduce_armor[7][MAXLEVEL]; + float upkeep[MAXLEVEL]; + float charge_per_shot[MAXLEVEL]; } info_weapon; typedef struct { char name[32]; - int slot_weapon; - int slot_armor; - int slot_aug; - float weight_max; - float hp; - float speed; + int slot_weapon[MAXLEVEL]; + int slot_armor[MAXLEVEL]; + int slot_aug[MAXLEVEL]; + float weight_max[MAXLEVEL]; + float hp[MAXLEVEL]; + float speed[MAXLEVEL]; + float upkeep[MAXLEVEL]; } info_chassis; typedef struct { char name[32]; - float weight; - float capacity; - int recharge; + float weight[MAXLEVEL]; + float capacity[MAXLEVEL]; + int recharge[MAXLEVEL]; } info_battery; typedef struct { char name[32]; - float weight; - float armor[7]; + float weight[MAXLEVEL]; + float armor[7][MAXLEVEL]; + float upkeep[MAXLEVEL]; } info_armor; typedef struct { char name[32]; - float weight; - float add_damage[7]; - float add_armor[7]; - float add_range; - float add_cooldown; - float add_speed; - float add_hp; + float weight[MAXLEVEL]; + float add_damage[7][MAXLEVEL]; + float add_armor[7][MAXLEVEL]; + float add_range[MAXLEVEL]; + float add_cooldown[MAXLEVEL]; + float add_speed[MAXLEVEL]; + float add_hp[MAXLEVEL]; + float add_capacity[MAXLEVEL]; + float upkeep[MAXLEVEL]; } info_aug; typedef struct { char name[32]; + float upkeep[MAXLEVEL]; } info_brain; typedef struct { @@ -88,11 +103,14 @@ typedef struct { } infos; void info_unit_init (info_unit *u); +float info_unit_get_capacity (infos *info, info_unit *u); +float info_unit_get_upkeep (infos *info, info_unit *u); float info_unit_get_weight (infos *info, info_unit *u); float info_unit_get_dps (infos *info, info_unit *u); float info_unit_get_health(infos *info, info_unit *u); float info_unit_get_speed(infos *info, info_unit *u); float info_unit_get_damage(infos *info, info_unit *u, int w); +float info_unit_get_charge_per_shot(infos *info, info_unit *u, int w); 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); diff --git a/gst/units.c b/gst/units.c index 72089f2..dbf177b 100644 --- a/gst/units.c +++ b/gst/units.c @@ -36,6 +36,7 @@ void unit_init (infos *info, army *ar, map *m, u->owner = owner; u->hp = info_unit_get_health(info, iu); u->move_points = 0; + u->charge = info_unit_get_capacity(info, iu); for (int i=0; i<8; u->cooldown[i] = 1, i++); } @@ -113,6 +114,7 @@ int army_move_step (infos *info, army *ar, map *m) { unit *u = ar->us+i; if (u->move_points <= 0) continue; if (u->hp <= 0) continue; + if (u->charge <= 0) continue; // search target unit *t[32]; unit_search(info, ar, m, u, t, 100); @@ -180,7 +182,8 @@ void army_move (infos *info, army *ar, map *m) { void army_fire (infos *info, army *ar, map *m) { for (int i=0; i<ar->uslen; i++) { unit *u = ar->us+i; - for (int j=0; j<info->chassis[u->info.chassis].slot_weapon; j++) { + int lw = u->info.levels[LEVEL_CHASSIS]; + for (int j=0; j<info->chassis[u->info.chassis].slot_weapon[lw]; j++) { u->cooldown[j] += 1; } } @@ -189,7 +192,9 @@ void army_fire (infos *info, army *ar, map *m) { for (int i=0; i<ar->uslen; i++) { unit *u = ar->us+i; if (u->hp <= 0) continue; - for (int j=0; j<info->chassis[u->info.chassis].slot_weapon; j++) { + 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; if (u->cooldown[j] <= 0) continue; float range = info_unit_get_range(info, &u->info, j); @@ -200,6 +205,8 @@ void army_fire (infos *info, army *ar, map *m) { info, &u->info, j, &t[0]->info); dmgslen++; u->cooldown[j] -= info_unit_get_cooldown(info, &u->info, j); + u->charge -= info_unit_get_charge_per_shot(info, &u->info, j); + if (u->charge < 0) u->charge = 0; } } } @@ -209,4 +216,14 @@ void army_fire (infos *info, army *ar, map *m) { unit_dead(ar, m, dmgs[i].u); } } +} + +void army_upkeep (infos *info, army *ar, map *m) { + // 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); + if (u->charge < 0) u->charge = 0; + } }
\ No newline at end of file diff --git a/gst/units.h b/gst/units.h index 86f7fd7..615eaa7 100644 --- a/gst/units.h +++ b/gst/units.h @@ -36,5 +36,6 @@ void army_destory(army *ar); void army_spawn (army *ar, map *m, unit u); void army_move (infos *info, army *ar, map *m); void army_fire (infos *info, army *ar, map *m); +void army_upkeep (infos *info, army *ar, map *m); #endif
\ No newline at end of file @@ -115,7 +115,8 @@ int hud_fnu_check (info_unit *u, infos *info) { if (u->battery == -1) return 2; if (u->brain == -1) return 3; float curweight = info_unit_get_weight(info, u); - float maxweight = info->chassis[u->chassis].weight_max; + int chassis_lvl = u->levels[LEVEL_CHASSIS]; + float maxweight = info->chassis[u->chassis].weight_max[chassis_lvl]; if (curweight > maxweight) { return 4; } return 0; } @@ -272,8 +273,9 @@ void hud_process_form_new_unit (graphic_settings *gs, hud *h, MKb *mkb, 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; i++) + i<info->chassis[h->fnu.uinfo.chassis].slot_armor[lc]; i++) { float possa[2] = { h->fnu.rect_armor[i].x, h->fnu.rect_armor[i].y }; @@ -285,7 +287,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_weapon; i++) + i<info->chassis[h->fnu.uinfo.chassis].slot_weapon[lc]; i++) { float possa[2] = { h->fnu.rect_weapons[i].x, h->fnu.rect_weapons[i].y }; @@ -297,7 +299,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; i++) + i<info->chassis[h->fnu.uinfo.chassis].slot_aug[lc]; i++) { float possa[2] = { h->fnu.rect_augs[i].x, h->fnu.rect_augs[i].y }; @@ -552,12 +554,12 @@ void hud_render_sel (hud_sel *sc, MKb *mkb, info_unit *u, SDL_RenderFillRect(rend, &r); SDL_SetRenderDrawColor(rend, 0, 0, 0, 255); SDL_RenderDrawRect(rend, &r); - if (sel==0) render_view_chassis(rend, t, x, y, info, i, sprites); - if (sel==1) render_view_battery(rend, t, x, y, info, i); - if (sel==2) render_view_armor_detail(rend, t, x, y, info, i); - if (sel==3) render_view_weapon_detail(rend, t, x, y, info, i); - if (sel==4) render_view_aug_detail(rend, t, x, y, info, i); - if (sel==5) render_view_brain(rend, t, x, y, info, i); + if (sel==0) render_view_chassis(rend, t, x, y, info, i, 0, sprites); + if (sel==1) render_view_battery(rend, t, x, y, info, i, 0); + if (sel==2) render_view_armor_detail(rend, t, x, y, info, i, 0); + if (sel==3) render_view_weapon_detail(rend, t, x, y, info, i, 0); + if (sel==4) render_view_aug_detail(rend, t, x, y, info, i, 0); + if (sel==5) render_view_brain(rend, t, x, y, info, i, 0); } SDL_RenderSetClipRect(rend, NULL); } @@ -586,33 +588,37 @@ void hud_render_form_new_unit (form_new_unit *fnu, MKb *mkb, render_view_stats(rend, t, fnu->rect_stats.x, fnu->rect_stats.y, info, &fnu->uinfo); + int lc = fnu->uinfo.levels[LEVEL_CHASSIS]; if (fnu->uinfo.chassis != -1) { - for (int i=0; i<info->chassis[fnu->uinfo.chassis].slot_weapon; i++) { + for (int i=0; i<info->chassis[fnu->uinfo.chassis].slot_weapon[lc]; i++) { SDL_SetRenderDrawColor(rend, 200, 100, 255, 255); SDL_RenderFillRect(rend, fnu->rect_weapons+i); SDL_SetRenderDrawColor(rend, 0, 0, 0, 255); SDL_RenderDrawRect(rend, fnu->rect_weapons+i); render_view_weapon(rend, t, fnu->rect_weapons[i].x, - fnu->rect_weapons[i].y, info, fnu->uinfo.weapons[i]); + 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; i++) { + for (int i=0; i<info->chassis[fnu->uinfo.chassis].slot_armor[lc]; i++) { SDL_SetRenderDrawColor(rend, 200, 200, 255, 255); SDL_RenderFillRect(rend, fnu->rect_armor+i); SDL_SetRenderDrawColor(rend, 0, 0, 0, 255); SDL_RenderDrawRect(rend, fnu->rect_armor+i); render_view_armor(rend, t, fnu->rect_armor[i].x, - fnu->rect_armor[i].y, info, fnu->uinfo.armor[i]); + 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; i++) { + for (int i=0; i<info->chassis[fnu->uinfo.chassis].slot_aug[lc]; i++) { SDL_SetRenderDrawColor(rend, 200, 200, 255, 255); SDL_RenderFillRect(rend, fnu->rect_augs+i); SDL_SetRenderDrawColor(rend, 0, 0, 0, 255); SDL_RenderDrawRect(rend, fnu->rect_augs+i); render_view_aug(rend, t, fnu->rect_augs[i].x, - fnu->rect_augs[i].y, info, fnu->uinfo.augs[i]); + fnu->rect_augs[i].y, info, fnu->uinfo.augs[i], + fnu->uinfo.levels[LEVEL_AUGS+i]); } } @@ -681,11 +687,14 @@ void hud_render_form_new_unit (form_new_unit *fnu, MKb *mkb, render_view_chassis(rend, t, fnu->rect_chassis.x, fnu->rect_chassis.y, - info, fnu->uinfo.chassis, sprites); + info, fnu->uinfo.chassis, + fnu->uinfo.levels[LEVEL_CHASSIS], sprites); render_view_battery(rend, t, - fnu->rect_battery.x, fnu->rect_battery.y, info, fnu->uinfo.battery); + fnu->rect_battery.x, fnu->rect_battery.y, info, fnu->uinfo.battery, + fnu->uinfo.levels[LEVEL_BATTERY]); render_view_brain(rend, t, - fnu->rect_brain.x, fnu->rect_brain.y, info, fnu->uinfo.brain); + fnu->rect_brain.x, fnu->rect_brain.y, info, fnu->uinfo.brain, + fnu->uinfo.levels[LEVEL_BRAIN]); } void hud_render_overlay_game (overlay_game *og, MKb *mkb, @@ -708,7 +717,7 @@ void hud_render_overlay_game (overlay_game *og, MKb *mkb, for (int i=0; i<info->templateslen; i++) { float x = og->rect_templates.x+5; float y = og->rect_templates.y+5 + i*20 + 30; - render_view_template(rend, t, x, y, info, i); + render_view_template(rend, t, x, y, info, i, 0); } SDL_SetRenderDrawColor(rend, 0, 200, 120, 255); diff --git a/hud/hud_views.c b/hud/hud_views.c index 557ff1f..a7237e2 100644 --- a/hud/hud_views.c +++ b/hud/hud_views.c @@ -15,7 +15,8 @@ void render_view_stats (SDL_Renderer* rend, txtd *t, int px, int py, h += 35; float calcweight = info_unit_get_weight(info, tm); - float maxweight = info->chassis[tm->chassis].weight_max; + 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); @@ -55,7 +56,7 @@ void render_view_stats (SDL_Renderer* rend, txtd *t, int px, int py, } void render_view_chassis (SDL_Renderer* rend, txtd *t, int px, int py, - infos *info, int chassis, SDL_Texture *sprites) + infos *info, int chassis, int lvl, SDL_Texture *sprites) { if (chassis != -1) { float pname[2] = { px+10, py+10 }; @@ -85,7 +86,7 @@ void render_view_chassis (SDL_Renderer* rend, txtd *t, int px, int py, } void render_view_battery (SDL_Renderer* rend, txtd *t, int px, int py, - infos *info, int batt) + infos *info, int batt, int lvl) { if (batt != -1) { float pname[2] = { px+10, py+10 }; @@ -116,7 +117,7 @@ void render_view_battery (SDL_Renderer* rend, txtd *t, int px, int py, void render_view_armor (SDL_Renderer* rend, txtd *t, int px, int py, - infos *info, int armor) + infos *info, int armor, int lvl) { if (armor != -1) { float pname[2] = { px+10, py+10 }; @@ -128,9 +129,9 @@ void render_view_armor (SDL_Renderer* rend, txtd *t, int px, int py, j += strlen(temp); for (int i=0; i<7; i++) { if (i<7-1) { - sprintf(temp, "%.0f, ", info->armors[armor].armor[i]); + sprintf(temp, "%.0f, ", info->armors[armor].armor[i][lvl]); } else { - sprintf(temp, "%.0f", info->armors[armor].armor[i]); + sprintf(temp, "%.0f", info->armors[armor].armor[i][lvl]); } strcpy(sa+j, temp); j += strlen(temp); @@ -145,7 +146,7 @@ void render_view_armor (SDL_Renderer* rend, txtd *t, int px, int py, } void render_view_armor_detail (SDL_Renderer* rend, txtd *t, int px, int py, - infos *info, int armor) + infos *info, int armor, int lvl) { if (armor != -1) { float pname[2] = { px+10, py+10 }; @@ -153,7 +154,7 @@ void render_view_armor_detail (SDL_Renderer* rend, txtd *t, int px, int py, 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); + info->armors[armor].weight[lvl]); render_text_scaled(rend, sweight, pweight, t, 1); float pred[2] = { px+10, py+60 }; @@ -161,21 +162,21 @@ void render_view_armor_detail (SDL_Renderer* rend, txtd *t, int px, int py, int h=0; for (int i=0; i<7; i++) { - if (info->armors[armor].armor[i] < 0.001) continue; + 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]); + info->damage_types[i], info->armors[armor].armor[i][lvl]); render_text_scaled(rend, sa, pa, t, 1); h++; } } else { - render_view_weapon(rend, t, px, py, info, armor); + render_view_weapon(rend, t, px, py, info, armor, lvl); } } void render_view_weapon (SDL_Renderer* rend, txtd *t, int px, int py, - infos *info, int weapon) + infos *info, int weapon, int lvl) { if (weapon != -1) { float pname[2] = { px+10, py+10 }; @@ -184,7 +185,7 @@ void render_view_weapon (SDL_Renderer* rend, txtd *t, int px, int py, 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); + 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", @@ -192,15 +193,15 @@ void render_view_weapon (SDL_Renderer* rend, txtd *t, int px, int py, 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); + 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); + 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); + info->weapons[weapon].cooldown[lvl]); render_text_scaled(rend, scool, pcool, t, 1); } else { float pname[2] = { px+10, py+10 }; @@ -209,7 +210,7 @@ void render_view_weapon (SDL_Renderer* rend, txtd *t, int px, int py, } void render_view_weapon_detail (SDL_Renderer* rend, txtd *t, - int px, int py, infos *info, int weapon) + int px, int py, infos *info, int weapon, int lvl) { if (weapon != -1) { float pname[2] = { px+10, py+10 }; @@ -218,7 +219,7 @@ void render_view_weapon_detail (SDL_Renderer* rend, txtd *t, 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); + 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", @@ -226,24 +227,24 @@ void render_view_weapon_detail (SDL_Renderer* rend, txtd *t, 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); + 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); + 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); + info->weapons[weapon].cooldown[lvl]); render_text_scaled(rend, scool, pcool, t, 1); } else { - render_view_weapon(rend, t, px, py, info, weapon); + render_view_weapon(rend, t, px, py, info, weapon, lvl); } } void render_view_aug (SDL_Renderer* rend, txtd *t, int px, int py, - infos *info, int aug) + infos *info, int aug, int lvl) { if (aug != -1) { float pname[2] = { px+10, py+10 }; @@ -252,7 +253,7 @@ void render_view_aug (SDL_Renderer* rend, txtd *t, int px, int py, 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); + info->augs[aug].weight[lvl]); render_text_scaled(rend, sweight, pweight, t, 1); } else { float pname[2] = { px+10, py+10 }; @@ -261,7 +262,7 @@ void render_view_aug (SDL_Renderer* rend, txtd *t, int px, int py, } void render_view_aug_detail (SDL_Renderer* rend, txtd *t, int px, int py, - infos *info, int aug) + infos *info, int aug, int lvl) { if (aug != -1) { float h = 10; @@ -273,11 +274,11 @@ void render_view_aug_detail (SDL_Renderer* rend, txtd *t, int px, int py, float pweight[2] = { px+10, py+h }; char sweight[64]; sprintf(sweight, "WEIGHT: %.0f", - info->augs[aug].weight); + info->augs[aug].weight[lvl]); render_text_scaled(rend, sweight, pweight, t, 1); h += 15; - float range = info->augs[aug].add_range; + 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); @@ -285,7 +286,7 @@ void render_view_aug_detail (SDL_Renderer* rend, txtd *t, int px, int py, h += 15; } - float cooldown = info->augs[aug].add_cooldown; + float cooldown = info->augs[aug].add_cooldown[lvl]; if (cooldown != 0) { float p[2] = { px+10, py+h }; char s[64]; sprintf(s, "COOLDOWN: %.2f", cooldown); @@ -293,7 +294,7 @@ void render_view_aug_detail (SDL_Renderer* rend, txtd *t, int px, int py, h += 15; } - float speed = info->augs[aug].add_speed; + float speed = info->augs[aug].add_speed[lvl]; if (speed != 0) { float p[2] = { px+10, py+h }; char s[64]; sprintf(s, "SPEED: %.2f", speed); @@ -301,7 +302,7 @@ void render_view_aug_detail (SDL_Renderer* rend, txtd *t, int px, int py, h += 15; } - float hp = info->augs[aug].add_hp; + float hp = info->augs[aug].add_hp[lvl]; if (hp != 0) { float p[2] = { px+10, py+h }; char s[64]; sprintf(s, "HP: %.1f", hp); @@ -312,44 +313,44 @@ void render_view_aug_detail (SDL_Renderer* rend, txtd *t, int px, int py, h += 5; float sum = 0; - for (int i=0; i<7; i++) sum += fabs(info->augs[aug].add_armor[i]); + for (int i=0; i<7; i++) sum += fabs(info->augs[aug].add_armor[i][lvl]); 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] == 0) continue; + 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]); + info->damage_types[i], info->augs[aug].add_armor[i][lvl]); render_text_scaled(rend, sa, pa, t, 1); h += 15; } } sum = 0; - for (int i=0; i<7; i++) sum += fabs(info->augs[aug].add_damage[i]); + for (int i=0; i<7; i++) sum += fabs(info->augs[aug].add_damage[i][lvl]); 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] == 0) continue; + 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]); + info->damage_types[i], info->augs[aug].add_damage[i][lvl]); render_text_scaled(rend, sa, pa, t, 1); h += 15; } } } else { - render_view_aug(rend, t, px, py, info, aug); + render_view_aug(rend, t, px, py, info, aug, lvl); } } void render_view_brain (SDL_Renderer* rend, txtd *t, int px, int py, - infos *info, int brain) + infos *info, int brain, int lvl) { if (brain != -1) { float pname[2] = { px+10, py+10 }; @@ -364,7 +365,7 @@ void render_view_brain (SDL_Renderer* rend, txtd *t, int px, int py, void render_view_template (SDL_Renderer* rend, txtd *t, int px, int py, - infos *info, int temp) + infos *info, int temp, int lvl) { button b = { "edit", 4, { px, py } }; render_button(rend, t, &b); diff --git a/hud/hud_views.h b/hud/hud_views.h index ceced23..50311d2 100644 --- a/hud/hud_views.h +++ b/hud/hud_views.h @@ -16,32 +16,32 @@ void render_view_stats (SDL_Renderer* rend, txtd *t, int px, int py, void render_view_chassis (SDL_Renderer* rend, txtd *t, int px, int py, - infos *info, int chassis, SDL_Texture *sprites); + infos *info, int chassis, int lvl, SDL_Texture *sprites); void render_view_battery (SDL_Renderer* rend, txtd *t, int px, int py, - infos *info, int batt); + infos *info, int batt, int lvl); void render_view_armor (SDL_Renderer* rend, txtd *t, int px, int py, - infos *info, int armor); + infos *info, int armor, int lvl); void render_view_armor_detail (SDL_Renderer* rend, txtd *t, int px, int py, - infos *info, int armor); + infos *info, int armor, int lvl); void render_view_weapon (SDL_Renderer* rend, txtd *t, int px, int py, - infos *info, int weapon); + infos *info, int weapon, int lvl); void render_view_weapon_detail (SDL_Renderer* rend, txtd *t, int px, int py, - infos *info, int weapon); + infos *info, int weapon, int lvl); void render_view_aug (SDL_Renderer* rend, txtd *t, int px, int py, - infos *info, int aug); + infos *info, int aug, int lvl); void render_view_aug_detail (SDL_Renderer* rend, txtd *t, int px, int py, - infos *info, int aug); + infos *info, int aug, int lvl); void render_view_brain (SDL_Renderer* rend, txtd *t, int px, int py, - infos *info, int brain); + infos *info, int brain, int lvl); void render_view_template (SDL_Renderer* rend, txtd *t, int px, int py, - infos *info, int temp); + infos *info, int temp, int lvl); #endif
\ No newline at end of file diff --git a/json/jsonparse.c b/json/jsonparse.c index 6cfae2e..34587b5 100644 --- a/json/jsonparse.c +++ b/json/jsonparse.c @@ -22,6 +22,10 @@ void json_parse_array(char *json, void *temp, jsmntok_t *t, int r, char type) { int8_t *p = (int8_t*)(intptr_t)temp+sizeof(int8_t)*i; *p = atoi(val); } + if (type == 'f') { + float *p = (float*)(intptr_t)temp+sizeof(float)*i; + *p = atof(val); + } } } } @@ -35,10 +39,13 @@ void json_dump_array (char *str, void *arr, int len, char type) { cur = strlen(str); } if (type == 'c') { - printf("%d\n", ((int8_t*)(intptr_t)(arr))[i]); sprintf(str+cur, "%d", ((int8_t*)(intptr_t)(arr))[i]); cur = strlen(str); } + if (type == 'f') { + sprintf(str+cur, "%f", ((float*)(intptr_t)(arr))[i]); + cur = strlen(str); + } if (i < len-1) { sprintf(str+cur, ", "); cur = strlen(str); } @@ -53,115 +60,4 @@ int json_parse_subtokens (char *json, jsmntok_t *t, int r, int i) { else { break; } } return rt; -} - -/* DEPRECATED TRIALS, delete after backup -// parses a <str, int> pair set with a set of already parsed tokens -int json_parse_dict_ci_init (char *json, - pair_ci *dict, jsmntok_t *t, int r) { - int obj_i = 0, dict_i = -1; - for (int i=0; i<r; i++) { - if (t[i].type == JSMN_OBJECT) { - dict_i ++; - obj_i = 0; - } - if (t[i].type == JSMN_STRING) { - if (obj_i == 0) { - substr_token(json, dict[dict_i].key, t+i); - } else if (obj_i == 1) { - char ts[13]; substr_token(json, ts, t+i); - dict[dict_i].i = atoi(ts); - } - obj_i++; - } - } - return dict_i+1; -} - -// parses a <str, int> pair set with a set of already parsed tokens -int json_parse_dict_cf_init (char *json, - pair_cf *dict, jsmntok_t *t, int r) { - int obj_i = 0, dict_i = -1; - for (int i=0; i<r; i++) { - if (t[i].type == JSMN_OBJECT) { - dict_i ++; - obj_i = 0; - } - if (t[i].type == JSMN_STRING) { - if (obj_i == 0) { - substr_token(json, dict[dict_i].key, t+i); - } else if (obj_i == 1) { - char ts[13]; substr_token(json, ts, t+i); - dict[dict_i].i = atof(ts); - } - obj_i++; - } - } - return dict_i+1; -} - - -// parses a <str, int> pair set -int json_parse_dict_ci (char *json, pair_ci *dict) { - jsmn_parser p; jsmn_init(&p); - jsmntok_t t[MAXTOKENS]; - int r = jsmn_parse(&p, json, strlen(json), t, MAXTOKENS); - json_parse_dict_ci_init(json, dict, t, r); -} - -// parses a <str, float> pair set -int json_parse_dict_cf (char *json, pair_cf *dict) { - jsmn_parser p; jsmn_init(&p); - jsmntok_t t[MAXTOKENS]; - int r = jsmn_parse(&p, json, strlen(json), t, MAXTOKENS); - json_parse_dict_cf_init(json, dict, t, r); -} - - - -// parses a list of objects which are lists of pairs <str, int> -int json_parse_list_ci (char *json, list_ci *list) { - jsmn_parser p; jsmn_init(&p); - jsmntok_t t[MAXTOKENS]; - int r = jsmn_parse(&p, json, strlen(json), t, MAXTOKENS); - int list_i = 0; - for (int i=1; i<r; i++) { // i=1: ignore outer [] - if (t[i].type == JSMN_ARRAY) { - int rt = 0; - for (int j=i; j<r; j++) { - if (t[j].start < t[i].end) { rt ++; } - else { break; } - } - int len = json_parse_dict_ci_init( - json, list[list_i].pairs, t+i, rt); - list[list_i].len = len; - list_i ++; - i += rt-1; - } - } - return list_i; -} - -// parses a list of objects which are lists of pairs <str, float> -int json_parse_list_cf (char *json, list_cf *list) { - jsmn_parser p; jsmn_init(&p); - jsmntok_t t[MAXTOKENS]; - int r = jsmn_parse(&p, json, strlen(json), t, MAXTOKENS); - int list_i = 0; - for (int i=1; i<r; i++) { // i=1: ignore outer [] - if (t[i].type == JSMN_ARRAY) { - int rt = 0; - for (int j=i; j<r; j++) { - if (t[j].start < t[i].end) { rt ++; } - else { break; } - } - int len = json_parse_dict_cf_init( - json, list[list_i].pairs, t+i, rt); - list[list_i].len = len; - list_i ++; - i += rt-1; - } - } - return list_i; -} -*/
\ No newline at end of file +}
\ No newline at end of file diff --git a/json/jsonparse.h b/json/jsonparse.h index 2186154..87a8960 100644 --- a/json/jsonparse.h +++ b/json/jsonparse.h @@ -12,24 +12,5 @@ void json_parse_array(char *json, void *temp, jsmntok_t *t, int r, char type); void json_dump_array (char *str, void *arr, int len, char type); int json_parse_subtokens (char *json, jsmntok_t *t, int r, int i); -/* -typedef struct { char key[32]; int i; } pair_ci; -typedef struct { char key[32]; float i; } pair_cf; - - -int json_parse_dict_ci_init (char *json, pair_ci *dict, jsmntok_t *t, int r); -int json_parse_dict_cf_init (char *json, pair_cf *dict, jsmntok_t *t, int r); -int json_parse_dict_ci (char *json, pair_ci *dict); -int json_parse_dict_cf (char *json, pair_cf *dict); - -#define MAXLISTLEN 64 -#define MAXOBJLEN 32 - -typedef struct { pair_ci pairs[MAXOBJLEN]; int len; } list_ci; -typedef struct { pair_cf pairs[MAXOBJLEN]; int len; } list_cf; - -int json_parse_list_ci (char *json, list_ci *list); -int json_parse_list_cf (char *json, list_cf *list); -*/ #endif
\ No newline at end of file @@ -50,6 +50,11 @@ int main( int argc, char* args[] ) { txtd textd; char_width_init(textd.cw); SDL_Surface* image = SDL_LoadBMP("content/gf.bmp"); textd.tex = SDL_CreateTextureFromSurface(rend, image); + SDL_SetTextureColorMod(textd.tex, 0, 0, 0); + + SDL_Surface* imagesmall = SDL_LoadBMP("content/gfsmall.bmp"); + SDL_Texture* txsmall = SDL_CreateTextureFromSurface(rend, imagesmall); + SDL_SetTextureColorMod(txsmall, 0, 0, 0); SDL_Surface* sprites = SDL_LoadBMP("content/sprites.bmp"); SDL_Texture* txsprites = SDL_CreateTextureFromSurface(rend, sprites); @@ -200,14 +205,21 @@ int main( int argc, char* args[] ) { / info_unit_get_health(&info, &ar->us[i].info); SDL_Rect hprect = { (int)x-posx, (int)y-posy+ts-5, - ts*amt, 5 }; + ts*amt, 6 }; int sw = 1 ? ar->us[i].owner : 0; SDL_SetRenderDrawColor(rend, 255*sw, 255*(1-sw), 0, 255); SDL_RenderFillRect(rend, &hprect); + SDL_SetTextureColorMod(txsmall, 0, 100, 0); char shp[32]; sprintf(shp, "%.0f", ar->us[i].hp); float php[2] = { (int)x-posx, (int)y-posy+ts-5 }; - render_text_scaled(rend, shp, php, &textd, 1); + render_text_small(rend, shp, php, txsmall); + + SDL_SetTextureColorMod(txsmall, 255, 160, 0); + char sch[32]; sprintf(sch, "%.0f", ar->us[i].charge); + float pch[2] = { (int)x-posx, (int)y-posy+ts+1 }; + render_text_small(rend, sch, pch, txsmall); + SDL_SetTextureColorMod(txsmall, 0, 0, 0); } hud_render(&_hud, rend, &textd, &mkb, &info, txsprites); diff --git a/render/render_text.c b/render/render_text.c index 67a13e2..df9317c 100644 --- a/render/render_text.c +++ b/render/render_text.c @@ -34,7 +34,7 @@ void render_text (SDL_Renderer* gRenderer, char str[], float off[], txtd *t) } } -void render_text_scaled (SDL_Renderer* gRenderer, char str[], +void render_text_scaled (SDL_Renderer* rend, char str[], float off[], txtd *t, float scale) { int width = 0; @@ -42,7 +42,20 @@ void render_text_scaled (SDL_Renderer* gRenderer, char str[], int char_i = str[i]; SDL_Rect srcRect = { (char_i%32)*6+1, (char_i/32)*12+1, 5, 11 }; SDL_Rect dstRect = { off[0]+width, off[1], 5*scale, 11*scale }; - SDL_RenderCopy(gRenderer, t->tex, &srcRect, &dstRect); + SDL_RenderCopy(rend, t->tex, &srcRect, &dstRect); width += t->cw[char_i]*scale+1*scale; } +} + +void render_text_small (SDL_Renderer* rend, char str[], float off[], + SDL_Texture *texsmall) +{ + int width = 0; + for (int i=0; str[i]!='\0'; i++) { + int char_i = str[i]; + SDL_Rect srcRect = { (char_i%32)*5+1, (char_i/32)*7+1, 4, 6 }; + SDL_Rect dstRect = { off[0]+width, off[1], 4, 6 }; + SDL_RenderCopy(rend, texsmall, &srcRect, &dstRect); + width += 5; + } }
\ No newline at end of file diff --git a/render/render_text.h b/render/render_text.h index e7474ff..a9e952e 100644 --- a/render/render_text.h +++ b/render/render_text.h @@ -15,4 +15,7 @@ void render_text (SDL_Renderer* gRenderer, char str[], float off[], txtd *t); void render_text_scaled (SDL_Renderer* gRenderer, char str[], float off[], txtd *t, float scale); +void render_text_small (SDL_Renderer* rend, char str[], float off[], + SDL_Texture *texsmall); + #endif
\ No newline at end of file |