ID:918969
 
Default coding:
turf/tiles/green/Click(obj/pieces/red/r, obj/pieces/blue/b)
if(usr.player!=turn) return /*There are 2 players. One has an ID called usr.player and the other player's ID is called !usr.player*/
if(!usr.hold) return /* usr.hold is src of obj/pieces/blue/Click() or red depending on the ID*/
if(get_dist(usr.hold,src)>1) return /*Distance between the piece I'm holding and the source of where I am clicking*/
if((usr.player && usr.hold.y>src.y) | (!usr.player && usr.hold.y<src.y)) return /*Limiting the move from going backwards depending on who's turn it is*/
else if(usr.hold && !usr.mustjump && get_dist(usr.hold,src)>0) // must jump is true if there is a jump available
usr.hold.Move(src)
turn=!turn
world << "Global Turn is [turn]"
else if(usr.hold && usr.mustjump)
usr << "You must jump!"


Edited coding (coding I tried messing with to get results):
turf/tiles/green/Click(obj/pieces/red/r, obj/pieces/blue/b) //original coding
if(usr.player!=turn) return // if your player ID does not equal the turn number(1 or 0), its not your turn
if(!usr.hold) return // if you are not holding a piece, you can't move
if(usr.player)
for(b in get_step(usr.hold,get_dir(usr.hold,src))) // for as long as there's a piece in the tile where your piece is moving to
if(get_dist(usr.hold,src)==1) return // if the distance is 1, if its right by you, then do nothing
if(get_dist(usr.hold,src)>1) // if the distance between your figure and where you want to go is greater than 1 tile away
for(var/obj/pieces/p in get_step(usr.hold,get_dir(usr.hold,src))) // if there is a blue piece in the tile northwest, jump over it
del p
usr.hold.Move(src)
turn=!turn
usr.mustjump=1
for(var/obj/pieces/p in oview(1,/obj/pieces/red))
if(istype(p,/obj/pieces/red))
world << "You must jump"
return
if((usr.player && usr.hold.y>src.y) | (!usr.player && usr.hold.y<src.y)) return
else if(usr.hold && !usr.mustjump && get_dist(usr.hold,src)>0)
usr.hold.Move(src)
turn=!turn
world << "Global Turn is [turn]"
else if(usr.hold && usr.mustjump)
usr << "You must jump!"


Problem description: I am making a checkers game for DM practice. But I am stuck here! I am trying to do these:

1)Make it so my piece jumps over enemy pieces
2)Make it so my piece must jump over other piece when its time. Alert and cancel out any other jump.
3)Make so it won't jump 2 tiles in another direction
4)When locked pieces at the end of both sides, you can move
5)If pieces block the jump, the piece can move elsewhere

But I can't figure out how to do it. For one thing I can't figure out how to separate each individual pieces. If I wanted to make it so when 2 pieces are near each other to make the piece jump over another, I don't know how to do it.
Well, assuming you're using turfs in this, it should be rather simple. You can make the pieces all objs, then you'd clearly have two different turfs(one for one color and another for the other). You can then use Click() and variables to keep track of which piece is clicked, then Click() to determine if the obj can enter the turf you click on. And Bump() to take out any opposing pieces, of course you'd have to check inside Click() for the turf if there's something blocking you from jumping that piece.

obj/Click()
usr.selected=src
turf/Click()
if(can_enter(usr.selected, src)) step_to(usr.selected, src)

Note: the above isn't intended to be used, it wont work. It is only meant to show an example to what I am talking about.
I already have all those but Bump() proc. How will it work if the pieces are right by each other not touching each other?
You have to move the piece to the selected tile, correct? You simply move it there instead of 'teleporting' it to the location, that'll cause it to take Bump() into anything in it's path.

You can get the distance and availability of a tile uppon Click() to see if it's within range, and you can check the dir to check if the piece can move in that direction(kings can move backwards aswell as forwards).
How do I check the distance between an "individual" piece against another individual piece?
get_dist
What would be the arguments of get dist?
In response to TheDarkChakra
It's a built in proc that you can find by simply pressing F1 in Dream Maker and typing in "get_dist".
No in my case what would be the arguments of get dist? How do i differentiate the pieces?
Click() usr.selected Click()

obj/Piece1
obj/Piece2
I don't get this. And step_to/walk_to just makes it move a little in that direction and not all the way. Seems I gotta use Move proc after all
In response to TheDarkChakra
step_to only takes a step to the location provided. You can call this multiple times.

while(src.loc!=newloc)
step_to(src,newloc)
I did that and it still takes one step and stops.

else if(usr.hold && !usr.mustjump && get_dist(usr.hold,src)>0)
var/newloc=src
while(src.loc!=newloc)
step_to(usr.hold,newloc)
sleep(1)
In response to TheDarkChakra
You're defining newloc as src. It's gonna end in a bad time.

usr.hold is the piece they chose, correct? then newloc should be locate(usr.hold)
No the src is the tile

turf/tiles/green/Click(obj/pieces/red/r, obj/pieces/blue/b)
I am not saying it isn't. I assumed as such.
        var/newloc=src
while(src.loc!=newloc)

If you do not see the issue there, you probaly should unplug your computer.
I changed it to this:

var/newloc=src
while(usr.hold.loc!=newloc)
step_to(usr.hold,newloc)
sleep(1)

It doesn't work either.
In response to TheDarkChakra
Because usr.hold.loc isn't valid. Try using locate(usr.hold)
This:

var/newloc=src
while(locate(usr.hold)!=newloc)
step_to(usr.hold,newloc)
sleep(1)
?
Didn't work :(.
Page: 1 2