Pawns reacting to Projectiles.

Topics regarding Scripting with Reality Factory
Post Reply
User avatar
GMer
Posts: 329
Joined: Thu Oct 25, 2007 4:49 pm
Location: On the rock in the 3rd solar orbit.

Pawns reacting to Projectiles.

Post by GMer » Sat Sep 26, 2009 8:46 pm

I was wondering (I'm back, W00T!) how I would make a pawn react to itself getting hit by a projectile, for example if it was hit by an explosion, it would fly backwards, land on its back for a bit, then get up again.
Over 3 years (has it been that long?) and just now I noticed the day and month of my birthday were switched. Whoops!

Some 2d games I made, haven't made anything in a year though O.o
http://www.yoyogames.com/users/GMer56

User avatar
metal_head
Posts: 1244
Joined: Sat Jan 05, 2008 8:31 pm
Location: Bulgaria,Sofia
Contact:

Re: Pawns reacting to Projectiles.

Post by metal_head » Sun Sep 27, 2009 6:18 pm

Well the projectiles have theese alt attributes, you'll have to add another attribute to the pawn and check in all of your low level orders if that attribute has decreased since the last time checked and if yes, go to a fly-back order :)

User avatar
GMer
Posts: 329
Joined: Thu Oct 25, 2007 4:49 pm
Location: On the rock in the 3rd solar orbit.

Re: Pawns reacting to Projectiles.

Post by GMer » Mon Sep 28, 2009 1:34 am

Aha, thank you.
For the flying backwards, I could use the jump command, somewhat like so? (This isn't the total script)

Code: Select all

Jump("flailing",128,false,"falling.wav")
// possibly a MoveBackward here?
Delay("crumpled",5+random(5),"")
Delay("getup",2,"getup.wav")
NewOrder(Lookaround)
The thing deciding when to do this would be similar to a pawn's health if I am not mistaken, using the alternate attribute instead of the main attribute.

I thank you metal head :) :) :) :)
Over 3 years (has it been that long?) and just now I noticed the day and month of my birthday were switched. Whoops!

Some 2d games I made, haven't made anything in a year though O.o
http://www.yoyogames.com/users/GMer56

User avatar
metal_head
Posts: 1244
Joined: Sat Jan 05, 2008 8:31 pm
Location: Bulgaria,Sofia
Contact:

Re: Pawns reacting to Projectiles.

Post by metal_head » Mon Sep 28, 2009 12:59 pm

Well I would suggest doing this in low level. You'll have to add a variable, with which we'll detect if the pawn's attribute has been decreased, let's say "TEMPHEALTH" and the script would look like this:

Code: Select all

SomeSetupOrderName[ ()
{
TEMPHEALTH = GetAttribute("Attributename");
self.think = "run";
} ]

run[ ()
{
if(GetAttribute("AttributeName") < TEMPHEALTH)
{
TEMPHEALTH = GetAttribute("Attributename");
self.think = "Flybackwards";
}

} ]

Flybackwards[ ()
{
ForceUp(80);
ForceBackward(80);
-----
And the animating stuff >>
} ] 
Now, I'm just giving an example of what it could be. For the flying back stuff I would use the ForceUp and Backward commands + an animation. BTW, this is low level, I don't think that there's a way of detecting if another attribute, given to the pawn has decreased, so you'll have to make all your orders that you wanna have this thing in in low level.

So you simply put this everywhere you want this feature:

Code: Select all

if(GetAttribute("AttributeName") < TEMPHEALTH)
{
TEMPHEALTH = GetAttribute("Attributename");
self.think = "Flybackwards";
}

Post Reply