PDA

View Full Version : granade explosion effect



malyczolg
21st October 2013, 18:23
hello
1.how delete standart grenade explosion effect [ mortar ], i add new effect and grenade have 2 explosion effect [ mortar and flashbang_explode]
projExplosionEffect\fx/flashbang_explode.efx
2.delete explosion sound fireSound\weap_germgrenade_fire\ = fireSound\\ but sound still
3.how change time cooking grenade?

IzNoGoD
21st October 2013, 18:46
1. fx/iw_impacts.csv
2. try something in stock soundaliases file
3. download a cookable nade mod, then edit some value that has descriptor with "cook" in it.

Tally
21st October 2013, 19:39
hello
1.how delete standart grenade explosion effect [ mortar ], i add new effect and grenade have 2 explosion effect [ mortar and flashbang_explode]
projExplosionEffect\fx/flashbang_explode.efx
2.delete explosion sound fireSound\weap_germgrenade_fire\ = fireSound\\ but sound still
3.how change time cooking grenade?

Delete the grenade just before it explodes, and spawn your flashbang grenade and FX at the origin of the grenade before you delete it. This is the standard way that gas and flash grenades are done.

IzNoGoD
21st October 2013, 19:41
Then i've been doing it the wrong way lol. Using scripted explosions for flashbangs/grenades/stuns/smokegrenades.

Works very fucking well though :D

Tally
21st October 2013, 20:22
Then i've been doing it the wrong way lol. Using scripted explosions for flashbangs/grenades/stuns/smokegrenades.

Works very fucking well though :D

The method I described above is used in COD4 modding, where you cannot edit iw_impacts.csv because you can't add it to a mod.ff without incurring the "exceeded 400 fx" error. You can likely use your method in COD2 because you can edit iw_impacts.csv and add it to a mod. So, for COD2 both methods described would work well.

Ni3ls
21st October 2013, 20:25
Delete the grenade just before it explodes, and spawn your flashbang grenade and FX at the origin of the grenade before you delete it. This is the standard way that gas and flash grenades are done.
And how do you do this? How to know where the origin of the grenade is?

serthy
21st October 2013, 21:03
And how do you do this? How to know where the origin of the grenade is?

http://killtube.org/showthread.php?1616-isThrowingGrenade-function

grenade.origin

IzNoGoD
21st October 2013, 21:55
IzNoGoD writes...
First: this tutorial is written only for the most experienced scripters in cod2. Others should steer clear of this explanation and hope someone writes them a proper implementation.


I got annoyed by all the non-working implementations of isthrowinggrenade() and decided to write my own function for it.

This was quite hard, as the cod2 engine has a lot(!) of limitations. Finally, all works :)

how it works:
As cod2 doesnt switch to the nadeweapon as cod1 does, we have to use the getcurrentoffhand() and switchtooffhand() to determine if the player is throwing a nade.
In essence, it is quite easy, but there are a lot of things you have to keep in mind.

First, if the player starts throwing a smokegrenade, getcurrentoffhand() will return the name of said nade, but the player will not switch back to any offhand. So we have to force it back to a grenade of our choice:


while(true)
{
self switchtooffhand("grenade");
wait 0.05;
}


This works fine, but it cannot detect any normal nadethrows, only the smokegrenade will show up.
If we force the player to the offhand smokegrenade, we can detect fraggrenades, but we lose the ability to detect any smokegrenades.

So what we need is a third offhand grenade. The weaponfile is pasted here:


WEAPONFILE\weaponType\grenade\weaponClass\grenade\ offhandClass\Frag Grenade\weaponSlot\none\displayName\WEAPON_M2FRAGG RENADE\AIOverlayDescription\\modeName\\playerAnimT ype\other\gunModel\viewmodel_mk2\handModel\viewmod el_hands_cloth\isHandModelOverridable\1\idleAnim\v iewmodel_mk2_idle\emptyIdleAnim\viewmodel_mk2_idle \fireAnim\viewmodel_mk2_throw\holdFireAnim\viewmod el_mk2_pullpin\lastShotAnim\viewmodel_mk2_throw\me leeAnim\viewmodel_mk2_idle\raiseAnim\viewmodel_mk2 _idle\dropAnim\viewmodel_mk2_idle\altRaiseAnim\vie wmodel_mk2_idle\altDropAnim\viewmodel_mk2_idle\aut oAimRange\1600\slowdownAimRange\50000\slowdownAimR angeAds\50000\lockonAimRange\50000\lockonAimRangeA ds\50000\moveSpeedScale\1\damage\0\meleeDamage\40\ fireDelay\0.1\meleeDelay\0.1\fireTime\0.3\holdFire Time\0.6\meleeTime\0.66\reloadTime\2\dropTime\0\ra iseTime\0\altDropTime\0\altRaiseTime\0\fuseTime\3. 5\clipOnly\1\hipIdleAmount\80\idleCrouchFactor\0.5 \idleProneFactor\0.15\parallelDefaultBounce\0.5\pa rallelBarkBounce\0.6\parallelBrickBounce\0.6\paral lelCarpetBounce\0.6\parallelClothBounce\0.2\parall elConcreteBounce\0.6\parallelDirtBounce\0.45\paral lelFleshBounce\0.2\parallelFoliageBounce\0.05\para llelGlassBounce\0.4\parallelGrassBounce\0.35\paral lelGravelBounce\0.5\parallelIceBounce\0.6\parallel MetalBounce\0.6\parallelMudBounce\0.2\parallelPape rBounce\0.2\parallelPlasterBounce\0.5\parallelRock Bounce\0.6\parallelSandBounce\0.3\parallelSnowBoun ce\0.2\parallelWaterBounce\0.2\parallelWoodBounce\ 0.6\parallelAsphaltBounce\0.6\perpendicularDefault Bounce\0.25\perpendicularBarkBounce\0.25\perpendic ularBrickBounce\0.25\perpendicularCarpetBounce\0.2 5\perpendicularClothBounce\0.2\perpendicularConcre teBounce\0.25\perpendicularDirtBounce\0.225\perpen dicularFleshBounce\0.2\perpendicularFoliageBounce\ 0.05\perpendicularGlassBounce\0.2\perpendicularGra ssBounce\0.15\perpendicularGravelBounce\0.25\perpe ndicularIceBounce\0.3\perpendicularMetalBounce\0.2 5\perpendicularMudBounce\0.1\perpendicularPaperBou nce\0.2\perpendicularPlasterBounce\0.25\perpendicu larRockBounce\0.25\perpendicularSandBounce\0.1\per pendicularSnowBounce\0.1\perpendicularWaterBounce\ 0.2\perpendicularWoodBounce\0.25\perpendicularAsph altBounce\0.25\swayMaxAngle\30\swayLerpSpeed\6\swa yPitchScale\0.1\swayYawScale\0.1\swayHorizScale\0. 1\swayVertScale\0.1\swayShellShockScale\5\worldMod el\xmodel/weapon_mk2fraggrenade\hudIcon\gfx/icons/hud@us_grenade.tga\modeIcon\\ammoName\idlenade\max Ammo\0\startAmmo\0\clipName\idlenade\clipSize\0\sh aredAmmoCapName\WEAPON_IDLENADE\sharedAmmoCap\0\dr opAmmoMin\0\dropAmmoMax\0\pickupSound\weap_pickup\ ammoPickupSound\\pullbackSound\weap_fraggrenade_pi n\fireSound\weap_fraggrenade_fire\lastShotSound\\r eloadSound\weap_fraggrenade_reload\altSwitchSound\ \raiseSound\\putawaySound\\noteTrackSoundA\\noteTr ackSoundB\\noteTrackSoundC\\noteTrackSoundD\\retic leCenter\gfx/reticle/center_cross.tga\reticleSide\\reticleCenterSize\32 \reticleSideSize\16\reticleMinOfs\4\altWeapon\\two Handed\0\cookOffHold\0\wideListIcon\0\killIcon\gfx/icons/hud@us_grenade.tga\wideKillIcon\0\flipKillIcon\1\s tandMoveF\0\standMoveR\1\standMoveU\-1.5\standRotP\0\standRotY\0\standRotR\0\duckedOfsF \-2\duckedOfsR\2\duckedOfsU\-0.2\duckedMoveF\0\duckedMoveR\1\duckedMoveU\-1.5\duckedRotP\0\duckedRotY\0\duckedRotR\0\proneOf sF\-6\proneOfsR\3.5\proneOfsU\0.8\proneMoveF\0\proneMo veR\1\proneMoveU\-1.5\proneRotP\0\proneRotY\0\proneRotR\0\posMoveRat e\4\posProneMoveRate\10\standMoveMinSpeed\110\duck edMoveMinSpeed\60\proneMoveMinSpeed\0\posRotRate\5 \posProneRotRate\10\standRotMinSpeed\110\duckedRot MinSpeed\60\proneRotMinSpeed\0\explosionRadius\256 \explosionInnerDamage\200\explosionOuterDamage\50\ projectileSpeed\940\projectileSpeedUp\120\projecti leModel\xmodel/projectile_mk2fraggrenade\projExplosionType\grenad e\projExplosionEffect\\projExplosionSound\\project ileTrail\none\projectileTrailTime\1\projectileTrai lRadius\32\projImpactExplode\0

as you can, or maybe cannot see, this nade has a max of 0 ammo, making it an addition to the player's loadout without any ammo. This is nice, because players will not have any additional nades.

We now need to put this code into a weaponfile, precache it and give it to all players on spawn. (warning: this WILL break the dropoffhand() function used to drop grenades. Write your own fix for this, like storing the last used grenade in a player var)

Now we can force the player to focus on this offhandtype, and catch any other offhands. I suggest you use something like this:



while(true)
{
self switchtooffhand("fraggrenade_idle_mp");
if(self getcurrentoffhand()!="fraggrenade_idle_mp")
{
//player is throwing a nade
}
wait 0.05;
}


And thats all.

Known bugs: If the smokegrenade is empty, but ppl press the smokegrenade button anyway, this system detects it as if a real nade is being thrown.

Tally
21st October 2013, 23:45
And how do you do this? How to know where the origin of the grenade is?

Complete method to find a grenade's origin:


//======================================
// GRENADE FUNCTIONS
//======================================

/************************************
This function is snaffled from
the eXtreme+ mod for COD2 - called from callback_startgametype()
*************************************/
TrackGrenades()
{
for( ;; )
{
nades = getentarray( "grenade", "classname" );
if( isDefined( nades ) )
{
for( i = 0; i < nades.size; i++ )
{
nade = nades[i];
if( !isDefined( nade.monitored ) )
nade thread monitorNade();
}
}

wait( 0.05 );
}
}

/************************************
This function is snaffled from
the eXtreme+ mod for COD2
*************************************/
monitorNade()
{
self.monitored = true;

players = getentarray( "player", "classname" );
for( i = 0; i < players.size; i++ )
{
player = players[i];
if( self istouching( player ) )
self.nadeThrower = player;
}

if( !isDefined( self.nadeThrower ) ) return;

if( !isAlive( self.nadeThrower ) )
{
if( isDefined( self ) )
self delete();
return;
}

self.nadeType = self.nadeThrower getcurrentoffhand();
self.nadeThrower notify( "grenade_thrown", self, self.nadeType );

}

/************************************
This function is mine - it picks
up on a player's thrown grenade
and threads to various methods.
Called from onPlayerSpawned()
*************************************/
WatchGrenades()
{
self endon( "killed_player" );
self endon( "disconnect" );

for( ;; )
{
self waittill( "grenade_thrown", grenade, grenadeType );

if( grenadeType == "your_grenade_mp" )
grenade thread getGrenadeOrigin();


}
}

getGrenadeOrigin()
{
// delay finding the grenade's origin until it lands
self waitTillNotMoving()

// this is the origin you want - do what you want with it from here
origin = self.origin;
}

waitTillNotMoving()
{
prevorigin = (0,0,0);
while( isDefined( self ) )
{
if( self.origin == prevorigin )
break;

prevorigin = self.origin;
wait( .15 );
}
}



The above method duplicate's COD4's engine functions, which in COD4 allows you to detect both when a grenade is thrown (COD4 notify flag - "grenade_pin_pulled"), and when the grenade has left the player's hand (COD4 notify flag - "grenade_thrown"). In COD2 you can only do the latter COD4 function: detect when a player has actually thrown a grenade. The only way around that is to use IzNoGod's jiggery pokery with weapon files and shit.

Ni3ls
3rd November 2013, 17:13
How to delete the nade and the explosion Tally?

Tally
3rd November 2013, 17:34
How to delete the nade and the explosion Tally?

It takes roughly 2.8 seconds for a grenade to explode once the grenade has stopped moving. Simply delete the grenade before the time is up:


getGrenadeOrigin()
{
// delay finding the grenade's origin until it lands
self waitTillNotMoving()

// this is the origin you want - do what you want with it from here
origin = self.origin;

wait( 1.8 );

if( isDefined( self ) ) self delete();
}