TribesNext

Welcome, Guest. Please login or register.
Did you miss your activation email?


TribesNext >  TribesNext.com Forums >  Tribes 2 >  Mods and Customization >  Request Help With Debugging Reloading Magazine System « previous next »
Pages: [1] Print
Author Topic: Request Help With Debugging Reloading Magazine System
mHyth
Nugget²

Posts: 57

View Profile
May 23, 2009, 11:47:59 PM »
I don't know how much 'debugging' it will need, in fact the whole thing may need be rewritten, although I would hope my coding abilities wouldn't be that lax.
The concept was when a player goes to a large, or deployable, inventory station that they would receive a certain number of clips(according to the armor they purchase). When they fire, it checks if they have fired an ammo based weapon and if you have any magazines left it would then add your max amount of ammo for that weapon(basically reload it to full) and minus a magazine.
Code...
Projectiles.cs
Code:
$Clip[0] = PlasmaClip;
$Clip[1] = ChaingunClip;
$Clip[2] = DiscClip;
$Clip[3] = GrenadeLauncherClip;
$Clip[4] = MortarClip;
$Clip[5] = MissileLauncherClip;
$Clip[6] = MMinigunClip;
$numClips = 7;
ShapeBaseImageData
Code:
   if(%data.usesEnergy)
   {
      if(%data.useMountEnergy)
      {
         %useEnergyObj = %obj.getObjectMount();
         if(!%useEnergyObj)
            %useEnergyObj = %obj;
         %energy = %useEnergyObj.getEnergyLevel();
         %vehicle = %useEnergyObj;
      }
      else
         %energy = %obj.getEnergyLevel();
     
      if(%data.useCapacitor && %data.usesEnergy)
      {   
         if( %useEnergyObj.turretObject.getCapacitorLevel() < %data.minEnergy )
         {   
            return;
         }
      }
      else if(%energy < %data.minEnergy)
         return;
   }
   ////////////////////////////////////////////Began Editing
   else if(%data.ammo == 0)
   {
        for(%c = 0; %c < $numClips; %c++)
        {
            %clip = $Clip[%c];
            if(%obj.getInventory(%clip) != 0)
            {
               reloadweapon(%obj, %data);
               %clip--;
            }
            else
            {

            }
        }
   }
   ////////////////////////////////////////ended//Used top to show location
New Function Created Directly Below ShapeBaseImageData
Code:
///////////////////////////
function reloadweapon(%obj, %data)
{
      %obj.setInventory(%data.ammo, %obj.getDataBlock().max[%data.ammo]);
}
///////////////////////////
Inventoryhud.cs>buyFavorites(%client);>At End Of Function
Code:
////////////////////
      %cpclip = %client.player;
   if(%curArmor $= "light")
   {
      %cpclip.PlasmaClip = 2;
      %cpclip.ChaingunClip = 3;
      %cpclip.DiscClip = 2;
      %cpclip.GrenadeLauncherClip = 2;
//      %client.player.MortarClip = 2;
//      %client.player.MissileLauncherClip = 2;
//      %client.player.MMinigunClip = 2;
   }
   else if(%curArmor $= "medium")
   {
      %cpclip.PlasmaClip = 3;
      %cpclip.ChaingunClip = 4;
      %cpclip.DiscClip = 2;
      %cpclip.GrenadeLauncherClip = 3;
//      %client.player.MortarClip = 2;
      %cpclip.MissileLauncherClip = 2;
//      %client.player.MMinigunClip = 2;
   }
   else if(%curArmor $= "heavy")
   {
      %cpclip.PlasmaClip = 4;
      %cpclip.ChaingunClip = 4;
      %cpclip.DiscClip = 3;
      %cpclip.GrenadeLauncherClip = 2;
      %cpclip.MortarClip = 1;
      %cpclip.MissileLauncherClip = 3;
      %cpclip.MMinigunClip = 2;
   }
////////////////////////
Inventoryhud.cs>buyDeployableFavorites(%client)>End Of Function
Code:
   ////////////////////
      %curArmor = %client.player.getDatablock();
      %cpclip = %client.player;
   if(%curArmor $= "light")
   {
      %cpclip.PlasmaClip = 1;
      %cpclip.ChaingunClip = 2;
      %cpclip.DiscClip = 1;
      %cpclip.GrenadeLauncherClip = 1;
//      %cpclip.MortarClip = 2;
//      %cpclip.MissileLauncherClip = 2;
//      %cpclip.MMinigunClip = 2;
   }
   if(%curArmor $= "medium")
   {
      %cpclip.PlasmaClip = 2;
      %cpclip.ChaingunClip = 2;
      %cpclip.DiscClip = 1;
      %cpclip.GrenadeLauncherClip = 2;
//      %client.player.MortarClip = 2;
      %cpclip.MissileLauncherClip = 1;
//      %client.player.MMinigunClip = 2;
   }
   if(%curArmor $= "heavy")
   {
      %cpclip.PlasmaClip = 2;
      %cpclip.ChaingunClip = 2;
      %cpclip.DiscClip = 2;
      %cpclip.GrenadeLauncherClip = 1;
      %cpclip.MortarClip = 1;
      %cpclip.MissileLauncherClip = 2;
      %cpclip.MMinigunClip = 1;
   }
////////////////////////Basically the same :P

Please don't judge me for my lack of experience, I'm just here to learn(actually, mostly to actually get this working, learning how to do it and like things is a bonus Cheesy). No syntax errors found for either files, nothing has changed in the game basically, firing is the same, invs, everything I can think of. Again, it may be all wrong or just part, help would be appreciated, thanks to all in advance.
« Last Edit: May 24, 2009, 10:01:58 AM by mHyth »


---------------------------------------------------------
Obsession. The spark of Innovation!
Phantom139
Seņor Nugget

Posts: 214

View Profile WWW
1: May 24, 2009, 01:13:58 PM »
what functions were each of these in? You did not mention them for some of your code.

Bio:
Founder/Creator Phantom Games Development.
Tribes 2 Modder, T3D Owner and Developer
Site:
www.phantomdev.net
mHyth
Nugget²

Posts: 57

View Profile
2: May 24, 2009, 01:24:21 PM »
Each bold term is where the code below it is, so the first is at the top of projectiles.cs, second is in ShapeBaseImageData::onFire, guess I forgot the onFire, its below the check for if it uses energy(in segment of code). Third is directly below onFire, the fourth and fifth are both at the very end of buyFavorites and buyDeployableFavorites respectively.


---------------------------------------------------------
Obsession. The spark of Innovation!
watermonger
Nugget
Posts: 8

View Profile
3: June 02, 2009, 12:51:16 PM »
The word clip makes me cringe.
Phantom139
Seņor Nugget

Posts: 214

View Profile WWW
4: June 03, 2009, 06:31:28 PM »
I can kind of see an error. where is the relation between %CPClip and $Clip?

Bio:
Founder/Creator Phantom Games Development.
Tribes 2 Modder, T3D Owner and Developer
Site:
www.phantomdev.net
mHyth
Nugget²

Posts: 57

View Profile
5: June 04, 2009, 07:16:38 AM »
$Clip[%c] indicates which clip you are using, such as PlasmaClip, and %CPClip = %client.player. Again, I haven't a real clue as in how to fix this.


---------------------------------------------------------
Obsession. The spark of Innovation!
keen
Seņor Nugget

Posts: 244

View Profile WWW
6: June 04, 2009, 07:36:17 AM »
Code:
else if(%data.ammo == 0)
%data (the datablock) does not store current ammo, you'd instead need to do something like
Code:
%ammo = %obj.getInventory(x);
where x = ammo name

This is what I saw first glance, I haven't checked anything else but that might be the majority of your problem.

Formerly DynaBlade
Radiant Age - My Projects:
Meltdown 1 & 2, Tactical Sky Wars, MechSiege
Pages: [1] Print 
« previous next »
Jump to:  

irc.tribalwar.com / #TribesNext Powered by SMF 1.1.18 | SMF © 2005, Simple Machines