Page 1 of 1

Pawn

Posted: Thu Jun 26, 2008 1:24 am
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.

Re: Pawn

Posted: Thu Jun 26, 2008 12:29 pm
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

Re: Pawn

Posted: Thu Jun 26, 2008 3:22 pm
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.

Re: Pawn

Posted: Thu Jun 26, 2008 7:56 pm
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

Re: Pawn

Posted: Fri Jun 27, 2008 1:37 am
by jon980
Image
I just started using this program and need to know how to script the pawn to move and attack.

Re: Pawn

Posted: Fri Jun 27, 2008 9:59 am
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. :)

Re: Pawn

Posted: Fri Jun 27, 2008 11:01 am
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'

Re: Pawn

Posted: Fri Jun 27, 2008 1:47 pm
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.

Re: Pawn

Posted: Fri Jun 27, 2008 1:51 pm
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

Re: Pawn

Posted: Wed Jul 02, 2008 2:05 am
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

Re: Pawn

Posted: Wed Jul 02, 2008 10:19 am
by metal_head
no idea...everything looks fine...

Re: Pawn

Posted: Wed Jul 02, 2008 10:40 am
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?

Re: Pawn

Posted: Wed Jul 02, 2008 10:43 am
by metal_head
Oh,haven't see that,yes if you want your pawn to see everything arround it,set the FOV to 360

Re: Pawn

Posted: Wed Jul 02, 2008 5:37 pm
by jon980
Great! It worked! Thanks for the help.

Re: Pawn

Posted: Sat Jul 05, 2008 8:11 pm
by steven8
You're welcome.