legacy-EggXzaB
07-14-2003, 05:14 PM
right, I have my own gun, about the same as assaultrifle, but with headshot function.
Now the problem is, when I copied the Headshot function (from the sniperrifle) the bullet hole / bullet spark on the walls disappeared.
This is my whole glock40Fire.uc :
class glock40Fire extends InstantFire;
var float LastFireTime;
var float ClickTime;
// headshot vars //
var() class<xEmitter> HitEmitterClass;
var() class<xEmitter> SecHitEmitterClass;
var() int NumArcs;
var() float SecDamageMult;
var() float SecTraceDist;
var() float HeadShotDamageMult;
var() float HeadShotRadius;
var() class<DamageType> DamageTypeHeadShot;
// eind HS vars //
function InitEffects()
{
Super.InitEffects();
if ( FlashEmitter != None )
Weapon.AttachToBone(FlashEmitter, 'tip');
}
function FlashMuzzleFlash()
{
local rotator r;
r.Roll = 65536; // Rand(65536);
Weapon.SetBoneRotation('Bone_Flash', r, 0, 1.f);
Super.FlashMuzzleFlash();
}
event ModeDoFire()
{
if ( Level.TimeSeconds - LastFireTime > 0.5 ) // als je pas na een halve seconde weer vuurt
{
Spread = 0.0; // is de spread dus 0
}
else // zo niet, dus binnen halve seconde weer vuren
{
Spread = FMin(Spread+0.02,0.12); // dan is de spread random groter, eigen schuld :P
}
LastFireTime = Level.TimeSeconds;
Super.ModeDoFire();
}
simulated function bool AllowFire()
{
if (Super.AllowFire())
return true;
else
{
if ( (PlayerController(Instigator.Controller) != None) && (Level.TimeSeconds > ClickTime) )
{
PlayerController(Instigator.Controller).PlayOwnedS ound(Sound'WeaponSounds.P1Reload5');
ClickTime = Level.TimeSeconds + 0.25;
}
return false;
}
}
// start Headshot check script //
function DoTrace(Vector Start, Rotator Dir)
{
local Vector X,Y,Z, End, HitLocation, HitNormal, RefNormal;
local Actor Other, mainArcHitTarget;
local int Damage, ReflectNum, arcsRemaining;
local bool bDoReflect;
local xEmitter hitEmitter;
local class<Actor> tmpHitEmitClass;
local float tmpTraceRange, dist;
local vector arcEnd, mainArcHit;
Weapon.GetViewAxes(X, Y, Z);
if ( Weapon.WeaponCentered() )
arcEnd = (Instigator.Location +
Weapon.EffectOffset.X * X +
1.5 * Weapon.EffectOffset.Z * Z);
else
arcEnd = (Instigator.Location +
Instigator.CalcDrawOffset(Weapon) +
Weapon.EffectOffset.X * X +
Weapon.Hand * Weapon.EffectOffset.Y * Y +
Weapon.EffectOffset.Z * Z);
arcsRemaining = NumArcs;
tmpHitEmitClass = HitEmitterClass;
tmpTraceRange = TraceRange;
ReflectNum = 0;
while (true)
{
bDoReflect = false;
X = Vector(Dir);
End = Start + tmpTraceRange * X;
Other = Trace(HitLocation, HitNormal, End, Start, true);
if ( Other != None && (Other != Instigator || ReflectNum > 0) )
{
if (bReflective && Other.IsA('xPawn') && xPawn(Other).CheckReflect(HitLocation, RefNormal, DamageMin*0.25))
{
bDoReflect = true;
}
else if ( Other != mainArcHitTarget )
{
if ( !Other.bWorldGeometry )
{
Damage = (DamageMin + Rand(DamageMax - DamageMin)) * DamageAtten;
if ( (Pawn(Other) != None) && (arcsRemaining == NumArcs)
&& Other.GetClosestBone( HitLocation, X, dist, 'head', HeadShotRadius ) == 'head' )
Other.TakeDamage(Damage * HeadShotDamageMult, Instigator, HitLocation, Momentum*X, DamageTypeHeadShot);
else
{
if ( arcsRemaining < NumArcs )
Damage *= SecDamageMult;
Other.TakeDamage(Damage, Instigator, HitLocation, Momentum*X, DamageType);
}
}
else
HitLocation = HitLocation + 2.0 * HitNormal;
}
}
else
{
HitLocation = End;
HitNormal = Normal(Start - End);
}
hitEmitter = xEmitter(Spawn(tmpHitEmitClass,,, arcEnd, Rotator(HitNormal)));
if ( hitEmitter != None )
hitEmitter.mSpawnVecA = HitLocation;
if( arcsRemaining == NumArcs )
{
mainArcHit = HitLocation + (HitNormal * 2.0);
if ( Other != None && !Other.bWorldGeometry )
mainArcHitTarget = Other;
}
if (bDoReflect && ++ReflectNum < 4)
{
//Log("reflecting off"@Other@Start@HitLocation);
Start = HitLocation;
Dir = Rotator( X - 2.0*RefNormal*(X dot RefNormal) );
}
else if ( arcsRemaining > 0 )
{
arcsRemaining--;
// done parent arc, now move trace point to arc trace hit location and try child arcs from there
Start = mainArcHit;
Dir = Rotator(VRand());
tmpHitEmitClass = SecHitEmitterClass;
tmpTraceRange = SecTraceDist;
arcEnd = mainArcHit;
}
else
{
break;
}
}
}
// eind HS check script //
defaultproperties
{
FireSound=Sound'WeaponSounds.AssaultRifle.AssaultR ifleFire'
FireForce="AssaultRifleFire" // jdf
TraceRange=17000 //Maximum range of the weapon.
Momentum=1000 //How much the victim is pushed when hit.
AmmoClass=class'glock40Ammo'
AmmoPerFire=1
DamageType=class'glock40DamType'
DamageMin=30 //Min and Max can be different, to do a random damage between the two, or the same to do consistent damage.
DamageMax=32
FireAnim=Fire
FireEndAnim=None
FireLoopAnim=None
FireAnimRate=1.0
// FlashEmitterClass=class'XEffects.AssaultMuzFlash1s t'
FlashEmitterClass=class'XEffects.MinigunMuzFlash1s t'
Spread=0.020
SpreadStyle=SS_Random
PreFireTime=0.0
bModeExclusive=true
FireRate=0.3 //How fast it fires.
BotRefireRate=0.3 //How fast bots should try to fire.
AimError=800 //How accurate bots are.
bPawnRapidFireAnim=false
//These settings controll how your vire shakes when you fire.
ShakeOffsetMag=(X=-15.0,Y=0.0,Z=10.0)
ShakeOffsetRate=(X=-4000.0,Y=0.0,Z=4000.0)
ShakeOffsetTime=1.6
ShakeRotMag=(X=0.0,Y=0.0,Z=0.0)
ShakeRotRate=(X=0.0,Y=0.0,Z=0.0)
ShakeRotTime=2
HeadShotDamageMult=10.0
HeadShotRadius=10.0
DamageTypeHeadShot=class'DamTypeSniperHeadShot'
}
Well, before that i just had the bullet holes on the ground, standing in my attachment class :
class glock40Attachment extends xWeaponAttachment;
var byte OldSpawnHitCount;
var class<xEmitter> mMuzFlashClass;
var xEmitter mMuzFlash3rd;
var xEmitter mMuzFlash3rdAlt;
simulated function Destroyed()
{
if (mMuzFlash3rd != None)
mMuzFlash3rd.Destroy();
if (mMuzFlash3rdAlt != None)
mMuzFlash3rdAlt.Destroy();
Super.Destroyed();
}
/* UpdateHit
- used to update properties so hit effect can be spawn client side
*/
function UpdateHit(Actor HitActor, vector HitLocation, vector HitNormal)
{
SpawnHitCount++;
mHitLocation = HitLocation;
mHitActor = HitActor;
mHitNormal = HitNormal;
}
simulated event ThirdPersonEffects()
{
local rotator r;
if ( Level.NetMode != NM_DedicatedServer )
{
if (FiringMode == 0)
{
WeaponLight();
if ( OldSpawnHitCount != SpawnHitCount )
{
OldSpawnHitCount = SpawnHitCount;
GetHitInfo();
Spawn(class'HitEffect'.static.GetHitEffect(mHitAct or, mHitLocation, mHitNormal),,, mHitLocation, Rotator(mHitNormal));
}
if (mMuzFlash3rd == None)
{
mMuzFlash3rd = Spawn(mMuzFlashClass);
AttachToBone(mMuzFlash3rd, 'tip');
}
mMuzFlash3rd.mStartParticles++;
r.Roll = Rand(65536);
SetBoneRotation('Bone_Flash', r, 0, 1.f);
}
else if (FiringMode == 1 && FlashCount > 0)
{
WeaponLight();
if (mMuzFlash3rdAlt == None)
{
mMuzFlash3rdAlt = Spawn(mMuzFlashClass);
AttachToBone(mMuzFlash3rdAlt, 'tip2');
}
mMuzFlash3rdAlt.mStartParticles++;
r.Roll = Rand(65536);
SetBoneRotation('Bone_Flash02', r, 0, 1.f);
}
}
Super.ThirdPersonEffects();
}
defaultproperties
{
Mesh=mesh'Weapons.AssaultRifle_3rd'
mMuzFlashClass=class'XEffects.AssaultMuzFlash3rd'
bHeavy=false
bRapidFire=true
bAltRapidFire=false
bDynamicLight=false
LightType=LT_Pulse
LightEffect=LE_NonIncidence
LightPeriod=3
LightBrightness=150
LightHue=30
LightSaturation=150
LightRadius=4.0
}
So this worked untill I put in the HeadShot function..
anyone has ideas to solve this?
thx a lot :)
Now the problem is, when I copied the Headshot function (from the sniperrifle) the bullet hole / bullet spark on the walls disappeared.
This is my whole glock40Fire.uc :
class glock40Fire extends InstantFire;
var float LastFireTime;
var float ClickTime;
// headshot vars //
var() class<xEmitter> HitEmitterClass;
var() class<xEmitter> SecHitEmitterClass;
var() int NumArcs;
var() float SecDamageMult;
var() float SecTraceDist;
var() float HeadShotDamageMult;
var() float HeadShotRadius;
var() class<DamageType> DamageTypeHeadShot;
// eind HS vars //
function InitEffects()
{
Super.InitEffects();
if ( FlashEmitter != None )
Weapon.AttachToBone(FlashEmitter, 'tip');
}
function FlashMuzzleFlash()
{
local rotator r;
r.Roll = 65536; // Rand(65536);
Weapon.SetBoneRotation('Bone_Flash', r, 0, 1.f);
Super.FlashMuzzleFlash();
}
event ModeDoFire()
{
if ( Level.TimeSeconds - LastFireTime > 0.5 ) // als je pas na een halve seconde weer vuurt
{
Spread = 0.0; // is de spread dus 0
}
else // zo niet, dus binnen halve seconde weer vuren
{
Spread = FMin(Spread+0.02,0.12); // dan is de spread random groter, eigen schuld :P
}
LastFireTime = Level.TimeSeconds;
Super.ModeDoFire();
}
simulated function bool AllowFire()
{
if (Super.AllowFire())
return true;
else
{
if ( (PlayerController(Instigator.Controller) != None) && (Level.TimeSeconds > ClickTime) )
{
PlayerController(Instigator.Controller).PlayOwnedS ound(Sound'WeaponSounds.P1Reload5');
ClickTime = Level.TimeSeconds + 0.25;
}
return false;
}
}
// start Headshot check script //
function DoTrace(Vector Start, Rotator Dir)
{
local Vector X,Y,Z, End, HitLocation, HitNormal, RefNormal;
local Actor Other, mainArcHitTarget;
local int Damage, ReflectNum, arcsRemaining;
local bool bDoReflect;
local xEmitter hitEmitter;
local class<Actor> tmpHitEmitClass;
local float tmpTraceRange, dist;
local vector arcEnd, mainArcHit;
Weapon.GetViewAxes(X, Y, Z);
if ( Weapon.WeaponCentered() )
arcEnd = (Instigator.Location +
Weapon.EffectOffset.X * X +
1.5 * Weapon.EffectOffset.Z * Z);
else
arcEnd = (Instigator.Location +
Instigator.CalcDrawOffset(Weapon) +
Weapon.EffectOffset.X * X +
Weapon.Hand * Weapon.EffectOffset.Y * Y +
Weapon.EffectOffset.Z * Z);
arcsRemaining = NumArcs;
tmpHitEmitClass = HitEmitterClass;
tmpTraceRange = TraceRange;
ReflectNum = 0;
while (true)
{
bDoReflect = false;
X = Vector(Dir);
End = Start + tmpTraceRange * X;
Other = Trace(HitLocation, HitNormal, End, Start, true);
if ( Other != None && (Other != Instigator || ReflectNum > 0) )
{
if (bReflective && Other.IsA('xPawn') && xPawn(Other).CheckReflect(HitLocation, RefNormal, DamageMin*0.25))
{
bDoReflect = true;
}
else if ( Other != mainArcHitTarget )
{
if ( !Other.bWorldGeometry )
{
Damage = (DamageMin + Rand(DamageMax - DamageMin)) * DamageAtten;
if ( (Pawn(Other) != None) && (arcsRemaining == NumArcs)
&& Other.GetClosestBone( HitLocation, X, dist, 'head', HeadShotRadius ) == 'head' )
Other.TakeDamage(Damage * HeadShotDamageMult, Instigator, HitLocation, Momentum*X, DamageTypeHeadShot);
else
{
if ( arcsRemaining < NumArcs )
Damage *= SecDamageMult;
Other.TakeDamage(Damage, Instigator, HitLocation, Momentum*X, DamageType);
}
}
else
HitLocation = HitLocation + 2.0 * HitNormal;
}
}
else
{
HitLocation = End;
HitNormal = Normal(Start - End);
}
hitEmitter = xEmitter(Spawn(tmpHitEmitClass,,, arcEnd, Rotator(HitNormal)));
if ( hitEmitter != None )
hitEmitter.mSpawnVecA = HitLocation;
if( arcsRemaining == NumArcs )
{
mainArcHit = HitLocation + (HitNormal * 2.0);
if ( Other != None && !Other.bWorldGeometry )
mainArcHitTarget = Other;
}
if (bDoReflect && ++ReflectNum < 4)
{
//Log("reflecting off"@Other@Start@HitLocation);
Start = HitLocation;
Dir = Rotator( X - 2.0*RefNormal*(X dot RefNormal) );
}
else if ( arcsRemaining > 0 )
{
arcsRemaining--;
// done parent arc, now move trace point to arc trace hit location and try child arcs from there
Start = mainArcHit;
Dir = Rotator(VRand());
tmpHitEmitClass = SecHitEmitterClass;
tmpTraceRange = SecTraceDist;
arcEnd = mainArcHit;
}
else
{
break;
}
}
}
// eind HS check script //
defaultproperties
{
FireSound=Sound'WeaponSounds.AssaultRifle.AssaultR ifleFire'
FireForce="AssaultRifleFire" // jdf
TraceRange=17000 //Maximum range of the weapon.
Momentum=1000 //How much the victim is pushed when hit.
AmmoClass=class'glock40Ammo'
AmmoPerFire=1
DamageType=class'glock40DamType'
DamageMin=30 //Min and Max can be different, to do a random damage between the two, or the same to do consistent damage.
DamageMax=32
FireAnim=Fire
FireEndAnim=None
FireLoopAnim=None
FireAnimRate=1.0
// FlashEmitterClass=class'XEffects.AssaultMuzFlash1s t'
FlashEmitterClass=class'XEffects.MinigunMuzFlash1s t'
Spread=0.020
SpreadStyle=SS_Random
PreFireTime=0.0
bModeExclusive=true
FireRate=0.3 //How fast it fires.
BotRefireRate=0.3 //How fast bots should try to fire.
AimError=800 //How accurate bots are.
bPawnRapidFireAnim=false
//These settings controll how your vire shakes when you fire.
ShakeOffsetMag=(X=-15.0,Y=0.0,Z=10.0)
ShakeOffsetRate=(X=-4000.0,Y=0.0,Z=4000.0)
ShakeOffsetTime=1.6
ShakeRotMag=(X=0.0,Y=0.0,Z=0.0)
ShakeRotRate=(X=0.0,Y=0.0,Z=0.0)
ShakeRotTime=2
HeadShotDamageMult=10.0
HeadShotRadius=10.0
DamageTypeHeadShot=class'DamTypeSniperHeadShot'
}
Well, before that i just had the bullet holes on the ground, standing in my attachment class :
class glock40Attachment extends xWeaponAttachment;
var byte OldSpawnHitCount;
var class<xEmitter> mMuzFlashClass;
var xEmitter mMuzFlash3rd;
var xEmitter mMuzFlash3rdAlt;
simulated function Destroyed()
{
if (mMuzFlash3rd != None)
mMuzFlash3rd.Destroy();
if (mMuzFlash3rdAlt != None)
mMuzFlash3rdAlt.Destroy();
Super.Destroyed();
}
/* UpdateHit
- used to update properties so hit effect can be spawn client side
*/
function UpdateHit(Actor HitActor, vector HitLocation, vector HitNormal)
{
SpawnHitCount++;
mHitLocation = HitLocation;
mHitActor = HitActor;
mHitNormal = HitNormal;
}
simulated event ThirdPersonEffects()
{
local rotator r;
if ( Level.NetMode != NM_DedicatedServer )
{
if (FiringMode == 0)
{
WeaponLight();
if ( OldSpawnHitCount != SpawnHitCount )
{
OldSpawnHitCount = SpawnHitCount;
GetHitInfo();
Spawn(class'HitEffect'.static.GetHitEffect(mHitAct or, mHitLocation, mHitNormal),,, mHitLocation, Rotator(mHitNormal));
}
if (mMuzFlash3rd == None)
{
mMuzFlash3rd = Spawn(mMuzFlashClass);
AttachToBone(mMuzFlash3rd, 'tip');
}
mMuzFlash3rd.mStartParticles++;
r.Roll = Rand(65536);
SetBoneRotation('Bone_Flash', r, 0, 1.f);
}
else if (FiringMode == 1 && FlashCount > 0)
{
WeaponLight();
if (mMuzFlash3rdAlt == None)
{
mMuzFlash3rdAlt = Spawn(mMuzFlashClass);
AttachToBone(mMuzFlash3rdAlt, 'tip2');
}
mMuzFlash3rdAlt.mStartParticles++;
r.Roll = Rand(65536);
SetBoneRotation('Bone_Flash02', r, 0, 1.f);
}
}
Super.ThirdPersonEffects();
}
defaultproperties
{
Mesh=mesh'Weapons.AssaultRifle_3rd'
mMuzFlashClass=class'XEffects.AssaultMuzFlash3rd'
bHeavy=false
bRapidFire=true
bAltRapidFire=false
bDynamicLight=false
LightType=LT_Pulse
LightEffect=LE_NonIncidence
LightPeriod=3
LightBrightness=150
LightHue=30
LightSaturation=150
LightRadius=4.0
}
So this worked untill I put in the HeadShot function..
anyone has ideas to solve this?
thx a lot :)