Help pls asked around no one knows . . .

  • 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.

Fustrun

Artist
Oct 30, 2002
31
0
0
Visit site
Hi everyone.

I modified the assault rifle that will go for the M16 and what i want is when a player is crouched that the spread will change to more accurate but i tried and asked people around everyone gave me some sulotions and none worked hope u can help here is the code . . .

Event Tick(float deltatime)
{
local Pawn P;

P = instigator;
if (P.bIsCrouched)
{
Spread = 0.000100;
}
else
{
Spread = Default.Spread;
}
}

Maybe im using the wrong bool "P.bIsCrouched" pls help.

And how can i make my m16 switch fire modes from semi to brust by pressing the key "T" ??
 

Postal

I apear to have lost my pin.
Nov 14, 1999
1,388
0
0
WoD.BeyondUnreal.com
Using the tick is wastefull in this situation. Place a check in the "event ModeDoFire()" or something like that. "if(Instigator.bIsCrouched)" should work.

Semi auto can be made by adding "bWaitForRelease=True"

Tell Oli that Postal said "Hi".
 
Last edited:

Fustrun

Artist
Oct 30, 2002
31
0
0
Visit site
Damn it doesnt work . . .

event IfCrouched()
{
local Pawn P;

P = xPawn(Owner);
if (Instigator.bIsCrouched)
{
Spread = 10.000000;
}
else
{
Spread = Default.Spread;
}
}

Mabye im using a wrong bool ?
And if u can tell me how to make a brust fire ill be very glad and thankfull (-8
 

soldat

resident potato
Oct 28, 2002
70
0
0
39
the corner pocket
Visit site
bIsCrouched should be correct... a few possibilities: 1. you aren't using spread in your weapon firing code. 2. you aren't calling IfCrouched in the right place. i tend to think its the first one. If you are using the stock InstantHit code, it doesn't use Spread, but AimError instead. Spread is for projectiles.

okay here's my burst code from objpoint. use with care and love.

first, add a bCantShoot bool.

now call this function after the weapon actually fires (in DoFireEffect or something).

function HandleFireMode()
{
bWaitForRelease=false;

if(FireCount>1)
{
if(!Instigator.Controller.IsA('PlayerController'))
{
bCantShoot=true;
SetTimer(0.3,false);
}
else
bWaitForRelease=true;
}
}

----------------------------
and then add this

function Timer()
{
bCantShoot=false;
}

------------------------------
finally, update your AllowFire()

simulated function bool AllowFire()
{
if(bCantShoot)
return false;

// ... blah blah rest of AllowFire

return super.AllowFire();
}
 
Last edited:

Fustrun

Artist
Oct 30, 2002
31
0
0
Visit site
class m16Fire extends InstantFire;

#EXEC OBJ LOAD FILE=Csutsounds.uax

var float LastFireTime;
var float ClickTime;
var bool Crouched;

function InitEffects()
{
Super.InitEffects();
if ( FlashEmitter != None )
Weapon.AttachToBone(FlashEmitter, 'tip');
}

function FlashMuzzleFlash()
{
local rotator r;
r.Roll = Rand(65536);
Weapon.SetBoneRotation('Bone_Flash', r, 0, 1.f);
Super.FlashMuzzleFlash();
}

event IfCrouched()
{
local Pawn P;

P = xPawn(Owner);
if (Instigator.bIsCrouched)
{
Spread = 10.000000;
}
else
{
Spread = Default.Spread;
}
}

simulated function bool AllowFire()
{
if (Super.AllowFire())
return true;
else
{
if ( (PlayerController(Instigator.Controller) != None) && (Level.TimeSeconds > ClickTime) )
{
Instigator.PlaySound(Sound'WeaponSounds.P1Reload5');
ClickTime = Level.TimeSeconds + 0.25;
}
return false;
}
}

function StartBerserk()
{
DamageMin = default.DamageMin * 1.33;
DamageMax = default.DamageMax * 1.33;
}

function StopBerserk()
{
DamageMin = default.DamageMin;
DamageMax = default.DamageMax;
}

function StartSuperBerserk()
{
FireRate = default.FireRate * 1.5/Level.GRI.WeaponBerserk;
FireAnimRate = default.FireAnimRate * 0.667 * Level.GRI.WeaponBerserk;
DamageMin = default.DamageMin * 1.5;
DamageMax = default.DamageMax * 1.5;
if (AssaultRifle(Weapon) != None && AssaultRifle(Weapon).bDualMode)
FireRate *= 0.55;
}

defaultproperties
{
DamageType=XWeapons.DamTypeAssaultBullet
DamageMin=45
DamageMax=45
Momentum=0.000000
bPawnRapidFireAnim=True
FireLoopAnim=
FireEndAnim=
FireSound=Csutsounds.M16fire
FireForce="AssaultRifleFire"
FireRate=0.300000
bWaitForRelease=True
AmmoClass=Csut.M16Ammo
AmmoPerFire=1
ShakeRotMag=(X=50.000000,Y=50.000000,Z=50.000000)
ShakeRotRate=(X=10000.000000,Y=10000.000000,Z=10000.000000)
ShakeRotTime=2.000000
ShakeOffsetMag=(X=1.000000,Y=1.000000,Z=1.000000)
ShakeOffsetRate=(X=1000.000000,Y=1000.000000,Z=1000.000000)
ShakeOffsetTime=2.000000
BotRefireRate=0.990000
FlashEmitterClass=XEffects.AssaultMuzFlash1st
aimerror=80000.000000
Spread=0.020000
SpreadStyle=SS_Random
}


This is my code rewrite it so it would work PLS cant understand my problem . . .
I checked and spread is the right object "aimerror=80000.000000" and im shooting very accurate (-8

is this what u ment ?
__________________________________-
class m16Fire extends InstantFire;

#EXEC OBJ LOAD FILE=Csutsounds.uax

var float LastFireTime;
var float ClickTime;
var bool Crouched;

function InitEffects()
{
Super.InitEffects();
if ( FlashEmitter != None )
Weapon.AttachToBone(FlashEmitter, 'tip');
}

function HandleFireMode()
{
bWaitForRelease=false;

if(FireCount>1)
{
if(!Instigator.Controller.IsA('PlayerController'))
{
bCantShoot=true;
SetTimer(0.3,false);
}
else
bWaitForRelease=true;
}
}

function Timer()
{
bCantShoot=false;
}

function FlashMuzzleFlash()
{
local rotator r;
r.Roll = Rand(65536);
Weapon.SetBoneRotation('Bone_Flash', r, 0, 1.f);
Super.FlashMuzzleFlash();
}

event IfCrouched()
{
local Pawn P;

P = xPawn(Owner);
if (Instigator.bIsCrouched)
{
Spread = 10.000000;
}
else
{
Spread = Default.Spread;
}
}

simulated function bool AllowFire()
{
if(bCantShoot)
return false;

if (Super.AllowFire())
return true;
else
{
if ( (PlayerController(Instigator.Controller) != None) && (Level.TimeSeconds > ClickTime) )
{
Instigator.PlaySound(Sound'WeaponSounds.P1Reload5');
ClickTime = Level.TimeSeconds + 0.25;
}
return false;
}
return super.AllowFire();
}

function StartBerserk()
{
DamageMin = default.DamageMin * 1.33;
DamageMax = default.DamageMax * 1.33;
}

function StopBerserk()
{
DamageMin = default.DamageMin;
DamageMax = default.DamageMax;
}

function StartSuperBerserk()
{
FireRate = default.FireRate * 1.5/Level.GRI.WeaponBerserk;
FireAnimRate = default.FireAnimRate * 0.667 * Level.GRI.WeaponBerserk;
DamageMin = default.DamageMin * 1.5;
DamageMax = default.DamageMax * 1.5;
if (AssaultRifle(Weapon) != None && AssaultRifle(Weapon).bDualMode)
FireRate *= 0.55;
}

defaultproperties
{
DamageType=XWeapons.DamTypeAssaultBullet
DamageMin=45
DamageMax=45
Momentum=0.000000
bPawnRapidFireAnim=True
FireLoopAnim=
FireEndAnim=
FireSound=Csutsounds.M16fire
FireForce="AssaultRifleFire"
FireRate=0.300000
bWaitForRelease=True
AmmoClass=Csut.M16Ammo
AmmoPerFire=1
ShakeRotMag=(X=50.000000,Y=50.000000,Z=50.000000)
ShakeRotRate=(X=10000.000000,Y=10000.000000,Z=10000.000000)
ShakeRotTime=2.000000
ShakeOffsetMag=(X=1.000000,Y=1.000000,Z=1.000000)
ShakeOffsetRate=(X=1000.000000,Y=1000.000000,Z=1000.000000)
ShakeOffsetTime=2.000000
BotRefireRate=0.990000
FlashEmitterClass=XEffects.AssaultMuzFlash1st
aimerror=80000.000000
Spread=0.020000
SpreadStyle=SS_Random
}
____________________________________________________

Because if yes im getting this error . . .
"Bad or missing expression in If. M16Fire.uc (Line 62)"

And any idea how i can change my fire rate from brust to semi with key assaign ?? PLS im so thankfull its the first place im actually getting answers :eek: so be very glad if u can help me out here looking a month allready for an answer
 
Last edited:

soldat

resident potato
Oct 28, 2002
70
0
0
39
the corner pocket
Visit site
1) AllowFire looks pretty ugly, re-write it.

2) add "var bool bCantShoot"

3) you're never calling HandleFireMode(). add code like this:

function DoFireEffect()
{
super.DoFireEffect();
HandleFireMode();
}

4) Finally, what are you trying to do with "Spread=0.020000"? Typical spread values should be 50 (for a sniper), 600 (for handgun), to 1900 (for shotgun pellets).
 

EvilDrWong

Every line of code elevates you
Jun 16, 2001
932
0
0
40
Inside the machine
Visit site
soldat said:
Finally, what are you trying to do with "Spread=0.020000"? Typical spread values should be 50 (for a sniper), 600 (for handgun), to 1900 (for shotgun pellets).
No wonder its so freakin hard to hit with your guns! ;)
Spread should be less than 1. Aimerror is the one that should be bigger, as its added directly to the rotator. Spread is used in instant hit weapons to figure the normal spread for the traces, for players i suppose. AimError is used mostly, if not completely, by the AI to help screw bots' aim up beyond that initial spread to make low skilled bots have a harder time hitting than the high skilled ones.
 

Fustrun

Artist
Oct 30, 2002
31
0
0
Visit site
Thx Thx Thx Thx the brust works like a butiy LOVE IT !!
And any idea how can i change the fire rate "brust" "semi" with a key ?

and it still doesnt change

Event Tick(float deltatime)
{
local Pawn P;

P = instigator;
if (P.bIsCrouched)
{
Spread = 1800.000000;
aimerror=80000.000000;
}
else
{
Spread = Default.Spread;
}
}

If it workes i need to see a diffrence dont u think ? (-8
 

Postal

I apear to have lost my pin.
Nov 14, 1999
1,388
0
0
WoD.BeyondUnreal.com
I tried to say like 3 times, dont use tick. Use something like that code I showed you up above

Code:
event ModeDoFire()
{
if(Instigator.bIsCrouched)
{
}
Super.ModeDoFire();
}

Put youre aim and spread in there in youre fireclass
 

Fustrun

Artist
Oct 30, 2002
31
0
0
Visit site
Yes it works the crouch thing works . . !!!
THANK U SO MUCH !!!

Now about the brust when i fire it i can stop in the middle of my brust fire and the brust fire shoots 3 bullets only if I keep my mouse button pressed and if i leave it, it will stop the brust firing process . . .
 

Fustrun

Artist
Oct 30, 2002
31
0
0
Visit site
exec function FireRate()
{
local int i;

for(i=1;i<2;i++)
{
If ( i == 1)
{
FireModeClass(0) = FireModeClass(0).M16FireSemi;
}
if ( i == 2)
{
FireModeClass(0) = Default.FireModeClass(0);
}
else
( i == 1 )
}
}

Hows this for fire rate ??
 

Fustrun

Artist
Oct 30, 2002
31
0
0
Visit site
GGGGGGRRRRRRR !!!!!!!!!!!!!!

Error in M16Rifle.uc (101): '(': Expression has no effect

exec function FireRate()
{
local int i;

for(i=1;i<2;i++)
{
If ( i == 1)
{
FireModeClass(0) = FireModeClass(0).M16FireSemi; <----- Line 101
}
if ( i == 2)
{
FireModeClass(0) = Default.FireModeClass(0);
}
else
( i == 1 )
}
}

And i still didnt solve the problem with the brust fire )-8 ?
 

Fustrun

Artist
Oct 30, 2002
31
0
0
Visit site
I changed the Code to this . . .
But he shows only the first log message!!
And doesnt continues the IF's but he compiled it fine !

exec function FireRate()
{
i = 1;
log("I HAVE BEEN ACTIVATED !!!!"); <----------- This one
If ( i == 1)
{
log("I HAVE BEEN ACTIVATED !!!!");
FireModeClass[0]=class'M16FireSemi';
}
else if ( i == 2)
{
log("I HAVE BEEN ACTIVATED !!!!");
FireModeClass[0]=class'M16FireBrust';
i = 1;
}
}

Oh and sorry for my stupid question the earlier post (-8