Post tutorial RSS Inserting the Dryfire code in scripting

A small turotial n how to implement the Dryfire sound ability with some minor scripting

Posted by on - Intermediate Other

The Dryfire sound is inside the wonderful Doom 3 game, but for some reason it was left outside the scripts, buts its not really hard to implement it with some minor scripting tweaks.
Lets take the pistol as an example,
check the Scripts folder ("Pak000.pk4" in base, copy it to another folder thats not in any way connected to the Doom installment folder, easiest is to copy it to a new hd alltogether, that way theres a very slim risk of working with wrong folder etc, rename it into "pak000.zip" and then unzip it with your chosen winrar/winzip archiver, in there youll find the "scripts" folder)
and openup "weapon_pistol.script\" with a text editor, wordpad works good,
heres the very beginning of it -
/***********************************************************************

weapon_pistol.script //id software default script

***********************************************************************/

#define PISTOL_FIRERATE 0.4 //set it to around 0.12 to enable the fire-as-fast-as-you-press-fire
#define PISTOL_LOWAMMO 4
#define PISTOL_NUMPROJECTILES 1

// blend times
#define PISTOL_IDLE_TO_LOWER 2
#define PISTOL_IDLE_TO_FIRE 1
#define PISTOL_IDLE_TO_RELOAD 3
#define PISTOL_RAISE_TO_IDLE 3
#define PISTOL_FIRE_TO_IDLE 4
#define PISTOL_RELOAD_TO_IDLE 4,

now, to enable the Dryfire you must insert
a couple of lines, under the Blend Times -

// blend times
#define PISTOL_IDLE_TO_LOWER 2
#define PISTOL_IDLE_TO_FIRE 1
#define PISTOL_IDLE_TO_RELOAD 3
#define PISTOL_IDLE_TO_NOAMMO 3 //dryfire
#define PISTOL_NOAMMO_TO_RELOAD 4 //dryfire
#define PISTOL_NOAMMO_TO_IDLE 3 //dryfire
#define PISTOL_RAISE_TO_IDLE 4
#define PISTOL_FIRE_TO_IDLE 4
#define PISTOL_RELOAD_TO_IDLE 3 ,
"IDLE_TO_NOAMMO", "NOAMMO_TO_RELOAD"
and "NOAMMO_TO_IDLE" are the new ones,
btw for the record, anything written after the "//" means that the engine wont read or "execute" whatever is written after it throughout the entire line,
now were kinda halfway in having a
working Dryfire, next scroll down just a
couple of lines until you reach the
"object weapon_pistol : weapon_base ", you must add the line
"void NoAmmo();" in that section, like this -
float next_attack;
float spread;
void init();
void Lower();
void Raise();
void Idle();
void NoAmmo(); //dryfire
void Fire();
void Reload();
void ExitCinematic();
};
,
then we come to the "void weapon_pistol::Idle() {",
simply copy n paste this entire section
and put into your script (minus the "
of course) -

"void weapon_pistol::Idle() {
float currentTime;
float ammoClip;
float avail;
float clip_size;

clip_size = clipSize();

//dryfire tweak bel0w

weaponReady();
if ( !ammoInClip() ) {
playCycle( ANIMCHANNEL_ALL, "idle_empty" );
} else {
playCycle( ANIMCHANNEL_ALL, "idle" );
}
while( 1 ) {
if ( WEAPON_LOWERWEAPON ) {
weaponState( "Lower", PISTOL_IDLE_TO_LOWER );
}
currentTime = sys.getTime();
ammoClip = ammoInClip();
if ( ( currentTime >= next_attack ) && WEAPON_ATTACK ) {
if ( ammoClip > 0 ) {
weaponState( "Fire", PISTOL_IDLE_TO_FIRE );
} else if ( ammoAvailable() > 0 ) {
if ( autoReload() ) {
netReload();
weaponState( "Reload", PISTOL_IDLE_TO_RELOAD );
} else {
weaponState( "NoAmmo", PISTOL_IDLE_TO_NOAMMO );
}
} else {
weaponState( "NoAmmo", PISTOL_IDLE_TO_NOAMMO );
}
}
if ( WEAPON_RELOAD && ( ammoAvailable() > ammoClip ) && ( ammoClip < clip_size ) ) {
netReload();
weaponState( "Reload", PISTOL_IDLE_TO_RELOAD );
}
if ( WEAPON_NETRELOAD ) {
WEAPON_NETRELOAD = false;
weaponState( "Reload", PISTOL_IDLE_TO_RELOAD );
}
waitFrame();
}
}

void weapon_pistol::NoAmmo() {

if ( WEAPON_NETRELOAD ) {
WEAPON_NETRELOAD = false;
weaponState( "Reload", PISTOL_IDLE_TO_RELOAD );
}

playAnim( ANIMCHANNEL_ALL, "noammo" );
waitUntil( animDone( ANIMCHANNEL_ALL, PISTOL_NOAMMO_TO_IDLE ) );
weaponState( "Idle", PISTOL_NOAMMO_TO_IDLE );
}

//dryfire tweak end"

Voila, now you have Dryfire enabled,
you must put the Auto reload to NO
in Options too,
this scriptingtweak can be used to enable
Dryfire in Shotgun, Machinegun and Plasma
as well, I havent tested Plasma myself but
i cant see why it wouldnt work,
Chaingu also can have Dryfire, but its
a tad different, but one can have a working
empty barrelspin sound a la Predator :p
Credit for that coding goes to Dafama,
as much of the latest Doom modding
overall is tributed to him,
Ill post a tutorial on implementing
the empty barrelspin soon

Comments
CzechDeath
CzechDeath

Error: file script\weapon_pistol.script, line 115: "weaponReady" is not a type

Reply Good karma Bad karma+1 vote
Valorin
Valorin

But in the dark future of 2020 it works as intended...

Reply Good karma Bad karma+1 vote
Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.