Announcement

Collapse
No announcement yet.

Replicate explosion on instant hit?

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

    #16
    Originally posted by ZippyDSMlee View Post
    I thought hurtradius had to be in the parent class of the weapon in order for it to process hurtradius.
    Go into detail so I can explain the logic a bit more.

    In general, you should have to look at the framework of UT3, the Unrealscript code base v1.5, in order to know what any code is doing. UnCodeX is a great addition to search and examine the code base. Also, Visual Studio (nFringe) or any other IDE is recommended.

    If you check the parent class of your weapon, which will likely be UTWeapon or a subclass of UTWeapon (for instance UTWeap_SniperRifle), you can see when the ProcessInstantHit function is called - also, why it is called. That function requires some options you have to adjust for instance the weapon needs to use the InstantFire logic (which would be WeaponFireTypes(0)=EWFT_InstantHit). The ProcessInstantHit function is used to damage the hit actor. If we want to bypass or override it, we can create a function with the same signature in our own weapon class.

    Code:
    class MySniperTest extends UTWeap_SniperRife;
    
    simulated function ProcessInstantHit( byte FiringMode, ImpactInfo Impact )
    {
    }
    In this case the sniper will fire but it won't damage anything. The first thing we can do in order to create our own damaging code would be to stop clients processing that logic.
    Code:
    class MySniperTest extends UTWeap_SniperRife;
    
    simulated function ProcessInstantHit( byte FiringMode, ImpactInfo Impact )
    {
        // exclude clients from doing anything
        if (Role == ROLE_Authority)
        {
             // ...
        }
    }
    As a explosion mostly handles damages on a sphere (damage all surrounding players) the hurt radius function is actually a good way to achieve that. If you check the HurtRadius method of the parent class, you can see what the method is doing.
    The least implemenation would be Actor::HurtRadius.
    Code:
    //Actor.uc
    
    /* HurtRadius()
     Hurt locally authoritative actors within the radius.
    */
    simulated function bool HurtRadius
    (
        float                BaseDamage,
        float                DamageRadius,
        class<DamageType>    DamageType,
        float                Momentum,
        vector                HurtOrigin,
        optional Actor        IgnoredActor,
        optional Controller InstigatedByController = Instigator != None ? Instigator.Controller : None,
        optional bool       bDoFullDamage
    )
    {
        local Actor    Victim;
        local bool bCausedDamage;
    
        // Prevent HurtRadius() from being reentrant.
        if ( bHurtEntry )
            return false;
    
        bHurtEntry = true;
        bCausedDamage = false;
        foreach VisibleCollidingActors( class'Actor', Victim, DamageRadius, HurtOrigin )
        {
            if ( !Victim.bWorldGeometry && (Victim != self) && (Victim != IgnoredActor) && (Victim.bProjTarget || (NavigationPoint(Victim) == None)) )
            {
                Victim.TakeRadiusDamage(InstigatedByController, BaseDamage, DamageRadius, DamageType, Momentum, HurtOrigin, bDoFullDamage, self);
                bCausedDamage = bCausedDamage || Victim.bProjTarget;
            }
        }
        bHurtEntry = false;
        return bCausedDamage;
    }
    As we can see it will damage surrounding players by calling TakeRadiusRamage of all these actors.

    If we call HurtRadius from the inside of a different instance, like a Projectile, the logic might be slightly different as the Projectile class implement a own HurtRadius method.

    In the upper psudeo code we spawn the explosion and play a sound. Both will be replicated to clients. UTEmit_ShockCombo is a subclassed replicated emitter which will spawn the combo explosion. As we're already doing the damaging logic in our weapon code, there is no need for an extra projectile that's why we only spawn the explosion effect. You can easily create your own explosion by subclassing UTReplicatedEmitter.

    Code:
    class MyBoomExplosion extends UTReplicatedEmitter;
    
    defaultproperties
    {
        EmitterTemplate=ParticleSystem'MyPackage.Effects.FX_Boom'
    }
    The code for the instant hit explosion could look like the following code. This is a very very basic implemenation.
    Code:
    var float ExplosionRadius;
    
    simulated function ProcessInstantHit( byte FiringMode, ImpactInfo Impact )
    {
        // exclude clients from doing anything
        if (Role == ROLE_Authority)
        {
             HurtRadius(InstantHitDamage[FiringMode], ExplosionRadius, InstantHitDamageTypes[FiringMode], InstantHitMomentum[FiringMode], Impact.HitLocation );
             Spawn(class'MyBoomExplosion',,, Impact.HitLocation);
             PlaySound(SoundCue'A_Weapon_ShockRifle.Cue.A_Weapon_SR_AltFireImpactCue');
        }
    }
    
    defaultproperties
    {
        ExplosionRadius=128
    }

    Comment


      #17
      First off thank you for taking the time to break it down for me.

      I see one of the things I mis understood was the parent child relationship , I thought it only went so far into the parent classes and overlooked actor class.

      I need to do a better job of looking through all the parent classes before opening my trap and sucking all the air out of my head LOL

      Is wotgreal the only editor for UT3 that can check out where the parent code comes from? (like I right click a class or var it gives a drop down menu that lets you go to the parent code). I looked at Unreal_X-Editor but it seems UDK only. I'm using notepad++ right now. Might help if I have something with some code exploring ability.


      Again thank you for your time and effort!

      Comment


        #18
        Not sure if Wotgreal still works well but I use nFringe (because I'm familiar with Visual Studio). You can try Unreal Sed.

        Comment


          #19
          Going to try sed, I've run into one annoying problem with the radius damage its always doing head shots, I tried doing something simple like "HeadDamage != HurtRadius" but not matter how I splice it it crashes the compiler and if I reverse it it complies but dose not exclude hurtradius from head damage....am I using the right operator?.

          Comment


            #20
            Without seeing your code, i'm not able to answer anything as you can do everything with code ...

            Comment


              #21
              I'm probably just using the wrong implementation whats throwing me off the ones that compile do not work and the ones that will not compile tend to crash the compiler. Then again I might have not been seeing straight got up at 4 since I could not sleep.
              Code:
              simulated function ProcessInstantHit( byte FiringMode, ImpactInfo Impact )
              {
              	local float Scaling;
              	local int HeadDamage;
              	
              	 if(Role == Role_Authority)
                      { 
              	 HurtRadius(Damage, Radius, myDamageType, MomentumTransfer, Impact.HitLocation );
                       Spawn(class'Zippylabsut3.UTeffect_zippylabsut3grenadesniper',,, Impact.HitLocation);
                       PlaySound(SoundCue'A_Weapon_RocketLauncher.Cue.A_Weapon_RL_Impact_Cue');
              		 }
                  else
                       return;
              	
              
              	if( (Role == Role_Authority) && !bUsingAimingHelp )
              	{
                	 
              		if (Instigator == None || VSize(Instigator.Velocity) < Instigator.GroundSpeed * Instigator.CrouchedPct)
              		{
              			Scaling = SlowHeadshotScale;
              		}
              		else
              		{
              			Scaling = RunningHeadshotScale;
              		}
              		
                      
              		HeadDamage = InstantHitDamage[FiringMode]* HeadShotDamageMult;
              		if ( (UTPawn(Impact.HitActor) != None && UTPawn(Impact.HitActor).TakeHeadShot(Impact, HeadShotDamageType, HeadDamage, Scaling, Instigator.Controller)) ||
              			(UTVehicleBase(Impact.HitActor) != None && UTVehicleBase(Impact.HitActor).TakeHeadShot(Impact, HeadShotDamageType, HeadDamage, Scaling, Instigator.Controller)) )
              			
              		{    
              //============================
              		    HurtRadius != HeadDamage;
              //============================
              			SetFlashLocation(Impact.HitLocation);
              			return;
              		}
              			  		  
              	}
              	super.ProcessInstantHit( FiringMode, Impact );
              
              }

              Comment


                #22
                Oh boy. ^^

                You cannot write code one after another. You have to merge the logic into 1. But i don't see a reason for having the Headshot logic for your instant explosion.

                Code:
                simulated function ProcessInstantHit( byte FiringMode, ImpactInfo Impact )
                {   
                    if(Role == Role_Authority)
                    { 
                        HurtRadius(Damage, Radius, myDamageType, MomentumTransfer, Impact.HitLocation );
                        Spawn(class'Zippylabsut3.UTeffect_zippylabsut3grenadesniper',,, Impact.HitLocation);
                        PlaySound(SoundCue'A_Weapon_RocketLauncher.Cue.A_Weapon_RL_Impact_Cue');
                    }
                }
                That's probably all you need.

                If you extend UTWeap_SniperRifle and call super.ProcessInstantHit( FiringMode, Impact ), it would result into a possible headshot as super calls the ProcessInstantHit method of the parent class (which is UTWeap_SniperRifle if you extend that one).

                Comment


                  #23
                  Okay, lets see, it still dose a headshot call when you kill someone with radius damage.

                  Comment


                    #24
                    Copy-paste ready weapon with replicated explosion, radial damage and sound.

                    Code:
                    class MySniperTest extends UTWeap_SniperRifle;
                    
                    var float ExplosionRadius;
                    
                    simulated function ProcessInstantHit( byte FiringMode, ImpactInfo Impact )
                    {
                        // exclude clients from doing anything
                        if (Role == ROLE_Authority)
                        {
                             HurtRadius(InstantHitDamage[FiringMode], ExplosionRadius, InstantHitDamageTypes[FiringMode], InstantHitMomentum[FiringMode], Impact.HitLocation );
                             Spawn(class'UTEmit_ShockCombo',,, Impact.HitLocation);
                             PlaySound(SoundCue'A_Weapon_RocketLauncher.Cue.A_Weapon_RL_Impact_Cue',,,, Impact.HitLocation);
                        }
                    }
                    
                    defaultproperties
                    {
                        ExplosionRadius=128
                    }

                    Comment


                      #25
                      Okay, lets see, oh LOL headshot and zoom is brokenz.

                      I did not change the zoom stuff at all 0_o could it be the stuff in default properties?
                      http://jmp.sh/vZeGblC

                      Dumb question but can't you just negate damage done by a combination of hurtraduis or explosionradius and headdamage? Or call up a instant hit damage that's set at 0 thus nullifying the headdamge multiplier upon radius damage.

                      Comment


                        #26
                        You can do everything. It depends on what you are trying to achieve...

                        Comment


                          #27
                          That would be negating radius damage when combined with headdamage. Basically hurtadius and headdamage equal no headdamage. Tho I do not think you can directly combine them in a single line of code.

                          Comment


                            #28
                            What's your intention with the code? You do want an instant-hit weapon but also doing radial damage on the same fire mode and you want a headshot capability with a explosion?

                            Nothing needs to be done with a single line of code. The more complex the logic is the more complex the code will be.

                            Comment


                              #29
                              Basically I'd like to be able to do headshots but not with radius damage.I'd like raduis damage to still gib a ragdoll. As it is now each kill equals a headshot which is a bit much. I do not want as silly as my fo3 grenade sniper which is nearly an instant gib weapon with crazy momentum/collision issues(it can throw a target for 20-50 or more feet).


                              Ya but it helps to keep things simple rather than starting out complicated and trying to simplify, tho in my case simple=stupid LOL

                              Comment

                              Working...
                              X