Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → 1st person Legs
1st person Legs
2005-06-07, 12:32 PM #1
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:

Code:
# 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... ;)
2005-06-07, 2:14 PM #2
Code:
# 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.
May the mass times acceleration be with you.
2005-06-07, 2:54 PM #3
Nope. Doesnt work. The legs just don't even come up.
2005-06-07, 7:24 PM #4
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.
May the mass times acceleration be with you.
2005-06-08, 7:16 AM #5
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
-Hell Raiser
2005-06-08, 11:23 AM #6
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.
May the mass times acceleration be with you.
2005-06-08, 1:00 PM #7
Right, thanks, you saved us both alot of trouble lol

↑ Up to the top!