Pawn

Topics regarding Scripting with Reality Factory
Post Reply
User avatar
jon980
Posts: 10
Joined: Wed Jun 25, 2008 1:26 am

Pawn

Post by jon980 »

Hi, I'm new to RF and I created a level with a basic pawn. It just stands there and I can't kill it. Can anyone help me with scripting? The only script I have is the very basic one from the manual. I don't really understand the advanced part. Call me stupid if you want.
User avatar
metal_head
Posts: 1244
Joined: Sat Jan 05, 2008 8:31 pm
Location: Bulgaria,Sofia
Contact:

Re: Pawn

Post by metal_head »

I see that you have read the manual,that's good.You are using the robot right?Well your Pawn entity should look like this:
PawnType robot <---I assume you've already done this
ScriptName robot.s <---this is the script for the robot
SpawnOrder Spawn <---well,this is very important,because this line defines what command from the script should the pawn execute.If you open the robot.s script you'll see that in there the first oreder is called Spawn.

If theese three lines are correct your pawn should work
User avatar
jon980
Posts: 10
Joined: Wed Jun 25, 2008 1:26 am

Re: Pawn

Post by jon980 »

Thanks, but my problem is that it just stands there and I can't kill it. I want it to attack me and walk around.
User avatar
metal_head
Posts: 1244
Joined: Sat Jan 05, 2008 8:31 pm
Location: Bulgaria,Sofia
Contact:

Re: Pawn

Post by metal_head »

well,tell me more about the problem,what have you done so far,did you used the right script or I don't know,give me a screenshot of your pawn entity,I want to see where could the problem be
User avatar
jon980
Posts: 10
Joined: Wed Jun 25, 2008 1:26 am

Re: Pawn

Post by jon980 »

Image
I just started using this program and need to know how to script the pawn to move and attack.
User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Re: Pawn

Post by Juutis »

The SpawnOrder must be 'Spawn', not 'spawn'. There's a difference.

Welcome to the forums. I hope you have a good time with RF. :)
Pain is only psychological.
User avatar
metal_head
Posts: 1244
Joined: Sat Jan 05, 2008 8:31 pm
Location: Bulgaria,Sofia
Contact:

Re: Pawn

Post by metal_head »

SpawnOrder Spawn <---well,this is very important,because this line defines what command from the script should the pawn execute.If you open the robot.s script you'll see that in there the first oreder is called Spawn
I wrote Spawn not spawn,but have forgoten to tell about the big 'S'
User avatar
QuestOfDreams
Site Admin
Posts: 1520
Joined: Sun Jul 03, 2005 11:12 pm
Location: Austria
Contact:

Re: Pawn

Post by QuestOfDreams »

Just using a different script won't teach jon980 how to use the scripting feature of RF.
Hi, I'm new to RF and I created a level with a basic pawn. It just stands there and I can't kill it.
That's fine, the basic script in the manual isn't supposed to do more than play the idle animation of the pawn's actor.
Can anyone help me with scripting? The only script I have is the very basic one from the manual. I don't really understand the advanced part. Call me stupid if you want.
First, if you start to write a new script it's always good to add

Code: Select all

Console(true);
as the first method in the SpawnOrder. This will show you if the script gets executed without errors in-game.

If you want the pawn to get killed by the player you have to:
a) give the pawn some health
b) tell the pawn what to do when the health value reaches zero

This can be done by using the script method AttributeOrder(string AttributeName, int Amount, string Order);
This will give the pawn an attribute called AttributeName and will initialize it to Amount.
Order is the script order that gets executed when the attribute value reaches zero.

The default player weapons are affecting the attribute enemy_health. So you need to give your pawn this attribute as its health attribute.

Code: Select all

AttributeOrder("enemy_health", 100, "Death");
We need to add a new order called Death to the script now, eg

Code: Select all

Death[()
{
	SetNoCollision();		// remove bounding box so there are no collisions with corpse
	AnimateStop("Die", 15, "");	
	FadeOut(10, 0); 		// fade out corpse
	Remove(true);		// remove actor
}]
This will turn off collision detection for the pawn,
play a dying animation, wait 15 seconds,
fade out the actor within 10 seconds,
remove the pawn's actor from the level and stop the execution of the script.

The complete script would be

Code: Select all

{
	Spawn[()
	{
		Console(true);
		AttributeOrder("enemy_health", 100, "Death");
		NewOrder("Idle");
	}]
	
	Idle[()
	{
		PlayAnimation("Idle", true, "");
		RestartOrder();
	}]
	
	Death[()
	{
		SetNoCollision();		// remove bounding box so there are no collisions with corpse
		AnimateStop("Die", 15, "");
		FadeOut(10, 0); 		// fade out corpse
		Remove(true);			// remove actor
	}
}
Note that I moved the PlayAnimation and RestartOrder methods to a separate order as we want to call the Console and AttributeOrder methods only once.
User avatar
QuestOfDreams
Site Admin
Posts: 1520
Joined: Sun Jul 03, 2005 11:12 pm
Location: Austria
Contact:

Re: Pawn

Post by QuestOfDreams »

More info about scripting:
E-Book: Making 3D Games with Reality Factory (on the downloads page)
The RF Manual: Component Reference -> Scripting
Sample scripts in your RF installation
Simkin documentation: http://www.simkin.co.uk/Docs/cpp/index.html
User avatar
jon980
Posts: 10
Joined: Wed Jun 25, 2008 1:26 am

Re: Pawn

Post by jon980 »

Thanks everyone, it really helped. Only one problem, I was editing things like the heath, shoot range, and sight, but than they stopped attacking me in the game and they never even noticed me. Can someone help? Here's the robot.s part of the script that I changed, the rest is the same as it came with when I downloaded RF:

{

IDLE [idle] // idle animation
WALK [walk] // walk animation
DIE [die] // die animation
SHOOT [shoot] // shoot animation
MISC1 [slump] // misc1 animation

GROUP [robot]
HOSTILEPLAYER [true] // hostile to player
HOSTILESAME [false] // hostile to same Pawn group

HEALTHATTRIBUTE [enemy_health] // name of pawns health attribute
HEALTH [300] // initial pawn health
DAMAGEATTRIBUTE [health] // attribute damaged by attack

ALERTTRIGGER [AlertG] // name of alert trigger
DIEHOLD [15] // time corpse still appears
DIEFADE [10] // fadeout time of corpse

FOV [1000] // field of view
SIGHTDIST [1400] // max distance pawn can see at idle
ALERTSIGHTDIST [1800] // max distance pawn can see when alert
YAWSPEED [110]
WALKSPEED [70]

SHOOTRANGE [700] // max distance to start missile attack
PROJECTILE [10mm_shell] // projectile name
FIREBONE [Joint15] // projectile launch bone
OFFSETX [0] // launch offsets
OFFSETY [0]
OFFSETZ [25]
ATTACKDELAY [0.5] // time between shots
FIREDELAY [0.1] // delay after animation starts before projectile launch
SKILL [7] // skill level 1 to 10

LOSTTIME [15] // time to search for enemy before giving up
POINTRADIUS [20] // radius from point when considered there

RUNFUNC [run_start] // monster run to attack function
SHOOTFUNC [shoot_start] // monster missile function
LOSTFUNC [lost_target_start] // monster lost target function
User avatar
metal_head
Posts: 1244
Joined: Sat Jan 05, 2008 8:31 pm
Location: Bulgaria,Sofia
Contact:

Re: Pawn

Post by metal_head »

no idea...everything looks fine...
User avatar
steven8
Posts: 1487
Joined: Wed Aug 24, 2005 9:08 am
Location: Barberton, OH

Re: Pawn

Post by steven8 »

FOV:
SetFOV(float Angle );
Set the field of view of the Pawn to be Angle degrees. This is the total number of
degrees from left to right that the Pawn can see. The center of the FOV is the
direction the Pawn is facing.
Max Degrees would be 360. Maybe that 1000 is throwing things off?
Steve Dilworth - Resisting change since 1965!
User avatar
metal_head
Posts: 1244
Joined: Sat Jan 05, 2008 8:31 pm
Location: Bulgaria,Sofia
Contact:

Re: Pawn

Post by metal_head »

Oh,haven't see that,yes if you want your pawn to see everything arround it,set the FOV to 360
User avatar
jon980
Posts: 10
Joined: Wed Jun 25, 2008 1:26 am

Re: Pawn

Post by jon980 »

Great! It worked! Thanks for the help.
User avatar
steven8
Posts: 1487
Joined: Wed Aug 24, 2005 9:08 am
Location: Barberton, OH

Re: Pawn

Post by steven8 »

You're welcome.
Steve Dilworth - Resisting change since 1965!
Post Reply