Scripted Stomp OTG

msmalik681

OpenBOR Developer
Staff member
I wanted to make a ground attack that only triggers if their is a valid target. I ended up using the default engine method but here was what I came up with for the keyscript solution. This might be useful to someone.  for this to work your stomp move in the example freespecial15 must have a range value and enemies fall animation must have a bbox.

Code:
#define OBC openborconstant
#define GEP getentityproperty
#define CEP changeentityproperty
#define SLV setlocalvar
#define GLV getlocalvar

void self = GLV("self"); //Get calling entity
void exists = GEP(self, "health")>1?1:NULL(); // Is caller alive
 if (OBV("in_level") && exists)
 {

int playerIndex = GEP(self,"playerindex"); //Get player by index
void jump = playerkeys(playerIndex, 1, "jump"); //New key status of "Jump"
void downH = playerkeys(playerIndex, 3, "movedown"); //New key status of holding "Down"

	if(jump && downH)
	{//Stomp attack
	void target = findtarget(self, OBC("ani_freespecial15"));
	
		if( target &&	 GEP(target,"aiflag","drop") && 	// check if target valid and has been knocked down
						!GEP(target,"aiflag","falling") && 	// check if no longer falling
						 GEP(target,"health") 				// check if still alive
		){  // otg stomp attack
CEP(self, "velocity", 0, 0, 0);
performattack (self, OBC("ani_freespecial15"));
}
		
	target = NULL();
	}
}

The reason I did not use this is if there is a closer enemy that is not downed it will not trigger and my stomp attack has a bit of range as you jump onto the target.
 
Back
Top Bottom