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 → Important tertiary fire laser mode
Important tertiary fire laser mode
2001-09-18, 10:05 AM #1
this goes at the end of my P90 gun cog:

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

user0:

SetMaterialCel(laseraimtex, 1);
SetFireWait(player, firewait - 0.04);
FireProjectile(player, laser, -1, -1, '0.0168 0.1896 0.00', '0 0 0', 0, 0, 0, 0);

Sleep(5);

SetMaterialCel(laseraimtex, 0);


return;

end

Is there a function which will keep user0 firing continuously? its a laser sight, and I want it to stay on, as well as the addcell bit

Ps, can normal fire still work when user0 is active?
Code:
if(getThingFlags(source) & 0x8){
  do her}
elseif(getThingFlags(source) & 0x4){
  do other babe}
else{
  do a dude}
2001-09-18, 11:19 AM #2
You should use a pulse for the laser sight, but I'm not sure what you want to do with the mat. Anyway, do something like this for the aiming laser:

Code:
Selected:
   #Other Code
   SetPulse(.1);
Return;
#=========#
deselected:
   #Other Code
   SetPulse(0);
Return;
#=========#
pulse:
   FireProjectile(player, laser, -1, -1, '0.0168 0.1896 0.00', '0 0 0', 0, 0, 0, 0);
Return;
#=========#
end


That will make the aiming laser come on when you select the weapon, and turn off when the weapon is deselected. Hideki has a good tutorial on making aiming lasers and getting them to work in MP.

You could get user0 to fire continuously by putting "call user0;" at the end of that message. But that might lag if you fired a projectile every time.

Yes, normal fire will work fine even if you're firing other projectiles almost simultaneously. Don't know about using a sleep(), though. I don't use them because they can crash JK.

------------------
Fiction must be more realistic than truth or no one will believe it.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2001-09-19, 12:01 PM #3
no no no, its very important that the laser isnt activated when you select the P90, i can do that anyway, but i want user0 to turn it on, then press user0 again, to turn it off.

Ya Dig?

Oh, also, in the same cog, to reload it, how do I play a keyframe and a sound after a previous keyframe? this wont work:

if(count==50) //we've gotten up to 50
{
jkPlayPOVKey( player, reloadAnim, 1, 0x38 );
PlaySoundThing(reloadSound, player, 1.0, -1, -1, 0x80);
SetFireWait(player, GetKeyLen(reloadAnim));
count=0; //reset your counter variable for the next go round
jkPlayPOVKey( player, gunAnim, 1, 0x38 );
PlaySoundThing(gunSound, player, 1.0, -1, -1, 0x80);
SetFireWait(player, GetKeyLen(gunAnim));

}

Return;
it only plays the first

[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-09-19, 5:06 PM #4
Actually in the tertiary fire mode cog which sends a message to the weapon cog, place this.

SetInvWait(player, your3rdFireCogInvNumber, someWaitInSeconds);

So whenever you press the key it will make the inventory not to work for a certain amount of time, making it not possible to fire so rapidly and if you also want to make the usual fire mode to stay as well, place

FireWait(some params);

In the user0 message.


------------------
http://millennium.massassi.net/ - Millennium
2001-09-20, 12:05 AM #5
Why would I want the inventory to stop working? you mean the reload cog? thanks anyway but I have that working now, simply by using "sleep" and some other stuff.

Heres what I have for the user0 laseraim

Pulse:

FireLaser(para)
Setmaterial(the laser turning on)
sleep(same number as pulse)
Setmaterial(the laser turning off)

user0:

SetFirewait(whatever)
SetPulse(0.012);

I think its something like that, what that should do is activate the pulse when you press user0, then everypulse the laser will shoot and the material will change.

When I stop pressing it the pulse is deacivated and everything goes back to normal
Code:
if(getThingFlags(source) & 0x8){
  do her}
elseif(getThingFlags(source) & 0x4){
  do other babe}
else{
  do a dude}
2001-09-20, 8:07 AM #6
Ok, the following code will set the mat on and start the laser when user0 is pressed. And when pressed again the mat and the pulse will turn off.

Code:
#=============#
pulse:
   FireProjectile()

Return;
#=============#
user0:
   if(pulsevar == 0)
   {
     SetPulse(.1); #Or faster than that
     pulsevar=1;
     SetMaterialCel(mat, 1); #Turn it on
   }
   else if(pulsevar == 1)
   {
     SetPulse(0);
     pulsevar=0;
     SetMaterialCel(mat, 0); #Turn it off
   }

Return;
#=============#


You can't change the mat in the same pulse that fires the projectile because the projectile has to fire too quickly. Putting a sleep in there won't work.

---------

If you want the mat to continually change while the pulse is going, you should use alternating timers:

Code:
#==============#
timer:
   id=GetSenderId();
   if(id == 1)
   {
     SetMaterialCel(mat, 1);
     SetTimerEx(0.5, 0, 0, 0); #Id of zero
   }
   else if(id == 0)
   {
     SetMaterialCel(mat, 0);
     SetTimerEx(0.5, 1, 0, 0); #Id of one
   }

Return;
#=============#
user0:
   if(pulsevar == 0)
   {
     SetPulse(.1);
     pulsevar=1;
     SetTimerEx(0.5, 1, 0, 0); #Turn it on
   }
   else if(pulsevar == 1)
   {
     SetPulse(0);
     pulsevar=0;
     KillTimerEx(1); #Kill both timers
     KillTimerEx(0);
   }

Return;
#=============#


Also, put both KillTimerExes in the deselected message. Hope that solves your problem [http://forums.massassi.net/html/wink.gif]

------------------
Fiction must be more realistic than truth or no one will believe it.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.

↑ Up to the top!