How to make weapon 'Shoot' animation faster

A refuge for those migrating from the fallen DXEditing.com and a place for general discussion relating to Deus Ex editing (coding, mapping, etc).
SkrillaX
NSF
Posts: 86
Joined: Sun Oct 02, 2016 4:43 am

Re: How to make weapon 'Shoot' animation faster

Post by SkrillaX »

//=============================================================================
// TraceHitSpawner class so we can reduce nettraffic for hitspangs
//=============================================================================
class TraceHitSpawner extends Actor;

var float HitDamage;
var bool bPenetrating; // shot that hit was a penetrating shot
var bool bHandToHand; // shot that hit was hand to hand
var bool bInstantHit;
var Name damageType;

simulated function PostBeginPlay()
{
Super.PostBeginPlay();

if (Owner == None)
SetOwner(Level);
SpawnEffects(Owner,HitDamage);
}

simulated function Timer()
{
Destroy();
}

//
// we have to use an actor to play the hit sound at the correct location
//
simulated function PlayHitSound(actor destActor, Actor hitActor)
{
local float rnd;
local sound snd;

// don't ricochet unless it's hit by a bullet
if ((damageType != 'Shot') && (damageType != 'Sabot'))
return;

rnd = FRand();

if (rnd < 0.25)
snd = sound'Ricochet1';
else if (rnd < 0.5)
snd = sound'Ricochet2';
else if (rnd < 0.75)
snd = sound'Ricochet3';
else
snd = sound'Ricochet4';

// play a different ricochet sound if the object isn't damaged by normal bullets
if (hitActor != None)
{
if (hitActor.IsA('DeusExDecoration') && (DeusExDecoration(hitActor).minDamageThreshold > 10))
snd = sound'ArmorRicochet';
else if (hitActor.IsA('Robot'))
snd = sound'ArmorRicochet';
}
if (destActor != None)
destActor.PlaySound(snd, SLOT_None,,, 1024, 1.1 - 0.2*FRand());
}

simulated function SpawnEffects(Actor Other, float Damage)
{
local SmokeTrail puff;
local int i;
local BulletHole hole;
local RockChip chip;
local Rotator rot;
local DeusExMover mov;
local Spark spark;

SetTimer(0.1,False);
if (Level.NetMode == NM_DedicatedServer)
return;

if (bPenetrating && !bHandToHand && !Other.IsA('DeusExDecoration'))
{
// Every hit gets a puff in multiplayer
if ( Level.NetMode != NM_Standalone )
{
puff = spawn(class'Hitpuff1',,,Location+(Vector(Rotation)*1.5), Rotation);
if ( puff != None )
{
puff.DrawScale = 1.0;
puff.OrigScale = puff.DrawScale;
puff.LifeSpan = 1.0;
puff.OrigLifeSpan = puff.LifeSpan;
puff.RemoteRole = ROLE_None;
}
}
else
{
if (FRand() < 0.5)
{
puff = spawn(class'Hitpuff2',,,Location+Vector(Rotation), Rotation);
if (puff != None)
{
puff.DrawScale *= 1.0;
puff.OrigScale = puff.DrawScale;
puff.LifeSpan = 1.0;
puff.OrigLifeSpan = puff.LifeSpan;
puff.RemoteRole = ROLE_None;
}
}
}
if (!Other.IsA('DeusExMover'))
for (i=0; i<2; i++)
if (FRand() < 0.8)
{
chip = spawn(class'Rockchip',,,Location+Vector(Rotation));
if (chip != None)
chip.RemoteRole = ROLE_None;
}
}

if ((!bHandToHand) && bInstantHit && bPenetrating)
{
hole = spawn(class'BulletHole', Other,, Location+Vector(Rotation), Rotation);
if (hole != None)
hole.RemoteRole = ROLE_None;

if ( !Other.IsA('DeusExPlayer') ) // Sparks on people look bad
{
spark = spawn(class'Spark',,,Location+Vector(Rotation), Rotation);
if (spark != None)
{
spark.RemoteRole = ROLE_None;
if ( Level.NetMode != NM_Standalone )
spark.DrawScale = 0.25;
else
spark.DrawScale = 0.05;
PlayHitSound(spark, Other);
}
}
}

// draw the correct damage art for what we hit
if (bPenetrating || bHandToHand)
{
if (Other.IsA('DeusExMover'))
{
mov = DeusExMover(Other);
if ((mov != None) && (hole == None))
{
hole = spawn(class'BulletHole', Other,, Location+Vector(Rotation), Rotation);
if (hole != None)
hole.remoteRole = ROLE_None;
}

if (hole != None)
{
if (mov.bBreakable && (mov.minDamageThreshold <= Damage))
{
// don't draw damage art on destroyed movers
if (mov.bDestroyed)
hole.Destroy();
else if (mov.FragmentClass == class'GlassFragment')
{
// glass hole
if (FRand() < 0.5)
hole.Texture = Texture'FlatFXTex29';
else
hole.Texture = Texture'FlatFXTex30';

hole.DrawScale = 0.1;
hole.ReattachDecal();
}
else
{
// non-glass crack
if (FRand() < 0.5)
hole.Texture = Texture'FlatFXTex7';
else
hole.Texture = Texture'FlatFXTex8';

hole.DrawScale = 0.4;
hole.ReattachDecal();
}
}
else
{
if (!bPenetrating || bHandToHand)
hole.Destroy();
}
}
}
}
}

defaultproperties
{
HitDamage=-1.000000
bPenetrating=True
bInstantHit=True
RemoteRole=ROLE_None
DrawType=DT_None
bGameRelevant=True
CollisionRadius=0.000000
CollisionHeight=0.000000
}
SkrillaX
NSF
Posts: 86
Joined: Sun Oct 02, 2016 4:43 am

Re: How to make weapon 'Shoot' animation faster

Post by SkrillaX »

Code: Select all

//=============================================================================
// TraceHitSpawner class so we can reduce nettraffic for hitspangs
//=============================================================================
class TraceHitSpawner extends Actor;

var float HitDamage;
var bool bPenetrating; // shot that hit was a penetrating shot
var bool bHandToHand; // shot that hit was hand to hand
var bool bInstantHit;
var Name damageType;

simulated function PostBeginPlay()
{
Super.PostBeginPlay();

if (Owner == None)
SetOwner(Level);
SpawnEffects(Owner,HitDamage);
}

simulated function Timer()
{
Destroy();
}

//
// we have to use an actor to play the hit sound at the correct location
//
simulated function PlayHitSound(actor destActor, Actor hitActor)
{
local float rnd;
local sound snd;

// don't ricochet unless it's hit by a bullet
if ((damageType != 'Shot') && (damageType != 'Sabot'))
return;

rnd = FRand();

if (rnd < 0.25)
snd = sound'Ricochet1';
else if (rnd < 0.5)
snd = sound'Ricochet2';
else if (rnd < 0.75)
snd = sound'Ricochet3';
else
snd = sound'Ricochet4';

// play a different ricochet sound if the object isn't damaged by normal bullets
if (hitActor != None) 
{
if (hitActor.IsA('DeusExDecoration') && (DeusExDecoration(hitActor).minDamageThreshold > 10))
snd = sound'ArmorRicochet';
else if (hitActor.IsA('Robot'))
snd = sound'ArmorRicochet';
}
if (destActor != None)
destActor.PlaySound(snd, SLOT_None,,, 1024, 1.1 - 0.2*FRand());
}

simulated function SpawnEffects(Actor Other, float Damage)
{
local SmokeTrail puff;
local int i;
local BulletHole hole;
local RockChip chip;
local Rotator rot;
local DeusExMover mov;
local Spark	spark;

SetTimer(0.1,False);
if (Level.NetMode == NM_DedicatedServer)
return;

if (bPenetrating && !bHandToHand && !Other.IsA('DeusExDecoration'))
{
// Every hit gets a puff in multiplayer
if ( Level.NetMode != NM_Standalone )
{
puff = spawn(class'Hitpuff1',,,Location+(Vector(Rotation)*1.5), Rotation);
if ( puff != None )
{
puff.DrawScale = 1.0;
puff.OrigScale = puff.DrawScale;
puff.LifeSpan = 1.0;
puff.OrigLifeSpan = puff.LifeSpan;
puff.RemoteRole = ROLE_None;
}
}
else
{
if (FRand() < 0.5)
{
puff = spawn(class'Hitpuff2',,,Location+Vector(Rotation), Rotation);
if (puff != None)
{
puff.DrawScale *= 1.0;
puff.OrigScale = puff.DrawScale;
puff.LifeSpan = 1.0;
puff.OrigLifeSpan = puff.LifeSpan;
puff.RemoteRole = ROLE_None;
}
}
}
if (!Other.IsA('DeusExMover'))
for (i=0; i<2; i++)
if (FRand() < 0.8)
{
chip = spawn(class'Rockchip',,,Location+Vector(Rotation));
if (chip != None)
chip.RemoteRole = ROLE_None;
}
}

if ((!bHandToHand) && bInstantHit && bPenetrating)
{
hole = spawn(class'BulletHole', Other,, Location+Vector(Rotation), Rotation);
if (hole != None) 
hole.RemoteRole = ROLE_None;

if ( !Other.IsA('DeusExPlayer') )	// Sparks on people look bad
{
spark = spawn(class'Spark',,,Location+Vector(Rotation), Rotation);
if (spark != None)
{
spark.RemoteRole = ROLE_None;
if ( Level.NetMode != NM_Standalone )
spark.DrawScale = 0.25;
else
spark.DrawScale = 0.05;
PlayHitSound(spark, Other);
}
}
}

// draw the correct damage art for what we hit
if (bPenetrating || bHandToHand)
{
if (Other.IsA('DeusExMover'))
{
mov = DeusExMover(Other);
if ((mov != None) && (hole == None))
{
hole = spawn(class'BulletHole', Other,, Location+Vector(Rotation), Rotation);
if (hole != None)
hole.remoteRole = ROLE_None;
}

if (hole != None)
{
if (mov.bBreakable && (mov.minDamageThreshold <= Damage))
{
// don't draw damage art on destroyed movers
if (mov.bDestroyed)
hole.Destroy();
else if (mov.FragmentClass == class'GlassFragment')
{
// glass hole
if (FRand() < 0.5)
hole.Texture = Texture'FlatFXTex29';
else
hole.Texture = Texture'FlatFXTex30';

hole.DrawScale = 0.1;
hole.ReattachDecal();
}
else
{
// non-glass crack
if (FRand() < 0.5)
hole.Texture = Texture'FlatFXTex7';
else
hole.Texture = Texture'FlatFXTex8';

hole.DrawScale = 0.4;
hole.ReattachDecal();
}
}
else
{
if (!bPenetrating || bHandToHand)
hole.Destroy();
}
}
}
}
}

defaultproperties
{
HitDamage=-1.000000
bPenetrating=True
bInstantHit=True
RemoteRole=ROLE_None
DrawType=DT_None
bGameRelevant=True
CollisionRadius=0.000000
CollisionHeight=0.000000
}
Cybernetic pig
Illuminati
Posts: 2284
Joined: Thu Mar 08, 2012 3:21 am

Re: How to make weapon 'Shoot' animation faster

Post by Cybernetic pig »

Goddamn it man, copy it from the .uc file to here, and then put it in code tags so that the formatting is not destroyed.

Example where the formatting is not lost:

Code: Select all

function bool ShouldBeStartled(Pawn startler)
{
	local float speed;
	local float time;
	local float dist;
	local float dist2;
	local bool  bPh33r;

	bPh33r = false;
	if (startler != None)
	{
		speed = VSize(startler.Velocity);
		if (speed >= 20)
		{
			dist = VSize(Location - startler.Location);
			time = dist/speed;
			if (time <= 3.0)
			{
				dist2 = VSize(Location - (startler.Location+startler.Velocity*time));
				if (dist2 < speed*1.5)
					bPh33r = true;
			}
		}
	}

	return bPh33r;
}
Same code, without the formatting:

Code: Select all

function bool ShouldBeStartled(Pawn startler)
{
local float speed;
local float time;
local float dist;
local float dist2;
local bool bPh33r;

bPh33r = false;
if (startler != None)
{
speed = VSize(startler.Velocity);
if (speed >= 20)
{
dist = VSize(Location - startler.Location);
time = dist/speed;
if (time <= 3.0)
{
dist2 = VSize(Location - (startler.Location+startler.Velocity*time));
if (dist2 < speed*1.5)
bPh33r = true;
}
}
}

return bPh33r;
}
Last edited by Cybernetic pig on Sun Oct 09, 2016 3:50 pm, edited 1 time in total.
SkrillaX
NSF
Posts: 86
Joined: Sun Oct 02, 2016 4:43 am

Re: How to make weapon 'Shoot' animation faster

Post by SkrillaX »

//=============================================================================
// TraceHitSpawner class so we can reduce nettraffic for hitspangs
//=============================================================================
class TraceHitSpawner extends Actor;

var float HitDamage;
var bool bPenetrating; // shot that hit was a penetrating shot
var bool bHandToHand; // shot that hit was hand to hand
var bool bInstantHit;
var Name damageType;

simulated function PostBeginPlay()
{
Super.PostBeginPlay();

if (Owner == None)
SetOwner(Level);
SpawnEffects(Owner,HitDamage);
}

simulated function Timer()
{
Destroy();
}

//
// we have to use an actor to play the hit sound at the correct location
//
simulated function PlayHitSound(actor destActor, Actor hitActor)
{
local float rnd;
local sound snd;

// don't ricochet unless it's hit by a bullet
if ((damageType != 'Shot') && (damageType != 'Sabot'))
return;

rnd = FRand();

if (rnd < 0.25)
snd = sound'Ricochet1';
else if (rnd < 0.5)
snd = sound'Ricochet2';
else if (rnd < 0.75)
snd = sound'Ricochet3';
else
snd = sound'Ricochet4';

// play a different ricochet sound if the object isn't damaged by normal bullets
if (hitActor != None)
{
if (hitActor.IsA('DeusExDecoration') && (DeusExDecoration(hitActor).minDamageThreshold > 10))
snd = sound'ArmorRicochet';
else if (hitActor.IsA('Robot'))
snd = sound'ArmorRicochet';
}
if (destActor != None)
destActor.PlaySound(snd, SLOT_None,,, 1024, 1.1 - 0.2*FRand());
}

simulated function SpawnEffects(Actor Other, float Damage)
{
local SmokeTrail puff;
local int i;
local BulletHole hole;
local RockChip chip;
local Rotator rot;
local DeusExMover mov;
local Spark spark;

SetTimer(0.1,False);
if (Level.NetMode == NM_DedicatedServer)
return;

if (bPenetrating && !bHandToHand && !Other.IsA('DeusExDecoration'))
{
// Every hit gets a puff in multiplayer
if ( Level.NetMode != NM_Standalone )
{
puff = spawn(class'Hitpuff1',,,Location+(Vector(Rotation)*1.5), Rotation);
if ( puff != None )
{
puff.DrawScale = 1.0;
puff.OrigScale = puff.DrawScale;
puff.LifeSpan = 1.0;
puff.OrigLifeSpan = puff.LifeSpan;
puff.RemoteRole = ROLE_None;
}
}
else
{
if (FRand() < 0.5)
{
puff = spawn(class'Hitpuff2',,,Location+Vector(Rotation), Rotation);
if (puff != None)
{
puff.DrawScale *= 1.0;
puff.OrigScale = puff.DrawScale;
puff.LifeSpan = 1.0;
puff.OrigLifeSpan = puff.LifeSpan;
puff.RemoteRole = ROLE_None;
}
}
}
if (!Other.IsA('DeusExMover'))
for (i=0; i<2; i++)
if (FRand() < 0.8)
{
chip = spawn(class'Rockchip',,,Location+Vector(Rotation));
if (chip != None)
chip.RemoteRole = ROLE_None;
}
}

if ((!bHandToHand) && bInstantHit && bPenetrating)
{
hole = spawn(class'BulletHole', Other,, Location+Vector(Rotation), Rotation);
if (hole != None)
hole.RemoteRole = ROLE_None;

if ( !Other.IsA('DeusExPlayer') ) // Sparks on people look bad
{
spark = spawn(class'Spark',,,Location+Vector(Rotation), Rotation);
if (spark != None)
{
spark.RemoteRole = ROLE_None;
if ( Level.NetMode != NM_Standalone )
spark.DrawScale = 0.25;
else
spark.DrawScale = 0.05;
PlayHitSound(spark, Other);
}
}
}

// draw the correct damage art for what we hit
if (bPenetrating || bHandToHand)
{
if (Other.IsA('DeusExMover'))
{
mov = DeusExMover(Other);
if ((mov != None) && (hole == None))
{
hole = spawn(class'BulletHole', Other,, Location+Vector(Rotation), Rotation);
if (hole != None)
hole.remoteRole = ROLE_None;
}

if (hole != None)
{
if (mov.bBreakable && (mov.minDamageThreshold <= Damage))
{
// don't draw damage art on destroyed movers
if (mov.bDestroyed)
hole.Destroy();
else if (mov.FragmentClass == class'GlassFragment')
{
// glass hole
if (FRand() < 0.5)
hole.Texture = Texture'FlatFXTex29';
else
hole.Texture = Texture'FlatFXTex30';

hole.DrawScale = 0.1;
hole.ReattachDecal();
}
else
{
// non-glass crack
if (FRand() < 0.5)
hole.Texture = Texture'FlatFXTex7';
else
hole.Texture = Texture'FlatFXTex8';

hole.DrawScale = 0.4;
hole.ReattachDecal();
}
}
else
{
if (!bPenetrating || bHandToHand)
hole.Destroy();
}
}
}
}
}

defaultproperties
{
HitDamage=-1.000000
bPenetrating=True
bInstantHit=True
RemoteRole=ROLE_None
DrawType=DT_None
bGameRelevant=True
CollisionRadius=0.000000
CollisionHeight=0.000000
}
SkrillaX
NSF
Posts: 86
Joined: Sun Oct 02, 2016 4:43 am

Re: How to make weapon 'Shoot' animation faster

Post by SkrillaX »

Code: Select all

//=============================================================================
// TraceHitSpawner class so we can reduce nettraffic for hitspangs
//=============================================================================
class TraceHitSpawner extends Actor;

var float HitDamage;
var bool bPenetrating; // shot that hit was a penetrating shot
var bool bHandToHand; // shot that hit was hand to hand
var bool bInstantHit;
var Name damageType;

simulated function PostBeginPlay()
{
Super.PostBeginPlay();

if (Owner == None)
SetOwner(Level);
SpawnEffects(Owner,HitDamage);
}

simulated function Timer()
{
Destroy();
}

//
// we have to use an actor to play the hit sound at the correct location
//
simulated function PlayHitSound(actor destActor, Actor hitActor)
{
local float rnd;
local sound snd;

// don't ricochet unless it's hit by a bullet
if ((damageType != 'Shot') && (damageType != 'Sabot'))
return;

rnd = FRand();

if (rnd < 0.25)
snd = sound'Ricochet1';
else if (rnd < 0.5)
snd = sound'Ricochet2';
else if (rnd < 0.75)
snd = sound'Ricochet3';
else
snd = sound'Ricochet4';

// play a different ricochet sound if the object isn't damaged by normal bullets
if (hitActor != None) 
{
if (hitActor.IsA('DeusExDecoration') && (DeusExDecoration(hitActor).minDamageThreshold > 10))
snd = sound'ArmorRicochet';
else if (hitActor.IsA('Robot'))
snd = sound'ArmorRicochet';
}
if (destActor != None)
destActor.PlaySound(snd, SLOT_None,,, 1024, 1.1 - 0.2*FRand());
}

simulated function SpawnEffects(Actor Other, float Damage)
{
local SmokeTrail puff;
local int i;
local BulletHole hole;
local RockChip chip;
local Rotator rot;
local DeusExMover mov;
local Spark   spark;

SetTimer(0.1,False);
if (Level.NetMode == NM_DedicatedServer)
return;

if (bPenetrating && !bHandToHand && !Other.IsA('DeusExDecoration'))
{
// Every hit gets a puff in multiplayer
if ( Level.NetMode != NM_Standalone )
{
puff = spawn(class'Hitpuff1',,,Location+(Vector(Rotation)*1.5), Rotation);
if ( puff != None )
{
puff.DrawScale = 1.0;
puff.OrigScale = puff.DrawScale;
puff.LifeSpan = 1.0;
puff.OrigLifeSpan = puff.LifeSpan;
puff.RemoteRole = ROLE_None;
}
}
else
{
if (FRand() < 0.5)
{
puff = spawn(class'Hitpuff2',,,Location+Vector(Rotation), Rotation);
if (puff != None)
{
puff.DrawScale *= 1.0;
puff.OrigScale = puff.DrawScale;
puff.LifeSpan = 1.0;
puff.OrigLifeSpan = puff.LifeSpan;
puff.RemoteRole = ROLE_None;
}
}
}
if (!Other.IsA('DeusExMover'))
for (i=0; i<2; i++)
if (FRand() < 0.8)
{
chip = spawn(class'Rockchip',,,Location+Vector(Rotation));
if (chip != None)
chip.RemoteRole = ROLE_None;
}
}

if ((!bHandToHand) && bInstantHit && bPenetrating)
{
hole = spawn(class'BulletHole', Other,, Location+Vector(Rotation), Rotation);
if (hole != None) 
hole.RemoteRole = ROLE_None;

if ( !Other.IsA('DeusExPlayer') )   // Sparks on people look bad
{
spark = spawn(class'Spark',,,Location+Vector(Rotation), Rotation);
if (spark != None)
{
spark.RemoteRole = ROLE_None;
if ( Level.NetMode != NM_Standalone )
spark.DrawScale = 0.25;
else
spark.DrawScale = 0.05;
PlayHitSound(spark, Other);
}
}
}

// draw the correct damage art for what we hit
if (bPenetrating || bHandToHand)
{
if (Other.IsA('DeusExMover'))
{
mov = DeusExMover(Other);
if ((mov != None) && (hole == None))
{
hole = spawn(class'BulletHole', Other,, Location+Vector(Rotation), Rotation);
if (hole != None)
hole.remoteRole = ROLE_None;
}

if (hole != None)
{
if (mov.bBreakable && (mov.minDamageThreshold <= Damage))
{
// don't draw damage art on destroyed movers
if (mov.bDestroyed)
hole.Destroy();
else if (mov.FragmentClass == class'GlassFragment')
{
// glass hole
if (FRand() < 0.5)
hole.Texture = Texture'FlatFXTex29';
else
hole.Texture = Texture'FlatFXTex30';

hole.DrawScale = 0.1;
hole.ReattachDecal();
}
else
{
// non-glass crack
if (FRand() < 0.5)
hole.Texture = Texture'FlatFXTex7';
else
hole.Texture = Texture'FlatFXTex8';

hole.DrawScale = 0.4;
hole.ReattachDecal();
}
}
else
{
if (!bPenetrating || bHandToHand)
hole.Destroy();
}
}
}
}
}

defaultproperties
{
HitDamage=-1.000000
bPenetrating=True
bInstantHit=True
RemoteRole=ROLE_None
DrawType=DT_None
bGameRelevant=True
CollisionRadius=0.000000
CollisionHeight=0.000000
}
Cybernetic pig
Illuminati
Posts: 2284
Joined: Thu Mar 08, 2012 3:21 am

Re: How to make weapon 'Shoot' animation faster

Post by Cybernetic pig »

I'll wait patiently until you succeed.
SkrillaX
NSF
Posts: 86
Joined: Sun Oct 02, 2016 4:43 am

Re: How to make weapon 'Shoot' animation faster

Post by SkrillaX »

I thought that it was only relevant to readability ?
Cybernetic pig
Illuminati
Posts: 2284
Joined: Thu Mar 08, 2012 3:21 am

Re: How to make weapon 'Shoot' animation faster

Post by Cybernetic pig »

Yes, and I need to read it if you want help. That and for any other future questions you may have for myself and others.

I'll make it easy for you:

1. Bring up the .uc file -> right click -> select all -> Ctrl + C.

Don't just copy the text above, it needs to be copied from the .uc file where the formatting is intact.

2. Paste it into the browser here, then wrap it in code tags.
SkrillaX
NSF
Posts: 86
Joined: Sun Oct 02, 2016 4:43 am

Re: How to make weapon 'Shoot' animation faster

Post by SkrillaX »

Best Option. Go 2 Unrealed . Press ''Export All''. Go to TraceHitspawner. That is the file in the original Deus Ex
Made in China
MJ12
Posts: 466
Joined: Thu Apr 02, 2009 7:55 pm

Re: How to make weapon 'Shoot' animation faster

Post by Made in China »

Oh, FFS! SkrillaX, There's a "Preview" button. You can see if the formatting is OK if you're unsure whether you did well.

Code: Select all

//=============================================================================
// TraceHitSpawner class so we can reduce nettraffic for hitspangs
//=============================================================================
class TraceHitSpawner extends Actor;

var float HitDamage;
var bool bPenetrating; // shot that hit was a penetrating shot
var bool bHandToHand;  // shot that hit was hand to hand
var bool bInstantHit;
var Name damageType;

simulated function PostBeginPlay()
{
   Super.PostBeginPlay();
   
   if (Owner == None)
      SetOwner(Level);
   SpawnEffects(Owner,HitDamage);
}

simulated function Timer()
{
   Destroy();
}

//
// we have to use an actor to play the hit sound at the correct location
//
simulated function PlayHitSound(actor destActor, Actor hitActor)
{
	local float rnd;
	local sound snd;

	// don't ricochet unless it's hit by a bullet
	if ((damageType != 'Shot') && (damageType != 'Sabot'))
		return;

	rnd = FRand();

	if (rnd < 0.25)
		snd = sound'Ricochet1';
	else if (rnd < 0.5)
		snd = sound'Ricochet2';
	else if (rnd < 0.75)
		snd = sound'Ricochet3';
	else
		snd = sound'Ricochet4';

	// play a different ricochet sound if the object isn't damaged by normal bullets
	if (hitActor != None) 
	{
		if (hitActor.IsA('DeusExDecoration') && (DeusExDecoration(hitActor).minDamageThreshold > 10))
			snd = sound'ArmorRicochet';
		else if (hitActor.IsA('Robot'))
			snd = sound'ArmorRicochet';
	}
	if (destActor != None)
		destActor.PlaySound(snd, SLOT_None,,, 1024, 1.1 - 0.2*FRand());
}

simulated function SpawnEffects(Actor Other, float Damage)
{
   local SmokeTrail puff;
   local int i;
   local BulletHole hole;
   local RockChip chip;
   local Rotator rot;
   local DeusExMover mov;
	local Spark		spark;

   SetTimer(0.1,False);
   if (Level.NetMode == NM_DedicatedServer)
      return;

	if (bPenetrating && !bHandToHand && !Other.IsA('DeusExDecoration'))
	{
		// Every hit gets a puff in multiplayer
		if ( Level.NetMode != NM_Standalone )
		{
			puff = spawn(class'Hitpuff1',,,Location+(Vector(Rotation)*1.5), Rotation);
			if ( puff != None )
			{
				puff.DrawScale = 1.0;
				puff.OrigScale = puff.DrawScale;
				puff.LifeSpan = 1.0;
				puff.OrigLifeSpan = puff.LifeSpan;
            puff.RemoteRole = ROLE_None;
			}
		}
		else
		{
			if (FRand() < 0.5)
			{
				puff = spawn(class'Hitpuff2',,,Location+Vector(Rotation), Rotation);
				if (puff != None)
				{
					puff.DrawScale *= 1.0;
					puff.OrigScale = puff.DrawScale;
					puff.LifeSpan = 1.0;
					puff.OrigLifeSpan = puff.LifeSpan;
               puff.RemoteRole = ROLE_None;
				}
			}
		}
     if (!Other.IsA('DeusExMover'))
         for (i=0; i<2; i++)
            if (FRand() < 0.8)
            {
               chip = spawn(class'Rockchip',,,Location+Vector(Rotation));
               if (chip != None)
                  chip.RemoteRole = ROLE_None;
            }
	}

   if ((!bHandToHand) && bInstantHit && bPenetrating)
	{
      hole = spawn(class'BulletHole', Other,, Location+Vector(Rotation), Rotation);
      if (hole != None)      
         hole.RemoteRole = ROLE_None;

		if ( !Other.IsA('DeusExPlayer') )		// Sparks on people look bad
		{
			spark = spawn(class'Spark',,,Location+Vector(Rotation), Rotation);
			if (spark != None)
			{
				spark.RemoteRole = ROLE_None;
				if ( Level.NetMode != NM_Standalone )
					spark.DrawScale = 0.25;
				else
					spark.DrawScale = 0.05;
				PlayHitSound(spark, Other);
			}
		}
	}

	// draw the correct damage art for what we hit
	if (bPenetrating || bHandToHand)
	{
		if (Other.IsA('DeusExMover'))
		{
			mov = DeusExMover(Other);
			if ((mov != None) && (hole == None))
         {
            hole = spawn(class'BulletHole', Other,, Location+Vector(Rotation), Rotation);
            if (hole != None)
               hole.remoteRole = ROLE_None;
         }

			if (hole != None)
			{
				if (mov.bBreakable && (mov.minDamageThreshold <= Damage))
				{
					// don't draw damage art on destroyed movers
					if (mov.bDestroyed)
						hole.Destroy();
					else if (mov.FragmentClass == class'GlassFragment')
					{
						// glass hole
						if (FRand() < 0.5)
							hole.Texture = Texture'FlatFXTex29';
						else
							hole.Texture = Texture'FlatFXTex30';

						hole.DrawScale = 0.1;
						hole.ReattachDecal();
					}
					else
					{
						// non-glass crack
						if (FRand() < 0.5)
							hole.Texture = Texture'FlatFXTex7';
						else
							hole.Texture = Texture'FlatFXTex8';

						hole.DrawScale = 0.4;
						hole.ReattachDecal();
					}
				}
				else
				{
					if (!bPenetrating || bHandToHand)
						hole.Destroy();
				}
			}
		}
	}
}

defaultproperties
{
     HitDamage=-1.000000
     bPenetrating=True
     bInstantHit=True
     RemoteRole=ROLE_None
     DrawType=DT_None
     bGameRelevant=True
     CollisionRadius=0.000000
     CollisionHeight=0.000000
}
SkrillaX
NSF
Posts: 86
Joined: Sun Oct 02, 2016 4:43 am

Re: How to make weapon 'Shoot' animation faster

Post by SkrillaX »

Thanks ! Your brain must've been made in China! Thanks for your help.
Cybernetic pig
Illuminati
Posts: 2284
Joined: Thu Mar 08, 2012 3:21 am

Re: How to make weapon 'Shoot' animation faster

Post by Cybernetic pig »

Right, now that that has been dealt with:

Code: Select all

simulated function SpawnEffects(Actor Other, float Damage)
{
   local SmokeTrail puff;
   local int i;
   local BulletHole hole;
   local RockChip chip;
   local Rotator rot;
   local DeusExMover mov;
   local Spark      spark;

   SetTimer(0.1,False);
   if (Level.NetMode == NM_DedicatedServer)
      return;

   if (bPenetrating && !bHandToHand && !Other.IsA('DeusExDecoration'))
   {
      // Every hit gets a puff in multiplayer
      if ( Level.NetMode != NM_Standalone )
      {
         puff = spawn(class'Hitpuff1',,,Location+(Vector(Rotation)*1.5), Rotation);
         if ( puff != None )
         {
            puff.DrawScale = 1.0;
            puff.OrigScale = puff.DrawScale;
            puff.LifeSpan = 1.0;
            puff.OrigLifeSpan = puff.LifeSpan;
            puff.RemoteRole = ROLE_None;
         }
      }
As you're a struggling newbie, You can use the multiplayer code there for hitpuffs. To keep it simple for you, just change

Code: Select all

// Every hit gets a puff in multiplayer
      if ( Level.NetMode != NM_Standalone )

to:

Code: Select all

// Every hit gets a puff in multiplayer
      if ( Level.NetMode == NM_Standalone )
      
However it only applies to level geometry, not when shooting actors, and the effect used is low quality. Naturally GMDX addresses all that stuff ;)

To make it use your hitpuff effect you said you made, make it spawn your class instead of 'Hitpuff1'.
And if you don't want to modify DeusEx.u hook it in with spawnNotify instead by following hanfling's example in the other thread.
SkrillaX
NSF
Posts: 86
Joined: Sun Oct 02, 2016 4:43 am

Re: How to make weapon 'Shoot' animation faster

Post by SkrillaX »

Didnt work . Type mismatch in ==
Cybernetic pig
Illuminati
Posts: 2284
Joined: Thu Mar 08, 2012 3:21 am

Re: How to make weapon 'Shoot' animation faster

Post by Cybernetic pig »

You did something wrong.
SkrillaX
NSF
Posts: 86
Joined: Sun Oct 02, 2016 4:43 am

Re: How to make weapon 'Shoot' animation faster

Post by SkrillaX »

Was I only supposed to edit the ! with = . Or was I supposed to copy the whole code above
Post Reply