View Full Version : Two different Recharge Rates
Dr.Thunder
02-03-2011, 08:35 AM
Hey Guys,
I was looking to change the LinkGun's recharge function to allow it to fill the AmmoCount at a different rates depending if I use Primary or Secondary fire. So if the standard recharge rate is AmmoCount += 1, I want the AmmoCount += 0.5 if I used the secondary fire.
I'm looking into the UTWeap_LinkGun file, mainly with the function RechargeAmmo() and all the variables that it involves, and any tips or advice would help get this rolling.
Also, I made bAutoCharge= true, so I don't need to pick up ammo.
daimaku
02-03-2011, 10:00 AM
you can write two custom event to change the increase amount of AmmoCount and binding the events to the primary an secondary fire in the udk input ini file, and you can modify the line with something like this
AmmoCount+=wRechargeRate;
you will modify the variable wRechargeRate when the events that are binding in the primary and secondary fire will called, but all this is in theory because i have not seen your code.
hope this help you
Dr.Thunder
02-03-2011, 03:11 PM
Will upload some code shortly, but thanks for the response. Will try it soon!
Dr.Thunder
02-04-2011, 01:06 PM
Here's some code that I'm working with.
Inside my UTWeap_LinkGun file:
function RechargeAmmo()
{
if ( AmmoCount < MaxAmmoCount && SecondFireRateON == FALSE )
{
AmmoCount += 1;
if ( AmmoCount < MaxAmmoCount )
{
SetTimer(RechargeRate, false, 'RechargeAmmo');
}
}
///////////////////////////////Secondary Fire Recharge
///Has to be true to start this recharge rate instead of the normal rate
if ( AmmoCount < MaxAmmoCount && SecondFireRateON == true)
{
AmmoCount += 1;
if ( AmmoCount < MaxAmmoCount )
{
SetTimer(RechargeRate2, false, 'RechargeAmmo');
}
}
}
Also, RechargeRate2 is defined in the default's portion. Its set to RechargeRate2 =0.004, a slow recharge rate.
In my UTProj_LinkPlasma file, I'm trying to tell the bool variable SecondFireRate to be False. The logic here (at least what I think should happen) is that when the projectile is active, the secondary recharge rate should be turned off and the primary rate already waits a few seconds already before recharging. Here's an example.
simulated event PostBeginPlay()
{
super.PostBeginPlay();
///Secondary Recharge Rate
UTWeap_LinkGun.SecondFireRateON(true);
}
Again, any advice or examples are helpful and appreciated.
daimaku
02-04-2011, 07:35 PM
hello, in the very first place i want to tell you that you can't modify your base classes, you must write your own class extending from UTWeap_LinkGun, something like
Class MyLinkGun extends UTWeap_LinkGun;
the file "MyLinkGun.uc must be in your custom class folder.
now your RechargeRates variables, are only changing the time that the function RechargeAmmo will be accessed, i think that this can do the trick
if ( AmmoCount < MaxAmmoCount && SecondFireRateON == FALSE )
{
if ( AmmoCount < MaxAmmoCount )
{
AmmoCount += 1;
}
}
if ( AmmoCount < MaxAmmoCount && SecondFireRateON == true)
{
if ( AmmoCount < MaxAmmoCount )
{
AmmoCount += 3; // i'm thinking that you want to reload fast if you
// want too slow you can increment another variable
// and when the variables reach some value you will
// increase AmmoCount
}
}
Dr.Thunder
02-07-2011, 05:27 PM
Yeah, I created the weapon files and its projectiles in its own custom class folder (by following other tutorials and such) so I got that basic down.
This is what I am up to now:
function RechargeAmmo()
{
if ( AmmoCount < MaxAmmoCount && SecondFireRateON == FALSE)
{
RechargeRate = 0.01;
AmmoCount += 1;
if ( AmmoCount < MaxAmmoCount )
{
SetTimer(RechargeRate, false, 'RechargeAmmo');
}
}
///////////////////////////////Secondary Fire Recharge
///Has to be TRUE to start this recharge rate instead of the normal rate
if ( AmmoCount < MaxAmmoCount && SecondFireRateON == TRUE)
{
RechargeRate = 0.009;
AmmoCount += 1;
if ( AmmoCount < MaxAmmoCount )
{
SetTimer(RechargeRate, false, 'RechargeAmmo');
}
}
}
The trick now is to get the SecondFireRateON = true (or) false at the right function.
I'm gonna try to set it in this function
simulated function SetCurrentFireMode(byte FiringModeNum)
{
local byte InstigatorFireMode;
CurrentFireMode = FiringModeNum;
// on the pawn, set a value of 2 if we're linked so the weapon attachment knows the difference
// and a value of 3 if we're not linked to anyone but others are linked to us
if (Instigator != None)
{
if (CurrentFireMode == 1)
{
///////////Change recharge rate
SecondFireRateON = True;
if (LinkedTo != None)
{
InstigatorFireMode = 1;
}
else
{
CalcLinkStrength();
if ( (LinkStrength > 1) || (Instigator.DamageScaling >= 2.0) )
{
if ( bBeamHit )
InstigatorFireMode = 4;
else
InstigatorFireMode = 3;
}
else
{
if ( bBeamHit )
InstigatorFireMode = 5;
else
InstigatorFireMode = CurrentFireMode;
}
}
}
if (CurrentFireMode == 2)
{
InstigatorFireMode = CurrentFireMode;
SecondFireRateON = False;
}
else
{
InstigatorFireMode = CurrentFireMode;
///////////Change recharge rate
SecondFireRateON = False;
}
Instigator.SetFiringMode(Self, InstigatorFireMode);
}
}
I'm wondering if this is the best method.
Dr.Thunder
02-09-2011, 06:35 PM
So this is how I solved different recharge rates. Thanks to daimaku for the help
function RechargeAmmo()
{
///PRIMARY FIRE RECHARGE RATE
if (SecondFireRateON == FALSE)
{
WorldInfo.Game.Broadcast(self,"Primary Recharge!");
AmmoCount += 1;
if (AmmoCount < MaxAmmoCount)
{
SetTimer(RechargeRate, false, 'RechargeAmmo');
}
}
//////Secondary Fire Recharge
else if (SecondFireRateON == TRUE)
{
WorldInfo.Game.Broadcast(self,"Secondary Recharge!");
RechargeRate += 2;
AmmoCount += 1;
if ( AmmoCount < MaxAmmoCount )
{
SetTimer(RechargeRate, false, 'RechargeAmmo');
}
}
}
Place SecondFireRateON = TRUE/FALSE when you fire.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.