generic player- camera won't attach and he's not moving

Topics regarding Scripting with Reality Factory
Post Reply
wabogenadod
Posts: 18
Joined: Mon Dec 17, 2012 9:59 pm

generic player- camera won't attach and he's not moving

Post by wabogenadod »

Hi.
I'm trying to use an adaption on the generic player to make a scripted player but it isn't working.
The actor I'm using is virgil and at the moment I'm just trying to get it to run through the pawn. However, the player loads and the actor virgil simply stands idle in the corner where i placed him. He doesn't move when i press the buttons. Just stands in idle. The code I'm using is:

{
FIREAMMO [pistolbullet] // Projectile fired by pawn
FIREEFFECT [Electric] // muzzleflash effect
WEAPONMODEL [Laser] // Weapon held by pawn
FIRERATE [0.1] // Weapon firing rate
GROUP [Friendly] // Pawn Group - must be targetted by enemies
PLAYERSPEED [96] // Walk Speed
HEALTHATTRIB [health] // health attribute given to pawn
HEALTHAMOUNT [500] // amount of health given to pawn
DAMAGEATTRIB [health] // Atribute damaged by pawn
BOX [24] // Box width

IDLEANIM [Idle] // Idle AnimationSpeed
SHOOTANIM [Shoot1] // Shoot anim
WALKANIM [Walk] // Walk anim
BACKANIM [WalkBack] // Walk back anim
STRAFELEFT [SStrafeLeft1] // Strafe left anim
STRAFERIGHT [SStrafeRight1] // Strafe right anim
INTERANIM [Slash2] // Pawn interact anim
DEATHANIM [Die] // Death Anim
ROOTBONE [Bip01] // Pawn root bone
WEAPONHAND [Bip01 R Hand] // Pawn weapon bone

K_INTER [73] // INTERACT KEY - RIGHT MOUSE
K_FIRE [72] // FIRE KEY - LEFT MOUSE
K_FOR [15] // FORWARD - W
K_BAK [27] // BACK - S
K_LEFT [26] // STRAFE LEFT - A
K_RIGHT [28] // STRAFE RIGHT - D
K_RUN [36] // RUN - LEFT SHIFT KEY

ANIM [string] // Do Not Edit
ANC [0] // Do Not Edit
LASTANC [0] // Do Not Edit
DIR [0] // Do Not Edit
AT [0.5] // Do Not Edit
INTER [string] // Do Not Edit
TM [0] // Do Not Edit
SPEED [0] // Do Not Edit

Spawn[()
{
Console(True);
BoxWidth(BOX);
SetGroup(GROUP);
AttributeOrder(HEALTHATTRIB, HEALTHAMOUNT, "Die");
SetWeapon(WEAPONMODEL);
LowLevel("Setup");
}]

Setup[()
{
AttachCamera();
self.yaw_speed=256;
AnimateHold(IDLEANIM);
ANIM=StringCopy(IDLEANIM);
ANC=0;
LASTANC=0;
TM=self.time;
self.think="RunPlayer";
}]

RunPlayer[()
{
//debug(self.key_pressed);
PlayerRender(false);
self.ideal_yaw=self.player_yaw;
ChangeYaw();

DIR=0; // Default straight
SPEED=0; // Default - no motion
AT=0.1; // Default
ANC=0; // Default
AnimationSpeed(1); // Default

// handle health status
if(self.health < 1)
{
HighLevel("Die");
return 0;
}

// handle controls
//if(IsKeyDown(K_INTER))
//{
//strike/interact
// AnimateBlend(INTERANIM, 0.25);
// self.think="Interact";
// return 0;
//}

if(IsKeyDown(K_FOR))
{
// forward
ANIM=StringCopy(WALKANIM);
ANC=2;
SPEED=Integer(PLAYERSPEED);
}

if(IsKeyDown(K_BAK))
{
// back
ANIM=StringCopy(BACKANIM);
ANC=3;
DIR=ConvertDegrees(180);
SPEED=Integer(PLAYERSPEED);
}

if(IsKeyDown(K_LEFT))
{
// strafe left
ANIM=StringCopy(STRAFELEFT);
// make strafe transition smoother
AT=0.5;
ANC=4;
DIR=ConvertDegrees(90);
SPEED=Integer(PLAYERSPEED);
}

if(IsKeyDown(K_RIGHT))
{
// strafe right
ANIM=StringCopy(STRAFERIGHT);
// make strafe transition smoother
AT=0.5;
ANC=5;
DIR=ConvertDegrees(270);
SPEED=Integer(PLAYERSPEED);
}

if(IsKeyDown(K_FIRE))
{
// fire
if(ANC < 1)
{
//only go to shoot anim if at idle
ANIM=StringCopy(SHOOTANIM);
ANC=1;
}
// Check fire rate
if(self.time > TM+FIRERATE)
{
TM=self.time;
FireProjectileBlind(FIREAMMO, WEAPONHAND, 0, 0, 0, DAMAGEATTRIB);
AddExplosion(FIREEFFECT, WEAPONHAND, 0, 0, 0);
TM=self.time;
}
}

if(ANC < 1)
{
//no button
ANIM=StringCopy(IDLEANIM);
AT=0.5;
}

if(IsKeyDown(K_RUN))
{
//left shift key - toggle run
AnimationSpeed(1.5);
SPEED=SPEED+(SPEED/2);
}

//handle animations
if(Integer(LASTANC) != Integer(ANC))
{
AnimateBlend(ANIM,AT);
}
LASTANC=Integer(ANC);
if(self.animate_at_end)
{
AnimateHold(ANIM);
}

//handle motions
walkmove(self.current_yaw+DIR,SPEED);
}]

//Interact[()
//{
// if(self.animate_at_end)
// {
// INTER=TraceToActor(ROOTBONE, 0, 0, 32);
// if(INTER != "FALSE")
// {
// SetEventState(INTER # "Trigger", true);
// }
// self.think="RunPlayer";
// return 0;
// }
//}]

Die[()
{
AnimateStop(DEATHANIM, 0, "Die");
}]
}

The code I'm using for this pawn in Pawn.ini is:

[scriptedvirgil]
actorname = Virgil.act
actorrotation = -90 180 0
actorscale = 1.5
fillcolor = 255 255 255
ambientcolor = 255 255 255
subjecttogravity = true
boundingboxanimation = Idle
shadowsize = 30

And in the pawn entity i have:

PawnType scriptedvirgil
Scriptname genericplayer.s
SpawnOrder Spawn

I don't really understand what I'm doing wrong here but then again I am new.
Thanks
User avatar
steven8
Posts: 1487
Joined: Wed Aug 24, 2005 9:08 am
Location: Barberton, OH

Re: generic player- camera won't attach and he's not moving

Post by steven8 »

I have never successfully created a scripted player, so hopefully someone else will be able to give you a hand. Have you created a working level with the standard player(s) yet?

I did, however stop by to welcome you to RF! It's a little old, and a little rusty, but it's darned good, clean fun!! Enjoy!
Steve Dilworth - Resisting change since 1965!
wabogenadod
Posts: 18
Joined: Mon Dec 17, 2012 9:59 pm

Re: generic player- camera won't attach and he's not moving

Post by wabogenadod »

Yeah. I have but i reached its limits pretty quickly.
User avatar
steven8
Posts: 1487
Joined: Wed Aug 24, 2005 9:08 am
Location: Barberton, OH

Re: generic player- camera won't attach and he's not moving

Post by steven8 »

wabogenadod wrote:Yeah. I have but i reached its limits pretty quickly.
Yes, that is true. For the player character. However, in the meantime, you can experiment with Pawns. Try modeling enemies and working with those monster scripts. That will also help you get familiar with the scripting.
Steve Dilworth - Resisting change since 1965!
User avatar
QuestOfDreams
Site Admin
Posts: 1520
Joined: Sun Jul 03, 2005 11:12 pm
Location: Austria
Contact:

Re: generic player- camera won't attach and he's not moving

Post by QuestOfDreams »

Code: Select all

FIREAMMO [pistolbullet] // Projectile fired by pawn
FIREEFFECT [Electric] // muzzleflash effect
WEAPONMODEL [Laser] // Weapon held by pawn
Are these objects defined in the respective INI files (weapon.ini, explosion.ini, pawn.ini)?
wabogenadod
Posts: 18
Joined: Mon Dec 17, 2012 9:59 pm

Re: generic player- camera won't attach and he's not moving

Post by wabogenadod »

Yeah, that's what the problem was.
Thanks
User avatar
steven8
Posts: 1487
Joined: Wed Aug 24, 2005 9:08 am
Location: Barberton, OH

Re: generic player- camera won't attach and he's not moving

Post by steven8 »

wabogenadod wrote:Yeah, that's what the problem was.
Thanks
Excellent. QOD is the man, isn't he??
Steve Dilworth - Resisting change since 1965!
wabogenadod
Posts: 18
Joined: Mon Dec 17, 2012 9:59 pm

Re: generic player- camera won't attach and he's not moving

Post by wabogenadod »

steven8 wrote:
wabogenadod wrote:Yeah, that's what the problem was.
Thanks
Excellent. QOD is the man, isn't he??
Deffinetly
Post Reply