ID:163810
 
I want to make an obj that harms you when you step, or leap onto it. Like spikes. But I don't know how to make it KNOW when you are on it, and how to make the person who stepped on it 'bounce off'

Any help?
Avlein wrote:
I want to make an obj that harms you when you step, or leap onto it. Like spikes. But I don't know how to make it KNOW when you are on it, and how to make the person who stepped on it 'bounce off'

Any help?

Is your game a side-scroller, or a regular top-down map game? If it is a side-scroller, then you can just bounce off the player when they bump into it, however the method is different if it uses a conventional top-down map.

If you want an event to be triggered when an object enters another object's location, you cannot use the normal conventional means of Entered(), since that is called when an object enters another object's contents. An object's contents is its inventory, so you'll have to use another method. This other method is well explained in the forums and other resources, but the method is to define a proc to be called on the event an object enters the location of another object. This means we need to overwrite turf/Entered(). On the proc, we need to loop through all of the triggerable objects in the turf's location. This requires a for loop. In the loop, you should now call the obj's Trigger() proc. In this proc you can define actions you want to be done on the event. Here is a short snippet you can build upon.

turf/Entered(atom/movable/A) // any movable atom can enter a turf
for(var/obj/O in src.loc)
O.Trigger(A) // call the object's trigger proc, and send 'A' through the parameter in order to identify what triggered the event.

obj
proc
Trigger(atom/movable/A) // proc definition

spikes
Trigger(atom/movable/A)
// On the event something triggers a spike
// you want to make all players who enter jump off
// This requires checking if the object that entered is a player
if(ismob(A))
var/mob/M = A // type cast
M.JumpUp() // and do the action
In response to Unknown Person
Oops. Oh yeah. IT's a sidescroller.