a lil DooM3 scripting

vanilla Doom has the ability of playing
a “Dryfire” sound for whenever the held weapon
runs out of ammo. but for some reason
it wasnt put into the individual weapon scripts,
nor the capability of scripting the weps to behave
more lifelike; a weapon on full auto shoots all over
the place kinda, altho the AK47 assault rifle does so more than,
for example, a MP5 submachinegun, its down to
firerates and calibre etc, so i scripted my AK47 in
DooM3 to be more realistic with the spread + i also
put the Dryfire code in there too, and yes the AK47
was taken from the Full Metal Jacket mod for DooM3,
thats why i can never upload it anywhere as a mod since
I didnt do this weapon, same with the Benelli M3 pumpshottie
and the Colt M16 (altho he called it XM177E2),
those plus the Doublebarrel shotgun i took from the
expansion Resurrection of Evil are the weps i use
95 pcg of the time (except for when I insert the MAC10
and FAMAS into my Doom, and yes theyre nicked from
Counterstrike muhaha :p And no, ill never ever
upload them anywhere ever so dont ask cuss
it wont ever happen), i also took the Glock skin and
used it for Doom altho i never took the entire weapon
but only the skin and use it for the buttugly default Doom
skin for the pistol (also from the FMJ mod),
below is the AK47 script i compiled,
as you can see while firing singleshot the spread
isnt much (ok one cant see it here but in the corresponding
def.file i put it to “1”) and every bullet pretty much hits what one
aims for, but as soon as you start to shoot fullauto
(only complete n00bs does that with automatic rifles but nm)
the spread is “7”, that pretty much disables a bodyhit
over a fairly long distance on fullauto,
for a crashcourse in auomatic rifle handling,
watch episode one of “Strike Back”, based on ex-SAS
Chris Ryans book, the operatives all fire either single shot
or short, controlled 1-2 bursts


weapon_ak47.script, tweaked by ice_trey with working dryfire and realistic spread


#define AK47_FIRERATE 0.08
#define AK47_LOWAMMO 10
#define AK47_BURSTTIME 0.08
#define AK47_MAXSPREAD 7

// blend times
#define AK47_IDLE_TO_LOWER 4
#define AK47_IDLE_TO_FIRE 0
#define AK47_IDLE_TO_RELOAD 4
#define AK47_RAISE_TO_IDLE 4
#define AK47_FIRE_TO_IDLE 0
#define AK47_RELOAD_TO_IDLE 4
#define AK47_FIRE_TO_FIRE 2
#define AK47_IDLE_TO_NOAMMO 3
#define AK47_NOAMMO_TO_IDLE 3

object weapon_ak47 : weapon_base {
float next_attack;
float spread;
float firetype; //added

void init();

void Lower();
void Raise();
void Idle();
void NoAmmo(); //add
void Fire();
void Reload();
void ExitCinematic();

void weapon_ak47::init() {
next_attack = 0;
spread = getFloatKey( “spread” );
firetype = 1; //add
weaponState( “Raise”, 0 );

void weapon_ak47::Raise() {
playAnim( ANIMCHANNEL_ALL, “raise” );
waitUntil( animDone( ANIMCHANNEL_ALL, AK47_RAISE_TO_IDLE ) );
weaponState( “Idle”, AK47_RAISE_TO_IDLE );

void weapon_ak47::Lower() {
playAnim( ANIMCHANNEL_ALL, “putaway” );
waitUntil( animDone( ANIMCHANNEL_ALL, 0 ) );
weaponState( “Raise”, 0 );

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

clip_size = clipSize();

if ( !ammoInClip() ) {
playCycle( ANIMCHANNEL_ALL, “idle_empty” );
} else {
playCycle( ANIMCHANNEL_ALL, “idle” );
while( 1 ) {
weaponState( “Lower”, AK47_IDLE_TO_LOWER );
currentTime = sys.getTime();
ammoClip = ammoInClip();
if ( ( currentTime >= next_attack ) && WEAPON_ATTACK ) {
if ( ammoClip > 0 ) {
weaponState( “Fire”, AK47_IDLE_TO_FIRE );
} else if ( ammoAvailable() > 0 ) {
if ( autoReload() ) {
weaponState( “Reload”, AK47_IDLE_TO_RELOAD );
} else {
weaponState( “NoAmmo”, AK47_IDLE_TO_NOAMMO );
} else {
weaponState( “NoAmmo”, AK47_IDLE_TO_NOAMMO );

if ( WEAPON_RELOAD && ( ammoAvailable() > ammoClip ) && ( ammoClip 0){
if(spread 0){
firetype = 2;
weaponState( “Fire”, AK47_FIRE_TO_FIRE );
spread = getFloatKey( “spread” );
firetype = 1;
waitUntil( animDone( ANIMCHANNEL_ALL, AK47_FIRE_TO_IDLE ) );
weaponState( “Idle”, AK47_FIRE_TO_IDLE );

void weapon_ak47::Reload() {
playAnim( ANIMCHANNEL_ALL, “reload” );
waitUntil( animDone( ANIMCHANNEL_ALL, AK47_RELOAD_TO_IDLE ) );
addToClip( clipSize() );
weaponState( “Idle”, AK47_RELOAD_TO_IDLE );

void weapon_ak47::ExitCinematic() {
next_attack = 0;
weaponState( “Idle”, 0 );

you can do this with the vanilla machinegun, the xm177e2,
and, with slight modification, the chaingun too,
and you can do this with the pistol as well, then itll become
fullauto :p

NOTE Ice_trey is ME, in case you didnt know,
check my profile on the moddb databse site —
( :
“A small step for a hologram but a giant step
for mankind…”


Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s