Announcement

Collapse
No announcement yet.

Reflected shock beam question

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Reflected shock beam question

    So I've made an instagib gun that has the shield as secondary fire.view here The instagib beam is reflected by the shield, but i want to cause a pawn hit by the reflected beam to be gibbed. i thought that there was a reference that needed to be changed since i subclassed the shockbeamfire/shockbeameffect, but the shock beam does not deal damage when reflected either. does anyone know how i could go about doing this??? here is the code for the reflection of the shield gun: if ( CheckReflect(HitLocation, HitNormal, 0) )
    {
    Drain = Min( AmmoAmount(1)*2, Damage );
    Drain = Min(Drain,DamageMax);
    Reflect = MirrorVectorByNormal( Normal(Location - HitLocation), Vector(Instigator.Rotation) );
    Damage -= Drain;
    Momentum *= 1.25;
    if ( (Instigator != None) && (Instigator.PlayerReplicationInfo != None) && (Instigator.PlayerReplicationInfo.HasFlag != None) )
    {
    Drain = Min(AmmoAmount(1), Drain);
    ConsumeAmmo(1,Drain);
    DoReflectEffect(Drain);
    }
    else
    {
    ConsumeAmmo(1,Drain/2);
    DoReflectEffect(Drain/2);
    }
    }
    }

    function DoReflectEffect(int Drain)
    {
    PlaySound(ShieldHitSound, SLOT_None);
    ShieldAltFire(FireMode[1]).TakeHit(Drain);
    ClientTakeHit(Drain);
    }

    simulated function ClientTakeHit(int Drain)
    {
    ClientPlayForceFeedback(ShieldHitForce);
    ShieldAltFire(FireMode[1]).TakeHit(Drain);
    }

    simulated function float AmmoStatus(optional int Mode) // returns float value for ammo amount
    {
    if ( Instigator == None || Instigator.Weapon != self )
    {
    if ( (FireMode[1].TimerInterval != 0.f) && (FireMode[1].NextTimerPop < Level.TimeSeconds) )
    {
    FireMode[1].Timer();
    if ( FireMode[1].bTimerLoop )
    FireMode[1].NextTimerPop = FireMode[1].NextTimerPop + FireMode[1].TimerInterval;
    else
    FireMode[1].TimerInterval = 0.f;
    }
    }
    return Super.AmmoStatus(Mode);
    }


    function bool CheckReflect( Vector HitLocation, out Vector RefNormal, int AmmoDrain )
    {
    local Vector HitDir;
    local Vector FaceDir;

    if (!FireMode[1].bIsFiring || AmmoAmount(0) == 0) return false;

    FaceDir = Vector(Instigator.Controller.Rotation);
    HitDir = Normal(Instigator.Location - HitLocation + Vect(0,0,8));
    //Log(self@"HitDir"@(FaceDir dot HitDir));

    RefNormal = FaceDir;

    if ( FaceDir dot HitDir < -0.37 ) // 68 degree protection arc
    {
    if (AmmoDrain > 0)
    ConsumeAmmo(0,AmmoDrain);
    return true;
    }
    return false;
    }

    function AnimEnd(int channel)
    {
    if (FireMode[0].bIsFiring)
    {
    LoopAnim('Charged');
    }
    else if (!FireMode[1].bIsFiring)
    {
    Super.AnimEnd(channel);
    }
    I'm just not sure how i would go about telling the engine that the reflected beam should deal damage and have the same damage type properties of the beamfire. Is it even possible, since the beam is instant hit? is the reflected beam just an emitter and not the beamfire itself? questions i need answers to! any help would be much appreciated!

    #2
    Re: Reflected shock beam question

    This looks a bit too tricky to answer flat out, but here's a start... The location the beam ends up at is not important, it's the actor that gets hit. They're both determined in the shock rifle's TraceFire, and I bet that from there the reflect thingly only determines a new location and not a new actor. You'd need to look at the shock rifle's TraceFire (or its base class InstantFire's TraceFire) to see how the reflect check gets handled and whether a new actor is determined. Once you know how that is handled, it shouldn't be too hard to figure out who/what gets hit at the end of the reflected beam.

    Comment


      #3
      ok, so ive looked at both the shockbeam's trace function and the instantfire class. i found this in the shockbeamfire class:
      Beam = Weapon.Spawn(BeamEffectClass,,, Start, Dir);
      if (ReflectNum != 0) Beam.Instigator = None; // prevents client side repositioning of beam start
      Beam.AimAt(HitLocation, HitNormal);
      }

      I'm not really sure what i'm looking for here

      the instantfire class seems to make more sense:
      function DoTrace(Vector Start, Rotator Dir)
      {
      local Vector X, End, HitLocation, HitNormal, RefNormal;
      local Actor Other;
      local int Damage;
      local bool bDoReflect;
      local int ReflectNum;

      MaxRange();

      ReflectNum = 0;
      while (true)
      {
      bDoReflect = false;
      X = Vector(Dir);
      End = Start + TraceRange * X;

      Other = Weapon.Trace(HitLocation, HitNormal, End, Start, true);

      if ( Other != None && (Other != Instigator || ReflectNum > 0) )
      {
      if (bReflective && Other.IsA('xPawn') && xPawn(Other).CheckReflect(HitLocation, RefNormal, DamageMin*0.25))
      {
      bDoReflect = true;
      HitNormal = Vect(0,0,0);
      }

      else if ( !Other.bWorldGeometry )
      {
      Damage = DamageMin;
      if ( (DamageMin != DamageMax) && (FRand() > 0.5) )
      Damage += Rand(1 + DamageMax - DamageMin);
      Damage = Damage * DamageAtten;

      // Update hit effect except for pawns (blood) other than vehicles.
      if ( Other.IsA('Vehicle') || (!Other.IsA('Pawn') && !Other.IsA('HitScanBlockingVolume')) )
      WeaponAttachment(Weapon.ThirdPersonActor).UpdateHi t(Other, HitLocation, HitNormal);

      Other.TakeDamage(Damage, Instigator, HitLocation, Momentum*X, DamageType);
      HitNormal = Vect(0,0,0);
      }
      else if ( WeaponAttachment(Weapon.ThirdPersonActor) != None )
      WeaponAttachment(Weapon.ThirdPersonActor).UpdateHi t(Other,HitLocation,HitNormal);
      }
      else
      {
      HitLocation = End;
      HitNormal = Vect(0,0,0);
      WeaponAttachment(Weapon.ThirdPersonActor).UpdateHi t(Other,HitLocation,HitNormal);
      }

      SpawnBeamEffect(Start, Dir, HitLocation, HitNormal, ReflectNum);

      if (bDoReflect && ++ReflectNum < 4)
      {
      //Log("reflecting off"@Other@Start@HitLocation);
      Start = HitLocation;
      Dir = Rotator(RefNormal); //Rotator( X - 2.0*RefNormal*(X dot RefNormal) );
      }
      else
      {
      break;
      }
      }
      }

      function SpawnBeamEffect(Vector Start, Rotator Dir, Vector HitLocation, Vector HitNormal, int ReflectNum)
      {
      }

      it seems that the code in bold is what i need to change... i'm just not sure what to change. any idea?
      I've got everything else working the way i want it for my weapon, but i would really like the reflected beam to do damage. Any help is much appreciated!

      Comment


        #4
        Tricky indeed... :weird:

        Reading the code, the reflected beam does seem to find a target and deal damage to it. You'd have to insert some log or broadcast statements to see what it's hitting and how much damage it's trying to deal.

        I personally am a great fan of
        Code:
        Level.Game.Broadcast(Instigator.Controller, "Your text here.", 'Say');
        but some people prefer the log.

        Comment


          #5
          wow... that just confuses me more. i dunno where to begin with this.

          Comment


            #6
            OK, step by step...
            1. Copy/paste the TraceFire function into your gun, and get the gun to work like that.
            2. Copy/paste the broadcast line into the TraceFire code, right before the code you highlighted.
            3. Make the broadcast line display the Other (Other $ " was hit!").
            4. Shoot something and watch for the message.

            Comment


              #7
              i talked with a clanmate who is more adept at coding than i, and it looks as if in order to get this working the way i would like, i'm gonna have to rewrite "dotrace". I dont think I'm up for this yet Thank you much for all of your help though

              Comment

              Working...
              X