summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2020-12-25 12:10:01 -0300
committerJesusaves <cpntb1@ymail.com>2020-12-25 12:10:01 -0300
commit0248a71aaa842a728e4375cad0bafdad737c0430 (patch)
tree53e21ef3dc5d19f3f8e9e3894ee660781c87dae9
parent61a0b9b9fec3a390dca60db81e18f26ae2e821b7 (diff)
downloadclient-0248a71aaa842a728e4375cad0bafdad737c0430.tar.gz
client-0248a71aaa842a728e4375cad0bafdad737c0430.tar.bz2
client-0248a71aaa842a728e4375cad0bafdad737c0430.tar.xz
client-0248a71aaa842a728e4375cad0bafdad737c0430.zip
Fork code, replace some ifs with showifs in screen, add dummy structures.
Hopefully, code will be more stable from now on. It might still crash, but then I'll be sure the bug is on the draggroups.
-rw-r--r--game/01_init.rpy19
-rw-r--r--game/ATTRIBUTION2
-rw-r--r--game/battle.rpy13
-rw-r--r--game/gfx/mobs/0.pngbin0 -> 126189 bytes
-rw-r--r--game/gfx/units/0.pngbin0 -> 1067295 bytes
-rw-r--r--game/gui/battle.rpy435
6 files changed, 250 insertions, 219 deletions
diff --git a/game/01_init.rpy b/game/01_init.rpy
index cd45f0a..d90bf7e 100644
--- a/game/01_init.rpy
+++ b/game/01_init.rpy
@@ -106,6 +106,25 @@ init -3 python:
IRC_AUTH_NICK =2
IRC_AUTH_CHAN =3
+ # Special error structs
+ ERR_MOBSTRUCT ={
+ "name": "ERROR",
+ "unit_id": 0,
+ "max_hp": 0,
+ "hp": 0,
+ "atk": 0,
+ "ele": 0,
+ "status_effects": 0
+ }
+ ERR_PLAYERSTRUCT={
+ "unit_id": 0,
+ "max_hp": 0,
+ "hp": 0,
+ "atk": 0,
+ "ele": 0,
+ "status_effects": 0
+ }
+
# Smart Print command
def stdout(message):
if debug:
diff --git a/game/ATTRIBUTION b/game/ATTRIBUTION
index 76a2413..1c8ac50 100644
--- a/game/ATTRIBUTION
+++ b/game/ATTRIBUTION
@@ -92,6 +92,7 @@ Where relevant, you must also include a link to https://tmw2.org in your credit.
gfx/gui/ele_4.png (Chrisdesign) (CC0) (From OpenGameArt)
gfx/gui/ele_5.png (Chrisdesign) (CC0) (From OpenGameArt)
## MOBS
+ gfx/mobs/0.png (-) (-) (-)
gfx/mobs/950004.png
gfx/mobs/950008.png
## SPHERE
@@ -122,6 +123,7 @@ Where relevant, you must also include a link to https://tmw2.org in your credit.
gfx/summons/2.webp (-) (-) (-)
gfx/summons/3.webp (-) (-) (-)
## UNITS
+ gfx/units/0.png (-) (-) (-)
gfx/units/10000000.png (David Revoy) (CC BY 3.0) (From OpenGameArt)
# GUI
diff --git a/game/battle.rpy b/game/battle.rpy
index bf7d8e9..2e9dd18 100644
--- a/game/battle.rpy
+++ b/game/battle.rpy
@@ -64,17 +64,20 @@ label combat:
en1=Battle["enemy"][0]
show_img("mob_"+str(en1["unit_id"]), False) # Validate
except:
- en1={"hp": 0}
+ en1=copy.copy(ERR_MOBSTRUCT)
try:
en2=Battle["enemy"][1]
show_img("mob_"+str(en2["unit_id"]), False) # Validate
except:
- en2={"hp": 0}
+ en2=copy.copy(ERR_MOBSTRUCT)
try:
en3=Battle["enemy"][2]
show_img("mob_"+str(en3["unit_id"]), False) # Validate
except:
- en3={"hp": 0}
+ en3=copy.copy(ERR_MOBSTRUCT)
+
+ while len(Battle["party"]) < 4:
+ Battle["party"].append(copy.copy(ERR_PLAYERSTRUCT))
$stdout("================= call begin")
# TODO: Swap units support
@@ -87,7 +90,9 @@ label combat:
except:
traceback.print_exc()
stdout("FAILED to render battle screen, trying again...")
- sdelay(0.5)
+ renpy.hide_screen("battle")
+ sdelay(1.5)
+ raise
renpy.jump("combat")
stdout("================= call ended")
diff --git a/game/gfx/mobs/0.png b/game/gfx/mobs/0.png
new file mode 100644
index 0000000..5ef6126
--- /dev/null
+++ b/game/gfx/mobs/0.png
Binary files differ
diff --git a/game/gfx/units/0.png b/game/gfx/units/0.png
new file mode 100644
index 0000000..20ed9f3
--- /dev/null
+++ b/game/gfx/units/0.png
Binary files differ
diff --git a/game/gui/battle.rpy b/game/gui/battle.rpy
index bdfb642..a22a515 100644
--- a/game/gui/battle.rpy
+++ b/game/gui/battle.rpy
@@ -85,9 +85,51 @@ label bl_context:
return
#############################################################################
+screen battle_mobs():
+ ####################################################
+ # Render enemies
+ fixed:
+ # Enemy 1
+ showif (en1["hp"] > 0):
+ add At("mob_"+str(en1["unit_id"]), enemy1)
+ vbox:
+ xalign 0.5
+ yanchor 0.5
+ ypos 0.24
+ xmaximum 180
+ ymaximum 20
+ text en1["name"]
+ bar value en1["hp"] range en1["max_hp"]
+
+ # Enemy 2
+ showif (en2["hp"] > 0):
+ add At("mob_"+str(en2["unit_id"]), enemy2)
+ vbox:
+ xalign 1.0
+ yanchor 0.5
+ ypos 0.24
+ xmaximum 180
+ ymaximum 20
+ text en2["name"]
+ bar value en2["hp"] range en2["max_hp"]
+
+ # Enemy 3
+ showif (en3["hp"] > 0):
+ add At("mob_"+str(en3["unit_id"]), enemy3)
+ vbox:
+ xalign 0.0
+ yanchor 0.5
+ ypos 0.24
+ xmaximum 180
+ ymaximum 20
+ text en3["name"]
+ bar value en3["hp"] range en3["max_hp"]
+
+#############################################################################
screen battle():
# Background
add "bg battle"
+ use battle_mobs
####################################################
# Render HUD
@@ -106,7 +148,7 @@ screen battle():
# Preferences button
null width 20
imagebutton auto "gfx/gui/cog_%s.png" action ShowMenu('preferences')
- textbutton _("Party") action Function(blayout)
+ #textbutton _("Party") action Function(blayout)
null width 20
text "%d " % (Battle["turn"])
text _(" Turn")
@@ -121,258 +163,221 @@ screen battle():
textbutton _("I'm ready") action Return()
####################################################
- # Render enemies
-
- # Enemy 1
- if (en1["hp"] > 0):
- add At("mob_"+str(en1["unit_id"]), enemy1)
- vbox:
- xalign 0.5
- yanchor 0.5
- ypos 0.24
- xmaximum 180
- ymaximum 20
- text en1["name"]
- bar value en1["hp"] range en1["max_hp"]
-
- # Enemy 2
- if (en2["hp"] > 0):
- add At("mob_"+str(en2["unit_id"]), enemy2)
- vbox:
- xalign 1.0
- yanchor 0.5
- ypos 0.24
- xmaximum 180
- ymaximum 20
- text en2["name"]
- bar value en2["hp"] range en2["max_hp"]
-
- # Enemy 3
- if (en3["hp"] > 0):
- add At("mob_"+str(en3["unit_id"]), enemy3)
- vbox:
- xalign 0.0
- yanchor 0.5
- ypos 0.24
- xmaximum 180
- ymaximum 20
- text en3["name"]
- bar value en3["hp"] range en3["max_hp"]
-
- ####################################################
# Render allies
# TODO: Gray out and unmovable if dead
# One drag group per party member defined in Battle
- draggroup:
- xpos 0.25
- xanchor 1.0
- yanchor 1.0
- ypos config.screen_height-10
- xmaximum 256
- ymaximum 480
- # Display the background
- drag:
- child At("gfx/action.png", party1)
- draggable False
- droppable False
- # Display the card (if there's one)
- if (fx1):
+ fixed:
+ draggroup:
+ xpos 0.25
+ xanchor 1.0
+ yanchor 1.0
+ ypos config.screen_height-10
+ xmaximum 256
+ ymaximum 480
+ # Display the background
drag:
- drag_name "party1"
- child At(fx1, c_party1)
+ child At("gfx/action.png", party1)
+ draggable False
droppable False
- if (Battle["party"][0]["hp"] > 0):
- dragged combat_action
- else:
+ # Display the card (if there's one)
+ if (fx1):
+ drag:
+ drag_name "party1"
+ child At(fx1, c_party1)
+ droppable False
+ if (Battle["party"][0]["hp"] > 0):
+ dragged combat_action
+ else:
+ draggable False
+ ypos 48
+ # The action areas
+ drag:
+ drag_name "Skill"
+ child At("gfx/actionarea.png", party1)
draggable False
- ypos 48
- # The action areas
- drag:
- drag_name "Skill"
- child At("gfx/actionarea.png", party1)
- draggable False
- ypos 0.0
+ ypos 0.0
+ drag:
+ drag_name "Sphere"
+ child At("gfx/actionarea.png", party1)
+ draggable False
+ yalign 1.0
+ # Display the sphere
drag:
- drag_name "Sphere"
- child At("gfx/actionarea.png", party1)
+ child ("gfx/sphere/"+str(Battle["spheres"][0])+".png")
draggable False
+ droppable False
yalign 1.0
- # Display the sphere
- drag:
- child ("gfx/sphere/"+str(Battle["spheres"][0])+".png")
- draggable False
- droppable False
- yalign 1.0
- xalign 0.5
- if (fx1 and Battle["party"][0]["hp"] <= 0):
- add At("gfx/off.png", party1)
+ xalign 0.5
+ if (fx1 and Battle["party"][0]["hp"] <= 0):
+ add At("gfx/off.png", party1)
- # One drag group per party member defined in Battle
- draggroup:
- xpos 0.50
- xanchor 1.0
- yanchor 1.0
- ypos config.screen_height-10
- xmaximum 256
- ymaximum 480
- drag:
- child At("gfx/action.png", party2)
- draggable False
- droppable False
- if (fx2):
+ # One drag group per party member defined in Battle
+ draggroup:
+ xpos 0.50
+ xanchor 1.0
+ yanchor 1.0
+ ypos config.screen_height-10
+ xmaximum 256
+ ymaximum 480
drag:
- drag_name "party2"
- child At(fx2, c_party2)
+ child At("gfx/action.png", party2)
+ draggable False
droppable False
- if (Battle["party"][1]["hp"] > 0):
- dragged combat_action
- else:
+ if (fx2):
+ drag:
+ drag_name "party2"
+ child At(fx2, c_party2)
+ droppable False
+ if (Battle["party"][1]["hp"] > 0):
+ dragged combat_action
+ else:
+ draggable False
+ ypos 48
+ drag:
+ drag_name "Skill"
+ child At("gfx/actionarea.png", party2)
draggable False
- ypos 48
- drag:
- drag_name "Skill"
- child At("gfx/actionarea.png", party2)
- draggable False
- ypos 0.0
+ ypos 0.0
+ drag:
+ drag_name "Sphere"
+ child At("gfx/actionarea.png", party2)
+ draggable False
+ yalign 1.0
drag:
- drag_name "Sphere"
- child At("gfx/actionarea.png", party2)
+ child ("gfx/sphere/"+str(Battle["spheres"][1])+".png")
draggable False
+ droppable False
yalign 1.0
- drag:
- child ("gfx/sphere/"+str(Battle["spheres"][1])+".png")
- draggable False
- droppable False
- yalign 1.0
- xalign 0.5
+ xalign 0.5
- if (fx2 and Battle["party"][1]["hp"] <= 0):
- add At("gfx/off.png", party2)
- # One drag group per party member defined in Battle
- draggroup:
- xpos 0.75
- xanchor 1.0
- yanchor 1.0
- ypos config.screen_height-10
- xmaximum 256
- ymaximum 480
- drag:
- child At("gfx/action.png", party3)
- draggable False
- droppable False
- if (fx3):
+ if (fx2 and Battle["party"][1]["hp"] <= 0):
+ add At("gfx/off.png", party2)
+ # One drag group per party member defined in Battle
+ draggroup:
+ xpos 0.75
+ xanchor 1.0
+ yanchor 1.0
+ ypos config.screen_height-10
+ xmaximum 256
+ ymaximum 480
drag:
- drag_name "party3"
- child At(fx3, c_party3)
+ child At("gfx/action.png", party3)
+ draggable False
droppable False
- if (Battle["party"][2]["hp"] > 0):
- dragged combat_action
- else:
+ if (fx3):
+ drag:
+ drag_name "party3"
+ child At(fx3, c_party3)
+ droppable False
+ if (Battle["party"][2]["hp"] > 0):
+ dragged combat_action
+ else:
+ draggable False
+ ypos 48
+ drag:
+ drag_name "Skill"
+ child At("gfx/actionarea.png", party3)
draggable False
- ypos 48
- drag:
- drag_name "Skill"
- child At("gfx/actionarea.png", party3)
- draggable False
- ypos 0.0
+ ypos 0.0
+ drag:
+ drag_name "Sphere"
+ child At("gfx/actionarea.png", party3)
+ draggable False
+ yalign 1.0
drag:
- drag_name "Sphere"
- child At("gfx/actionarea.png", party3)
+ child ("gfx/sphere/"+str(Battle["spheres"][2])+".png")
draggable False
+ droppable False
yalign 1.0
- drag:
- child ("gfx/sphere/"+str(Battle["spheres"][2])+".png")
- draggable False
- droppable False
- yalign 1.0
- xalign 0.5
+ xalign 0.5
- if (fx3 and Battle["party"][2]["hp"] <= 0):
- add At("gfx/off.png", party3)
- # One drag group per party member defined in Battle
- draggroup:
- xpos 1.0
- xanchor 1.0
- yanchor 1.0
- ypos config.screen_height-10
- xmaximum 256
- ymaximum 480
- drag:
- child At("gfx/action.png", party4)
- draggable False
- droppable False
- if (fx4):
+ if (fx3 and Battle["party"][2]["hp"] <= 0):
+ add At("gfx/off.png", party3)
+ # One drag group per party member defined in Battle
+ draggroup:
+ xpos 1.0
+ xanchor 1.0
+ yanchor 1.0
+ ypos config.screen_height-10
+ xmaximum 256
+ ymaximum 480
drag:
- drag_name "party4"
- child At(fx4, c_party4)
+ child At("gfx/action.png", party4)
+ draggable False
droppable False
- if (Battle["party"][3]["hp"] > 0):
- dragged combat_action
- else:
+ if (fx4):
+ drag:
+ drag_name "party4"
+ child At(fx4, c_party4)
+ droppable False
+ if (Battle["party"][3]["hp"] > 0):
+ dragged combat_action
+ else:
+ draggable False
+ ypos 48
+ drag:
+ drag_name "Skill"
+ child At("gfx/actionarea.png", party4)
draggable False
- ypos 48
- drag:
- drag_name "Skill"
- child At("gfx/actionarea.png", party4)
- draggable False
- ypos 0.0
+ ypos 0.0
+ drag:
+ drag_name "Sphere"
+ child At("gfx/actionarea.png", party4)
+ draggable False
+ yalign 1.0
drag:
- drag_name "Sphere"
- child At("gfx/actionarea.png", party4)
+ child ("gfx/sphere/"+str(Battle["spheres"][3])+".png")
draggable False
+ droppable False
yalign 1.0
- drag:
- child ("gfx/sphere/"+str(Battle["spheres"][3])+".png")
- draggable False
- droppable False
- yalign 1.0
- xalign 0.5
+ xalign 0.5
- if (fx4 and Battle["party"][3]["hp"] <= 0):
- add At("gfx/off.png", party4)
+ if (fx4 and Battle["party"][3]["hp"] <= 0):
+ add At("gfx/off.png", party4)
####################################################
# Render HPBARs
- if (fx1):
- frame:
- xpos 0.125
- xanchor 0.5
- yanchor 1.0
- ypos 1.0
- ymaximum 10
- xmaximum 256
- bar value Battle["party"][0]["hp"] range Battle["party"][0]["max_hp"] xmaximum 256
+ fixed:
+ showif (fx1):
+ frame:
+ xpos 0.125
+ xanchor 0.5
+ yanchor 1.0
+ ypos 1.0
+ ymaximum 10
+ xmaximum 256
+ bar value Battle["party"][0]["hp"] range Battle["party"][0]["max_hp"] xmaximum 256
- if (fx2):
- frame:
- xpos 0.375
- xanchor 0.5
- yanchor 1.0
- ypos 1.0
- ymaximum 10
- xmaximum 256
- bar value Battle["party"][1]["hp"] range Battle["party"][1]["max_hp"] xmaximum 256
+ showif (fx2):
+ frame:
+ xpos 0.375
+ xanchor 0.5
+ yanchor 1.0
+ ypos 1.0
+ ymaximum 10
+ xmaximum 256
+ bar value Battle["party"][1]["hp"] range Battle["party"][1]["max_hp"] xmaximum 256
- if (fx3):
- frame:
- xpos 0.625
- xanchor 0.5
- yanchor 1.0
- ypos 1.0
- ymaximum 10
- xmaximum 256
- bar value Battle["party"][2]["hp"] range Battle["party"][2]["max_hp"] xmaximum 256
+ showif (fx3):
+ frame:
+ xpos 0.625
+ xanchor 0.5
+ yanchor 1.0
+ ypos 1.0
+ ymaximum 10
+ xmaximum 256
+ bar value Battle["party"][2]["hp"] range Battle["party"][2]["max_hp"] xmaximum 256
- if (fx4):
- frame:
- xpos 0.875
- xanchor 0.5
- yanchor 1.0
- ypos 1.0
- ymaximum 10
- xmaximum 256
- bar value Battle["party"][3]["hp"] range Battle["party"][3]["max_hp"] xmaximum 256
+ showif (fx4):
+ frame:
+ xpos 0.875
+ xanchor 0.5
+ yanchor 1.0
+ ypos 1.0
+ ymaximum 10
+ xmaximum 256
+ bar value Battle["party"][3]["hp"] range Battle["party"][3]["max_hp"] xmaximum 256
screen battle_layout(lb="Select unit"):
vbox: