// Template file v5.12 (010/14/01) modified different gun
sounds
// by the Mad Dog
////////////////////////////////////////////////////////////////////////
// File: weapon1.wdl
// WDL prefabs for weapon entities
& effects
////////////////////////////////////////////////////////////////////////
// change these sounds and graphics for your weapon
IFNDEF WEAPON_DEFS;
sound mysword,<myswrd1.wav>; //mad dog's over rides
gun_wham sound
sound pick,<pickax.wav>; //mad dog's over rides gun_wham sound
sound gunmine,<snd1.wav>; //mad dog's over rides gun_wham sound
/// The above 3 sounds and gun_wham sound are controlled in
" function _flashup"
///////////////////////////////////////////////////////
SOUND
gun_click,<empty.wav>;
SOUND
gun_wham,<wham.wav>;
SOUND
explo_wham,<explo.wav>;
DEFINE
hit_wham,explo_wham;
SOUND
gun_fetch,<beamer.wav>;
DEFINE
ammo_fetch,gun_fetch;
DEFINE
health_fetch,gun_fetch;
DEFINE
muzzle_flash,<particle.pcx>;
DEFINE
small_flash,<particle.pcx>;
DEFINE
fireball,<blitz.pcx>;
DEFINE
BULLET_EXPLO,<explo+7.pcx>;
DEFINE
EXPLO_FRAMES,7;
DEFINE
WEAPON_AMPL,0.2; // swaying
ENDIF;
IFNDEF WEAPON_DEFS2;
DEFINE
bullethole_map,<bulhole.pcx>;
// bullet hole bitmap ***
DEFINE
ibullethole_map,<ibulhole.pcx>;
// inverted bullet hole bitmap (white) ***
ENDIF;
//////////////////////////////////////////////////////////////////////
// adapt those skills and strings to your game
// ammo starting and maximum values
var ammo1[3] = 0, 0, 200;
var ammo2[3] = 0, 0, 100;
var ammo3[3] = 0, 0,
40;
var ammo4[3] = 0, 0,
10;
var ammo5[3] = 0, 0,
10;
var ammo6[3] = 0, 0,
10;
var ammo7[3] = 0, 0,
10;
// dynamic light values
var light_explo[3]
= 50, 50, 255;// { RED 50; GREEN 50; BLUE 255; }
var light_flash[3] =
200, 150, 50;// { RED 200; GREEN 150;
BLUE 50; }
var light_muzzle[3] = 200,
20, 20;// { RED 200; GREEN 20;
BLUE 20; }
var light_bullet[3] = 200,
50, 20;// { RED 200; GREEN 50;
BLUE 20; }
// you'll probably want to redefine those strings. No
problem.
STRING got_ammo1_str,"Got an ammo pack!";
STRING got_ammo2_str,"Got a big ammo pack!";
STRING got_ammo3_str,"Got a grenade pack!";
STRING got_ammo4_str,"Got a battery pack!";
STRING got_ammo5_str,"Got ammo5 pack!";
STRING got_ammo6_str,"Got a rocket pack!";
STRING got_ammo7_str,"Got ammo7 pack!";
STRING got_medi_str,"Got a first aid kit!";
STRING got_gun1_str,"Got a small gun!";
STRING got_gun2_str,"Got a medium gun!";
STRING got_gun3_str,"Got a large gun!";
STRING got_gun4_str,"Got a laser gun!";
STRING got_gun5_str,"Got a shotgun!";
STRING got_gun6_str,"Got a rocket launcher!";
STRING got_gun7_str,"Got a gun no. 7!";
//////////////////////////////////////////////////////////////////////
/* Gun Action
FLAG1 (__ROTATE from
doors.wdl)
If this
flag is set, the gun model rotates before being picked up.
FLAG2 (__SILENT from
doors.wdl)
If this
flag is set, the message on picking up the item will be
suppressed.
FLAG5 (__BOB from
movement.wdl)
If this flag is
marked, the gun sways a little if the camera is
moving. The
sway period is the same as used for head bobbing in the
movement.wdl.
If the flag is not marked, the gun stands still.
FLAG7 (__REPEAT)
If this flag is
marked, it's a machine gun. Otherwise, a single
action gun.
SKILL1..SKILL3
(_OFFS_X, _OFFS_Y, _OFFS_Z)
X Y Z
position of the gun relative to the camera.
SKILL4 (_AMMOTYPE)
Ammo type
(1..7). If 0, the gun doesn't consume ammunition. The part
after the
decimal, times 100, gives the amount of ammo to be added
on picking
up the gun. E.g. 2.30 = Ammo type 2, 30 rounds are
already in
the gun.
SKILL5 (_BULLETSPEED)
Speed of
the bullet, default = 200 quants / tick. The part after the
decimal,
times 10, gives the strength of the recoil. If 0, then
there is no
recoil. If SKILL5 is above 0, the recoil is done by
moving
backwards. If SKILL5 is below 0, then the recoil is done by
swinging
upwards.
SKILL6
(_WEAPONNUMBER)
Weapon
number that determines the key (1..7) to be pressed to select
that gun.
SKILL7 (_FIRETIME)
The time (in
ticks) the gun needs to reload. Includes the time for
the gun animation,
if any.
SKILL8 (_FIREMODE from movement.wdl)
Fire mode, can be
composed by adding the following numbers:
1 - Damage
is applied by a SHOOT instruction, without bullet (DAMAGE_SHOOT).
2 - Damage
is applied by IMPACT of the bullet (DAMAGE_IMPACT).
3 - Damage
is applied by a SCAN explosion of the bullet (DAMAGE_EXPLODE).
4 - the gun
fires line of particles (FIRE_PARTICLE).
8 - the gun
fires single particles (FIRE_DPARTICLE).
12 - the
gun fires orange fireballs, which radiate light (FIRE_BALL).
16 - the
gun fires a rocket model w/smoke trail (FIRE_ROCKET)
20 - (NEW
11/17/00) the gun fires a laser (FIRE_LASER)
24 -
Reserved
28 -
Reserved
32 - the
bullets leave smoke trails(BULLET_SMOKETRAIL).
64 -
reserved
128 - at
hit point there will be a light flash (HIT_FLASH).
256 - at
hit point there will be an explosion (HIT_EXPLO).
384 - at
hit point there will be a big explosion (HIT_GIB).
512 - at
hit point a cloud of smoke will ascend (HIT_SMOKE).
1024 -
there will be multiple hit points, as by a shotgun (HIT_SCATTER).
2048 - the
gun spits out cartridge cases (GUNFX_BRASS).
4096 - the
bullets follow gravity.
8192 - at
hit point a shower of sparks (HIT_SPARKS).
16384 -
bullet hole at hit point (HIT_HOLE)
32768 - gun
has a "shot" animation (GUNFX_ANIMATE)
The part
after the decimal, times 100, gives the amount of damage
the bullet
produces (default = 10). ***
SKILL11..SKILL13
(_GUN_SOURCE_X, _GUN_SOURCE_Y, _GUN_SOURCE_Z)
X Y Z
offset position of the bullet starting point (in 1st person view)
if X == 0
then the gun muzzle will be used.
*/
///////////////////////////////////////////////////////////////////////
// Define Flags
//FLAG1 = __ROTATE from doors.wdl
//FLAG2 = __SILENT from doors.wdl
//FLAG5 = __BOB from movement.wdl
DEFINE __REPEAT,FLAG7;
// Define SKILLs
DEFINE _OFFS_X,SKILL1;
DEFINE _OFFS_Y,SKILL2;
DEFINE _OFFS_Z,SKILL3;
DEFINE _AMMOTYPE,SKILL4;
DEFINE _BULLETSPEED,SKILL5;
DEFINE _WEAPONNUMBER,SKILL6;
DEFINE _FIRETIME,SKILL7;
//SKILL8 = _FIREMODE from movement.wdl
DEFINE _GUN_SOURCE_X,SKILL11;
DEFINE _GUN_SOURCE_Y,SKILL12;
DEFINE _GUN_SOURCE_Z,SKILL13;
DEFINE _OFFS_FLASH,SKILL14;
DEFINE _RECOIL,SKILL15;
DEFINE _DAMAGE,SKILL16;
DEFINE _DISPLACEMENT,SKILL17;
DEFINE _FIRE,SKILL18;
// Constants
DEFINE MODE_DAMAGE,3;
DEFINE DAMAGE_SHOOT,1;
DEFINE DAMAGE_IMPACT,2;
DEFINE DAMAGE_EXPLODE,3;
DEFINE MODE_FIRE,28;
DEFINE FIRE_PARTICLE,4;
DEFINE FIRE_DPARTICLE,8;
DEFINE FIRE_BALL,12;
DEFINE FIRE_ROCKET,16;
DEFINE FIRE_LASER,20;
DEFINE BULLET_SMOKETRAIL,32;
DEFINE MODE_HIT,384;
DEFINE HIT_FLASH,128;
DEFINE HIT_EXPLO,256;
DEFINE HIT_GIB,384;
DEFINE HIT_SMOKE, 512;
DEFINE HIT_SCATTER,1024;
DEFINE GUNFX_BRASS,2048; // gun drops brass
DEFINE HIT_SPARKS,8192;
DEFINE HIT_HOLE 16384;
DEFINE GUNFX_ANIMATE, 32768; // gun has a firing animation
///////////////////////////////////////////////////////////////////////
entity* weapon;
// The weapon must be a model pointing into X-direction,
// its center must be inside the barrel.
DEFINE kMaxWeapons
= 7;
entity* weapon1;
entity* weapon2;
entity* weapon3;
entity* weapon4;
entity* weapon5;
entity* weapon6;
entity* weapon7;
entity* weaponTmpSyn;
// tmp ENTITY pointer
var weapon_1 = 0; //
set to 1 if the player owns that weapon
var weapon_2 = 0;
var weapon_3 = 0;
var weapon_4 = 0;
var weapon_5 = 0;
var weapon_6 = 0;
var weapon_7 = 0;
var gun_muzzle[3];
var gun_source[4]; //
trace start point (gun_source[3] = 9
if used)
var gun_target[3];
var gun_loaded = 1;
var fireball_speed = 0;
var weapon_number = 0;
var ammo_number = 0;
var range = 0;
var damage = 0;
var fire_mode = 0;
var weapon_firing = 0;
//////////////////////////////////////////////////////////////////////
// 'Default' First Person Shooter guns
/****************************************************************
Weapon
Actions - Some pre-defined weapons
todo:
perhaps come up with a way to have the world
models
(laying on the ground) separate and different
from the
view models (in player's hand).
******************************************************************/
// Desc: basic animated machinegun type weapon
// Created: 07/25/01 DCP
action weap_mg_animated
{
MY.__ROTATE
= ON; //
gun rotates before being picked up
MY.__REPEAT
= ON; //
repeats (Auto-fire)
MY.__BOB =
ON; // 'bobs' when the player moves
MY.SKILL1 =
45; //
x,y,z pos of the gun
MY.SKILL2 =
15;
MY.SKILL3 =
15;
MY._AMMOTYPE
= 1.99; // type of ammo '.' rounds in gun
if
(MY._WEAPONNUMBER == 0) { MY._WEAPONNUMBER = 2; } // weapon number (press to equip)
MY._BULLETSPEED
= 1000.01; // bulletspeed '.' recoil
MY._FIRETIME
= 2; // time to cycle (reload)
// SHOOT
damage (immediate)
// + hole
at hit point
// + eject
brass
// + gun
"shot" animation
// 20
points of damage per shot
MY._FIREMODE
= DAMAGE_SHOOT + HIT_HOLE + GUNFX_BRASS + GUNFX_ANIMATE + 0.20;
gun();
}
///////////////////////////////////////////////////
// Desc: basic 'M16' type weapon
//
// Created: MWS 06/25/01
action weap_m16
{
MY.__ROTATE
= ON; //
gun rotates before being picked up
MY.__REPEAT
= ON; //
repeats (Auto-fire)
MY.__BOB =
ON; // 'bobs' when the player moves
MY.SKILL1 =
30; //
x,y,z pos of the gun
MY.SKILL2 =
10;
MY.SKILL3 =
10;
MY._AMMOTYPE
= 1.30; // type of ammo '.' rounds in gun
if
(MY._WEAPONNUMBER == 0) { MY._WEAPONNUMBER = 1; } // weapon number (press to equip)
MY._BULLETSPEED
= 1000.01; // bulletspeed '.' recoil
MY._FIRETIME
= 1; // time to cycle (reload)
// SHOOT
damage (immediate)
// + flash
at hit point
// + sparks
at hit point
// 10
points of damage per shot
MY._FIREMODE
= DAMAGE_SHOOT + HIT_HOLE + HIT_FLASH + HIT_SPARKS + 0.10;
gun();
}
////////////////////////////////////////////////////////
// Desc: basic 'rocket launcher' type weapon
// Created: MWS 06/25/01
action weap_rocketlauncher
{
MY.__ROTATE
= ON; //
gun rotates before being picked up
MY.__REPEAT
= ON; //
repeats (Auto-fire)
MY.__BOB =
ON; // 'bobs' when the player moves
MY.SKILL1 =
35; //
x,y,z pos of the gun
MY.SKILL2 =
10;
MY.SKILL3 =
10;
MY._AMMOTYPE
= 6.10; // type of ammo '.' rounds in gun
if
(MY._WEAPONNUMBER == 0) { MY._WEAPONNUMBER = 6; } // weapon number (press to equip)
MY._BULLETSPEED
= 200.10; // bulletspeed '.' recoil
MY._FIRETIME
= 10; // time to cycle (reload)
// SHOOT
damage (immediate)
// + flash
at hit point
// + sparks
at hit point
// 50
points of damage per shot
MY._FIREMODE
= DAMAGE_EXPLODE + FIRE_ROCKET + HIT_GIB + HIT_SPARKS + 0.50;
gun();
}
/**************************************************************
Ammo
Actions - Default ammopacs from weapons.wdl,
but with
specific ammunition types (to simplify
things for
the WED user). Uses defines from
weapons.wdl,
thus must
be included after it.
***************************************************************/
// Desc: ammo boxes (weapons 1-7)
// Created: MWS 06/25/01
action ammo_type1 {
MY.__ROTATE
= 1;
MY._AMMOTYPE
= 1;
ammopac();
}
action ammo_type2 {
MY.__ROTATE
= 1;
MY._AMMOTYPE
= 2;
ammopac();
}
action ammo_type3 {
MY.__ROTATE
= 1;
MY._AMMOTYPE
= 3;
ammopac();
}
action ammo_type4 {
MY.__ROTATE
= 1;
MY._AMMOTYPE
= 4;
ammopac();
}
action ammo_type5 {
MY.__ROTATE
= 1;
MY._AMMOTYPE
= 5;
ammopac();
}
action ammo_type6 {
MY.__ROTATE
= 1;
MY._AMMOTYPE
= 6;
ammopac();
}
action ammo_type7 {
MY.__ROTATE
= 1;
MY._AMMOTYPE
= 7;
ammopac();
}
/////////////////////////////////////////////////////////////////////
// testgun, logangun, lasergun, sparkgun, & flashgun are
all examples
//on how to create guns with the template code. Each one
calls 'gun'.
// Desc: a testgun. This gun is special because it is
removed if you do
// not define
'TEST'.
ACTION testgun
{
IFNDEF TEST;
remove(ME);
return;
ENDIF;
MY.__ROTATE
= ON;
MY.__REPEAT
= ON;
MY.__BOB =
ON;
MY.SKILL1 =
50;
MY.SKILL2 =
20;
MY.SKILL3 =
20;
MY._AMMOTYPE
= 1.50;
MY._WEAPONNUMBER
= 1;
MY._BULLETSPEED
= -500.05;
MY._FIRETIME
= 2;
MY._FIREMODE
= DAMAGE_SHOOT+FIRE_PARTICLE+HIT_FLASH+0.30;
gun();
}
////////////////////////////////////////////////////////////
// Desc: "Logan's Run" type gun, used for testing
ACTION logangun
{
MY.__ROTATE
= ON; // gun rotates before being
picked up
MY.__REPEAT
= ON; // repeats (Auto-fire)
MY.__BOB =
ON; //
'bobs' when the player moves
MY.SKILL1 =
42; // x,y,z pos of the gun
MY.SKILL2 =
20;
MY.SKILL3 =
7;
MY._AMMOTYPE
= 0.0; // type of ammo '.' rounds in gun
//(0 means no ammo needed)
MY._WEAPONNUMBER
= 3; //
weapon number (press 3 to equip)
MY._BULLETSPEED
= 1000.25; // bulletspeed '.'
recoil
MY._FIRETIME
= 5; // time to cycle (reload)
// SHOOT
damage (immediate)
// + flash
at hit point
// + smoke
at hit point
// + sparks
at hit point
// 50
points of damage per shot
MY._FIREMODE
= DAMAGE_SHOOT + HIT_FLASH + HIT_SMOKE + HIT_SPARKS + FIRE_PARTICLE + 0.50;
gun();
}
///////////////////////////////////////////////////////////////////
// Desc: shotgun type gun
ACTION shotgun
{
MY.__ROTATE
= ON; // gun rotates before being
picked up
MY.__REPEAT
= ON; // repeats (Auto-fire)
MY.__BOB =
ON; //
'bobs' when the player moves
MY.SKILL1 =
42; // x,y,z pos of the gun
MY.SKILL2 =
20;
MY.SKILL3 =
7;
MY._AMMOTYPE
= 5.20; // type of ammo '.' rounds in gun
//(0 means no ammo needed)
MY._WEAPONNUMBER
= 5; //
weapon number (press 3 to equip)
MY._BULLETSPEED
= -300.50; // bulletspeed '.'
recoil
MY._FIRETIME
= 10; // time to cycle (reload)
// SHOOT
damage (immediate)
// + flash
at hit point
// + smoke
at hit point
// + sparks
at hit point
// 50
points of damage per shot
MY._FIREMODE
= DAMAGE_SHOOT + HIT_SCATTER + HIT_HOLE + 0.15;
gun();
}
///////////////////////////////////////////////////////////////////
// Desc: Laser beam type gun
ACTION lasergun
{
MY.__ROTATE
= ON; // gun rotates before being
picked up
MY.__REPEAT
= OFF;// repeats (Auto-fire)
MY.__BOB =
ON; //
'bobs' when the player moves
MY.SKILL1 =
42; // x,y,z pos of the gun
MY.SKILL2 =
20;
MY.SKILL3 =
7;
MY._AMMOTYPE
= 0.0; // type of ammo '.' rounds in gun
//(0 means no ammo needed)
MY._WEAPONNUMBER
= 4; //
weapon number (press 3 to equip)
MY._BULLETSPEED
= 1000.25; // bulletspeed '.'
recoil
MY._FIRETIME
= 5; // time to cycle (reload)
// SHOOT
damage (immediate)
// + use
laser beam
// + flash
at hit point
// + smoke
at hit point
// + sparks
at hit point
// 50
points of damage per shot
MY._FIREMODE
= DAMAGE_SHOOT + FIRE_LASER + HIT_FLASH + HIT_SMOKE + HIT_SPARKS + 0.50;
gun();
}
///////////////////////////////////////////////////////////
// Desc: simple particle gun
ACTION sparkgun
{
MY.__ROTATE
= ON;
MY.__REPEAT
= ON;
MY.__BOB =
ON;
MY.SKILL1 =
50;
MY.SKILL2 =
20;
MY.SKILL3 =
20;
MY._AMMOTYPE
= 1.50;
MY._WEAPONNUMBER
= 1;
MY._BULLETSPEED
= -500.05;
MY._FIRETIME
= 2;
MY._FIREMODE
= DAMAGE_SHOOT+FIRE_PARTICLE+HIT_FLASH+0.30;
gun();
}
//////////////////////////////////////////////////////
// Desc: Fires orange fireballs
ACTION flashgun
{
MY.__ROTATE
= ON;
MY.__REPEAT
= ON;
MY.__BOB =
ON;
MY.SKILL1 =
42;
MY.SKILL2 =
20;
MY.SKILL3 =
7;
MY._AMMOTYPE
= 0.0;//--?? 2.15;
MY._WEAPONNUMBER
= 2;
MY._BULLETSPEED
= 150.05;
MY._FIRETIME
= 5;
MY._FIREMODE
= DAMAGE_EXPLODE+FIRE_BALL+HIT_EXPLO+BULLET_SMOKETRAIL+0.50;
gun();
}
////////////////////////////////////////////////////////////////////////
// Desc: Called from player_move action; player must exist
here
ACTION weapon_carry
{
if(weapon == NULL || player == NULL)
{ return; }
if(person_3rd
!= 0)
{
weapon.INVISIBLE = ON;
player._FIREMODE =
weapon._FIRE; //show the attack
animation for the player
/* // if firing in 3rd person mode,
calculate the player's attack frame
if(weapon._FIRE > 0)
{
temp = (weapon._FIRETIME -
weapon._FIRE) / weapon._FIRETIME;
if(temp < 0) { temp = 0; }
if(temp > 0.9) { temp = 0.9; }
player.FRAME = 1 +
player._WALKFRAMES + player._RUNFRAMES + 1 + player._ATTACKFRAMES * temp;
}
*/
}
else
{
weapon.INVISIBLE = OFF;
MY_POS.X = weapon.SKILL1;
MY_POS.Y = -weapon.SKILL2;
MY_POS.Z = -weapon.SKILL3;
if(weapon._RECOIL > 0)
{
MY_POS.X -= weapon._DISPLACEMENT;
}
if(player.__BOB == ON)
{
MY_POS.Y += headwave * WEAPON_AMPL;
MY_POS.X += headwave * WEAPON_AMPL;
MY_POS.Z -= headwave * WEAPON_AMPL;
}
_set_pos_ahead_xyz();
weapon.X = MY_POS.X ;
weapon.Y = MY_POS.Y;
weapon.Z = MY_POS.Z;
weapon.PAN = CAMERA.PAN;
weapon.TILT = CAMERA.TILT;
if(weapon._RECOIL < 0)
{
weapon.TILT -= weapon._DISPLACEMENT;
}
}
}
////////////////////////////////////////////////////////////////////////
// Gun select functions
ACTION _gun_select1 { weapon_number = 1; gun_select(); }
ACTION _gun_select2 { weapon_number = 2; gun_select(); }
ACTION _gun_select3 { weapon_number = 3; gun_select(); }
ACTION _gun_select4 { weapon_number = 4; gun_select(); }
ACTION _gun_select5 { weapon_number = 5; gun_select(); }
ACTION _gun_select6 { weapon_number = 6; gun_select(); }
ACTION _gun_select7 { weapon_number = 7; gun_select(); }
// Desc: select the 'next' weapon
// Mod Date: 05/04/01 DCP
// Fix endless loop when no weapon
exists
// (Note: this would be cleaner with a
do..while loop)
function gun_select_cycle_up()
{
temp =
weapon_number; // save the current weapon_number
weapon_number
+= 1;
while(temp
!= weapon_number)
{
if(weapon_number > kMaxWeapons)
{
weapon_number = 0;
if(temp == 0) // started with no weapon
{
return(0);
}
}
if(gun_select() != -1)
{
return(weapon_number);
}
weapon_number += 1; // try next weapon
}
}
////////////////////////////////////////////////////
// Desc: select the 'prev' weapon
//
// Mod Date: 05/04/01 DCP
// Fix endless loop when player has max
weapon and no other
// (Note: this would be cleaner with a
do..while loop)
function gun_select_cycle_down()
{
temp =
weapon_number; // save the current weapon_number
weapon_number
-= 1;
while(temp
!= weapon_number)
{
if(weapon_number < 0)
{
weapon_number = kMaxWeapons;
if(temp == kMaxWeapons) // started with max weapon
{
return(kMaxWeapons);
}
}
if(gun_select() != -1)
{
return(weapon_number);
}
weapon_number -= 1; // try next weapon
}
}
///////////////////////////////////////////////////////////////
// Desc: select/switch weapon
// Mod:
07/25/01 DCP
// Changed to function
function gun_select()
{
if(weapon
!= NULL)
{ // remove old weapon
weapon.INVISIBLE = ON;
weapon.PASSABLE = ON;
}
if(weapon_number
== 1) { ME = weapon1; }
if(weapon_number
== 2) { ME = weapon2; }
if(weapon_number
== 3) { ME = weapon3; }
if(weapon_number
== 4) { ME = weapon4; }
if(weapon_number
== 5) { ME = weapon5; }
if(weapon_number
== 6) { ME = weapon6; }
if(weapon_number
== 7) { ME = weapon7; }
if(ME ==
NULL) { return(-1); }
ammo_number
= MY._AMMOTYPE;
MY.INVISIBLE
= OFF;
MY.PASSABLE
= ON; // prevent collision with
obstacles
MY.NEAR =
ON; // prevent clipping
weapon =
ME; // I'm the current weapon now
carry =
weapon_carry;
EXCLUSIVE_GLOBAL;
// handle
firing
while(weapon
== ME)
{
if(weapon_firing &&
(gun_loaded > 0) && (MY._FIRE <= 0) )
{
gun_fire();
}
if((weapon_firing == 0) &&
(gun_loaded == 0) && (MY.__REPEAT == OFF))
{
gun_loaded = 1;
}
wait(1);
}
return(weapon_number);
}
//////////////////////////////////////////////////////////////////////
// Pickup functions
// Desc: limit ammo to maximum values
// Mod: 04/11/01 DCP
// Added ammo5, ammo6, & ammo7
function _ammo_limit()
{
if(ammo1
> ammo1.Z) { ammo1 = ammo1.Z; }
if(ammo2
> ammo2.Z) { ammo2 = ammo2.Z; }
if(ammo3
> ammo3.Z) { ammo3 = ammo3.Z; }
if(ammo4
> ammo4.Z) { ammo4 = ammo4.Z; }
if(ammo5
> ammo5.Z) { ammo5 = ammo5.Z; }
if(ammo6
> ammo6.Z) { ammo6 = ammo6.Z; }
if(ammo7
> ammo7.Z) { ammo7 = ammo7.Z; }
}
/////////////////////////////////////////////////////////////
// Desc: handle gun pickup event
// Mod: 04/11/01 DCP
// Turned into function
// Added ammo5, ammo6, & ammo7
function gun_pickup()
{
if(EVENT_TYPE
== EVENT_SCAN && indicator != _HANDLE) { return; }
if(EVENT_TYPE
== EVENT_PUSH && YOU != player) { return; }
MY.ENABLE_SCAN
= OFF;
MY.ENABLE_CLICK
= OFF;
MY.ENABLE_PUSH
= OFF;
if(INT(MY._AMMOTYPE)
== 1) { ammo1 += INT(FRC(MY._AMMOTYPE) * 100 + 0.5); }
if(INT(MY._AMMOTYPE)
== 2) { ammo2 += INT(FRC(MY._AMMOTYPE) * 100 + 0.5); }
if(INT(MY._AMMOTYPE)
== 3) { ammo3 += INT(FRC(MY._AMMOTYPE) * 100 + 0.5); }
if(INT(MY._AMMOTYPE)
== 4) { ammo4 += INT(FRC(MY._AMMOTYPE) * 100 + 0.5); }
if(INT(MY._AMMOTYPE)
== 5) { ammo5 += INT(FRC(MY._AMMOTYPE) * 100 + 0.5); }
if(INT(MY._AMMOTYPE)
== 6) { ammo6 += INT(FRC(MY._AMMOTYPE) * 100 + 0.5); }
if(INT(MY._AMMOTYPE)
== 7) { ammo7 += INT(FRC(MY._AMMOTYPE) * 100 + 0.5); }
MY._AMMOTYPE
= INT(MY._AMMOTYPE); // ammo
type
_ammo_limit();
weapon_number
= MY._WEAPONNUMBER;
if(weapon_number
== 1) { weapon1 = ME; weapon_1 =
1; ON_1 = _gun_select1; msg.STRING = got_gun1_str; }
if(weapon_number
== 2) { weapon2 = ME; weapon_2 =
1; ON_2 = _gun_select2; msg.STRING = got_gun2_str; }
if(weapon_number
== 3) { weapon3 = ME; weapon_3 =
1; ON_3 = _gun_select3; msg.STRING = got_gun3_str; }
if(weapon_number
== 4) { weapon4 = ME; weapon_4 =
1; ON_4 = _gun_select4; msg.STRING = got_gun4_str; }
if(weapon_number
== 5) { weapon5 = ME; weapon_5 =
1; ON_5 = _gun_select5; msg.STRING = got_gun5_str; }
if(weapon_number
== 6) { weapon6 = ME; weapon_6 =
1; ON_6 = _gun_select6; msg.STRING = got_gun6_str; }
if(weapon_number
== 7) { weapon7 = ME; weapon_7 =
1; ON_7 = _gun_select7; msg.STRING = got_gun7_str; }
if(MY.__SILENT
!= ON) { show_message(); }
gun_select();
}
///////////////////////////////////////////////////////
// Desc: handle ammo pickup event
// Mod: 04/11/01 DCP
// Added ammo5, ammo6, & ammo7
function ammo_pickup()
{
if(EVENT_TYPE
== EVENT_SCAN && indicator != _HANDLE) { return; }
if(EVENT_TYPE
== EVENT_PUSH && YOU != player) { return; }
if(MY._AMMOTYPE
== 1) { ammo1 += MY.SKILL5; msg.STRING
= got_ammo1_str; }
if(MY._AMMOTYPE
== 2) { ammo2 += MY.SKILL5; msg.STRING
= got_ammo2_str; }
if(MY._AMMOTYPE
== 3) { ammo3 += MY.SKILL5; msg.STRING
= got_ammo3_str; }
if(MY._AMMOTYPE
== 4) { ammo4 += MY.SKILL5; msg.STRING
= got_ammo4_str; }
if(MY._AMMOTYPE
== 5) { ammo5 += MY.SKILL5; msg.STRING
= got_ammo5_str; }
if(MY._AMMOTYPE
== 6) { ammo6 += MY.SKILL5; msg.STRING
= got_ammo6_str; }
if(MY._AMMOTYPE
== 7) { ammo7 += MY.SKILL5; msg.STRING
= got_ammo7_str; }
if(MY.__SILENT
!= ON) { show_message(); }
_ammo_limit();
PLAY_SOUND
ammo_fetch,50;
if(MY.__SILENT
!= ON)
{
// hide item..
MY.EVENT = NULL;
MY.PASSABLE = ON;
MY.INVISIBLE = ON;
waitt(MSG_TICKS); // wait for message to vanish
}
remove(ME);
}
////////////////////////////////////////////////////////////
// Desc: ammo pack entity
// Mod: 04/11/01 DCP
// Added ammo5, ammo6, & ammo7
ACTION ammopac
{
// default
ammo type is 1
if(MY._AMMOTYPE
== 0) { MY._AMMOTYPE = 1; }
// default
ammo amount is a quarter of ammo maximum
if(MY.SKILL5
== 0)
{
if(MY._AMMOTYPE == 1) { MY.SKILL5 =
ammo1.Z * 0.25; }
if(MY._AMMOTYPE == 2) { MY.SKILL5 =
ammo2.Z * 0.25; }
if(MY._AMMOTYPE == 3) { MY.SKILL5 =
ammo3.Z * 0.25; }
if(MY._AMMOTYPE == 4) { MY.SKILL5 =
ammo4.Z * 0.25; }
if(MY._AMMOTYPE == 5) { MY.SKILL5 =
ammo5.Z * 0.25; }
if(MY._AMMOTYPE == 6) { MY.SKILL5 =
ammo6.Z * 0.25; }
if(MY._AMMOTYPE == 7) { MY.SKILL5 =
ammo7.Z * 0.25; }
}
MY.EVENT =
ammo_pickup;
item_pickup();
}
//////////////////////////////////////////////////////////////////
// Desc: handle medipac event
function medi_pickup()
{
if(EVENT_TYPE
== EVENT_SCAN && indicator != _HANDLE) { return; }
if(EVENT_TYPE
== EVENT_PUSH && YOU != player) { return; }
if(YOU ==
NULL) { YOU = player; }
if(YOU ==
NULL) { return; }
YOUR._HEALTH
+= MY.SKILL5;
if(YOUR._HEALTH
> 100) { YOUR._HEALTH = 100; } //
health max at 100%
PLAY_SOUND
health_fetch,50;
msg.STRING
= got_medi_str;
if(MY.__SILENT
!= ON) { show_message(); }
remove(ME);
}
////////////////////////////////////////////////////////////
// Desc: medipac entity
ACTION medipac
{
if(MY.SKILL5
== 0) { MY.SKILL5 = 25; }
MY.EVENT =
medi_pickup;
item_pickup();
}
//////////////////////////////////////////////////////////////
// Desc: restore a gun already owned by the player (from a
previous level)
// Note: keep the gun in the level
function gun_restore()
{
// weapon
was already picked up by the player
MY._AMMOTYPE
= INT(MY._AMMOTYPE); // happens
on pickup
MY.INVISIBLE
= ON;
MY.PASSABLE
= ON;
MY.ENABLE_SCAN
= OFF;
MY.ENABLE_CLICK
= OFF;
MY.ENABLE_PUSH
= OFF;
MY.EVENT =
NULL;
// Was it
the last weapon the player carried?
if(weapon_number
== MY._WEAPONNUMBER) { gun_select(); }
}
//////////////////////////////////////////////////////////////////
// Desc: set up a gun
// Mod: 04/17/01 DCP
// set the weapon source offset (if one
is not already defined)
// Mod: 07/26/01 DCP
// broke out 'gun_restore' function
ACTION gun
{
// set the
weapon camera offset (if one is not already defined)
if(MY._OFFS_X
== 0)
{
MY._OFFS_X = 50;
MY._OFFS_Y = 20;
MY._OFFS_Z = 20;
}
// set the
weapon source offset (if one is not already defined)
if(MY._GUN_SOURCE_X
== 0)
{
MY._GUN_SOURCE_X = MY._OFFS_X +
MY._OFFS_FLASH;
MY._GUN_SOURCE_Y = -MY._OFFS_Y;
MY._GUN_SOURCE_Z = -MY._OFFS_Z;
}
// make
sure we have a valid _WEAPONNUMBER
if(MY._WEAPONNUMBER
<= 0 || MY._WEAPONNUMBER > 7)
{
MY._WEAPONNUMBER = 1; }
// set damage
MY._DAMAGE
= FRC(MY._FIREMODE) * 100;
if(MY._DAMAGE == 0)
{
MY._DAMAGE = 20; } // default to 20 damage
// set
firemode
MY._FIREMODE
= INT(MY._FIREMODE);
if(MY._FIREMODE
== 0)
{
MY._FIREMODE = DAMAGE_SHOOT+FIRE_PARTICLE+HIT_FLASH; } // default to
// set
recoil (up or back)
MY._RECOIL
= FRC(MY._BULLETSPEED) * 100;
// set
bullet speed
MY._BULLETSPEED
= ABS(MY._BULLETSPEED);
if(MY._BULLETSPEED
< 1)
{
MY._BULLETSPEED = 200; } // default to
200
MY._OFFS_FLASH
= MY.MAX_X + 1; // Muzzle flash
offset
MY.EVENT =
gun_pickup;
item_pickup();
// check
whether this gun was picked up before in another level,
// and has
to be re-created for this level
if(MY._WEAPONNUMBER
== 1 && weapon_1 == 1 && weapon1 == NULL)
{ weapon1 =
ME; gun_restore(); return; }
if(MY._WEAPONNUMBER
== 2 && weapon_2 == 1 && weapon2 == NULL)
{ weapon2 =
ME; gun_restore(); return; }
if(MY._WEAPONNUMBER
== 3 && weapon_3 == 1 && weapon3 == NULL)
{ weapon3 =
ME; gun_restore(); return; }
if(MY._WEAPONNUMBER
== 4 && weapon_4 == 1 && weapon4 == NULL)
{ weapon4 =
ME; gun_restore(); return; }
if(MY._WEAPONNUMBER
== 5 && weapon_5 == 1 && weapon5 == NULL)
{ weapon5 =
ME; gun_restore(); return; }
if(MY._WEAPONNUMBER
== 6 && weapon_6 == 1 && weapon6 == NULL)
{ weapon6 =
ME; gun_restore(); return; }
if(MY._WEAPONNUMBER
== 7 && weapon_7 == 1 && weapon7 == NULL)
{ weapon7 =
ME; gun_restore(); return; }
}
///////////////////////////////////////////////////////////
// Desc: start the player with this gun
// Use:
CREATE(<WAFFE1.MDL>,nullskill,startgun1);
// Mod: 04/17/01 DCP
// Added _GUN_SOURCE_X/Y/Z values
function startgun1()
{
// NOTE:
these are the stats you should adjust in your 'startgun'
MY.__REPEAT
= ON;
MY.__BOB =
ON;
MY._OFFS_X
= 50;
MY._OFFS_Y
= 20;
MY._OFFS_Z
= 20;
MY._GUN_SOURCE_X
= -1;
MY._GUN_SOURCE_Y
= 2;
MY._GUN_SOURCE_Z
= -1;
MY._AMMOTYPE
= 0.0; // type 0 with
unlimited ammo
MY._WEAPONNUMBER
= 1; // weapon 1
MY._BULLETSPEED
= -500.05; // speed/range . 5 recoil
MY._FIRETIME
= 2;
MY._FIREMODE
= DAMAGE_SHOOT+FIRE_PARTICLE+HIT_SPARKS+HIT_FLASH+0.30+GUNFX_BRASS;
// Always
end with a call to 'gun_givePlayer'
gun_givePlayer();
}
////////////////////////////////////////////////////////////////////
// Desc: init a gun, give it to the player, and select it
// Note: see the Action 'startgun1' to see how to use this
function
function gun_givePlayer()
{
gun(); // init the gun
MY.ENABLE_SCAN
= OFF;
MY.ENABLE_CLICK
= OFF;
MY.ENABLE_PUSH
= OFF;
if(INT(MY._AMMOTYPE)
== 1) { ammo1 += INT(FRC(MY._AMMOTYPE) * 100 + 0.5); }
if(INT(MY._AMMOTYPE)
== 2) { ammo2 += INT(FRC(MY._AMMOTYPE) * 100 + 0.5); }
if(INT(MY._AMMOTYPE)
== 3) { ammo3 += INT(FRC(MY._AMMOTYPE) * 100 + 0.5); }
if(INT(MY._AMMOTYPE)
== 4) { ammo4 += INT(FRC(MY._AMMOTYPE) * 100 + 0.5); }
if(INT(MY._AMMOTYPE)
== 5) { ammo5 += INT(FRC(MY._AMMOTYPE) * 100 + 0.5); }
if(INT(MY._AMMOTYPE)
== 6) { ammo6 += INT(FRC(MY._AMMOTYPE) * 100 + 0.5); }
if(INT(MY._AMMOTYPE)
== 7) { ammo7 += INT(FRC(MY._AMMOTYPE) * 100 + 0.5); }
MY._AMMOTYPE
= INT(MY._AMMOTYPE); // ammo
type
_ammo_limit();
weapon_number
= MY._WEAPONNUMBER;
if(weapon_number
== 1) { weapon1 = ME; weapon_1 =
1; ON_1 = _gun_select1; msg.STRING = got_gun1_str; }
if(weapon_number
== 2) { weapon2 = ME; weapon_2 =
1; ON_2 = _gun_select2; msg.STRING = got_gun2_str; }
if(weapon_number
== 3) { weapon3 = ME; weapon_3 =
1; ON_3 = _gun_select3; msg.STRING = got_gun3_str; }
if(weapon_number
== 4) { weapon4 = ME; weapon_4 =
1; ON_4 = _gun_select4; msg.STRING = got_gun4_str; }
if(weapon_number
== 5) { weapon5 = ME; weapon_5 =
1; ON_5 = _gun_select5; msg.STRING = got_gun5_str; }
if(weapon_number
== 6) { weapon6 = ME; weapon_6 =
1; ON_6 = _gun_select6; msg.STRING = got_gun6_str; }
if(weapon_number
== 7) { weapon7 = ME; weapon_7 =
1; ON_7 = _gun_select7; msg.STRING = got_gun7_str; }
if(MY.__SILENT
!= ON) { show_message(); }
gun_select();
}
//////////////////////////////////////////////////////////////////////
// Desc: fire weapon
function weapon_fire()
{
weapon_firing
= 1;
while(KEY_CTRL || MOUSE_LEFT) {
wait(1); }
weapon_firing
= 0;
}
// Desc: deselect weapon
function weapon_remove()
{
if(weapon
!= NULL)
{
weapon.INVISIBLE = ON;
weapon = NULL;
weapon_number = 0;
}
}
///////////////////////////////////////////////////////////////////
// Desc: put weapons and ammo to inital state
function weapon_init()
{
weapon_remove();
ammo1 = 0;
ammo2 = 0;
ammo3 = 0;
ammo4 = 0;
ammo5 = 0;
ammo6 = 0;
ammo7 = 0;
weapon_1 =
0;
weapon_2 =
0;
weapon_3 =
0;
weapon_4 =
0;
weapon_5 =
0;
weapon_6 =
0;
weapon_7 =
0;
weapon_number
= 0;
}
//////////////////////////////////////////////////////////////////////
string anim_gun_shot
= "shot"; // gun animation
string
// used
in 'gun_animate()'
// Desc: animate the gun model using _FIRETIME and _FIRE
// Mod: 07/25/01 DCP
// Created
function gun_animate()
{
while(MY._FIRE
> 0)
{
// play one cycle
temp = ((MY._FIRETIME - MY._FIRE)/
MY._FIRETIME) * 100;
ent_cycle(anim_gun_shot,temp);
wait(1);
}
ent_frame(anim_gun_shot,0);
// return to base frame
}
//////////////////////////////////////////////////////////
// Desc: Handle the
player firing the gun
// Mod: 04/11/01 DCP
// Added ammo5, ammo6, & ammo7
// Mod: 04/17/01 DCP
// Make player passable before calling
'gun_shot' (restore afterwords)
// Mod: 04/18/01 DCP
// Calculate 'gun_source' here now. Set
'gun_source[3] = 9' so gun_shot
// knows to
use the 'gun_source' vector for traces.
// Modified 3rd person 'gun_source',
'gun_muzzle', & 'gun_target' calculation
// (no longer
depends on cammera location)
// Mod: 04/18/01 DCP
// Replaced goto no_ammo with
_gun_fire_no_ammo();
// Mod: 07/25/01 DCP
// Added check
for gun animation (calls "gun_animate()").
function gun_fire()
{
// check to
make sure we have ammo
// if so,
reduce ammo# count by one
// else got
'no_ammo'
if(MY._AMMOTYPE
== 1)
{
if(ammo1 > 0) { ammo1 -= 1; }
else{ _gun_fire_no_ammo(); return; }
}
if(MY._AMMOTYPE
== 2)
{
if(ammo2 > 0) { ammo2 -= 1; }
else{ _gun_fire_no_ammo(); return; }
}
if(MY._AMMOTYPE
== 3)
{
if(ammo3 > 0) { ammo3 -= 1; }
else{ _gun_fire_no_ammo(); return; }
}
if(MY._AMMOTYPE
== 4)
{
if(ammo4 > 0) { ammo4 -= 1; }
else{ _gun_fire_no_ammo(); return; }
}
if(MY._AMMOTYPE
== 5)
{
if(ammo5 > 0) { ammo5 -= 1; }
else{ _gun_fire_no_ammo(); return; }
}
if(MY._AMMOTYPE
== 6)
{
if(ammo6 > 0) { ammo6 -= 1; }
else{ _gun_fire_no_ammo(); return; }
}
if(MY._AMMOTYPE
== 7)
{
if(ammo7 > 0) { ammo7 -= 1; }
else{ _gun_fire_no_ammo(); return; }
}
gun_loaded = 0;
// place
muzzle flash
if((person_3rd
!= 0) && (player != null))
{
MY_POS.X = player.MAX_X -
player.MIN_X;
MY_POS.Y = 0;
MY_POS.Z = 0;
vec_rotate(MY_POS,player.PAN);
MY_POS.X += player.X;
MY_POS.Y
+= player.Y;
MY_POS.Z
+= player.Z;
}
else
{
MY_POS.X = MY.SKILL1 +
MY._OFFS_FLASH;
MY_POS.Y = -MY.SKILL2;
MY_POS.Z = -MY.SKILL3;
_set_pos_ahead_xyz();
}
vec_set(gun_muzzle.X,MY_POS.X);
create(muzzle_flash,gun_muzzle,_flashup);
//
calculate target
MY_POS.X =
MY._BULLETSPEED;
if((person_3rd
!= 0) && (player != NULL))
{
MY_POS.Y = 0;
MY_POS.Z = 0;
vec_rotate(MY_POS,player.PAN);
MY_POS.X += player.X;
MY_POS.Y
+= player.Y;
MY_POS.Z
+= player.Z;
}
else
{
MY_POS.Y = -MY.SKILL2;
MY_POS.Z = -MY.SKILL3;
_set_pos_ahead_xyz();
}
vec_set(gun_target.X,MY_POS.X);
wait(1); //
allow muzzle_flash to become passable (so bullet does not hit it!)
// place
gun trace source back (DCP fix 04/13/01)
if((person_3rd
!= 0) && (player != NULL))
{
MY_POS.X = (player.MAX_X -
player.MIN_X);
MY_POS.Y = 0;
MY_POS.Z = 0;
vec_rotate(MY_POS,player.PAN);
MY_POS.X += player.X;
MY_POS.Y
+= player.Y;
MY_POS.Z
+= player.Z;
}
else
{
MY_POS.X =
MY._GUN_SOURCE_X;//?-(player.MAX_X - player.MIN_X)/2; //--MY.SKILL1 +
MY._OFFS_FLASH;