ID:168462
 
I need some help coding a turn-based combat system, I want it to go to a battlefield, possibly using swap-maps, and have an HUD panel show up when it's your turn, maybe similar to F_click_menu, but I just don't know where to start at, I know how to code the spells...items...HUD...etc, just not the base turn system.

Reply if you can explain it.
Okay, easiest way and perhaps the best way is to use SwapMaps. In fact, it's probably the only way if you plan on havin a lot of players.

Anyway, have an object arrow. When it's moved, define an object in it's location and make sure you have it's pixel_x being -32. It's easiest that way. When you hit enter, call a proc that pertains to the object and delete he HUD, going on to the next person.

So, an example to help your further understand an easy way (I think at least.) of doing this. You have the commands on your screen, an arrow on Attack. The arrow will have a pixel_x of -32, that way you can look for an object in it's location, rather than getting an object to the right side of it. Note that the command text will have to be objects. Now, if you hit enter, look for an object of a certain type in the arrow's location and call a proc pertaining to what that object does. Then, get rid of it.

I find that you'll better understand this if I show it to you in some way.
obj/Battle
HUD
arrow
icon=''
icon_state=""
//HUD objects here
BattleText
Attack
icon=''
icon_state=""
proc/Execute()
//Attack stuff here
Run
icon=''
icon_state=""
proc/Execute()
//Run stuff here


Then have client/[Direction] overide it's function if you have a true variable set at the beggining of the battle, move the arrow. Then identify the object in the arrows location using something like
var/obj/O = locate(/obj/Battle/HUD/Arrow/) in src.client.screen

var/obj/Battle/BattleText/T=locate(/obj/Battle/BattleText/) in O.loc


And call the function T.Execute() if you are going to provide a few if() checks, or T:Execute() if you're just going to call the Execute(), knowingly that you have all the Execute proc's created. I'd suggest that you use src.Execute() with the checks and such, just to be safe.