Alternative to HurtRadius(), extra features.

Discussions about Coding and Scripting

Alternative to HurtRadius(), extra features.

Postby Higor » Thu Jul 05, 2012 3:31 am

I've been wondering on some common issues related to explosions, and decided to rework the explosion code.
I haven't tested it, expecting some feedback first to make proper modifications.

Code: Select all
function XC_HurtRadius( float DamageAmount, float DamageRadius, name DamageName, float Momentum, vector HitLocation, optional actor HitActor , optional float ExtraSeek)
{
   local actor Victims, aTrace;
   local float damageScale, dist;
   local vector dir, HLoc, HNorm;
   
   if( bHurtEntry )
      return;

   //Hitactor takes full damage, it's a forced hit
   if ( HitActor != none )
   {
      HNorm = Normal(HitActor.Location - HitLocation);
      HitActor.TakeDamage( DamageAmount, Instigator, HitActor.Location - HNorm * 0.5 * (HitActor.CollisionHeight + HitActor.CollisionRadius), HNorm * Momentum, DamageName);
      HitActor.bHurtEntry = true;
   }

   bHurtEntry = true;
   foreach VisibleCollidingActors( class 'Actor', Victims, DamageRadius + ExtraSeek, HitLocation )
   {
      if ( !Victims.bHurtEntry )
      {
         DamageScale = 1;
         aTrace = none;
         ForEach TraceActors( class'Actor', aTrace, HLoc, HNorm, Victims.Location,  HitLocation)
         {
            if ( aTrace == Victims )
            {
               damageScale *= 1 - VSize(HLoc - HitLocation) / DamageRadius;
               if ( damageScale > 0 )
                  Victims.TakeDamage( damageScale * DamageAmount, Instigator, HLoc, (Momentum * damageScale * HNorm), DamageName);
               break;
            }
            if ( (aTrace == Level) || (Mover(aTrace) != none) )
               break;

            //Apply damage reduction if blocked by actor, adjustable here
            if ( aTrace.bBlockActors )
               DamageScale *= 0.7;
         }
      }
   }
   bHurtEntry = false;
   if ( HitActor != none )
      HitActor.bHurtEntry = false;
}


Differences:
- Direct impact damage for special explosions, usage is optional.
Ensures this actor receives full damage, to use when a colliding actor is placed outside of map geometry.
Would solve some issues with misplaced FortStandards, and other pawns/decorations placed outside of the map.

- ExtraSeek parameter allows seeking for greater distances, this prevents some low radius projectiles from failing to damage big Pawns.
A common issue is trying to damage a titan with the ASMD or Shock Rifle alt, an ExtraSeek value of 30 or 40 will solve it.

- HitLocation and Momentum vectors are precise, contributes to better hit information.
Some other mutators or actors might find the benefits of this.

- Damage and Momentum correctly scaled due to precision.
HurtRadius doesn't deal full damage if you hit a player's feet or head.

- Movers properly block the traces, even on NM_DedicatedServer mode.
Otherwise, you can kill enemies through doors and lifts on servers.

- Adjustable body shielding damage reduction, now hiding behind a decoration or another player will have positive consequences.
I know a couple of gametypes that could find this very useful...


Opinions?
Higor
Adept
 
Posts: 319
Joined: Sun Mar 04, 2012 6:47 pm

Re: Alternative to HurtRadius(), extra features.

Postby Dr.Flay » Thu Jul 05, 2012 4:03 am

:thuup:
:tu:
:rock:
A standard way of dealing with out-of-bounds, lost bots would be very cool. very useful with monsters and zombies etc.
To be honest it all sound great :D
You should talk to Shadow, and see if it can be included or factored in to the SDK, as these are root additions that would have great benefits if made the part of the UT99 standard.
User avatar
Dr.Flay
Godlike
 
Posts: 1115
Joined: Thu Aug 04, 2011 9:26 pm
Location: Kernow, UK
Personal rank: C= AMIGA freak

Re: Alternative to HurtRadius(), extra features.

Postby Feralidragon » Thu Jul 05, 2012 4:41 pm

Looks and sounds nice, but I don't understand why you should add ExtraSeek as an argument.

I mean, if the purpose of ExtraSeek is just to be able to hit bigger pawns with smaller radius impacts, you can always calculate such value yourself within the function (from HitActor, or if null, you can either zero it or assume a default value if the radius is small enough), since as someone wanting to do a projectile, I just want to define the Radius and HitActor at max, and not make the math myself of that value.
User avatar
Feralidragon
Site Staff
 
Posts: 3704
Joined: Wed Feb 27, 2008 6:24 pm
Location: Portugal - Lisbon
Personal rank: The Unreal Boy

Re: Alternative to HurtRadius(), extra features.

Postby Higor » Thu Jul 05, 2012 5:29 pm

The extra parameters make this sort of a general function, it will be at the coder's judgement and good sense to determine the best combination for his explosions.
Body shielding could be a parameter as well, with a little modification.
Higor
Adept
 
Posts: 319
Joined: Sun Mar 04, 2012 6:47 pm


Return to Coding, Scripting

Who is online

Users browsing this forum: No registered users and 1 guest