PDA

View Full Version : Trying to make a few first weapons here



MukiHyena
12-09-2008, 01:39 AM
Hey all, noob here, trying to make my first couple of modified weapons for a mutator.

Basically what I'm trying to make are three weapons; a shotgun, an SMG, and a three-round burst rifle using the standard Enforcer.

Here's what I'm trying to accomplish:

SMG style Enforcer (replaces starting enforcer):
Primary - 0.66 FireInterval, spread of 4 degrees
Secondary - Disabled

Burst-rifle style Enforcer (replacing sniper rifle):
Primary - 0.66 burstfire of 3 shots, 0.4 cooldown, 1.5 headshot multiplier, perfect accuracy
Secondary - 2x zoom

Shotgun style enforcer (replacing flak cannon):
Primary 1 FireInterval, spread of 10 degrees, 15 pellets
Secondary - Disabled

I've followed a tutorial on making my first mutator, and I've had success in some areas, but not others. I've managed to up the firing rate and starting/maximum ammo. However, I haven't figured out how to make multiple projectiles come out at once (IE shotgun), nor have I figured out how to modify the cone of bullet spread.

Here is what I have so far:

class FirstMutator extends UTMutator;

function InitMutator(string Options, out string ErrorMessage)
{
if (UTGame(WorldInfo.Game) != None)
{
UTGame(WorldInfo.Game).DefaultInventory[0] = class'FirstMutator.UTWeap_EnforcerPlusOne';
}

Super.InitMutator(Options, ErrorMessage);
}

function bool CheckReplacement(Actor Other)
{
if (Other.IsA('UTWeap_Enforcer') && !Other.IsA('UTWeap_EnforcerPlusOne'))
{
ReplaceWith(Other, "UTWeap_EnforcerPlusOne");
}

return true;
}

DefaultProperties
{
}


class UTWeap_EnforcerPlusOne extends UTWeap_Enforcer;

/**
* Adds any fire spread offset to the passed in rotator
* @param BaseAim the base aim direction
* @return the adjusted aim direction
*/
simulated function rotator AddSpread(rotator BaseAim)
{
local float SpreadMod;

SpreadMod = PendingFire(1) ? 1.3 : 1.0;
if ( WorldInfo.TimeSeconds - LastFireTime > 0.8/CustomTimeDilation )
{
Spread[CurrentFireMode] = Default.Spread[CurrentFireMode];
}
else
{
if ( DualMode == EDM_Dual )
{
Spread[0] = FMin(Spread[0]+0.015,0.075);
Spread[1] = FMin(Spread[1]+0,0);
}
else
{
Spread[0] = FMin(Spread[0]+0.015,0.075);
Spread[1] = FMin(Spread[1]+0,0);
}

Spread[0] *= SpreadMod;
Spread[1] *= SpreadMod;
}

return Super.AddSpread(BaseAim);
}



DefaultProperties
{
BurstCoolDownTime=0.35
AmmoCount=120
LockerAmmoCount=120
MaxAmmoCount=240
InstantHitDamage(0) = 12
InstantHitDamage(1) = 12
FireInterval(0)=0.066
FireInterval(1)=0.066
aimerror=0.000000
Spread(0)=0.000000
Spread(1)=0.000000
}

Keep in mind I have very little experience with scripting and programming in general, so I would appreciate details on any changes I'd have to make, as well as what I'm changing and why.

What I have now is an enforcer with a firing rate of .066 for the primary and alternate fire, a full-auto primary, burst secondary. Unfortunately my modification of the spread and aimerror seem to have done nothing to the accuracy.

Thanks in advance for any help.

Malachor
12-09-2008, 01:56 AM
For the multiple projectiles, look at the Flakcannon.
I don't know about the spread part, but there doesn't seem to be any aimerror, which won't affect accuracy.

Xyx
12-09-2008, 08:06 AM
The Flak Cannon basically divides the world in front of it into a tic-tac-toe grid and then fires one shard at each grid space. This rather convoluted process tries to lower the randomness of the spread. I advise you to dispense with such subtleties for that 15 pellet shotgun blast and simply use a random spread.

AimError probably just lets the bots know what level of inaccuracy they should fake (them being aimbots by their very nature). It should not have any effect on the weapon itself, so it shouldn't apply when the weapon is used by a player.

Acecutter69
12-09-2008, 01:17 PM
k I have some experience in this aspect. For the enforcer, to disable the alternate fire, you might as well make it the same as the primary fire. In the default properties of the enforcer, you will find something like:

FiringState(1)="Bursting"

Simply change that to "Firing" and now no matter what button you press, the weapon will fire the same way. It really not disabling it cause quite frankly that would take a lot of work that is really not necesary and this method achieves the same goal though through a much easier method.

Now for the sniper rifle, your looking into simple default property changes. Dont forget to add the object lines so that you have your mesh rather than the default one (sorry kinda sick and tired of people doing behavior mods to weapons and calling them their own). Now alright just as I stated on the top paragraph we can some simple changes to the sniper as well. To change the single fire to a burst (careful with this as it plays one animation for all 3 shots). First we make sure we have the default properties necesary:

Burst = 3 // This is the amount of shots before bursting is done
CoolDownTime = 3.0000 // This is the float that determines the time between bursts (syntax could be wrong but after all i am telling you this from memory, please search the files and make sure you have the right syntax or else I am not going to help you with dumb compile error because you copied and pasted what I am posting here).

You need those two to tell the bursting state what to do. Now you can add this line as well:

FiringState(0)="Bursting"

This tells the weapon to use the bursting state rather than the firing state for the primary fire. And there you go. Please I state this again, I am just explaining this of the top of my head, you must do some work and read the post and read the files and find the attribues you need and copy them from there and not this post. I might have stated the variables incorrectly but they should be close enough for you to recognize them in the exported scritps. Good luck.

MukiHyena
12-11-2008, 09:28 PM
k I have some experience in this aspect. For the enforcer, to disable the alternate fire, you might as well make it the same as the primary fire. In the default properties of the enforcer, you will find something like:

FiringState(1)="Bursting"

Simply change that to "Firing" and now no matter what button you press, the weapon will fire the same way. It really not disabling it cause quite frankly that would take a lot of work that is really not necesary and this method achieves the same goal though through a much easier method.

Now for the sniper rifle, your looking into simple default property changes. Dont forget to add the object lines so that you have your mesh rather than the default one (sorry kinda sick and tired of people doing behavior mods to weapons and calling them their own). Now alright just as I stated on the top paragraph we can some simple changes to the sniper as well. To change the single fire to a burst (careful with this as it plays one animation for all 3 shots). First we make sure we have the default properties necesary:

Burst = 3 // This is the amount of shots before bursting is done
CoolDownTime = 3.0000 // This is the float that determines the time between bursts (syntax could be wrong but after all i am telling you this from memory, please search the files and make sure you have the right syntax or else I am not going to help you with dumb compile error because you copied and pasted what I am posting here).

You need those two to tell the bursting state what to do. Now you can add this line as well:

FiringState(0)="Bursting"

This tells the weapon to use the bursting state rather than the firing state for the primary fire. And there you go. Please I state this again, I am just explaining this of the top of my head, you must do some work and read the post and read the files and find the attribues you need and copy them from there and not this post. I might have stated the variables incorrectly but they should be close enough for you to recognize them in the exported scritps. Good luck.


Thanks for the advice, I'll see what I can do. Also, I'm not using any custom mesh or anything. This is, in fact, only a behavior mod at this point. I'm just starting out with this, this is my first attempt at anything. So nothing too flashy, and nothing I'm planning on releasing until I learn more.

m86firestorm
12-12-2008, 12:12 AM
If you want to completely disable secondary fire, try this:


simulated function StartFire(byte FireModeNum)
{
if (FireModeNum == 0) {
super.StartFire(FireModeNum);
}
}

It'll make it so if you right click, absolutely nothing happens. I'd personally do Acecutter's solution, as it is kinda wierd to right click and nothing happen (since everything else in the game has an alt-fire) but if that's what you really want, that code should work.