Author Topic: Change functions of the same weapon  (Read 907 times)

How to change the functions of the same weapon, like the portalgun changes to gravitygun-mode?
How would I let the RL change to a gun-mode (so it shoots gun bullets)?

I tried to find it in the portalgun code, but it was so much that I couldn't find which of the lines were the lines that let it change


The portal gun 'changing mode' actually mounts a gravity gun that looks like the portal gun.

or you could just do:
if(somethingThatSaysYouAreInAnot herMode)
   return theOtherWeapon::whateverFunctionIsCurentlyBei ngCalled()

Quite vague, but it might help.

The portal gun 'changing mode' actually mounts a gravity gun that looks like the portal gun.
but what exactly is the code for it?

Search for "servercmdLight".

Code: [Select]
function servercmdLight(%client)
 {
  if(isObject(%client.player) && isObject(%client.player.getMountedImage(0)))
  {
   %name = %client.player.getMountedImage(0).getName();
   if(%name $= "pGunBlueImage" || %name $= "pGunOrangeImage")
   {
    if(%client.player.lockPortalPickup)
    {
     serverPlay3d(PgunInvalidSound,%client.player.getTransform());
     return;
    }
    %client.player.mountImage(pGunPickupImage,0);return;
   }
   else if(%name $= "pGunPickupImage")
   {
    if(%client.player.lockBluePortal)
    {
     serverPlay3d(PgunInvalidSound,%client.player.getTransform());
     return;
    }
    %client.player.mountImage(PGunBlueImage,0);return;
   }
  }
  Parent::servercmdLight(%client);
 }

I see the code is based on the light function.
How would I let it change on pressing mouse2? (alternate attack-button)

Look at the Flak Cannon.

You can find pretty much everything you need by looking at mods with similar functions...

Look at the Flak Cannon.

You can find pretty much everything you need by looking at mods with similar functions...
I didn't knew flak cannon had a second attack ;D

Well, if you're already looking at the Portal Gun very similar code is there too.

yeah, I have the code now, thanks