Results 1 to 9 of 9
  1. #1
    Redeemer
    Join Date
    Mar 2003
    Posts
    1,651

    Default hit players through walls

    I am trying to make the fire class of the is wepaon to hit players through walls. This code is 99% done by Mr. Evil for his helious weapon from his WOE mod. I am using this with permission... I can get the rail effect to go through solid objects, but you can only shoot through vehicles and other players currently and cause damage. If you you shoot through a wall or any other solid object and hit a player or vehicle it does no damage I have been workign this for a few days and cannot get it to work, can anyone see what I may change?

    Code:
    class railFire extends InstantFire;
    
    #exec LOAD OBJ FILE=forcompile\WGS_rail_SNDS.uax PACKAGE=WGS_UWEPm
    
    var() class<railBeamEffect> BeamClass;
    
    var() float ChargeExponent;
    
    var() float HeadShotDamageMult;
    var() float HeadShotRadius;
    var() class<DamageType> HeadshotDamageType;
    
    var() float LimbShotDamageMult;
    
    var() float TorsoShotRadius;
    var() class<DamageType> TorsoshotDamageType;
    
    var rail Gun;
    
    simulated function PostBeginPlay()
    {
    	Super.PostBeginPlay();
    
    	Gun = rail(Owner);
    }
    
    function StartBerserk() {
        FireRate = default.FireRate * 0.70;
        FireAnimRate = default.FireAnimRate / 0.70;
    }
    
    //Discharge after firing.
    function DoFireEffect()
    {
    	local float DamageMult;
    
    	DamageMult = Gun.ChargeLevel ** ChargeExponent;
    
    	DamageMax = Default.DamageMax * DamageMult;
    	DamageMin = Default.DamageMin * DamageMult;
    
    	Super.DoFireEffect();
    
    	Gun.ChargeLevel = 0;
    }
    
    function DoTrace(Vector Start, Rotator Dir)
    {
    	local Vector X, End, HitLocation, HitNormal;
    	local Actor Other;
    	local int Damage;
    	local float dist;
    	local name HitBone;
    	local vector BoneTestLocation, ClosestLocation;
    	local float HitHorizontal, HitVertical;
    
    	X = Vector(Dir);
    	End = Start + TraceRange * X;
    
    	//Can fire straight through anything but world geometry.
    	foreach Weapon.TraceActors(class'Actor', Other, HitLocation, HitNormal, End, Start)
    	{
    		if(Other == Instigator)
    			continue;
    
    //Commented out to make the rail bolt pass through walls
    	/*	if(Other.bWorldGeometry)
    		{
    			if(WeaponAttachment(Weapon.ThirdPersonActor) != None)
    				WeaponAttachment(Weapon.ThirdPersonActor).UpdateHit(Other, HitLocation, HitNormal);
    
    			break;
    		}  */
    
    		Damage = DamageMin;
    
    		if((DamageMin != DamageMax) && (FRand() > 0.5))
    			Damage += Rand(1 + DamageMax - DamageMin);
    
    		if(Other.IsA('Pawn'))
    		{
                Instigator.PlaySound(Sound'WGS_UWEPm.rail_hitarmor');
    			//Find a point on the victim's Z axis at the same height as the HitLocation.
    			ClosestLocation = Other.Location;
    			ClosestLocation.Z += (HitLocation - Other.Location).Z;
    
    			//Extend the shot along its direction to a point where it is closest to the victim's Z axis.
    			BoneTestLocation = X;
    			BoneTestLocation *= VSize(ClosestLocation - HitLocation);
    			BoneTestLocation *= normal(ClosestLocation - HitLocation) dot normal(HitLocation - Start);
    			BoneTestLocation += HitLocation;
    
    			//Vehicles 'head' considered to be dead centre.
    			if(Other.IsA('Vehicle'))
    			{
                    Instigator.PlaySound(Sound'WGS_UWEPm.rail_hitflesh');
    				HitVertical = Abs(BoneTestLocation.Z - Other.Location.Z);
    				BoneTestLocation.Z = Other.Location.Z;
    				HitHorizontal = VSize(BoneTestLocation - Other.Location);
    
    				if(HitVertical < Other.CollisionHeight * 0.6 && HitHorizontal < Other.CollisionRadius * 0.6)
    				{
    					if(HitVertical < Other.CollisionHeight * 0.4 && HitHorizontal < Other.CollisionRadius * 0.4)
    						HitBone = 'head';
    					else
    						HitBone = 'spine';
    				}
    				else
    					HitBone = 'vehicle';
    			}
    			else
    			{
    				//Find the closest bone.
    				HitBone = Other.GetClosestBone(BoneTestLocation, X, dist, 'head', HeadShotRadius);
    
    				if(HitBone != 'head')
    					HitBone = Other.GetClosestBone(BoneTestLocation, X, dist, 'spine', TorsoShotRadius);
    			}
    
    			//Caters for monsters, and anything else without any bones.
    			if(HitBone =='None')
    			{
                    Instigator.PlaySound(Sound'WGS_UWEPm.rail_hitflesh');
    				HitVertical = BoneTestLocation.Z - Other.Location.Z;
    				BoneTestLocation.Z = Other.Location.Z;
    				HitHorizontal = VSize(BoneTestLocation - Other.Location);
    
    				if(HitHorizontal < Other.CollisionRadius * 0.6)
    				{
    
    					if(HitVertical > Other.CollisionHeight * 0.8)
    						HitBone = 'head';
    					else if(HitVertical > Other.CollisionHeight * -0.4)
    						HitBone = 'spine';
    				}
    			}
    
    			if(HitBone == 'head')
    			{
    				Damage *= HeadShotDamageMult;
    				DamageType = HeadshotDamageType;
    			}
    			else if(HitBone == 'spine')
    				DamageType = TorsoshotDamageType;
    			else
    			{
    				Damage *= LimbShotDamageMult;
    				DamageType = Default.DamageType;
    			}
    		}
    
    		Damage *= DamageAtten;
    		Damage *= Instigator.DamageScaling;
    		Other.TakeDamage(Damage, Instigator, HitLocation, Momentum * X, DamageType);
    
    		//Hack to get headshot announcements for killing monsters.
    		if(HitBone == 'head' && Other.IsA('Monster') && Pawn(Other).Health <= 0)
    			Instigator.ReceiveLocalizedMessage(class'wgsSpecialKillMessage', 0, Instigator.PlayerReplicationInfo, None, None);
    
    		HitNormal = Vect(0,0,0);
    	}
    
    	if(Other == None)
    	{
    		HitLocation = End;
    		HitNormal = Vect(0,0,0);
    	}
    
    	SpawnBeamEffect(Start, Dir, HitLocation, HitNormal, 0);
    }
    
    function InitEffects()
    {
        Super.InitEffects();
        if ( FlashEmitter != None )
            Weapon.AttachToBone(FlashEmitter, 'Bone_Flash');
    }
    
    function SpawnBeamEffect(Vector Start, Rotator Dir, Vector HitLocation, Vector HitNormal, int ReflectNum)
    {
    	local railBeamEffect Beam;
    
    	Beam = Spawn(BeamClass,,, Start, Dir);
    	Beam.AimAt(HitLocation, HitNormal, Gun.ChargeLevel);
    }
    G for Grenade!
    http://gforgrenade.com

  2. #2
    MSgt. Shooter Person
    Join Date
    Sep 2006
    Location
    Finland
    Posts
    218

    Default

    Theres at least 1 thing you could change, at the end of function "DoTrace":

    Code:
    	if(Other == None)
    	{
    		HitLocation = End;
    		HitNormal = Vect(0,0,0);
    	}
    
    	SpawnBeamEffect(Start, Dir, HitLocation, HitNormal, 0);
    }
    Change into:
    Code:
    	SpawnBeamEffect(Start,Dir,End,-X,0);
    }

  3. #3

    Default

    Trace for a hit. Wherever you hit something, trace further starting from there.

  4. #4
    MSgt. Shooter Person
    Join Date
    Sep 2006
    Location
    Finland
    Posts
    218

    Default

    It's more effective to use TraceActors iterator for that, becouse that way you cant really trace through wall (you dont know how deep that wall is before open space again).

  5. #5
    Redeemer
    Join Date
    Mar 2003
    Posts
    1,651

    Default

    Quote Originally Posted by .:..: View Post
    Theres at least 1 thing you could change, at the end of function "DoTrace":

    Code:
    	if(Other == None)
    	{
    		HitLocation = End;
    		HitNormal = Vect(0,0,0);
    	}
    
    	SpawnBeamEffect(Start, Dir, HitLocation, HitNormal, 0);
    }
    Change into:
    Code:
    	SpawnBeamEffect(Start,Dir,End,-X,0);
    }
    Thanks for the suggestion

    I'll try this when I get home from work and report back.
    G for Grenade!
    http://gforgrenade.com

  6. #6
    Redeemer
    Join Date
    Mar 2003
    Posts
    1,651

    Default

    does the same thing, the beam goes through the wall, but does not register as a hit on a player
    G for Grenade!
    http://gforgrenade.com

  7. #7
    Redeemer
    Join Date
    Mar 2003
    Posts
    1,651

    Default

    is it possible to make a hit scan wep go through walls and hit another player?
    G for Grenade!
    http://gforgrenade.com

  8. #8
    MSgt. Shooter Person
    Join Date
    Oct 2004
    Posts
    474
    Gamer IDs

    Gamertag: Lexikos

    Default

    I made an "xray gun" a while back; I vaguely recall TraceActors doesn't trace through geometry. I might've just assumed that, though...

    Anyway, instead of
    Code:
    foreach Weapon.TraceActors(class'Actor', Other, HitLocation, HitNormal, End, Start)
    	{
    I did something like
    Code:
    foreach Weapon.DynamicActors(class'Actor', Other)
            if (!Other.TraceThisActor(HitLocation, HitNormal, End, Start))
            {
    [TraceThisActor] Returns True if the trace did not hit the actor it was called for.
    You could also do a seperate loop per type of Actor so that you aren't looping through every dynamic actor in the map. I had mine trace for Pawns (note: vehicle is a subclass of pawn) and GameObjectives, but you might also want triggers and movers/staticmeshes.
    Quote Originally Posted by User CP
    Please contact the Administrator if your date of birth has changed.

  9. #9
    Redeemer
    Join Date
    Mar 2003
    Posts
    1,651

    Default

    This code:
    Code:
    foreach Weapon.DynamicActors(class'Actor', Other)
            if (!Other.TraceThisActor(HitLocation, HitNormal, End, Start))
    Works perfectly, it now hits and does damage through walls. 10,000 thank you's Porkmanii
    G for Grenade!
    http://gforgrenade.com


 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Copyright ©2009-2011 Epic Games, Inc. All Rights Reserved.
Digital Point modules: Sphinx-based search vBulletin skin by CompletevB.com.