[UT2004]InstantFire Shotgun

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

CheekyDevil

Earth Assault Design Lead
Apr 24, 2004
41
0
0
35
The Pit of Dispare
dasboogles.com
I have sucessfully implimented a shotgun into the mod I'm working on using ProjectileFire, but since all the other bullet based weapons are going to be InstantFire weapons, I feel like it would be more efficient and would make me feel better to have an InstantFire shotgun.
I've searched all over, in these forums, and have found some code that poeple have posted to do this, such as:
Code:
class BuckshotFire extends InstantFire;

function DoFireEffect()
{
local Vector StartTrace, SpreadRand;
local Rotator R, Aim;
local int i;

	Instigator.MakeNoise(1.0);

	StartTrace = Instigator.Location + Instigator.EyePosition();
	Aim = AdjustAim(StartTrace, AimError);

	for( i=0; i<TracesPerShot; i++ )
	{
		SpreadRand = VRand()*FRand()*Spread;

		R = rotator(vector(Aim) + SpreadRand);

		DoTrace(StartTrace, R);
	}
}
which was posted by EvilDrWong.
However, when I try to compile this class, I get an error "Error, Bad or missing expression after '<'" refuring to the i<TracesPerShot; part. Has anyone used code similar to this before? Or if you have code that you have used to do what I need and know it works, I would really appreciate seeing it.
 
Last edited:

Dark[NSF]

Northwest Secessionalist Forces
I could never get my instant fire shotgun to function right.. It always ended up shooting all the tracers in one spot.

Code:
local int i;

for (i=0; i < NumberOfShots; i++)
{
  Other=Trace(.. .. .. .. ..);
  if(Other)
  {
    //do stuff
  }
}

I used a loop method posted by SolidSnake, try this and see what happens for ya.
 

CheekyDevil

Earth Assault Design Lead
Apr 24, 2004
41
0
0
35
The Pit of Dispare
dasboogles.com
Dark[NSF] said:
I could never get my instant fire shotgun to function right.. It always ended up shooting all the tracers in one spot.

Code:
local int i;

for (i=0; i < NumberOfShots; i++)
{
  Other=Trace(.. .. .. .. ..);
  if(Other)
  {
    //do stuff
  }
}

I used a loop method posted by SolidSnake, try this and see what happens for ya.


Where would I put that exaclty? Should i replace the code I have right now, or add that to it? And what variables do I change to increase/decrease the spread?

EDIT: I put that in my ShottyFire class and it gives me an error "Local variables are only allowed in functions" every time. Is there a specific place it has to go? Is there anything else I need?
 
Last edited:

Dark[NSF]

Northwest Secessionalist Forces
Well it just uses less lines, look in instant fire where it does the trace, use that code and change the spread variable like on a normal ut weapon (try using assaultgun's spread value for example).

It should run through the loop and select a different location each time to hit.. Make sure you set NumberOfShots or TracesPerShot to something over 5 atleast so you can tell.
 

EvilDrWong

Every line of code elevates you
Jun 16, 2001
932
0
0
40
Inside the machine
Visit site
You cant use variables that dont exist.
Code:
class BuckshotFire extends InstantFire;

[b]var int TracesPerShot;[/b]        //You see what I did there?

function DoFireEffect()
{
local Vector StartTrace, SpreadRand;
local Rotator R, Aim;
local int i;

	Instigator.MakeNoise(1.0);

	StartTrace = Instigator.Location + Instigator.EyePosition();
	Aim = AdjustAim(StartTrace, AimError);

	for( i=0; [b]i<TracesPerShot;[/b] i++ )        //Now this will work because TracesPerShot exists
	{
		SpreadRand = VRand()*FRand()*Spread;

		R = rotator(vector(Aim) + SpreadRand);

		DoTrace(StartTrace, R);
	}
}

defaultproperties
{
    [b]TracesPerShot=7[/b]        //Here too!
}
 

CheekyDevil

Earth Assault Design Lead
Apr 24, 2004
41
0
0
35
The Pit of Dispare
dasboogles.com
Dark[NSF] said:
Well it just uses less lines, look in instant fire where it does the trace, use that code and change the spread variable like on a normal ut weapon (try using assaultgun's spread value for example).

It should run through the loop and select a different location each time to hit.. Make sure you set NumberOfShots or TracesPerShot to something over 5 atleast so you can tell.

So how exactly is this code suppost to work, because as far as I can see, it does like nothing but count up. Is something supposed to go in the //Do stuff part?
 

CheekyDevil

Earth Assault Design Lead
Apr 24, 2004
41
0
0
35
The Pit of Dispare
dasboogles.com
EvilDrWong said:
You cant use variables that dont exist.
Code:
class BuckshotFire extends InstantFire;

[b]var int TracesPerShot;[/b]        //You see what I did there?

function DoFireEffect()
{
local Vector StartTrace, SpreadRand;
local Rotator R, Aim;
local int i;

	Instigator.MakeNoise(1.0);

	StartTrace = Instigator.Location + Instigator.EyePosition();
	Aim = AdjustAim(StartTrace, AimError);

	for( i=0; [b]i<TracesPerShot;[/b] i++ )        //Now this will work because TracesPerShot exists
	{
		SpreadRand = VRand()*FRand()*Spread;

		R = rotator(vector(Aim) + SpreadRand);

		DoTrace(StartTrace, R);
	}
}

defaultproperties
{
    [b]TracesPerShot=7[/b]        //Here too!
}


Ah thanks. At least it compiles now. But I don't see any sparks or bullet holes when i shoot things, so it's hard to tell if there's any spread. I am extending AssaultFire, so I don't know what's the deal. To increse the spread I would just use the Spread=wuteva line in defaultproperties right?
And how can I do damage attenuation with InstantFire?
 

EvilDrWong

Every line of code elevates you
Jun 16, 2001
932
0
0
40
Inside the machine
Visit site
Yes, Spread=Wuteva in DefaultProperties will make spread equal to wuteva. The SpawnBeamEffect function should suffice for hit effects. Damage attenuation would be done in DoTrace. If Im not mistaken, that subject was brought up no more than a week ago here, shouldnt be too far down the page.
 

CheekyDevil

Earth Assault Design Lead
Apr 24, 2004
41
0
0
35
The Pit of Dispare
dasboogles.com
EvilDrWong said:
Yes, Spread=Wuteva in DefaultProperties will make spread equal to wuteva. The SpawnBeamEffect function should suffice for hit effects. Damage attenuation would be done in DoTrace. If Im not mistaken, that subject was brought up no more than a week ago here, shouldnt be too far down the page.

Sorry, but I'm a newb to programming (my partner is in charge of that, but he's away right now so I'm trying to get some things done on my own) but would I just add
Code:
function SpawnBeamEffect(Vector Start, Rotator Dir, Vector HitLocation, Vector HitNormal, int ReflectNum)
{
}
to my ShottyFire class or is there more to it?
And yes I have searched for topics on my problem and have found some, but none of them gave me any conclusive information. Maybe I'll check again for this DoTrace thing.

OK I figured out how to make a SpawnBeamEffect but I don't know if that's what i need. It works to make shock beams, which makes my shotgun into a crazy laser shotty :p but can it also be used for assault rifel type sparks and bullet holes, or is that a different function?
 
Last edited:

Postal

I apear to have lost my pin.
Nov 14, 1999
1,388
0
0
WoD.BeyondUnreal.com
the sparks and hit effects are handled by the weapon attachment. For instance, in AssaultAttach, theres where it tells to make sparks and whatnot.
 

CheekyDevil

Earth Assault Design Lead
Apr 24, 2004
41
0
0
35
The Pit of Dispare
dasboogles.com
Ok, well I got it all working, thanks to EvilDrWong. I had to figure out the right SpawnBeamEffect to use; in this case, xHeavyWallHitEffect.
Now I'm wondering how to attach multiple SpawnBeamEffects to the fire class. Like if I wanted to have the muzzle smoke as well as make wall sparks.
 

Dark[NSF]

Northwest Secessionalist Forces
CheekyDevil said:
Ok, well I got it all working, thanks to EvilDrWong. I had to figure out the right SpawnBeamEffect to use; in this case, xHeavyWallHitEffect.
Now I'm wondering how to attach multiple SpawnBeamEffects to the fire class. Like if I wanted to have the muzzle smoke as well as make wall sparks.

use a for( ;; ) loop

Code:
for(i=0;i<tracespershot;i++)

i=0 says where i should start
i<tracespershot says where the loop should stop
i++ says how many to increment by.
 
Last edited:

Dark[NSF]

Northwest Secessionalist Forces
wait what the hell am i thinking.. DoTrace() is already in a loop from your DoFireEffect().. you don't need a loop..

in your weaponfire's SpawnBeamEffects() have a spawn call that summons ur hiteffect class.
 
Last edited: