Skip to content

Commit

Permalink
Updated Fully Possessed scripts folder to be compatible with popular …
Browse files Browse the repository at this point in the history
…hi def mod. If the hidef mod is installed in the normal base directory, no changes will need to be made to the scripts folder for Fully Possessed to work.
  • Loading branch information
KozGit committed Mar 2, 2017
1 parent 3847acb commit 40ddcd4
Show file tree
Hide file tree
Showing 5 changed files with 524 additions and 1 deletion.
25 changes: 24 additions & 1 deletion vr_assets/Fully Possessed/script/doom_defs.script
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ This defines some variables needed by the game script.

#define GAME_FRAMETIME ( 1.0f / GAME_FPS )

#define NULL 0
//#define NULL 0 // original defintion but never used, new #define at end -Phrozo

#define TRUE 1
#define FALSE 0
Expand Down Expand Up @@ -103,6 +103,7 @@ This defines some variables needed by the game script.
#define SHADERPARM_DIVERSITY 5 // random between 0.0 and 1.0 for some effects (muzzle flashes, etc)
#define SHADERPARM_MODE 7 // for selecting which shader passes to enable
#define SHADERPARM_TIME_OF_DEATH 7 // for the monster skin-burn-away effect enable and time offset
#define SHADERPARM_INDICATOR 10 // new: used as a switch in weapon materials as a ammo indictor

//
// Contents flags NOTE: make sure these are up to date with renderer/Material.h
Expand Down Expand Up @@ -179,4 +180,26 @@ This defines some variables needed by the game script.
#define eachFrame for( 0; 1; waitFrame() )
#define waitUntil( x ) while( !( x ) ) { waitFrame(); }

//
// Phrozo
//
// color escape string ( from Doom 3 Source code )
#define S_COLOR_DEFAULT "^0"
#define S_COLOR_RED "^1"
#define S_COLOR_GREEN "^2"
#define S_COLOR_YELLOW "^3"
#define S_COLOR_BLUE "^4"
#define S_COLOR_CYAN "^5"
#define S_COLOR_MAGENTA "^6"
#define S_COLOR_WHITE "^7"
#define S_COLOR_GRAY "^8"
#define S_COLOR_BLACK "^9"

#define NULL $null_entity // since this is never used, I decided to use it for entity references to equal null
#define nullptr $null_entity // another way to check for null, like in C++ 11
#define bool boolean // wish there was typedef in script but this will do
#define this self // another way to reference self like in C/C++
#define IS_NIGHTMARE ( sys.getcvar( "g_skill" ) == "3" ) // easy way to test if in nightmare
#define SHADERPARM_POWER 7 // for the BFG projectile

#endif
228 changes: 228 additions & 0 deletions vr_assets/Fully Possessed/script/weapon_chaingun.script
Original file line number Diff line number Diff line change
@@ -0,0 +1,228 @@
/***********************************************************************

weapon_chaingun.script

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

#define CHAINGUN_FIRE_SKIPFRAMES 7 // 6 shots per second
#define CHAINGUN_LOWAMMO 10
#define CHAINGUN_NUMPROJECTILES 1
#define CHAINGUN_BARREL_SPEED ( 60 * ( GAME_FPS / CHAINGUN_FIRE_SKIPFRAMES ) )
#define CHAINGUN_BARREL_ACCEL_TIME 0.4
#define CHAINGUN_BARREL_DECCEL_TIME 1.0
#define CHAINGUN_BARREL_ACCEL ( CHAINGUN_BARREL_SPEED / CHAINGUN_BARREL_ACCEL_TIME )
#define CHAINGUN_BARREL_DECCEL ( CHAINGUN_BARREL_SPEED / CHAINGUN_BARREL_DECCEL_TIME )

// blend times
#define CHAINGUN_IDLE_TO_LOWER 4
#define CHAINGUN_IDLE_TO_FIRE 0
#define CHAINGUN_IDLE_TO_RELOAD 4
#define CHAINGUN_RAISE_TO_IDLE 0
#define CHAINGUN_WINDDOWN_TO_IDLE 0
#define CHAINGUN_RELOAD_TO_IDLE 0

object weapon_chaingun : weapon_base {
entity world_model;
float world_barrel_joint;
float barrel_joint;
float barrel_angle;
float current_rate;
float start_rate;
float end_rate;
float spin_start;
float spin_end;
float spread;

void init();

void UpdateBarrel();
void SpinUp();
void SpinDown();

void Lower();
void Raise();
void Idle();
void Fire();
void Reload();
void ExitCinematic();
};

void weapon_chaingun::init() {
world_model = getWorldModel();
world_barrel_joint = world_model.getJointHandle( "toob" );
barrel_joint = getJointHandle( "spinner" );
barrel_angle = 0;
current_rate = 0;
start_rate = 0;
end_rate = 0;
spin_start = 0;
spin_end = 0;
spread = getFloatKey( "spread" );

weaponState( "Raise", 0 );
}

void weapon_chaingun::destroy() {
stopSound( SND_CHANNEL_BODY3, false );
}

void weapon_chaingun::UpdateBarrel() {
float currentTime;
float t;
vector ang;

currentTime = sys.getTime();
if ( currentTime < spin_end ) {
t = ( currentTime - spin_start ) / ( spin_end - spin_start );
current_rate = start_rate + t * ( end_rate - start_rate );
} else {
current_rate = end_rate;
}

if ( current_rate ) {
barrel_angle = barrel_angle + current_rate * GAME_FRAMETIME;

ang_x = 0;
ang_y = 0;
ang_z = barrel_angle;
setJointAngle( barrel_joint, JOINTMOD_LOCAL, ang );

ang_y = barrel_angle;
ang_z = 0;
world_model.setJointAngle( world_barrel_joint, JOINTMOD_LOCAL, ang );
}
}

void weapon_chaingun::SpinUp() {
start_rate = current_rate;
end_rate = CHAINGUN_BARREL_SPEED;
spin_start = sys.getTime();
spin_end = spin_start + ( end_rate - current_rate ) / CHAINGUN_BARREL_ACCEL;
startSound( "snd_windup", SND_CHANNEL_BODY3, false );
}

void weapon_chaingun::SpinDown() {
start_rate = current_rate;
end_rate = 0;
spin_start = sys.getTime();
spin_end = spin_start + ( current_rate - end_rate ) / CHAINGUN_BARREL_DECCEL;
startSound( "snd_winddown", SND_CHANNEL_BODY3, false );
}

void weapon_chaingun::Raise() {
weaponRising();
playAnim( ANIMCHANNEL_ALL, "raise" );
waitUntil( animDone( ANIMCHANNEL_ALL, CHAINGUN_RAISE_TO_IDLE ) );
playCycle( ANIMCHANNEL_ALL, "idle" );
weaponState( "Idle", CHAINGUN_RAISE_TO_IDLE );
}

void weapon_chaingun::Lower() {
weaponLowering();
playAnim( ANIMCHANNEL_ALL, "putaway" );

while( !animDone( ANIMCHANNEL_ALL, 0 ) ) {
UpdateBarrel();
waitFrame();
}

weaponHolstered();
waitUntil( WEAPON_RAISEWEAPON );
weaponState( "Raise", 0 );
}

void weapon_chaingun::Idle() {
float ammoClip;
float avail;
float clip_size;

clip_size = clipSize();

if ( !ammoInClip() ) {
weaponOutOfAmmo();
} else {
weaponReady();
}

while( 1 ) {
if ( WEAPON_LOWERWEAPON ) {
weaponState( "Lower", CHAINGUN_IDLE_TO_LOWER );
}
ammoClip = ammoInClip();
if ( WEAPON_ATTACK ) {
if ( ammoClip > 0 ) {
weaponState( "Fire", CHAINGUN_IDLE_TO_FIRE );
} else if ( ammoAvailable() > 0 ) {
if ( autoReload() ) {
netReload();
weaponState( "Reload", CHAINGUN_IDLE_TO_RELOAD );
}
}
}
if ( WEAPON_RELOAD && ( ammoAvailable() > ammoClip ) && ( ammoClip < clip_size ) ) {
netReload();
weaponState( "Reload", CHAINGUN_IDLE_TO_RELOAD );
}
if ( WEAPON_NETRELOAD ) {
WEAPON_NETRELOAD = false;
weaponState( "Reload", CHAINGUN_IDLE_TO_RELOAD );
}
UpdateBarrel();
waitFrame();
}
}

void weapon_chaingun::Fire() {
float ammoClip;
float currentTime;
float skip;
SpinUp();
ammoClip = ammoInClip();
while( ( current_rate < end_rate ) && WEAPON_ATTACK && !WEAPON_RELOAD && ( ammoClip > 0 ) ) {
UpdateBarrel();
waitFrame();
ammoClip = ammoInClip();
}

startSound( "snd_spin", SND_CHANNEL_BODY3, false );
ammoClip = ammoInClip();
while( WEAPON_ATTACK && !WEAPON_RELOAD && ( ammoClip > 0 ) ) {
launchProjectiles( CHAINGUN_NUMPROJECTILES, spread, 0, 1.0, 1.0 );
startSound( "snd_fire", SND_CHANNEL_WEAPON, false );
ammoClip = ammoInClip();
if ( ammoClip == CHAINGUN_LOWAMMO ) {
startSound( "snd_lowammo", SND_CHANNEL_ITEM, false );
}

// skip frames
for( skip = 0; skip < CHAINGUN_FIRE_SKIPFRAMES; skip++ ) {
UpdateBarrel();
waitFrame();
}
}

SpinDown();
weaponState( "Idle", CHAINGUN_WINDDOWN_TO_IDLE );
}

void weapon_chaingun::Reload() {
weaponReloading();
playAnim( ANIMCHANNEL_ALL, "reload" );
while( !animDone( ANIMCHANNEL_ALL, CHAINGUN_RELOAD_TO_IDLE ) ) {
UpdateBarrel();
waitFrame();
}
addToClip( clipSize() );
playCycle( ANIMCHANNEL_ALL, "idle" );
weaponState( "Idle", CHAINGUN_RELOAD_TO_IDLE );
}

void weapon_chaingun::ExitCinematic() {
current_rate = 0;
start_rate = 0;
end_rate = 0;
spin_start = 0;
spin_end = 0;

weaponState( "Idle", 0 );
}
79 changes: 79 additions & 0 deletions vr_assets/Fully Possessed/script/weapon_fists.script
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/***********************************************************************

weapon_fists.script

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

// blend times
#define FISTS_IDLE_TO_LOWER 4
#define FISTS_IDLE_TO_PUNCH 0
#define FISTS_RAISE_TO_IDLE 4
#define FISTS_PUNCH_TO_IDLE 1

object weapon_fists : weapon_base {
float side;

void init();

void Lower();
void Raise();
void Idle();
void Punch();
void ExitCinematic();
string GetFireAnim();
};

void weapon_fists::init() {
weaponState( "Raise", 0 );
}

void weapon_fists::Raise() {
weaponRising();
playAnim( ANIMCHANNEL_ALL, "raise" );
waitUntil( animDone( ANIMCHANNEL_ALL, FISTS_RAISE_TO_IDLE ) );
weaponState( "Idle", FISTS_RAISE_TO_IDLE );
}

void weapon_fists::Lower() {
weaponLowering();
playAnim( ANIMCHANNEL_ALL, "putaway" );
waitUntil( animDone( ANIMCHANNEL_ALL, 0 ) );
weaponHolstered();
waitUntil( WEAPON_RAISEWEAPON );
weaponState( "Raise", 0 );
}

void weapon_fists::Idle() {
weaponReady();
playCycle( ANIMCHANNEL_ALL, "idle" );
while( 1 ) {
if ( WEAPON_LOWERWEAPON ) {
weaponState( "Lower", FISTS_IDLE_TO_LOWER );
}
if ( WEAPON_ATTACK ) {
weaponState( "Punch", FISTS_IDLE_TO_PUNCH );
}
waitFrame();
}
}

void weapon_fists::Punch() {
playAnim( ANIMCHANNEL_ALL, GetFireAnim() );
sys.wait( 0.1 );
melee();
waitUntil( animDone( ANIMCHANNEL_ALL, FISTS_PUNCH_TO_IDLE ) );
side = !side;
weaponState( "Idle", FISTS_PUNCH_TO_IDLE );
}

void weapon_fists::ExitCinematic() {
weaponState( "Idle", 0 );
}

string weapon_fists::GetFireAnim() {
if ( side ) {
return "punch_left";
} else {
return "punch_right";
}
}
Loading

0 comments on commit 40ddcd4

Please sign in to comment.