Announcement

Collapse
No announcement yet.

Code Question

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

    Code Question

    Ok might sound noobish but here goes.

    Is it possible to make it so that a weapon will only damage a vehicle, for example a modified redeemer missile that only damages vehicles but not players in its blast radius (players in destroyed vehicles are still dead )

    #2
    Kind of like a reverse-neutron bomb, eh? Yes, it's possible, but it takes a little more work that way. Instead of simply spawning a hurtradius, one will need to interate through nearby vehicles and manually cause them damage and/or apply velocity. This is one way of doing it, but I'm sure there are more.

    Comment


      #3
      u can customize hurtradius simply to only hurt a certain actor, ehre is the original code:
      Code:
      /* HurtRadius()
       Hurt locally authoritative actors within the radius.
      */
      simulated function HurtRadius( float DamageAmount, float DamageRadius, class<DamageType> DamageType, float Momentum, vector HitLocation )
      {
      	local actor Victims;
      	local float damageScale, dist;
      	local vector dir;
      
      	if ( bHurtEntry )
      		return;
      
      	bHurtEntry = true;
      	foreach VisibleCollidingActors( class 'Actor', Victims, DamageRadius, HitLocation )
      	{
      		// don't let blast damage affect fluid - VisibleCollisingActors doesn't really work for them - jag
      		if( (Victims != self) && (Hurtwall != Victims) && (Victims.Role == ROLE_Authority) && !Victims.IsA('FluidSurfaceInfo') )
      		{
      			dir = Victims.Location - HitLocation;
      			dist = FMax(1,VSize(dir));
      			dir = dir/dist;
      			damageScale = 1 - FMax(0,(dist - Victims.CollisionRadius)/DamageRadius);
      			if ( Instigator == None || Instigator.Controller == None )
      				Victims.SetDelayedDamageInstigatorController( InstigatorController );
      			if ( Victims == LastTouched )
      				LastTouched = None;
      			Victims.TakeDamage
      			(
      				damageScale * DamageAmount,
      				Instigator,
      				Victims.Location - 0.5 * (Victims.CollisionHeight + Victims.CollisionRadius) * dir,
      				(damageScale * Momentum * dir),
      				DamageType
      			);
      			if (Vehicle(Victims) != None && Vehicle(Victims).Health > 0)
      				Vehicle(Victims).DriverRadiusDamage(DamageAmount, DamageRadius, InstigatorController, DamageType, Momentum, HitLocation);
      
      		}
      	}
      	if ( (LastTouched != None) && (LastTouched != self) && (LastTouched.Role == ROLE_Authority) && !LastTouched.IsA('FluidSurfaceInfo') )
      	{
      		Victims = LastTouched;
      		LastTouched = None;
      		dir = Victims.Location - HitLocation;
      		dist = FMax(1,VSize(dir));
      		dir = dir/dist;
      		damageScale = FMax(Victims.CollisionRadius/(Victims.CollisionRadius + Victims.CollisionHeight),1 - FMax(0,(dist - Victims.CollisionRadius)/DamageRadius));
      		if ( Instigator == None || Instigator.Controller == None )
      			Victims.SetDelayedDamageInstigatorController(InstigatorController);
      		Victims.TakeDamage
      		(
      			damageScale * DamageAmount,
      			Instigator,
      			Victims.Location - 0.5 * (Victims.CollisionHeight + Victims.CollisionRadius) * dir,
      			(damageScale * Momentum * dir),
      			DamageType
      		);
      		if (Vehicle(Victims) != None && Vehicle(Victims).Health > 0)
      			Vehicle(Victims).DriverRadiusDamage(DamageAmount, DamageRadius, InstigatorController, DamageType, Momentum, HitLocation);
      	}
      
      	bHurtEntry = false;
      }
      In the:
      foreach VisibleCollidingActors( class 'Actor', Victims, DamageRadius, HitLocation )
      {
      ...
      }
      Code change the Class and the local Victims Var to what you want to damage, and it should work

      (Not sure if any tweakage needed, i used this to hurt only pawns and it seemed flawless)

      Comment


        #4
        /me sits back reads and gets confused.

        Well thanks for the help i have noted it down and will figure out how to use it (i hope). Hopefully this will be the icing on the cake of my plan muahahahahahahahahahaha. But if anyone feels like helping out a poor noob by explaning it in a little more detail as this the first sort of code i have ever done and i'm still trying to figure out how to set up the stuff for the rest of the vehicle to work.

        Comment


          #5
          sry i dont understand it *Exatly* my self but if u use this code in the bomb:
          Code:
          /* HurtRadius()
           Hurt locally authoritative actors within the radius.
          */
          simulated function HurtRadius( float DamageAmount, float DamageRadius, class<DamageType> DamageType, float Momentum, vector HitLocation )
          {
          	local Vehicle Victims;
          	local float damageScale, dist;
          	local vector dir;
          
          	if ( bHurtEntry )
          		return;
          
          	bHurtEntry = true;
          	foreach VisibleCollidingActors( class 'Vehicle', Victims, DamageRadius, HitLocation )
          	{
          		// don't let blast damage affect fluid - VisibleCollisingActors doesn't really work for them - jag
          		if( (Victims != self) && (Hurtwall != Victims) && (Victims.Role == ROLE_Authority) && !Victims.IsA('FluidSurfaceInfo') )
          		{
          			dir = Victims.Location - HitLocation;
          			dist = FMax(1,VSize(dir));
          			dir = dir/dist;
          			damageScale = 1 - FMax(0,(dist - Victims.CollisionRadius)/DamageRadius);
          			if ( Instigator == None || Instigator.Controller == None )
          				Victims.SetDelayedDamageInstigatorController( InstigatorController );
          			if ( Victims == LastTouched )
          				LastTouched = None;
          			Victims.TakeDamage
          			(
          				damageScale * DamageAmount,
          				Instigator,
          				Victims.Location - 0.5 * (Victims.CollisionHeight + Victims.CollisionRadius) * dir,
          				(damageScale * Momentum * dir),
          				DamageType
          			);
          			if (Victims != None && Victims.Health > 0)
          				Victims.DriverRadiusDamage(DamageAmount, DamageRadius, InstigatorController, DamageType, Momentum, HitLocation);
          
          		}
          	}
          	if ( (LastTouched != None) && (LastTouched != self) && (LastTouched.Role == ROLE_Authority) && !LastTouched.IsA('FluidSurfaceInfo') )
          	{
          		Victims = LastTouched;
          		LastTouched = None;
          		dir = Victims.Location - HitLocation;
          		dist = FMax(1,VSize(dir));
          		dir = dir/dist;
          		damageScale = FMax(Victims.CollisionRadius/(Victims.CollisionRadius + Victims.CollisionHeight),1 - FMax(0,(dist - Victims.CollisionRadius)/DamageRadius));
          		if ( Instigator == None || Instigator.Controller == None )
          			Victims.SetDelayedDamageInstigatorController(InstigatorController);
          		Victims.TakeDamage
          		(
          			damageScale * DamageAmount,
          			Instigator,
          			Victims.Location - 0.5 * (Victims.CollisionHeight + Victims.CollisionRadius) * dir,
          			(damageScale * Momentum * dir),
          			DamageType
          		);
          		if (Victims != None && Victims.Health > 0)
          			Victims.DriverRadiusDamage(DamageAmount, DamageRadius, InstigatorController, DamageType, Momentum, HitLocation);
          	}
          
          	bHurtEntry = false;
          }
          if will only destoy Vehiles and the Sub-Classes of Vehicle (I.E. Almost Any Vehicle In The Game)

          Comment

          Working...
          X