So I need some ideas on how to go about making this work cleanly. In my first try I just had one big looping proc that was called to start a battle. That seemed like a good way to go until I got to turns. When a players turn starts I want to give \him some commands, and allow them to move around in a designated area without a time limit. I did that in a proc(TakeTurn(), for future reference) and had the main loop wait for a return value, but finding out when the turn was over is what seemed wrong to me. The only way I could think of to do it, was to have TakeTurn() loop every second and check a flag variable that is set when they finished there turn.
That's my main concern about this, but anything related to making this type of battle system should help out. I'm limiting the players movement to a diamond shape instead of a square(thanks to a snippet posted by Shadowdarke a while ago) and it's working as expected. I haven't tried to do anything to adjust the movement range to account for densities yet, so I might as well get some opinions on that as well. Examples:
Fig.1 Fig.2 Fig.3
o o
ooo ooo o o
ooooo ooDoo ooDoo
ooooooo ooooooo ooooooo
ooooo ooooo ooooo
ooo ooo ooo
o o o
o = Movement range
D = Density
This is with a movement range of 3.
This should explain what I intend to accomplish. I'd like to take any turf that is dense(or has something dense occupying it) out of the movement range.(Fig.2) Then I would like to remove any other turfs they couldn't get to with a certain number of steps(no diagonals).(Fig.3) Should I try to use some math(wich I'm not great at =p), a mix of get_dir() and get_dist(), or something else entirely to achieve this? Thanks for reading, and replying if you see fit. Now, I leave you with another example of the movement range idea. :p
o o
ooo ooo o o
ooooo ooooo ooooo
ooooooo oooDooo oooDooo
ooooooooo ooooooooo ooooooooo
ooooooo ooooooo ooooooo
ooooo ooooo ooooo
ooo ooo ooo
o o o
This is with a movement range of 4.
[EDIT] Here it is in it's full, uncommented form.
If some of the procs look familiar, they are. The procs cardinal() and xrange() are pulled straight from Abyssdragon.Basicmath, with minor to no modifications. I found it easier to use a couple of procs rather than use the full library as I was planning on releasing this as a library at some point (with full credit mind you). I believe that the formula for tactics_dist() was also pulled from Basic Math.