Pawns use ladders?
Posted: Mon Mar 22, 2010 10:57 pm
If I have a scripted player, can it use the built-in ladder system?
Code: Select all
{
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 [recon_idle] // Idle AnimationSpeed
SHOOTANIM [recon_shoot] // Shoot anim
WALKANIM [recon_walk] // Walk anim
BACKANIM [recon_walk_back] // Walk back anim
STRAFELEFT [recon_strafe_left] // Strafe left anim
STRAFERIGHT [recon_strafe_right] // Strafe right anim
INTERANIM [recon_strike] // Pawn interact anim
DEATHANIM [recon_die] // Death Anim
ROOTBONE [Bip01] // Pawn root bone
WEAPONHAND [Bip01 L 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(false);
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_FOR))
{
if(GetEventState("ladder"))
{
AnimateStop("idle");;
}
else
{
Gravity(true);
// forward
ANIM=StringCopy(WALKANIM);
ANC=2;
SPEED=Integer(PLAYERSPEED);
}
}
if(IsKeyDown(K_BAK))
{
if(GetEventState("ladder"))
{
Gravity(false);;
}
else
{
Gravity(true);
// 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=2*PLAYERSPEED;
}
//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, "");
}]
}
Code: Select all
{
height [0]
Spawn[ ()
{
Console(false);
BoxHeight(400);
BoxWidth(20);
LowLevel("setup");
} ]
setup[ ()
{
self.ThinkTime = 0.1;
SetNoCollision();
Gravity(false);
//PawnRender(false);
height = RightCopy(EntityName,4) + 0;
SetScale(6,6*height/180,6);
self.think = "run";
} ]
run[ ()
{
self.ThinkTime = 0.5;
if(FastDistance("player",200 + height))
{
self.think = "active";
}
} ]
active[ ()
{
self.ThinkTime = 0.05;
playerx = GetEntityX("player");
playery = GetEntityY("player");
playerz = GetEntityZ("player");
if((playerx > self.current_X-40) and (playerx < self.current_X+40) and (playery > self.current_Y-10) and (playery < self.current_Y+height) and (playerz < self.current_Z+40) and (playerz > self.current_Z-40))
{
SetEventState("ladder",true);
}
else
{
SetEventState("ladder",false);
}
if(FastDistance("player",200 + height) = false)
{
SetEventState("ladder",false);
self.think = "run";
}
} ]
}