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 → Need to know "every -50 bullets, play keyfile"
Need to know "every -50 bullets, play keyfile"
2001-05-30, 8:51 AM #1
In the strifle cog, Ive added a new keyfile
reloadAnim=reload.key

in the messages section.

I need to know how to play this keyfile everytime I fire 50 bullets, so I can make my weapon reload.
What is the cog language for that, and in which section do I put it in (fire, activated etc)
Code:
if(getThingFlags(source) & 0x8){
  do her}
elseif(getThingFlags(source) & 0x4){
  do other babe}
else{
  do a dude}
2001-05-30, 9:48 AM #2
I don't know if this is the best way but here I go....

1. In the symbols create a new int "Example"
Code:
 int  bulletcount=0

2. In the Fire message, right after the projectile is fired have something like this,
Code:
 bulletcount = bulletcount+1


3. Then after that have,
Code:
 if(bulletcount >= 50)
{
key = PlayKey(player, reloadAnim , 0x1a);
}


that's my best guess.
Gravity isn't MY fault--I voted for velcro.
2001-05-30, 10:16 AM #3
That's the way I did my reload cogs.. [http://forums.massassi.net/html/smile.gif]
2001-05-30, 10:17 AM #4
I'm not sure either but this is my best guess
make the following changes to the cog
-------
symbols

int NumBulletsFired=0 local
-------
Fire
NumBulletsFired = NumBulletsFired + 1
if(NumBulletsFired == 50) PlayKey([gunmesh], [keyname], 1, [?flags?])

it's my best guess
Join JK2k on the zone! go to http://www.jk2k.8k.com
2001-05-30, 10:24 AM #5
Do not forget to set the bulletcount back to 0 when 50 shots has been reached, otherwise the key will only play once a game... and could possibly crash the game if you fire enough, because integers have a certain length.. I think the ints in JK go up around 32k.
2001-06-01, 10:42 AM #6
int bulletcount=0 local

Thats what I put in messages
IN the fire section:

player = GetSourceRef();
mode = GetSenderRef();

// Check that the player is still alive.
if(GetThingHealth(player) <= 3)
{
Return;
}

// Check Ammo - If we are out, autoselect best weapon.
// It should always use two energy cells, but -- as in DF --
// allow the last fire if there is only one left...
if(GetInv(player, 11) < 1.0)
{
PlaySoundThing(outSound, player, 1.0, -1, -1, 0x80);
if((GetAutoSwitch() & 1))
SelectWeapon(player, AutoSelectWeapon(player, 1));
Return;
}

// Get random aiming error
randVec = VectorSet((Rand()-0.1)*1, (Rand()-0.1)*1, 1.0);

SetPOVShake('0.0 -.003 0.0', '1.5 0.0 0.0', .05, 80.0);
dummy = FireProjectile(player, projectile, fireSound, 8, '0.01 0.1896 0.015', randVec, 1.0, 0x30, autoAimFOV, autoAimFOV*2);
// SetThingVel(dummy, vectorScale(GetThingVel(dummy), 0.01));


dummy = FireProjectile(player, projectile2, fireSound2, 8, '0.023 0.15 0.015', randVec, 1.0, 0x30, autoAimFOV, autoAimFOV*2);
// SetThingVel(dummy, vectorScale(GetThingVel(dummy), 0.01));

bulletcount = bulletcount+1;


ChangeInv( player, 11, -1.0 );
jkPlayPOVKey( player, povfireAnim, 1, 0x38 );

powerBoost = GetInv(player, 63);
ChangeFireRate(player, fireWait/powerBoost);

if(bulletcount >= 50)
{
key = PlayKey(player, reloadAnim , 0x1a);
}


Return;


No, nothing happened apart from the gun firing every single bullet in my inventory

And whats that bit about "set the bulletcount back to 0 when 50 shots has been reached".

If so how do I do that?
Code:
if(getThingFlags(source) & 0x8){
  do her}
elseif(getThingFlags(source) & 0x4){
  do other babe}
else{
  do a dude}
2001-06-01, 11:24 AM #7
You have to have it set it back to 0 or else it will continue counting and continue playing the key. So change
Code:
if(bulletcount >= 50)
{
key = PlayKey(player, reloadAnim , 0x1a);
}

to
Code:
if(bulletcount >= 50)
{
key = PlayKey(player, reloadAnim , 0x1a);
bulletcount = 0;
}



I'm not sure why it fired all your bullets. Perhaps you should debug it by having it print something when it get's past 50 bullets fired.
Gravity isn't MY fault--I voted for velcro.
2001-06-03, 7:09 AM #8
TO HELL WITH THIS!!!
THis obviously isnt going to work
Right, lets try something else.
How do I write in cog:
Whenever the inventory says either:
50
100
150
or 200
PLayKeyandSOund bla bla bla (i know that bit)
But I need to know how to do it ony once when the inv reaches those numbers.
I have 250 bullets in all and each clip holds 50, see where Im coming from,, no point in that curbulletsshots,bulletcount=0 whatever
THANK YOU [http://forums.massassi.net/html/smile.gif]
Code:
if(getThingFlags(source) & 0x8){
  do her}
elseif(getThingFlags(source) & 0x4){
  do other babe}
else{
  do a dude}
2001-06-03, 1:53 PM #9
Err, what's the prob with your cog?
Above posts will work if you've just followed properly.


------------------
http://millennium.massassi.net/ - Millennium
2001-06-03, 7:28 PM #10
Cog requires a bit of beginer programming knowledge. Also, if your key is a POV key, you'll need to use jkplayPOVkey(blah..); (look it up in the jkspecs [http://forums.massassi.net/html/smile.gif])

Using the code provided above, put this under the fireprojectile() command:

Code:
bulletcount=bulletcount+1; //everytime you fire, this will count up one

if(bulletcount==50) //we've gotten up to 50
{
  PlayKey OR jkPlayPOVKey //pending on if its external or POV
  bulletcount=0; //reset your counter variable for the next go round
}


see how easy that was when I explained it? [http://forums.massassi.net/html/smile.gif]
-Hell Raiser
2001-06-03, 8:52 PM #11
Sheesh , all this just for one problem.
2001-06-04, 5:28 AM #12
Nice of you to help, Seifer. [http://forums.massassi.net/html/biggrin.gif]
Gravity isn't MY fault--I voted for velcro.
2001-06-04, 8:35 AM #13
Fine, I must be a freakin retard! happy now?
Whats wrong with doing the key at 50 100 etc?
First of all I guess Im a total dunce when it comes to cogs, but maybe I ve done smthing to my strifle cog which stops it from working.
It probably didnt work because you have to be completely specific when it comes to explaining smthing like this to me, otherwise ILl make a right hash of it.
THis way of doing it surely wont work right if you count up 30 bullets, put the gun away, collect some more ammo, then fire another 20, the Inv ammo numbers wont be right
Ah forget it [http://forums.massassi.net/html/frown.gif]
Code:
if(getThingFlags(source) & 0x8){
  do her}
elseif(getThingFlags(source) & 0x4){
  do other babe}
else{
  do a dude}
2001-06-04, 8:57 PM #14
Wow you need to slow down dude , we can help you.
2001-06-05, 8:44 AM #15
if(bulletcount==50) //we've gotten up to 50
{
jkPlayPOVKey( player, reloadAnim, 1, 0x38 );
PlaySoundThing(mountSound, player, 1.0, -1, -1, 0x80);
SetMountWait(player, GetKeyLen(reloadAnim));
bulletcount=0; //reset your counter variable for the next go round
}
Return;

It works HAHAHA thank you all [http://forums.massassi.net/html/smile.gif]
Oh wait, hang on, Im not finished with you people yet...
when it plays the keyframe, How do you stop the gun from firing until the keyframe stops?
(it locks the trigger if see what I mean)
Code:
if(getThingFlags(source) & 0x8){
  do her}
elseif(getThingFlags(source) & 0x4){
  do other babe}
else{
  do a dude}
2001-06-05, 10:18 AM #16
I imagine it would be this,
Code:
Time = GetKeyLen(reloadAnim); 
SetFirewait(player,Time); 
Gravity isn't MY fault--I voted for velcro.
2001-06-06, 1:13 PM #17
integers in jedi knight are the same as integers in c++
32000 is the highest possible value
after that, the sign flag is set, and it gets set to -31999 at which point it will count up again
so the key would be played every 64000 shots fired, after the first fifty
And meanwhile the bus with legs has destroyed half of disneyland . . . and nobody cares!
2001-06-08, 12:07 AM #18
The SetMountWait(); cog verb DOES stop you from using the fire button. However, if you want to make it stop firing when the reload happens (which seems logical) then add this:

Deactivateweapon(player, mode);

this cogverb will stop the gun from firing. BTW, the fire message in a weapon cog is NOT the message that is called when you press the fire button. It is the activated message that is called when you press fire. The fire message is called when the "activateweapon(player, firewait, mode); is used". The deactivateWeapon cogverb is used to make the fire message stop. This cog verb is usually found in the deactivated message of the cog (deactivated is called when you release the fire button.)

-- SavageX

------------------
"Everyone dies." - Boba Fett
"Be kind to nerds because one day... one will be your boss."
SavageX's Editing Corner
2001-06-08, 12:46 PM #19
Well Discussed SavageX

↑ Up to the top!