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 → MotS weapon cog
MotS weapon cog
2002-05-18, 12:03 PM #1
What I need is simple (I think), when you pickup a weapon and you don't have it, you can't even pick it up, but if you have the weapon, you can pick up it's ammo.

Now, I've managed to get it right, for one problem, when you walk over the powerup, even though you don't have the gun (so u can't pick it up) it dissapears and still makes the pickup sound, and that's not right, does anybody know what the problem is. And if you would like to take a look at it, maybe you can even post an exmaple of how a weaponcog of this kind must look like to function properly, this is mine, I just deleted some stuff:


# Jedi Knight Cog Script
#
# POW_STRIFLE.COG
#
# POWERUP Script - Dropped Stormtrooper Rifle pickup
#
# [YB & CYW & CR]
#
# (C) 1997 LucasArts Entertainment Co. All Rights Reserved


symbols

thing powerup local
thing player local
int bin=3 local
int ammobin=11 local
sound pickupsnd=thrmlpu2.wav local
sound respawnsnd=Activate01.wav local
flex amount local

int bin_contents=0 local
int autopickup=0 local
int autoselect_weapon=-1 local

message touched
message taken
message respawn

end

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

code

touched:
player = GetSourceRef();

if (GetThingType(player) == 10) // Can only be taken by players.
{
if(IsMulti() || (GetInv(player, bin) == 0) || (GetInv(player, ammobin) < GetInvMax(player, ammobin)))
{
TakeItem(GetSenderRef(), -1);
call taken;
}
}

Return;

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

taken:
player = GetSourceRef();
powerup = GetSenderRef();

// Do effects.
PlaySoundLocal(pickupsnd, 1, 0, 0);
AddDynamicTint(player, 0.0, 0.0, 0.2);

if(GetInv(player, bin) == 0)
{

}
else
if(GetInv(player, ammobin) < GetInvMax(player, ammobin))
{
// Pickup ammo only.
// Print("Energy Cells");
jkPrintUNIString(player, ammobin);

// store the old bin contents
bin_contents = GetInv(player, ammobin);

ChangeInv(player, ammobin, 12.0);

// Check for Auto Reload
if(GetAutoReload() & 1)
{
if(!bin_contents)
{
if(!((GetAutoReload() & 2) && (GetWeaponBin(GetCurWeapon(player)) == jkGetMultiParam(1))))
{
// Try to autoselect and see if the best weapon is an energy cell weapon
autoselect_weapon = AutoSelectWeapon(player, 2);
if((autoselect_weapon == 2) || (autoselect_weapon == 3) || (autoselect_weapon == 12) || (autoselect_weapon == 13))
SelectWeapon(player, autoselect_weapon);
}
}
}
}

Return;

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

respawn:
PlaySoundThingLocal(respawnsnd, GetSenderRef(), 0.6, 5.0, 10.0, 0);

Return;

end




[This message has been edited by Sven Solo (edited May 18, 2002).]
Choose life. Choose a job. Choose sitting on a couch watching spirit crushing game shows, stuffing junk food into your mouth...
But why would I do a thing like that, i chose not to choose this life.
I chose the Star Wars life...
2002-05-19, 7:12 AM #2
Put this line right under the player assignment in the touched message:
Code:
If(GetInv(player, bin) < 1) Return;


So if that bin has a value less than one - meaning you don't have the weapon - JK will stop there.

------------
Code:
if(GetInv(player, bin) == 0)
{

}
else

This is bad coding. Replace it with:
Code:
if(GetInv(player, bin) > 0)


And also, you don't need to call the taken message, TakeItem() will do that.

Glad to help. [http://forums.massassi.net/html/wink.gif]


------------------
Author of the Jedi Knight DataMaster.
Visit Saber's Domain.

[This message has been edited by SaberMaster (edited May 19, 2002).]
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-05-20, 6:58 AM #3
Thanks SaberMaster, it works nicely, but there was one problem, I had to leave the call taken; command and I had to place the TakeItem right below the command telling you have the gun, well see for yourself, but it works:

code

touched:
player = GetSourceRef();

if (GetThingType(player) == 10) // Can only be taken by players.
{
if(IsMulti() || (GetInv(player, bin) == 0) || (GetInv(player, ammobin) < GetInvMax(player, ammobin)))
{

call taken;
}
}

Return;

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

taken:
player = GetSourceRef();
powerup = GetSenderRef();

If(GetInv(player, bin) < 1) Return;

// Do effects.
PlaySoundLocal(pickupsnd, 1, 0, 0);
AddDynamicTint(player, 0.0, 0.0, 0.2);



if(GetInv(player, bin) > 0)

TakeItem(GetSenderRef(), -1);

if(GetInv(player, ammobin) < GetInvMax(player, ammobin))
{
// Pickup ammo only.
// Print("Energy Cells");
jkPrintUNIString(player, ammobin);

Now you can't pick it up when you don't have it, so you will not hear a sound, and the powerup will not dissapear leaving it for when you do have the gun. And if you have the gun you can pick up the powerups ammo.


[This message has been edited by Sven Solo (edited May 20, 2002).]
Choose life. Choose a job. Choose sitting on a couch watching spirit crushing game shows, stuffing junk food into your mouth...
But why would I do a thing like that, i chose not to choose this life.
I chose the Star Wars life...

↑ Up to the top!