1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. 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.

Help pls asked around no one knows . . .

Discussion in 'Ask a Coder' started by Fustrun, Apr 18, 2004.

  1. Fustrun

    Fustrun Artist

    Joined:
    Oct 30, 2002
    Messages:
    31
    Likes Received:
    0
    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" ??
     
  2. Postal

    Postal I apear to have lost my pin.

    Joined:
    Nov 14, 1999
    Messages:
    1,388
    Likes Received:
    0
    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: Apr 18, 2004
  3. Fustrun

    Fustrun Artist

    Joined:
    Oct 30, 2002
    Messages:
    31
    Likes Received:
    0
    And how about brust pls ? (-8
     
  4. Fustrun

    Fustrun Artist

    Joined:
    Oct 30, 2002
    Messages:
    31
    Likes Received:
    0
    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
     
  5. soldat

    soldat resident potato

    Joined:
    Oct 28, 2002
    Messages:
    70
    Likes Received:
    0
    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: Apr 18, 2004
  6. Fustrun

    Fustrun Artist

    Joined:
    Oct 30, 2002
    Messages:
    31
    Likes Received:
    0
    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: Apr 18, 2004
  7. Postal

    Postal I apear to have lost my pin.

    Joined:
    Nov 14, 1999
    Messages:
    1,388
    Likes Received:
    0
    How about:

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

    Burst isnt hard at all, try using a loop.
     
  8. Fustrun

    Fustrun Artist

    Joined:
    Oct 30, 2002
    Messages:
    31
    Likes Received:
    0
    What do you mean ?
    and how?
     
  9. soldat

    soldat resident potato

    Joined:
    Oct 28, 2002
    Messages:
    70
    Likes Received:
    0
    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).
     
  10. EvilDrWong

    EvilDrWong Every line of code elevates you

    Joined:
    Jun 16, 2001
    Messages:
    932
    Likes Received:
    0
    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.
     
  11. Fustrun

    Fustrun Artist

    Joined:
    Oct 30, 2002
    Messages:
    31
    Likes Received:
    0
    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
     
  12. Postal

    Postal I apear to have lost my pin.

    Joined:
    Nov 14, 1999
    Messages:
    1,388
    Likes Received:
    0
    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
     
  13. Fustrun

    Fustrun Artist

    Joined:
    Oct 30, 2002
    Messages:
    31
    Likes Received:
    0
    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 . . .
     
  14. Fustrun

    Fustrun Artist

    Joined:
    Oct 30, 2002
    Messages:
    31
    Likes Received:
    0
    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 ??
     
  15. Postal

    Postal I apear to have lost my pin.

    Joined:
    Nov 14, 1999
    Messages:
    1,388
    Likes Received:
    0
    if that works, go for it. That would also work if you wanted say for a MP5, a semi burst and full auto.
     
  16. Fustrun

    Fustrun Artist

    Joined:
    Oct 30, 2002
    Messages:
    31
    Likes Received:
    0
    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 ?
     
  17. EvilDrWong

    EvilDrWong Every line of code elevates you

    Joined:
    Jun 16, 2001
    Messages:
    932
    Likes Received:
    0
    its funky, but when youre accessing arrays you use [ and ]'s in the body of the code, ( and )'s in default properties
     
  18. Fustrun

    Fustrun Artist

    Joined:
    Oct 30, 2002
    Messages:
    31
    Likes Received:
    0
    And that means ??
    Why doesnt it work ??
     
  19. Fustrun

    Fustrun Artist

    Joined:
    Oct 30, 2002
    Messages:
    31
    Likes Received:
    0
    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
     

Share This Page