PDA

View Full Version : 1st person Legs



Xzero Phoenix
06-07-2005, 03:32 PM
I have here a modified cog from Phantom Coder (Hell Raiser) for my new mod, iv fixed one bug, the standing leg bug (where they stand over dead bodys).

But now.. theres a glitch when in idle mode. They show under the player.

Here is the cog:


# JK Cog Script
#
# legs.cog
#
# Have legs in first person
#
# Created by: PhantomCoder and modified by Xzero Phoenix to fix the "standing legs over dead body" issue (lol it was funny, the legs would be out in 3rd person and be standing over your dead body lol)

flags=0x240

symbols

thing Player local
model Player_Mdl local

template Legs_Tpl=legs local

thing Legs=-1 local

message startup
message pulse
message killed

end

# ================================================== ======================================

code

startup:

Player=GetLocalPlayerThing();

//Sleep while level loads
Sleep(0.25);

SetPulse(0.01);

return;

# .................................................. ......................................

pulse:

if(GetCurrentCamera() == 1)
{
if(Legs != -1)
{
DestroyThing(Legs);
Legs=-1;
}
return;
}
if(GetThingHealth(player) < 1)
{
if(Legs != -1)
{
DestroyThing(Legs);
Legs=-1;
}
return;
}
if(Legs == -1)
{
Player_Mdl=GetThingModel(Player);

//Legs=CreateThing(Legs_Tpl, Player);
Legs=FireProjectile(Player, Legs_Tpl, -1, -1, '0 0 0', '0 0 0', -1, -1, -1, -1);
SetThingModel(Legs, Player_Mdl);
AmputateJoint(Legs, 2);
AttachThingToThingEx(Legs, Player, 0x8);
}
else
{
SetThingVel(Legs, GetThingVel(Player));
SetThingLook(Legs, GetThingLVec(Player));
if(IsThingCrouching(Player))
{SetPhysicsFlags(Legs, 0x10000);}
else
{ClearPhysicsFlags(Legs, 0x10000);}
}

return;

# .................................................. ......................................

killed:

if(Legs != -1)
{
DestroyThing(Legs);
}
return;

# ================================================== ======================================

end

Now how do i fix this?

Code tags, please. Quote tags just dont cut it... ;)

darthslaw
06-07-2005, 05:14 PM
# JK Cog Script
#
# legs.cog
#
# Have legs in first person
#
# Created by: PhantomCoder and modified by Xzero Phoenix to fix the "standing legs over dead body" issue (lol it was funny, the legs would be out in 3rd person and be standing over your dead body lol)

flags=0x240

symbols

thing Player local
thing Legs=-1 local

model Player_Mdl local

template Legs_Tpl=legs local

message startup
message newplayer
message pulse

end

code
# .................................................. .....................
startup:
//Sleep while level loads
Sleep(0.1);

newplayer:
Player = GetLocalPlayerThing();
call addlegs;

Return;
# .................................................. .....................
pulse:
Player = GetLocalPlayerThing();
if(GetThingHealth(Player) <= 0)
{
SetThingFlags(Legs, 0x10);
call removelegs;
Return;
}
if(GetThingModel(Player) != Player_Mdl) //player changed models
{
call removelegs;
call addlegs;
Return;
}
if(GetCurrentCamera() == 1) SetThingFlags(Legs, 0x10);
else ClearThingFlags(Legs, 0x10);
SetThingPos(Legs, GetThingPos(Player));
SetThingLook(Legs, GetThingLVec(Player));
if(IsThingCrouching(Player)) SetPhysicsFlags(Legs, 0x10000);
else ClearPhysicsFlags(Legs, 0x10000);

Return;
# .................................................. .....................
addlegs:
Player_Mdl = GetThingModel(Player);
Legs = CreateThing(Legs_Tpl, Player);
SetThingModel(Legs, Player_Mdl);
AmputateJoint(Legs, 2);
AttachThingToThingEx(Legs, Player, 0x8);
SetPulse(0.01);

Return;
# .................................................. .....................
removelegs:
if(Legs != -1) DestroyThing(Legs);
Legs = -1;
SetPulse(0);

Return;
# .................................................. .....................
end
Try this one instead. Didn't test yet, but it parses clean.

Xzero Phoenix
06-07-2005, 05:54 PM
Nope. Doesnt work. The legs just don't even come up.

darthslaw
06-07-2005, 10:24 PM
Well, I got mine working. For whatever reason, I think it might be my template, the torso won't be removed with the AmputateJoint() verb.

But I found the problem in yours... it's probably simpler to just change one line than the whole cog if yours works. Turns out there's more than just the 2 camera modes internal and external...

Camera 0 = internal
Camera 1 = external
Camera 4 = idle (circling kyle)
Camera 5 = Death cam
(there's possibly cameras 2 and 3, but I can't think of what they might be)


to fix it all, find the line:
if(GetCurrentCamera() == 1)

and change it to:
if(!(GetCurrentCamera() == 0))

The old code says, in english, if the camera is in external (mode 1), destroy it, but if it's anything else (mode 0, 4, 5) keep the legs.

Hell Raiser
06-08-2005, 10:16 AM
In order for AmputateJoint() to work, the template needs a puppet file.

And as I said in the other thread, excellent find on the camera modes. :D

darthslaw
06-08-2005, 02:23 PM
Oh, it's because my template doesn't use ky.pup... I used ra.pup, which is a blank file...
I should've known that :rolleyes: Thanks for the mind-jog.

Xzero Phoenix
06-08-2005, 04:00 PM
Right, thanks, you saved us both alot of trouble lol