ID:171714
 
Hello. I'm having some problems.

turf
LoseLife
density = 0
Enter(mob/M)
M.loc=locate(1,4,1)
usr.Life -= 1
usr.die()

When i fall down onto the above turf. it doesn't move me to the location as shown. instead i have to move east or west into it manualy for the thing to go into effect.
What i want to happen is that for when falling down i want it to instantly move the character to the stated location.

note: like in the megaman games. if u fall on spikes u move to another location.

please help some1

P.S. I'm not making a MegaMan Game, lol
Erm, try Bump().
In response to Hell Ramen
Hell Ramen wrote:
Erm, try Bump().

Well i tried the Bump() but i got a
error:Bump :undefined proc
In response to ElderKain
If you're using Bump, make the turf a mob, ...

mob/LoseLife
Bump(M as mob)
and so on...


There's better ways of doing this but for a quick fix that'll do it.
In response to The Conjuror
The Conjuror wrote:
If you're using Bump, make the turf a mob, ...

mob/LoseLife
Bump(M as mob)
and so on...


There's better ways of doing this but for a quick fix that'll do it.

Now I Get
mob
LoseLife
Bump(M as mob)
M.loc=locate(1,4,1)
usr.Life -= 1
usr.die()

and that gives a
error:M.loc:undefined var
In response to ElderKain
Im sorry, to fix that just use src.loc...etc, but you've made me realize something I never knew, this entire time I thought that Bump() only reffered to mobs, especially when you define it as mob/Bump(m as mob), but now I know it doesn't because I quickely wrote the lines..
mob/Bump(m as mob)
src.loc = locate(1,1,1)
in a new enviro file and found that when I ran not only into a mob I created but also turfs I would be teleported back to 1,1,1.... I can't believe with all these years I never knew that. Sorry for the confusion, but thanks for making me realize this.
In response to The Conjuror
for some reason it isn't working I have this

mob/LoseLife/Bump(M as mob)
src.loc = locate(1,4,1)
usr.Life -= 1
usr.die()

And when I fall from a ledge in the game i'm working on, nothing happens. I don't know what is wong. Can some1 post what type of coding like is done in like the sidescroller games that makes this happem. I'm stuck.
In response to ElderKain
As I said, this will solve your problem but make other problems possibly.

mob/Bump(M as mob)
src.loc = locate(whatever)
etc

just, mob/Bump, leave it at that and it should work but it may cause other problems.
In response to The Conjuror
The Conjuror wrote:
As I said, this will solve your problem but make other problems possibly.

mob/Bump(M as mob)
src.loc = locate(whatever)
etc

just, mob/Bump, leave it at that and it should work but it may cause other problems.

That just makes it worse. That makes it to where when I bump into anything it moves me to the location. I'm making it to where when the user falls down onto it because of a gravity proc. then it moves the player to the location.
In response to ElderKain
obj
DIEEEEE
Bump(mob/M)
M.life -= 1
M << "You have died..."
M.loc locate = (1,1,1)

Should work.
In response to Hell Ramen
Hell Ramen wrote:
> obj
> DIEEEEE
> Bump(mob/M)
> M.life -= 1
> M << "You have died..."
> M.loc locate = (1,1,1)

Should work.

sorry Hell Ramen That doesn't work right.
ElderKain wrote:
Hello. I'm having some problems.

turf
LoseLife
density = 0
Enter(mob/M)
M.loc=locate(1,4,1)
usr.Life -= 1
usr.die()

When i fall down onto the above turf. it doesn't move me to the location as shown. instead i have to move east or west into it manualy for the thing to go into effect.
What i want to happen is that for when falling down i want it to instantly move the character to the stated location.

note: like in the megaman games. if u fall on spikes u move to another location.

please help some1

P.S. I'm not making a MegaMan Game, lol

turf
LoseLife
density = 0
Entered(mob/M)
if(ismob(M))
M.loc=locate(1,4,1)
M.Life -= 1
M.die()
In response to Wanabe
sorry that doesn't work either.
In response to ElderKain
Bump for more help. all the suggestions that have been made don't work for me some odd reason.
ElderKain wrote:
When i fall down onto the above turf. it doesn't move me to the location as shown. instead i have to move east or west into it manualy for the thing to go into effect.

This makes me think the problem is in your gravity proc, it seems like you are setting loc directly instead of using Move() to make them go south. Changing it that way could cause some adverse effects though, namely, if you ever lock movement for mobs some could be stuck in the air. So you can either use Move() in gravity and not lock movement (or not worry about people getting locked in air), or you can add a bit to the gravity proc to check if the players new location is of type /turf/LoseLife.
In response to YMIHere
Yeah, that would probably be it. You should use Move() as opposed to setting loc directly whenever possible.

Even better for gravity would be step():

step(src, SOUTH)
In response to Crispy
This is the Gravity Proc I'm using
proc
Gravity(var/mob/M)
if(M.dir == EAST)
if(M.inair == 1)
var/turf/check = locate(M.x,M.y-1,M.z)
if(check.density == 1)
M.inair = 0
return
else
M.loc=locate(M.x,M.y-1,M.z)
sleep(2)
Gravity(M)
else
return 0
if(M.dir == WEST)
if(M.inair == 1)
var/turf/check = locate(M.x,M.y-1,M.z)
if(check.density == 1)
M.inair = 0
return
else
M.loc=locate(M.x,M.y-1,M.z)
sleep(2)
Gravity(M)
else
return 0

Note:It also requires a client addon also, mabue something needs done to it also
client
Northeast()
return
Northwest()
return
Southeast()
return
Southwest()
return
North()
if(src.mob.dir == EAST)
if(src.mob.inair == 0)
src.mob.inair = 1
for(var/i=1,i<4,i++)
src.Move(locate(src.mob.x,src.mob.y+1,src.mob.z),NORTH)
src.mob.dir = EAST
sleep(2)
Gravity(src.mob)
return
else
return
if(src.mob.dir == WEST)
if(src.mob.inair == 0)
src.mob.inair = 1
for(var/i=1,i<4,i++)
src.Move(locate(src.mob.x,src.mob.y+1,src.mob.z),NORTH)
src.mob.dir = WEST
sleep(2)
Gravity(src.mob)
return
else
return
East()
..()
if(src.mob.inair == 0)
var/turf/checkdense = locate(src.mob.x,src.mob.y-1,src.mob.z)
if(checkdense.density == 0)
src.mob.inair = 1
Gravity(src.mob)
return

West()
..()
if(src.mob.inair == 0)
var/turf/checkdense = locate(src.mob.x,src.mob.y-1,src.mob.z)
if(checkdense.density == 0)
src.mob.inair = 1
Gravity(src.mob)
return
South()
if(src.mob.inair == 1)
return


mabye some1 could show this Gravity proc addon thing, lol i'm kinda not that good at understanding coding, lol i'm sill adjusting to some terms in coding.
In response to ElderKain
There are some problems here. First things first, there is no difference between what you do for players facing east and players facing west, so use the logical or (||) operator.

proc
Gravity(var/mob/M)
if(M.dir == EAST || M.dir == WEST)
if(M.inair == 1)
var/turf/check = locate(M.x,M.y-1,M.z)
if(check.density == 1)
M.inair = 0
return
else
M.loc=locate(M.x,M.y-1,M.z)
sleep(2)
Gravity(M)
else
return 0


Now we can take another chunk out of this using step() as Crispy suggested. =)

proc
Gravity(var/mob/M)
if(M.dir == EAST || M.dir == WEST)
if(M.inair == 1)
if(!step(M,SOUTH))
M.inair = 0
else
spawn(2)
Gravity(M)
else
return 0


This may look a bit confusing to you so allow me to explain. step(M,SOUTH) will return 1 if M is able to move south, and 0 otherwise. It will also move the player if it can, even when called from inside an if statement. You may also notice I changed the sleep() to a spawn(), that's because you are calling the Gravity proc from withing itself. If you use sleep() the Gravity proc won't continue until the Gravity proc returns, but the Gravity proc won't return because it, too, will be waiting for the Gravity proc to return. Do you get what I'm saying here? The Gravity proc will never return and it will keep calling more (which is what we call stacking) quickly crashing your game in the proccess. What spawn() does is call the Gravity proc again, but allow the first one to finish without waiting for a return value. =)

Hope this helps. =)
In response to YMIHere
the thing with this
proc
Gravity(var/mob/M)
if(M.dir == EAST || M.dir == WEST)
if(M.inair == 1)
if(!step(M,SOUTH))
M.inair = 0
else
spawn(2)
Gravity(M)
else
return 0

is that when jumping u can't change directions.
the way it was, there was smooth turning. the user wouldn't thave to take an extra turn just to get it to go the opposite direction. but still this doesn't answer my first questiong of all. How can i get it to where when the user falls south due to the Gravity Proc, and when fallin' on cirtain area, it will move the user to the epecified location.
There have been many attempts to help. but none have actualy worked right.
In response to ElderKain
Ok, use this, it'll work, sorry for all the confusion on such a simple thing, dunno where my head was...

mob/Bump(mob/M)
if(istype(M,/mob/Die))
src << "You died!"
src.loc = locate(1,4,1)
die()
return

Page: 1 2