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 → Seifer's cog crashes game -- can't fix it
Seifer's cog crashes game -- can't fix it
2004-03-24, 6:43 PM #1
Seifer's pov cog crashes JK after you die and try to respawn. (side note: I tried "kill" to kill myself with my fists selected and it crashed JK instantly; I have only a replacement bryar and st.rifle cog and nothing else) Is there any way to fix this? I fixed a couple other bugs in the original code but this one is a biggie and I can't find any way to fix it. Here's my code.
Code:
# Jedi Knight Cog Script
#
# WEAP_BRYAR.COG
#
# WEAPON 2 Script - Bryar Pistol
#
# The trusty weapon of Kyle Katarn. This is actually an older modified rifle
# that has been cut down to more of a pistol size. It is very accurate but
# somewhat of a low power weapon. This weapon has only one type of fire.
#
# - Affected by MagSealed sectors/surfaces.
#
# Custom POV Model Cog created by *_Seifer_*
#==============================================================#
symbols

model     povModel=ggunv.3do                  local
model     weaponMesh=bryg.3do                 local

keyframe  mountAnim=ggunvmnt.key              local
keyframe  dismountAnim=ggunvdis.key           local
keyframe  povfireAnim=ggunvfire.key           local
#keyframe  mountAnim=bryvmnt.key              local
#keyframe  dismountAnim=bryvdis.key           local
#keyframe  povfireAnim=bryvpst1.key           local
keyframe  holsterAnim=kyhlstr.key             local

sound     outSound=pistout1.wav               local
sound     mountSound=df_bry_ready.wav         local
sound     dismountSound=PutWeaponAway01.wav   local
sound     fireSound=pistol-1.wav              local

template  projectile=+bryarbolt               local
template  lookghost=+timedghost               local
template  povtemp=+bryarmodel                 local
template  posghost=+timedghost                local

thing     player                              local
thing     weaplook                            local
thing     weaponpov                           local

int       direction=0
int       v_player                            local
int       y_vec                               local
int       weappos                             local
int       mode                                local
int       holsterTrack                        local
int       error=0                             local
int       gunweap                             local
int       weap=2                              local
int       ammobin=11                          local

vector    f_vec                               local

flex      fireWait=0.5                        local
flex      holsterWait                         local
flex      powerBoost                          local
flex      autoAimFOV=30                       local
flex      x_thrust                            local
flex      y_thrust                            local

message   activated
message   deactivated
message   selected
message   deselected
message   autoselect
message   killed
message   fire
message   timer
message   pulse

end
#==============================================================#
code
#------------------------------------------------------
selected:
	player = GetSourceRef();
	// Setup the meshes and models.
	jkSetPOVModel(player, povModel);
	jkSetWeaponMesh(player, weaponMesh);
	SetArmedMode(player, 1);
	ParseArg(player, "maxheadpitch=89.50");
	weaponpov = CreateThing(povtemp, player);
	SetThingPos(weaponpov, GetThingPos(player));
	AttachThingToThingEx(weaponpov, player, 0x8);
	SetThingModel(weaponpov, povModel);
	PlayKey(weaponpov, mountAnim, 1, 0x4);
	error = 0;
	SetPulse(0.01);
	PlayMode(player, 41);
	PlaySoundThing(mountSound, player, 1.0, -1.0, -1.0, 0x80);
	jkClearFlags(player, 0x5);
	SetCurWeapon(player, weap);
	gunweap = GetCurWeapon(player);
	SetMountWait(player, GetKeyLen(mountAnim));

Return;
#------------------------------------------------------
deselected:
	player = GetSourceRef();
	#weaponIndex = GetSenderRef();
	ParseArg(player, "maxheadpitch=90.00");
	SetTimerEx(GetKeyLen(dismountAnim), 1, 0.0, 0.0);
	PlaySoundThing(dismountSound, player, 1.0, -1, -1, 0x80);
	PlayKey(weaponpov, dismountAnim, 1, 0x18);
	holsterWait = GetKeyLen(holsterAnim);
	SetMountWait(player, holsterWait);
	holsterTrack = PlayKey(player, holsterAnim, 1, 0x4);
	SetTimerEx(holsterWait, 2, 0.0, 0.0);

Return;
#------------------------------------------------------
activated:
	player = GetSourceRef();
	mode = GetSenderRef();
	powerBoost = GetInv(player, 63);
	ActivateWeapon(player, fireWait / powerBoost, mode);

Return;
#------------------------------------------------------
fire:
	player = GetSourceRef();
	// Check that the player is still alive.
	if(GetThingHealth(player) <= 0) Return;
	// Check Ammo - If we are out, autoselect best weapon.
	if(GetInv(player, ammobin) < 1.0)
	{
		PlaySoundThing(outSound, player, 1.0, -1.0, -1.0, 0x80);
		if(GetAutoSwitch() & 1) SelectWeapon(player, AutoselectWeapon(player, 1));
		Return;
	}
	SetPOVShake('0.0 -.003 0.0', '1.0 0.0 0.0', .05, 80.0);
	FireProjectile(player, projectile, fireSound, 8, '0.0135 0.1624 0.0', '0 0 0', 1.0, 0x20, autoAimFOV, autoAimFOV * 2);
	PlayKey(weaponpov, povfireAnim, 1, 0x38);
	ChangeInv(player, ammobin, -1.0);
	powerBoost = GetInv(player, 63);
	ChangeFireRate(player, fireWait / powerBoost);

Return;
#------------------------------------------------------
deactivated:
	player = GetSourceRef();
	mode = GetSenderRef();
	DeactivateWeapon(player, mode);

Return;
#------------------------------------------------------
autoselect:
	player = GetSourceRef();
	// If the player has the weapon
	if(GetInv(player, weap) != 0.0)
	{
		// If the player has ammo
		if(GetInv(player, ammobin) != 0.0)
		{
			ReturnEx(500.0);
		}
		else
		{
			ReturnEx(-1.0);
		}
	}
	else
	{
		ReturnEx(-1.0);
	}

Return;
#------------------------------------------------------
timer:
	if(GetSenderID() == 1)
	{
		//if(GetCurWeapon(player) == gunweap)
		//{
		//	error = 1;
		//	Return;
		//}
		SetPulse(0);
		DestroyThing(weaponpov);
	}
	else if(GetSenderID() == 2) StopKey(player, holsterTrack, 0.0);

Return;
#------------------------------------------------------
pulse:
	if(error == 1)
	{
		if(GetCurWeapon(player) != gunweap)
		{
			error = 0;
			SetPulse(0);
			DestroyThing(weaponpov);
		}
	}
	if(GetCurrentCamera() == 0) ClearThingFlags(weaponpov, 0x10);
	else SetThingFlags(weaponpov, 0x10);
	weaplook = FireProjectile(player, lookghost, -1, -1, '0 0 0', '0 0 0', 1.0, 0x20, 30, 10);
	SetThingLook(weaponpov, GetThingLVec(weaplook));
	// Pov Waggle
	x_thrust = VectorX(GetThingThrust(player));
	y_thrust = VectorY(GetThingThrust(player));
	if(x_thrust < 0) x_thrust = x_thrust * -1;
	if(y_thrust < 0) y_thrust = y_thrust * -1;
	v_player = ((y_thrust + x_thrust) * 0.001) * 0.24;
	if(y_vec >= 0.006)
	{
		direction = 0;
	}
	if(y_vec <= -0.006)
	{
		direction = 1;
	}
	if(v_player <= 0)
	{
		if(direction == 0)
		{
			y_vec = y_vec + v_player;
		}
		if(direction == 1)
		{
			y_vec = y_vec - v_player;
		}
	}
	else
	{
		if(direction == 0)
		{
			y_vec = y_vec - v_player;
		}
		if(direction == 1)
		{
			y_vec = y_vec + v_player;
		}
	}
	f_vec = VectorSet(0, y_vec, 0);
	weappos = FireProjectile(player, posghost, -1, -1, f_vec, '0 0 0', 0, 0, 0, 0);
	SetThingPos(weaponpov, GetThingPos(weappos));
	//SetThingPos(weaponpov, f_vec);

Return;
#------------------------------------------------------
killed:
	error = 0;
	SetPulse(0);
	DestroyThing(weaponpov);

Return;
#------------------------------------------------------
end

Is it possible JK is crashing from something in the pulse message?

------------------
I am Darth Slaw.
The Dark Lord of the Sith,
And part of the Nightfire mod team
May the mass times acceleration be with you.
2004-03-24, 7:02 PM #2
I herd there is no way to stop that cog crashing but im not a cog expert so i wouldnt know.

------------------
Nightfire Mod
Spoting an error in post will result in a $100 reward.
Offer expires on 6/6/06. Valid one per customer, per day.

Rangi
2004-03-24, 8:46 PM #3
I havnt had the same problem as you... not sure why. You can goto the team battle forums and download TB if you want to see the problem I am having. It is like a random crash, like as though something isnt processed correctly... I dunno.

------------------
Team Battle.
Team Battle.
2004-03-25, 10:19 AM #4
I found a fix, but I'm not too fond of the cost. I have to make these guns have lower priority than the fists so they can't possibly be autoselected at startup. (In the "autoselect" message, I used ReturnEx(0);)
Like I said, I don't like selecting my fists right off the bat, but at least it works. This is certainly better than crashing.

Now I underatand why seifer copied the autoselect message from the fist cog; I got confused when I first saw that.

------------------
I am Darth Slaw.
The Dark Lord of the Sith,
And part of the Nightfire mod team
May the mass times acceleration be with you.
2004-03-27, 1:02 AM #5
your saying you fixed the siefer crashing prob? [http://forums.massassi.net/html/eek.gif]

------------------
Nightfire Mod
Spoting an error in post will result in a $100 reward.
Offer expires on 6/6/06. Valid one per customer, per day.

Rangi
2004-03-27, 8:09 AM #6
Yeah, but the downside to this solution is the fists have higher priority than the guns that use seifer's cog, so, for example, on startup (with default JK SP weapon allotment) you will autoselect the fists instead of the bryar.

BUT that is certainly more acceptable than crashing [http://forums.massassi.net/html/smile.gif] isn't it? (here's the part where you shake your head "yes" [http://forums.massassi.net/html/smile.gif] )

------------------
I am Darth Slaw.
The Dark Lord of the Sith,
And part of the Nightfire mod team

[This message has been edited by Darth Slaw (edited March 27, 2004).]
May the mass times acceleration be with you.
2004-03-27, 11:46 AM #7
Yes Yes thats ALOT betted than crashing


------------------
Nightfire Mod
Spoting an error in post will result in a $100 reward.
Offer expires on 6/6/06. Valid one per customer, per day.

Rangi
2004-03-28, 1:28 AM #8
Just create a separate startup cog that selects a gun about 1/2 second after the level loads. That would solve the initial gun selection. (although it still leaves priority switching messed up)

------------------
-There are easier things in life than finding a good woman, like nailing Jello to a tree, for instance

-Tazz
-There are easier things in life than finding a good woman, like nailing Jello to a tree, for instance

Tazz
2004-03-28, 1:22 PM #9
Hmmm... an interesting suggestion. I'll look into that.
Where would that new startup cog go; in the kyle.cog, static.jkl, ... ?

Actually, I just had another idea. I could make a variable for the value to be returned by autoselect, initialize it to 0, then after 0.5 seconds from atartup change it to what I want; theoretically, it should fix all priorities (except at startup) for the weapons, too.

------------------
Bond, Power, CA, The Force, Saber, IC, Epic, Oily Mexican Food, BG, /\ |> /\ /\/\, Sentences.
Now you know where I've been.
May the mass times acceleration be with you.
2004-03-28, 5:29 PM #10
Oooops!
Somehow, when I was editing the cog again, it started crashing when you died again (except when you fell into a pit). Turns out there was another part to this problem, in the "killed" message: DestroyThing(weaponpov);
I took that line out and now it works fine. I guess I commented it out when I was messing around trying to fix the cog, and then I must've put it back in today. Go figure. (I also took out "SetPulse(0);", but the cog might still work if it's in)

------------------
Bond, Power, CA, The Force, Saber, IC, Epic, Oily Mexican Food, BG, /\ |> /\ /\/\, Sentences.
Now you know where I've been.
May the mass times acceleration be with you.
2004-04-06, 3:23 AM #11
<3 Slaw

*Ruthven dances*
Code:
if(getThingFlags(source) & 0x8){
  do her}
elseif(getThingFlags(source) & 0x4){
  do other babe}
else{
  do a dude}

↑ Up to the top!