Badger Battle - Turn Based Game

Show off your games, demos and other (playable) creations.
coffee
Party member
Posts: 1206
Joined: Wed Nov 02, 2011 9:07 pm

Re: Badger Battle - Turn Based Game

Post by coffee »

viking badger wrote:
coffee wrote:Debugging Tserial stuff maybe could be complicated to me. But this could help perhaps. I'm using OSX. OS.execute bad commands? Let's just wait feedback from other people and see if could be only a Mac problem. But if I can/could help, I will.
Ohhh, I bet you're right. I'll try a different serialization library and see if that fixes it.
I'm not. Tserial is made by Taehl, is solid and don't seem to do the save/load.
BTW i loved your way of code and way of indent. I like to do the same.

I noticed things in your code like

Code: Select all

 local file = io.open("profiles", "r")
and

Code: Select all

	local data = TSerial.pack(profiles)	
	io.output(io.open("profiles", "w"))
	io.write(data)
	io.close()
Wouldn't be safer and more cross-os you use Love set of IO commands?
https://love2d.org/wiki/love.filesystem
User avatar
viking badger
Prole
Posts: 19
Joined: Sun Jul 08, 2012 1:00 am
Location: Denton, TX

Re: Badger Battle - Turn Based Game

Post by viking badger »

coffee wrote: I'm not. Tserial is made by Taehl, is solid and don't seem to do the save/load.
BTW i loved your way of code and way of indent. I like to do the same.

I noticed things in your code like

Code: Select all

 local file = io.open("profiles", "r")
and

Code: Select all

	local data = TSerial.pack(profiles)	
	io.output(io.open("profiles", "w"))
	io.write(data)
	io.close()
Wouldn't be safer and more cross-os you use Love set of IO commands?
https://love2d.org/wiki/love.filesystem
Doh. Thanks for pointing that out. I changed it to use love.filesystem. See if that fixes your problem.

I also added a little bit of randomization to the turn ordering (although it's still primarily dependent on the characters' speed attributes) and a backdrop to the skill reports for easier reading.
coffee
Party member
Posts: 1206
Joined: Wed Nov 02, 2011 9:07 pm

Re: Badger Battle - Turn Based Game

Post by coffee »

viking badger wrote: Doh. Thanks for pointing that out. I changed it to use love.filesystem. See if that fixes your problem.

I also added a little bit of randomization to the turn ordering (although it's still primarily dependent on the characters' speed attributes) and a backdrop to the skill reports for easier reading.
Yes, it starts good now. Good work. I'm glad to help on that. But about the error exiting the battle it's still happen. However now I never can't tell what error happened to report to you. Won't be better disable your error-catcher for now?

I liked new backgrounds in text. More visible text.
User avatar
viking badger
Prole
Posts: 19
Joined: Sun Jul 08, 2012 1:00 am
Location: Denton, TX

Re: Badger Battle - Turn Based Game

Post by viking badger »

coffee wrote:Yes, it starts good now. Good work. I'm glad to help on that. But about the error exiting the battle it's still happen. However now I never can't tell what error happened to report to you. Won't be better disable your error-catcher for now?

I liked new backgrounds in text. More visible text.
Thanks. I ran it on my mac (OS X Lion) and couldn't recreate your problem, so I don't think it's an OS issue. Are you using Love 0.8.0? I turned off release mode. Think you could copy/paste the error and traceback?
coffee
Party member
Posts: 1206
Joined: Wed Nov 02, 2011 9:07 pm

Re: Badger Battle - Turn Based Game

Post by coffee »

viking badger wrote:
coffee wrote:Yes, it starts good now. Good work. I'm glad to help on that. But about the error exiting the battle it's still happen. However now I never can't tell what error happened to report to you. Won't be better disable your error-catcher for now?

I liked new backgrounds in text. More visible text.
Thanks. I ran it on my mac (OS X Lion) and couldn't recreate your problem, so I don't think it's an OS issue. Are you using Love 0.8.0? I turned off release mode. Think you could copy/paste the error and traceback?
So should be almost the same with my Snow Leopard. Vanilla 0.8 (don't even start with 0.7.2). Here is the error:

Code: Select all

Error: lib/tserial.lua:30: [string "TSerial.table={1234={state={curAttack=10,curEvasion=10,curDefen..."]:1: '}' expected near '='
stack traceback:
[C]: in function 'assert'
lib/tserial.lua:30: in function <lib/tserial.lua:28>
(tail call): ?
main.lua:162: in function 'saveGame'
scrn/winscreen.lua:9: in function 'load'
main.lua:273: in function 'changeScreen'
scrn/battlescreen.lua:396: in function 'nextTurn'
scrn/battlescreen.lua:84: in function 'update'
main.lua:78: in function 'update'
[string "boot.lua"]:407: in function <[string "boot.lua"]:373>
[C]: in function 'xpcall'
A thing that I remembered. Could some old saved profile file doing this?
User avatar
viking badger
Prole
Posts: 19
Joined: Sun Jul 08, 2012 1:00 am
Location: Denton, TX

Re: Badger Battle - Turn Based Game

Post by viking badger »

coffee wrote:A thing that I remembered. Could some old saved profile file doing this?
Yeah, I think that's what it is. I just modified TSerial a little bit to check for corrupt tables when loading a file. If it finds one, it will return "BAD_TABLE". When that happens, my loadProfiles() function will backup the profiles to "profiles.bkp" and delete all the old profiles. Hopefully that will fix your problem!
Gravy
Citizen
Posts: 80
Joined: Sun Jan 22, 2012 10:15 pm
Location: CA, USA

Re: Badger Battle - Turn Based Game

Post by Gravy »

Hi!

Nice job. I've been working on a turn-based battle system too. My solution to the turn order thing is that I have two "states" for combat, "planning" and "resolve". Basically, the planning state is when the player and the AI choose their actions. At the end, a "script" is created based on the actions and sorted by the initiative roll (if you've played some DND). The Resolve state just goes through the script (i.e. X does this, plays an animation and a sound, does X damage).

I don't know whether this is the best way to program turn based combat, but I've found that it's very flexible, in terms off adding multiple enemies and multiple actions per combatant. You just have to add things to the script.
User avatar
viking badger
Prole
Posts: 19
Joined: Sun Jul 08, 2012 1:00 am
Location: Denton, TX

Re: Badger Battle - Turn Based Game

Post by viking badger »

Gravy wrote:Hi!

Nice job. I've been working on a turn-based battle system too. My solution to the turn order thing is that I have two "states" for combat, "planning" and "resolve". Basically, the planning state is when the player and the AI choose their actions. At the end, a "script" is created based on the actions and sorted by the initiative roll (if you've played some DND). The Resolve state just goes through the script (i.e. X does this, plays an animation and a sound, does X damage).

I don't know whether this is the best way to program turn based combat, but I've found that it's very flexible, in terms off adding multiple enemies and multiple actions per combatant. You just have to add things to the script.
Ahh, I really like that! I was actually trying to think of a better way to implement my system, especially if I decide to have multiple enemies. Right now it's pretty clunky. My skills have a button, animation, and action attached to them. When the button is clicked, it does the animation then the action, then goes to the next turn. On the enemies turn, the AI chooses a skill (instead of clicking a button), then does the animation then the action.

If you don't mind, I might try to put something together based on a system more like yours. I really like the idea of just adding things to a script then running through that script.
Gravy
Citizen
Posts: 80
Joined: Sun Jan 22, 2012 10:15 pm
Location: CA, USA

Re: Badger Battle - Turn Based Game

Post by Gravy »

I don't mind at all. I'm glad you like the idea. Here's some more detail.

Each combat action in my system is structured like this:

attack = {
test = {},
preliminary = {},
success = {},
failure = {}
}

So the test is a function, something like this:

Code: Select all

function meleeTest(s, t, c)
	local roll = _rand(0,1)
	if (c.accMod + s.skills.melee*.05 + roll) > (.2 + t.skills.reflex*.05) then
		return true
	else
		return false
	end
end
Where s is "Self", t is "Target", and c is your attack choice (just so attacks can have accMod (accuracy modifier)). You can have a bunch of these for different types of attacks.

Preliminary is a script item, something like "X attacks Y"

Then if test returns true, you add "success" to the script, else add "failure" (Note that success is usually more than one script item, one for the attack and animation, and another to stop the animation, check to see if the enemy is dead, etc.)

Also, I just remembered the big flaw of this system. The script can't be entirely static in the Resolve state. You have to check for when the player or enemies die as the script is running. If an enemy dies, and there are more left, you have to search the script and take out and actions it had left (or have a check before you run each script item, like if x.hitpoints > 0). I suppose you could check all this stuff while the script is being created, but that seems more complicated to me.

Hope this helps. If you think of any awesome ways to improve this, let me know!
User avatar
viking badger
Prole
Posts: 19
Joined: Sun Jul 08, 2012 1:00 am
Location: Denton, TX

Re: Badger Battle - Turn Based Game

Post by viking badger »

Ahh yeah, that does present a bit of a problem. I think I'm going to hold off on any major restructuring of my battle system for now. As the saying goes, "if it ain't broke, don't fix it!" But I do plan on trying to reorganize things a little and I'll keep your ideas in mind while I do. I appreciate the insight!
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 2 guests