Laser tied to pack -functionality for own mod

I am trying to find out the code what ties the laser rifle to energy pack.
Only thing what I can find is that laser rifle is limited for scout armors only. And then laser rifle is possible to be mounted by scout with any pack, but it is not possible to fire without energy pack. What I have found, is that laser rifle needs 6 energy to be shot. But that does not make any sense for me, because it should be the minimum energy what allows laser to be shooted.

Where/what is the code what ties laser rifle to energy pack?

Comments

  • Look in projectile.cs. This is the code that ties the energy pack to the laser rifle:
    function SniperRifleImage::onFire(%data,%obj,%slot)
    {
       if(!%obj.hasEnergyPack || %obj.getEnergyLevel() < %this.minEnergy) // z0dd - ZOD, 5/22/03. Check for energy too.
       {
          // siddown Junior, you can't use it
          serverPlay3D(SniperRifleDryFireSound, %obj.getTransform());
          return;
       }
    

    Additionally, there is also some code in inventoryHud.cs which makes it so you can't select any other pack when you have a laser rifle.
    function InventoryScreen::updateHud( %this, %client, %tag )
    {
    
    ...
    
    //Create - WEAPON - List
       for ( %y = 0; $InvWeapon[%y] !$= ""; %y++ )
       {
          %notFound = true;
          for ( %i = 0; %i < getFieldCount( %client.weaponIndex ); %i++ )
          {
             %WInv = $NameToInv[$InvWeapon[%y]];
             if ( ( $InvWeapon[%y] $= %client.favorites[getField( %client.weaponIndex,%i )] ) || !%armor.max[%WInv] )  
             {
                %notFound = false;
                break;
             }
             else if ( "SniperRifle" $= $NameToInv[%client.favorites[getField( %client.weaponIndex,%i )]] )
             {
                %noSniperRifle = false;
                %packList = "noSelect\tEnergy Pack\tEnergy Pack must be used when \tLaser Rifle is selected!";     
                %client.favorites[getField(%client.packIndex,0)] = "Energy Pack";
             }   
          }
    
  • Thanks, I will check those out. Seems nicely done.
  • Look in projectile.cs. This is the code that ties the energy pack to the laser rifle:
    function SniperRifleImage::onFire(%data,%obj,%slot)
    {
       if(!%obj.hasEnergyPack || %obj.getEnergyLevel() < %this.minEnergy) // z0dd - ZOD, 5/22/03. Check for energy too.
       {
          // siddown Junior, you can't use it
          serverPlay3D(SniperRifleDryFireSound, %obj.getTransform());
          return;
       }
    

    Additionally, there is also some code in inventoryHud.cs which makes it so you can't select any other pack when you have a laser rifle.
    function InventoryScreen::updateHud( %this, %client, %tag )
    {
    
    ...
    
    //Create - WEAPON - List
       for ( %y = 0; $InvWeapon[%y] !$= ""; %y++ )
       {
          %notFound = true;
          for ( %i = 0; %i < getFieldCount( %client.weaponIndex ); %i++ )
          {
             %WInv = $NameToInv[$InvWeapon[%y]];
             if ( ( $InvWeapon[%y] $= %client.favorites[getField( %client.weaponIndex,%i )] ) || !%armor.max[%WInv] )  
             {
                %notFound = false;
                break;
             }
             else if ( "SniperRifle" $= $NameToInv[%client.favorites[getField( %client.weaponIndex,%i )]] )
             {
                %noSniperRifle = false;
                %packList = "noSelect\tEnergy Pack\tEnergy Pack must be used when \tLaser Rifle is selected!";     
                %client.favorites[getField(%client.packIndex,0)] = "Energy Pack";
             }   
          }
    

    I love how you ripped that off of AVM :)
  • edited July 2009
    Yes, Phantom, you caught me. Even after all these years of scripting, I still don't know where to find the firing code for the laser rifle, so, I had to look off of a website.

    I mean, who knew code for firing would've been in projectile.cs?
    And the inventory hud stuff? Who knew that would've been in inventoryHud.cs? :o

    ::)
  • edited July 2009
    If you read over the scripts, you'd know where stuff is.

    Edit: Does AVM actually teach scripting, or just a resource for people to use other people's scripts?
Sign In or Register to comment.