charged shot

Discussions about Coding and Scripting
User avatar
>@tack!<
Adept
Posts: 338
Joined: Sat Apr 17, 2010 4:51 pm
Personal rank: lol?

charged shot

Post by >@tack!< »

can someone explain the mechanism of the biorifle charged shot? i really mean the details with some forced things and stuff cuz i copy pasted some stuff and changed some stuff and it didnt work out exactly how i wanted.
User avatar
Rakiayn
Masterful
Posts: 550
Joined: Fri Aug 28, 2009 3:33 pm

Re: charged shot

Post by Rakiayn »

Code: Select all


var float ChargeSize, Count;
var bool bBurst;

//'state altfiring' is called when you press altfire.


state AltFiring
{
	ignores AnimEnd;

	function Tick( float DeltaTime )
	{
                //the function tick is called avery few time ( probally a few times every second)

		//SetLocation(Owner.Location);
		if ( ChargeSize < 4.1 )
                                //checking to see if the charge is below 4.1
		{
                               
			Count += DeltaTime;
                                                //if it is, add to the count

			if ( (Count > 0.5) && AmmoType.UseAmmo(1) )
			{
                                                //checking to see if user has enough owner and if count is high enough
                                               
				ChargeSize += Count;
				Count = 0;
                                                                // if it is, add to the chargesize
                                                             
				if ( (PlayerPawn(Owner) == None) && (FRand() < 0.2) )
					GoToState('ShootLoad');
                                                                //check if player has no owner, if true , fire
			}
		}
		if( (pawn(Owner).bAltFire==0) ) 
			GoToState('ShootLoad');
                               //check if player is not using altfire, if true , fire
	}

	function BeginState()
	{
               // called the first time you press alt fire, setting count and chargesize to 0
		ChargeSize = 0.0;
		Count = 0.0;
	}

	function EndState()
	{
		ChargeSize = FMin(ChargeSize, 4.1);
                // called when you stop pressing altfire, chargesize is either 4.1 or the actual chargesize, depending on which is the lowest value
	}

Begin:
	FinishAnim();
}
Last edited by Rakiayn on Sat Feb 12, 2011 10:51 am, edited 1 time in total.
User avatar
Rakiayn
Masterful
Posts: 550
Joined: Fri Aug 28, 2009 3:33 pm

Re: charged shot

Post by Rakiayn »

Code: Select all

state ShootLoad
{
	function ForceFire()
	{
		bForceFire = true;
	}

	function ForceAltFire()
	{
		bForceAltFire = true;
	}

	function Fire(float F) 
	{
	}

	function AltFire(float F) 
	{
	}

	function Timer()
	{
		local rotator R;
		local vector start, X,Y,Z;

		GetAxes(Pawn(owner).ViewRotation,X,Y,Z);
		R = Owner.Rotation;
		R.Yaw = R.Yaw + Rand(8000) - 4000;
		R.Pitch = R.Pitch + Rand(1000) - 500;
		Start = Owner.Location + CalcDrawOffset() + FireOffset.X * X + FireOffset.Y * Y + FireOffset.Z * Z; 
		Spawn(AltProjectileClass,,, Start,R);

		R = Owner.Rotation;
		R.Yaw = R.Yaw + Rand(8000) - 4000;
		R.Pitch = R.Pitch + Rand(1000) - 500;
		Start = Owner.Location + CalcDrawOffset() + FireOffset.X * X + FireOffset.Y * Y + FireOffset.Z * Z; 
		Spawn(AltProjectileClass,,, Start,R);
	}

	function AnimEnd()
	{
		Finish();
	}

	function BeginState()
	{
		Local Projectile Gel;

		Gel = ProjectileFire(AltProjectileClass, AltProjectileSpeed, bAltWarnTarget);
		Gel.DrawScale = 1.0 + 0.8 * ChargeSize;
                                // In this code you see that the biogel that is spawned by altfire is affected by the chargesize
		PlayAltBurst();
	}

Begin:
}
so the drawscale of the biogel is defined by the chargesize, which builds up as you hold altfire. to a max of 4.1
the amount of splashes of the biogel is handled in the code of the biogel itself (depending on its drawscale)
User avatar
>@tack!<
Adept
Posts: 338
Joined: Sat Apr 17, 2010 4:51 pm
Personal rank: lol?

Re: charged shot

Post by >@tack!< »

that part is working well what i copy pasted only when i have shot, it wont shoot anymore and i cant switch to another weapon. and the weaponlogo on the bottom of the screen is constantly bright.
User avatar
Rakiayn
Masterful
Posts: 550
Joined: Fri Aug 28, 2009 3:33 pm

Re: charged shot

Post by Rakiayn »

perhaps you are using and unreal 1 ammotype?
that could be the problem.
if not, I think it has to do with the parentclass. under which class is your biorifle subclassed? you might want to look at the parents class code