ID:161729
 
Hi, BYOND Developers. I was curious about a certain type of Battle System which involves limiting movements per turn. Meaning, if you engaged in a battle, a movement proc would begin similar to Fallout/Final Fantasy Tactics. An Image may help for what I'm talking about -



I am not sure how I'd spawn a tile to spread out in places you can walk to if it's your turn, but it wouldn't allow you to move to a solid position (wall, water, building, etc). A walk in the right direction, or an example would be excellent.

I am also gonna be spawning a barrier around the battlefield in which you fight at. So It's gonna be a large invisible square so other people on the map can't interfere. I know how to approach that, but not as well as I want. Thanks for reading my topic, and thanks to those who will lend a hand.
umm mabey trying somthing like
mob/var/move1=(number of tiles)
mob/var/move2=(number of tiles for a different species of w/e)
//then just add density for objs
obj/wall
icon = 'wall.dmi'
icon_state = "wall"
density = 1


mabey, buy im not sure



In response to RanEsu
RanEsu wrote:
umm mabey trying somthing like
> mob/var/move1=(number of tiles)
> mob/var/move2=(number of tiles for a different species of w/e)
> //then just add density for objs
> obj/wall
> icon = 'wall.dmi'
> icon_state = "wall"
> density = 1
>

mabey, buy im not sure




I think I'd probably make a check to see if a turf is dense, then I can't move there. That way I wouldn't have to add any additional code for each dense turf.
lucky for you, I just wrote this a few hours before you posted. I'm working pretty hardcore on a really complex roguelike which uses a similar system to FFT/D&D for movement.

First off, create an icon file with a red block with about 128 alpha. Name the file dither.dmi, and the icon_state "red".

Next, you are going to need to write the comb_turn datum, which handles movement and limitations, as well as allows a player in-combat to move.

comb_turn
var
mob/mob
combat/combat
atom/start_loc
move_left
list/images
can_move = 0
proc
create_radius()
var/size = src.move_left
var/center = src.start_loc
var/list/L = block(locate(max(1,center.x-size),min(center.y+size,world.maxy),center.z),locate(min(center.x+size,world.maxx),max(center.y-size,1),center.z))
src.images = list()
for(var/turf/T in L)
if(abs(T.x-center.x)+abs(T.y-center.y)<=size)
src.images += image(icon='dither.dmi',icon_state="red",layer=TURF_LAYER)
src.mob.client.images += images
moved()
if(src.move_left==0)
src.end_turn()
end_turn()
src.mob.client.images -= src.images
src.combat.turn_over()
New(var/mob/tm,var/cb)
src.combat = cb
src.mob = tm
src.start_loc = src.mob.loc
src.move_left = tm.move_dist
if(src.mob.client)
src.create_radius()
src.can_move = 1
src.mob.start_turn()


Now, you need to move on to the combat datum, which will handle the creation and flow of turns.

combat
var
order = 0
list/combatants = list()
comb_turn/turn
proc
turn_over()
del src.turn
src.next_turn()
next_turn()
src.order = (order)%(src.combatants.len)+1
var/mob/M = src.combatants[M]
src.turn = new/turn(M,src)
died(var/mob/M)
src.combatants -= M
M << "You have been defeated!"
if(src.turn.mob==M)
src.turn.end_turn()
if(src.combatants.len==1)
src.end_combat()
end_combat()
var/mob/M = src.combatants[1]
M << "You have won!"
del src
New(var/list/combtns)
src.combatants = combtns
for(var/mob/M in combtns)
M.combat = src
src.next_turn()


Last, you have to modify and add a few things in the mob object.

mob
var
combat/combat
proc
start_turn()
src << "Your turn has started!"
//this proc also opens the door for NPC AI
death() //call this when the player dies.
src.combat.died(src)
Move(var/newloc,var/ndir)
if(src.combat&&(src.combat.turn.mob!=src||src.combat.turn.can_move*src.combat.turn.move_left<=0))
. = ..()
if(.)
src.combat.turn.move_left -= 1
src.combat.turn.moved()
return .
return 0
verb
engage()
set src in oview(1)
usr << "You engage [src] in combat!"
src << "[usr] engages you in combat!"
new/combat(usr,src)


This is a really simplistic approach, and will need a lot of work done to it to be used in a game. This demonstrates the skeleton of my in-combat movement engine.

Have fun! I dunno if there are any errors, here, so just check with me if you find any. I had to REALLY water down my code to make it independent of all my other systems in my game, and I had to add a few bits, like the highlighting of terrain.
In response to RanEsu
Ever hear the phrase: "The blind leading the blind"?

That's an excellent example of it. Good on you for creating a fantastic example of the phrase.