Pawns use ladders?
Pawns use ladders?
If I have a scripted player, can it use the built-in ladder system?
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
Some 2d games I made, haven't made anything in a year though O.o
http://www.yoyogames.com/users/GMer56
- QuestOfDreams
- Site Admin
- Posts: 1520
- Joined: Sun Jul 03, 2005 11:12 pm
- Location: Austria
- Contact:
Re: Pawns use ladders?
No, unfortunately not as there is no script method that allows you to get the zone a pawn's actor is in. The hard coded ladder system just handles the built-in player.
Re: Pawns use ladders?
Ok
So if I make an entity that the scripted player collides with (is there a script command for collision? Or will I just have to use basic distance detection?), I could make the scripted player not subject to gravity (and probably add some little thing for the player to move then on both axes).
So if I make an entity that the scripted player collides with (is there a script command for collision? Or will I just have to use basic distance detection?), I could make the scripted player not subject to gravity (and probably add some little thing for the player to move then on both axes).
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
Some 2d games I made, haven't made anything in a year though O.o
http://www.yoyogames.com/users/GMer56
Re: Pawns use ladders?
I scripted ladders in the newer Nirhis demo game. See ladder.s and the movement() method of player.s.
Pain is only psychological.
Re: Pawns use ladders?
Time for me to do some code crawling
*edit*
I think I see what is going on, correct me if I'm wrong.
The ladder script creates a box 20x400, and when the player collides with it, the Event State "ladder" is on, when the player stops colliding, Event State "ladder" is off.
In the Player script, when the player presses the forward (in this case, "W") the script checks to see if the Event State for "ladder" is on. and if it is on the pawn is not subject to gravity, and is able to be moved up (or down). If it isn't on the player just moves forward.
Seems too simple...
*edit*
I think I see what is going on, correct me if I'm wrong.
The ladder script creates a box 20x400, and when the player collides with it, the Event State "ladder" is on, when the player stops colliding, Event State "ladder" is off.
In the Player script, when the player presses the forward (in this case, "W") the script checks to see if the Event State for "ladder" is on. and if it is on the pawn is not subject to gravity, and is able to be moved up (or down). If it isn't on the player just moves forward.
Seems too simple...
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
Some 2d games I made, haven't made anything in a year though O.o
http://www.yoyogames.com/users/GMer56
Re: Pawns use ladders?
Ok, crawled over the Nirhis Train demo.... and I tried implementing it in my own game, here is the player:
The player functions fine (to the best of my knowledge), but the ladder script, directly copied from the demo creates a miniscule bounding box that the player cannot collide with.
This is the ladder script from said demo:
Sorry if I seem rather n00bish, as I've tried going through this myself and couldn't find squat, maybe another pair of eyes or two could help?
Thanks!
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, "");
}]
}
This is the ladder script from said demo:
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";
}
} ]
}
Thanks!
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
Some 2d games I made, haven't made anything in a year though O.o
http://www.yoyogames.com/users/GMer56