• Please make sure you are familiar with the forum rules. You can find them here: https://forums.tripwireinteractive.com/index.php?threads/forum-rules.2334636/

Code Cheking if a bullet hits a ZED

Kestasme

Member
Apr 18, 2014
9
0
So in the past few days I thought that I should try and create something myself instead of using other peoples mutators/guns etc. I thought of creating a perk based of a bullet that i would create myself. The idea of the bullet is that at first you shoot 1 normal bullet which if hits a zed spawns 6 bullets ( 4 with a Z height offset of 250 and 100 XY offsets to form a square and the other 2 only with Z250 and Y100 offsets to form a straight long line from the zed in both sides). Then these 6 bullets travel with a speed of 2000 with a pitch of 8192(45 degrees) outwards and if they hit a zed they spawn 1 Flame Nade that has a certain colored Texture, damage, damage radius and explosion time. I Have acomplished mostly everything however, when i shoot this weapon anywhere it works as intended only it spawns another 6 bullets somewhere in the map which also trigger somehow and explode. I dont really know much about UE coding and i dont know how and where to add the script in the process touch function to only check zeds and not walls etc.

The main bullet (Part of the code, Vlad bullet as base):

var() vector LocationV; (Used for a global variable so i can add the location in the timer function)
var() float SpawnDelay; (The timer duration)
var() float SpawnMaximum; (Since i dont want 9999 Bullets to spawn on touch i added this maximum variable so i can use it in a while function)

..........(Original Vlad Code)


simulated function ProcessTouch (Actor Other, vector HitLocation)
{
local vector X;
local Vector TempHitLocation, HitNormal;
local array<int> HitPoints;
local KFPawn HitPawn;
local bool bWasDecapitated;
local KFMonster KFM;

if ( Other == none || Other == Instigator || Other.Base == Instigator || !Other.bBlockHitPointTraces )
return;
LocationV = HitLocation; ( Location Variable to use later in timer)
SetTimer(SpawnDelay, False); ( Starting the Spawn Timer)

if( bFinishedPenetrating )
{
return;
}........................(Original Vlad Code)

function Timer() (Timer function for spawning the 6 Bullets)
{
Local int GC;
GC = 0;
while (GC < SpawnMaximum)
{
Spawn(Class'SPW.ZNailGunProjectileB',,, LocationV - vect(0,150,-200),rotator(vect(0,-8192,-32768)));
Spawn(Class'SPW.ZNailGunProjectileR',,, LocationV - vect(0,-150,-200),rotator(vect(0,8192,-32768)));
Spawn(Class'SPW.ZNailGunProjectileP',,, LocationV - vect(100,100,-200),rotator(vect(-8192,0,-32768)));
Spawn(Class'SPW.ZNailGunProjectileO',,, LocationV - vect(-100,100,-200),rotator(vect(8192,0,-32768)));
Spawn(Class'SPW.ZNailGunProjectileG',,, LocationV - vect(100,-100,-200),rotator(vect(-8192,0,-32768)));
Spawn(Class'SPW.ZNailGunProjectileY',,, LocationV - vect(-100,-100,-200),rotator(vect(8192,0,-32768)));
GC++;
}
}....... (Original Vlad Code)


SpawnDelay=1.00
SpawnMaximum=1 (Default properties variables)


Bare with me I have only studied the code for like 2 to 3 days at most.