ID:2000440
 
So im trying to setup code for a turn based rpg. The battle system I'm getting stuck on. The battles would be like the old school final fantasy. I have the initiating the fight done using bump but its the multiples problems of gathering multiple mobs, pausing actions till its the correct mobs turn, having a timer, and turn order that are getting me stopped up for the moment. Any advice will help.
mind you none of this has been tested yet i sorta winged it off the top of my head so tell me if im missing anything i shouldnt be though even though it was typed off my phone xD.
/mob
var
turn = null
_turn_time = 100
proc
_get_turn(mob/a)//gets the mob's turn.
if(istype(a,/mob)) //checks if its a mob.

a.turn = TRUE //it is now the mob's turn.
world.log << "it is now your turn." //test output.

_count_time(a) //activate counting proc.

sleep(a._turn_time) //determines the amount of time a player / mob has to attack.
a.turn = null //now it is not times up!

world.log << "your time is up !" //test output.

attack()
if(!turn)
return

else if(turn)
//proceed with the proc.

_count_time(mob/a) //count down bih!
var/map_text/m = new() //map text stuff.
client.screen += m //add's to the screen.

while(a.turn) //while it is still your turn.
if(!turn) //if set to false deletes our maptext datum object off the screen.
client.screen -= m //delete maptext off screen.

sleep(10) //hold on bih dont crash xD.
var/_temp_turn_time = a._turn_time //a temporary turn timer.
_temp_turn_time -- ; m.maptext = "[_temp_turn_time]" //reduces turn time.

world.log << "time left [_temp_turn_time] !" //display time left bih.

map_text
parent_type = /obj
New(client/c)
c.screen_loc = "1,1"//set the screen loc.

not trying to over complicate stuff for you tried making it simple , hopefully this help's you get the jist though i've never done turn based things so this is just how i think it would be passed down.
In response to Hebrons
Hebrons wrote:
>           while(a.turn == TRUE)           //while it is still your turn.
> if(turn == FALSE) //if set to false deletes our maptext datum object off the screen.
> client.screen -= m //delete maptext off screen.
>
> spawn(10) //hold on bih dont crash xD.
> var/_temp_turn_time = a._turn_time //a temporary turn timer.
> _temp_turn_time -- ; m.maptext = "[_temp_turn_time]" //reduces turn time.
>
> world.log << "time left [_temp_turn_time] !" //display time left bih.


This will still crash, I'm assuming you want a sleep instead of a spawn in here.
you see i didnt even notice haha silly mistake.
Well ill tweak this to fit for the game but i still got to grab multiple mobs into the battle and pausing actions. I dont know how to stop the players from mashing commands when its not their turn. Thanks btw guys for the turn timer stuff
no problem (; , and just put this in all of your commands.
            if(!turn)
return

else if(turn)
//proceed with the proc.
In response to Hebrons
Don't do this, as the semantics don't match the actual behavior. If turn = null, then turn is false but turn != FALSE. Likewise, if turn = 2 then turn is true but turn != TRUE.
I dunno what you did with the other code you posted, but doing turn != TRUE for false and turn != FALSE for true still won't work. E.g., null is considered false in DM, and null != TRUE is true, so that would evaluate as true.

The correct way to do it is just use boolean evaluation.
if(turn)
// Do something if turn is true (not equal to 0, "", or null).
else if(!turn)
// Do something else if turn is false (equal to 0, "", or null).


Values considered false in DM are 0, "" (a 0-length string), and null. At least, IIRC these are the false values.