Add 2 new files and modified player source code in game directory (part 2)

This commit is contained in:
LegendGuard 2023-07-25 01:09:17 +02:00 committed by GitHub
parent cdc61a1a53
commit e2d9b1df6a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 2076 additions and 408 deletions

File diff suppressed because it is too large Load diff

View file

@ -39,6 +39,8 @@ If you have questions concerning this license or the applicable additional terms
#include "PlayerIcon.h"
#include "GameEdit.h"
#include "Mover.h"
class idAI;
/*
@ -66,12 +68,6 @@ const int FOCUS_GUI_TIME = 500;
const int MAX_WEAPONS = 16;
const int DEAD_HEARTRATE = 0; // fall to as you die
const int LOWHEALTH_HEARTRATE_ADJ = 20; //
const int DYING_HEARTRATE = 30; // used for volumen calc when dying/dead
const int BASE_HEARTRATE = 70; // default
const int ZEROSTAMINA_HEARTRATE = 115; // no stamina
const int MAX_HEARTRATE = 130; // maximum
const int ZERO_VOLUME = -40; // volume at zero
const int DMG_VOLUME = 5; // volume when taking damage
const int DEATH_VOLUME = 15; // volume at death
@ -81,6 +77,10 @@ const int SAVING_THROW_TIME = 5000; // maximum one "saving throw" every five se
extern const int ASYNC_PLAYER_INV_AMMO_BITS;
extern const int ASYNC_PLAYER_INV_CLIP_BITS;
const int CLERIC = 0;
const int MAGE = 1;
const int FIGHTER = 2;
struct idItemInfo {
idStr name;
idStr icon;
@ -123,14 +123,18 @@ enum {
};
class idInventory {
// HEXEN : Zeroth
public:
int Class;
public:
int maxHealth;
int weapons;
int powerups;
int armor;
int maxarmor;
int ammo[ AMMO_NUMTYPES ];
int clip[ MAX_WEAPONS ];
float ammo[ AMMO_NUMTYPES ];
float clip[ MAX_WEAPONS ];
int powerupEndTime[ MAX_POWERUPS ];
// mp
@ -179,14 +183,17 @@ public:
ammo_t AmmoIndexForAmmoClass( const char *ammo_classname ) const;
int MaxAmmoForAmmoClass( idPlayer *owner, const char *ammo_classname ) const;
int WeaponIndexForAmmoClass( const idDict & spawnArgs, const char *ammo_classname ) const;
ammo_t AmmoIndexForWeaponClass( const char *weapon_classname, int *ammoRequired );
ammo_t AmmoIndexForWeaponClass( const char *weapon_classname, float *ammoRequired );
const char * AmmoPickupNameForIndex( ammo_t ammonum ) const;
void AddPickupName( const char *name, const char *icon );
int HasAmmo( ammo_t type, int amount );
bool UseAmmo( ammo_t type, int amount );
int HasAmmo( const char *weapon_classname ); // looks up the ammo information for the weapon class first
// HEXEN : Zeroth
public:
void DoCombinedMana( void );
float HasAmmo( ammo_t type, float amount );
bool UseAmmo( ammo_t type, float amount );
float HasAmmo( const char *weapon_classname ); // looks up the ammo information for the weapon class first
void UpdateArmor( void );
int nextItemPickup;
@ -242,6 +249,7 @@ public:
idScriptBool AI_STRAFE_LEFT;
idScriptBool AI_STRAFE_RIGHT;
idScriptBool AI_ATTACK_HELD;
idScriptBool AI_ATTACK2_HELD; // HEXEN : Zeroth
idScriptBool AI_WEAPON_FIRED;
idScriptBool AI_JUMP;
idScriptBool AI_CROUCH;
@ -264,20 +272,34 @@ public:
idUserInterface * hud; // MP: is NULL if not local player
idUserInterface * objectiveSystem;
bool objectiveSystemOpen;
idUserInterface * customGui;
bool customGuiOpen;
int weapon_soulcube;
int weapon_pda;
int weapon_fists;
int heartRate;
idInterpolate<float> heartInfo;
int lastHeartAdjust;
int lastHeartBeat;
int lastDmgTime;
// HEXEN : Zeroth
public:
bool PowerTome;
bool AutoMapOff;
idAngles SpawnViewAngles; // player view angles
bool invincible;
idVec3 SpawnPos;
int BeltSelection;
int BeltPosition;
int speedMod;
bool FreeMove;
int leftWater;
idList<idDict *> Artifact; // list of artifacts & quantities, and other artifact info
void SetClass( const int classnum );
bool beaten; // whether this eoc release has been beaten
int deathClearContentsTime;
bool doingDeathSkin;
int lastArmorPulse; // lastDmgTime if we had armor at time of hit
float stamina;
float healthPool; // amount of health to give over time
int nextHealthPulse;
bool healthPulse;
@ -381,7 +403,7 @@ public:
virtual void DamageFeedback( idEntity *victim, idEntity *inflictor, int &damage );
void CalcDamagePoints( idEntity *inflictor, idEntity *attacker, const idDict *damageDef,
const float damageScale, const int location, int *health, int *armor );
virtual void Damage( idEntity *inflictor, idEntity *attacker, const idVec3 &dir, const char *damageDefName, const float damageScale, const int location );
virtual void Damage( idEntity *inflictor, idEntity *attacker, const idVec3 &dir, const char *damageDefName, const float damageScale, const int location, const idVec3 &iPoint );
// use exitEntityNum to specify a teleport with private camera view and delayed exit
virtual void Teleport( const idVec3 &origin, const idAngles &angles, idEntity *destination );
@ -410,12 +432,42 @@ public:
void GiveItem( const char *name );
void GiveHealthPool( float amt );
bool GiveInventoryItem( idDict *item );
bool GiveInventoryItem( idItem *item );
void RemoveInventoryItem( idDict *item );
bool GiveInventoryItem( const char *name );
void RemoveInventoryItem( const char *name );
idDict * FindInventoryItem( const char *name );
// HEXEN : Zeroth
public:
void UpdateHudArtifacts( void );
void UpdateHudActiveArtifacts();
bool ArtifactVerify( int art ); // return whetherArtifact[art] is safe to use. Or if the artifact is Qty 0, delete it and return false.
void CleanupArtifactItems(); // deletes allAartifactItem[] elements marked as to be.
int InventoryItemQty( const char *name ) const;
int InventoryItemQty( int belt ); // specifically for artifacts
void SortArtifacts( void ); // sort belt items in ascending order of their "artifact" keys
void ArtifactExec( int belt, char *func, bool remove );
void ArtifactDrop( int belt, bool randomPos );
bool ArtifactRemove( int belt );
void ShowArtifactHud( void );
void UpdateArtifactHudDescription( void );
int FindArtifact( int art ); // returns the index inArtifact[] matching "artifact" spawnArg
bool ActiveArtifact( int art );
bool ActiveArtifact( const char *art );
void ArtifactValidateSelection( void );
void ArtifactScrollRight( int startfrom );
void ArtifactScrollLeft( int startfrom );
int Belt2Index(int belt_index); // translate an artitfacts position on the belt to it'sArtifactItem[] index.
// HEXEN : Zeroth
/*virtual*/ bool StuckToSurface( void );
void SpawnHellions( void );
void UpdateHudAutoMap( void );
void AutoMapChange( idStr mapFloor );
void ShowHudMessage( const char *message );
void ShowHudMessage( idStr message );
bool GetPowerTome( void ) { return PowerTome; };
void GivePDA( const char *pdaName, idDict *item );
void GiveVideo( const char *videoName, idDict *item );
void GiveEmail( const char *emailName );
@ -449,9 +501,6 @@ public:
void AddAIKill( void );
void SetSoulCubeProjectile( idProjectile *projectile );
void AdjustHeartRate( int target, float timeInSecs, float delay, bool force );
void SetCurrentHeartRate( void );
int GetBaseHeartRate( void );
void UpdateAir( void );
virtual bool HandleSingleGuiCommand( idEntity *entityGui, idLexer *src );
@ -637,10 +686,16 @@ private:
bool selfSmooth;
// HEXEN : Zeroth
private:
idVec3 hellion_danger_origin;
int hellion_danger_time;
void LookAtKiller( idEntity *inflictor, idEntity *attacker );
void StopFiring( void );
void FireWeapon( void );
void FireWeaponAlt( void );
void Weapon_Combat( void );
void Weapon_NPC( void );
void Weapon_GUI( void );
@ -695,6 +750,44 @@ private:
void Event_LevelTrigger( void );
void Event_Gibbed( void );
void Event_GetIdealWeapon( void );
// HEXEN : Zeroth
private:
void Event_GiveHealth( const float amount );
void Event_GiveSpeed( const float amount );
void Event_GiveArmor( const float amount );
void Event_GetHealth( void );
void Event_GetFullHealth( void );
void Event_GetArmor( void );
void Event_GetFullArmor( void );
void Event_SetHealth( const float amount );
void Event_SetArmor( const float amount );
void Event_GetClass( void );
void Event_SetAmmo( const char *ammo_classname, const float amount );
void Event_GetAmmo( const char *ammo_classname );
void Event_GetFullAmmo( const char *ammo_classname );
void Event_SetInvincible( const float number );
void Event_GetInvincible( void );
void Event_ChaosDevice( void );
void Event_SetFreeMove( const float yesorno );
void Event_SetViewAngles( idVec3 &vec );
void Event_GetEyePos( void );
void Event_SetPowerTome( float val );
void Event_GetPowerTome( void );
void Event_VecForwardP( void );
void Event_VecFacingP( void );
void Event_HudMessage( const char *message );
void Event_ArtifactUseFlash( void );
//the following are no longer used - perhaps they will be useful for something else, like sticky bombs of some kind
void Event_StickToSurface( const idVec3 &surfaceNormal );
void Event_UnstickToSurface( void );
void Event_StuckToSurface( void );
public:
idVec3 VecForwardP( void ) const;
idVec3 idPlayer::VecFacingP( void ) const;
void OpenCustomGui( idStr file );
};
ID_INLINE bool idPlayer::IsReady( void ) {

575
game/PlayerArtifacts.cpp Normal file
View file

@ -0,0 +1,575 @@
// HEXEN : Zeroth
#include "../idlib/precompiled.h"
#pragma hdrstop
#include "Game_local.h"
int idPlayer::FindArtifact( int art ) {
for (int belt=0; belt<Artifact.Num(); belt++) {
if (Artifact[belt]->GetInt("artifact") == art) {
return belt;
}
}
return -1;
}
bool idPlayer::ActiveArtifact( int art ) {
idItem *item;
int hash, i;
hash = gameLocal.entypeHash.GenerateKey( idItem::Type.classname, true );
for ( i = gameLocal.entypeHash.First( hash ); i != -1; i = gameLocal.entypeHash.Next( i ) ) {
if ( gameLocal.entities[i] && gameLocal.entities[i]->IsType( idItem::Type ) ) {
item = static_cast< idItem* >( gameLocal.entities[i] );
if ( item->GetOwner() != this ) {
item = NULL;
continue;
}
if ( !item->ArtifactActive ) {
item = NULL;
continue;
}
if ( item->spawnArgs.GetInt("artifact") != art) {
item = NULL;
continue;
}
return true;
}
}
return false;
}
bool idPlayer::ActiveArtifact( const char *art ) {
idDict tmp;
tmp.Set("art", art);
return ActiveArtifact(tmp.GetInt("art"));
}
void idPlayer::ArtifactExec( int belt, char * funcName, bool remove ) {
CleanupArtifactItems();
if (!ArtifactVerify(belt)) {
UpdateHudArtifacts();
return;
}
if (funcName == NULL) {
return;
}
const char *name=Artifact[belt]->GetString("name");
if (ActiveArtifact(Artifact[belt]->GetInt("artifact"))) {
return;
}
idItem *item;
int hash, i;
hash = gameLocal.entypeHash.GenerateKey( idItem::Type.classname, true );
for ( i = gameLocal.entypeHash.First( hash ); i != -1; i = gameLocal.entypeHash.Next( i ) ) {
if ( gameLocal.entities[i] && gameLocal.entities[i]->IsType( idItem::Type ) ) {
item = static_cast< idItem* >( gameLocal.entities[i] );
if ( item->GetOwner() != this ) {
continue;
}
if ( idStr::Icmp(name, item->spawnArgs.GetString("inv_name")) ) {
continue;
}
if ( item->Processing ) {
continue;
}
if ( item->DeleteMe ) {
continue;
}
item->CallFunc(funcName);
return;
}
}
}
void idPlayer::SortArtifacts( void ) {
int a,b;
idDict *temp;
for (a=0; a<Artifact.Num(); a++) {
for (b=a+1; b<Artifact.Num(); b++) {
if ( Artifact[a]->GetInt("artifact") < Artifact[b]->GetInt("artifact")) {
continue;
}
temp=Artifact[a];
Artifact[a]=Artifact[b];
Artifact[b]=temp;
temp=NULL;
if ( BeltSelection == a) {
BeltSelection = b;
} else if ( BeltSelection == b) {
BeltSelection = a;
}
// we don't callUpdateHudArtifacts(); because SortArtifacts is only called by GiveInventoryItem(), and that takes care of it.
}
}
}
void idPlayer::UpdateHudArtifacts( void ) {
int belt,art;
int pos; // belt item position marker
int onScreen=((7-1)/2); //number of on-screen artifacts to the left of the center. (belt_width - 1) / 2; belt_width must be odd (the middle number is center of belt)
int tileWidth=60; //width in pixels of an artifact on the belt
char itemStr[22];
ArtifactValidateSelection();
// disappear all artifacts
for ( art=0; art < NUM_UNIQUE_ARTIFACTS; art++) {
sprintf(itemStr, "eoc_Artifact%iVis", art);
hud->SetStateBool( itemStr, false );
sprintf(itemStr, "eoc_Artifact%iRotate", art);
hud->SetStateFloat( itemStr, 0.0f );
}
hud->SetStateInt( "eoc_Artifacts",Artifact.Num() );
hud->SetStateInt( "eoc_BeltSelection",BeltSelection );
// determine tile position and visibility
pos=0;
for (belt=0; belt < Artifact.Num(); belt++) {
art=Artifact[belt]->GetInt("artifact");
if (InventoryItemQty(belt) > 0) {
sprintf(itemStr, "eoc_Artifact%iPos", art);
hud->SetStateInt( itemStr, pos );
sprintf(itemStr, "eoc_Artifact%iQty", art);
hud->SetStateInt( itemStr,InventoryItemQty(belt) );
sprintf(itemStr, "eoc_Artifact%iVis", art);
if ((belt<BeltSelection-onScreen) || (belt>BeltSelection+onScreen)) {
hud->SetStateBool( itemStr, false ); // Hide artifacts that are off-screen
}else{
hud->SetStateBool( itemStr, true );
}
sprintf(itemStr, "eoc_Artifact%iRotate", art);
if (BeltSelection == belt) //ArtifactValidateSelection(); sould be called once before this in the same function
{
BeltPosition=pos;
hud->SetStateFloat( itemStr, 0.05f );
}else{
hud->SetStateFloat( itemStr, 0.0f );
}
pos+=tileWidth; //up the position for the next visible item
}else{
//the artifact is no longer in the inventory, but is in use
sprintf(itemStr, "eoc_Artifact%iVis", art);
hud->SetStateBool( itemStr, false );
sprintf(itemStr, "eoc_Artifact%iRotate", art);
hud->SetStateFloat( itemStr, 0.0f );
}
}
BeltPosition= -(BeltPosition)+(tileWidth*onScreen); // add onScreen*tielWidth to get to center of belt, negate to scroll in opposite (correct) direction
hud->SetStateInt( "eoc_BeltPosition",BeltPosition ); // set scrolled position of inventory
// update selected artifact
if (BeltSelection < 0 ) {
hud->SetStateString( "eoc_BeltSelectionQty", "" );
} else {
hud->SetStateInt( "eoc_BeltSelectionQty", InventoryItemQty(BeltSelection) );
}
UpdateArtifactHudDescription();
}
void idPlayer::UpdateHudActiveArtifacts() {
int i;
int numActive=0;
int pos=0; // active artifact position marker
int tileWidth=60; //width in pixels of an artifact on the belt
char itemStr[30];
idItem* item;
bool active[NUM_UNIQUE_ARTIFACTS];
bool cooling[NUM_UNIQUE_ARTIFACTS];
int totArtifacts=NUM_UNIQUE_ARTIFACTS; //Z.TODO this should be read from a def file or something
// initialize local variables
for (i=0; i < totArtifacts; i++) {
active[i]=false;
cooling[i]=false;
}
// figure out which artifacts are active or cooling
int hash;
hash = gameLocal.entypeHash.GenerateKey( idItem::Type.classname, true );
for ( i = gameLocal.entypeHash.First( hash ); i != -1; i = gameLocal.entypeHash.Next( i ) ) {
if ( gameLocal.entities[i] && gameLocal.entities[i]->IsType( idItem::Type ) ) {
item = static_cast< idItem* >( gameLocal.entities[i] );
if ( item->GetOwner() != this ) {
continue;
}
if ( !item->ArtifactActive ) {
continue;
}
active[item->spawnArgs.GetInt("artifact")] = true;
if ( item->Cooling ) {
cooling[item->spawnArgs.GetInt("artifact")] = true;
}
}
}
for (i=0; i < totArtifacts; i++ ) {
if ( active[i] ) {
sprintf(itemStr, "eoc_Artifact%iPosA", i);
hud->SetStateInt( itemStr, pos );
sprintf(itemStr, "eoc_Artifact%iVisA", i);
hud->SetStateBool( itemStr, true );
// artifact must be active for cooldown, but effects should be turned off at this point via script
sprintf(itemStr, "eoc_Artifact%iCoolDownVisA", i);
hud->SetStateBool( itemStr, cooling[i] );
pos+=tileWidth; //up the position for the next visible item
numActive++;
}else{
//no need to change pos
sprintf(itemStr, "eoc_Artifact%iVisA", i);
hud->SetStateBool( itemStr, false );
sprintf(itemStr, "eoc_Artifact%iCoolDownVisA", i);
hud->SetStateBool( itemStr, false );
}
}
hud->SetStateInt("eoc_ActiveArtifacts", numActive);
}
bool idPlayer::ArtifactVerify( int belt ) {
int art;
char itemStr[22];
//int iteration=rand();
if ( belt == -1 ) {
return false;
}
if ( belt >= Artifact.Num() ) {
return false;
}
art=Artifact[belt]->GetInt("artifact");
sprintf(itemStr,Artifact[belt]->GetString("name"));
if ( art == -1 ) {
return true; //?
}
if ( InventoryItemQty(itemStr) > 0 ) {
return true;
}
// remove the artifact, we have zero items of it's type
sprintf(itemStr, "eoc_Artifact%iPos", art);
hud->SetStateInt( itemStr, 0 );
sprintf(itemStr, "eoc_Artifact%iVis", art);
hud->SetStateBool( itemStr, false );
sprintf(itemStr, "eoc_Artifact%iQty", art);
hud->SetStateInt( itemStr, 0 );
sprintf(itemStr, "eoc_Artifact%iRotate", art);
hud->SetStateFloat( itemStr, 0.0f );
if (BeltSelection > belt) {
BeltSelection--;
}
delete Artifact[belt];
Artifact.RemoveIndex(belt);
Artifact.Condense();
return false;
}
void idPlayer::ArtifactValidateSelection( void ) {
int belt;
if ( gameLocal.inCinematic || health < 0 ) {
return;
}
if ( gameLocal.isClient ) {
return;
}
if (BeltSelection == -1) {
ArtifactScrollRight(1);
return;
}
if ( ArtifactVerify(BeltSelection) ) {
return;
}
belt=BeltSelection;
ArtifactScrollRight(0); // we start scrolling right from where we are because idList removes gaps between list items.
if ( belt == BeltSelection ) {
ArtifactScrollLeft(0);
}
if ( belt == BeltSelection ) {
BeltSelection = -1;
}
}
void idPlayer::ArtifactScrollRight( int startfrom ) {
int belt;
if ( gameLocal.inCinematic || health < 0 ) {
return;
}
if ( gameLocal.isClient ) {
return;
}
for (belt=BeltSelection+startfrom; belt <Artifact.Num(); belt++) {
if (InventoryItemQty(belt) > 0 ) {
BeltSelection = belt;
UpdateHudArtifacts();
return;
}
}
}
void idPlayer::ArtifactScrollLeft( int startfrom ) {
int belt;
if ( gameLocal.inCinematic || health < 0 ) {
return;
}
if ( gameLocal.isClient ) {
return;
}
for (belt=BeltSelection-startfrom; belt > -1; belt--) {
if (InventoryItemQty(belt) > 0 ) {
BeltSelection = belt;
UpdateHudArtifacts();
return;
}
}
}
void idPlayer::ArtifactDrop( int belt, bool randomPos ) {
CleanupArtifactItems();
if ( !ArtifactVerify(belt) ) {
UpdateHudArtifacts();
return;
}
const char *name=Artifact[belt]->GetString("name");
idEntity* ent;
idItem* item;
for (int i = 0; i < MAX_GENTITIES; i++ ) {
ent = gameLocal.entities[i];
if ( !ent ) {
continue;
}
if ( !ent->IsType( idItem::Type ) ) {
continue;
}
item = static_cast< idItem* >( ent );
if ( item->GetOwner() != this ) {
continue;
}
if ( idStr::Icmp(name, item->spawnArgs.GetString("inv_name") ) ) {
continue;
}
if ( item->Processing ) {
continue;
}
idAngles use=viewAngles;
float dist=80;
if ( randomPos ) {
use.yaw = gameLocal.random.CRandomFloat() * 360.0f;
dist = 40 + gameLocal.random.CRandomFloat() * 40;
}
idVec3 org = GetPhysics()->GetOrigin() + idAngles( 0, use.yaw, 0 ).ToForward() * dist + idVec3( 0, 0, 1 );
idDict dict;
dict.Set( "classname", item->spawnArgs.GetString("classname") );
dict.SetVector( "origin", org );
//dict.SetAngles( "angles", viewAngles.yaw + 180 );
idEntity *newItem;
gameLocal.SpawnEntityDef( dict, &newItem );
static_cast< idItem* >(newItem)->PickupDelayTime = gameLocal.time + 3000;
RemoveInventoryItem(name);
item->DeleteMe = true;
item->SetOwner(NULL);
UpdateHudArtifacts();
break;
}
return;
}
bool idPlayer::ArtifactRemove( int belt ) {
CleanupArtifactItems();
if ( !ArtifactVerify(belt) ) {
UpdateHudArtifacts();
return false;
}
const char *name=Artifact[belt]->GetString("name");
idItem *item;
int hash, i;
hash = gameLocal.entypeHash.GenerateKey( idItem::Type.classname, true );
for ( i = gameLocal.entypeHash.First( hash ); i != -1; i = gameLocal.entypeHash.Next( i ) ) {
if ( gameLocal.entities[i] && gameLocal.entities[i]->IsType( idItem::Type ) ) {
item = static_cast< idItem* >( gameLocal.entities[i] );
if ( item->GetOwner() != this ) {
continue;
}
if ( idStr::Icmp(name, item->spawnArgs.GetString("inv_name")) ) {
continue;
}
if ( item->Processing ) {
continue;
}
RemoveInventoryItem(name);
item->DeleteMe = true;
item->SetOwner(NULL);
UpdateHudArtifacts();
return true;
}
}
return false;
}
void idPlayer::ShowArtifactHud( void ) {
hud->HandleNamedEvent( "eoc_BeltShow" );
}
void idPlayer::UpdateArtifactHudDescription( void ) {
if ( g_noArtifactDescriptions.GetBool() ) {
hud->SetStateBool( "artifactDescShow", 0.0f );
hud->SetStateString( "artifactDesc", "" );
return;
}
CleanupArtifactItems();
if (!ArtifactVerify(BeltSelection)) {
hud->SetStateString( "artifactDesc", "" );
return;
}
hud->SetStateBool( "artifactDescShow", 1.0f );
idStr desc="";
const idDict *item = gameLocal.FindEntityDefDict( Artifact[BeltSelection]->GetString("defname") );
if ( !item ) {
desc = "";
} else {
desc = item->GetString("eoc_description");
if ( desc == "" ) {
switch( inventory.Class ) {
case CLERIC: desc = "eoc_description_cleric"; break;
case MAGE: desc = "eoc_description_mage"; break;
case FIGHTER: desc = "eoc_description_fighter"; break;
}
desc = item->GetString( desc.c_str() );
}
desc = "\n" + desc;
desc = Artifact[BeltSelection]->GetString("name") + desc;
}
hud->SetStateString( "artifactDesc", desc.c_str() );
}
// z.todo: this COULD be done with a post event ...
void idPlayer::CleanupArtifactItems() {
idItem *item;
int hash, i;
bool upd=false;
hash = gameLocal.entypeHash.GenerateKey( idItem::Type.classname, true );
for ( i = gameLocal.entypeHash.First( hash ); i != -1; i = gameLocal.entypeHash.Next( i ) ) {
if ( gameLocal.entities[i] && gameLocal.entities[i]->IsType( idItem::Type ) ) {
item = static_cast< idItem* >( gameLocal.entities[i] );
if ( item->GetOwner() != this ) {
continue;
}
if ( !item->DeleteMe ) {
continue;
}
delete item;
item=NULL;
upd=true;
}
}
if ( upd ) {
UpdateHudArtifacts();
}
}

156
game/PlayerScriptEvents.cpp Normal file
View file

@ -0,0 +1,156 @@
// HEXEN : Zeroth
#include "../idlib/precompiled.h"
#pragma hdrstop
#include "Game_local.h"
void idPlayer::Event_SetViewAngles( idVec3 &vec ) {
viewAngles[0] = vec.x;
viewAngles[1] = vec.y;
viewAngles[2] = vec.z;
}
void idPlayer::Event_GetEyePos( void ) {
idThread::ReturnVector( GetEyePosition() );
}
void idPlayer::Event_SetFreeMove( const float yesorno ) {
//spawnArgs.SetInt("freemovement", yesorno);
if (yesorno) {
FreeMove=true;
}else{
FreeMove=false;
}
}
void idPlayer::Event_ChaosDevice( void ) {
SetOrigin(SpawnPos);
SetViewAngles(SpawnViewAngles);
}
void idPlayer::Event_GiveHealth( const float amount ) {
health+=amount;
}
void idPlayer::Event_GiveSpeed( const float amount ) {
speedMod+=amount;
}
void idPlayer::Event_GiveArmor( const float amount ) {
inventory.armor+=amount;
}
void idPlayer::Event_SetHealth( const float amount ) {
health=amount;
}
void idPlayer::Event_SetArmor( const float amount ) {
inventory.armor=amount;
}
void idPlayer::Event_SetInvincible( const float number ) {
if (number != 0) {
invincible = true;
}else{
invincible = false;
}
}
void idPlayer::Event_GetInvincible( void ) {
if (godmode || invincible) {
idThread::ReturnFloat(1);
}else{
idThread::ReturnFloat(0);
}
}
void idPlayer::Event_GetClass( void ) {
idThread::ReturnFloat( inventory.Class );
}
void idPlayer::Event_GetHealth( void ) {
idThread::ReturnFloat( health );
}
void idPlayer::Event_GetFullHealth( void ) {
idThread::ReturnFloat( inventory.maxHealth );
}
void idPlayer::Event_GetFullArmor( void ) {
idThread::ReturnFloat( inventory.maxarmor );
}
void idPlayer::Event_GetFullAmmo( const char* ammo_classname ) {
idThread::ReturnFloat( spawnArgs.GetInt( va( "max_%s", ammo_classname ), "0" ) );
}
void idPlayer::Event_GetAmmo( const char* ammo_classname ) {
idThread::ReturnFloat( inventory.ammo[ idWeapon::GetAmmoNumForName( ammo_classname ) ] );
}
void idPlayer::Event_SetAmmo( const char* ammo_classname, float amount ) {
if ( ammo_classname ) {
inventory.ammo[ idWeapon::GetAmmoNumForName( ammo_classname ) ] = amount;
}
}
void idPlayer::Event_GetArmor( void ) {
idThread::ReturnFloat( inventory.armor );
}
void idPlayer::Event_StickToSurface( const idVec3 &surfaceNormal ) {
//idPhysics_Actor *x=GetPhysics();
physicsObj.SetSurfaceNormal(surfaceNormal);
physicsObj.SetStuckToSurface(true);
}
void idPlayer::Event_UnstickToSurface( void ) {
physicsObj.SetStuckToSurface(false);
}
bool idPlayer::StuckToSurface( void ) {
return physicsObj.StuckToSurface();
}
void idPlayer::Event_StuckToSurface( void ) {
idThread::ReturnFloat((float)StuckToSurface());
}
void idPlayer::Event_SetPowerTome( float val ) {
PowerTome = !(!val);
}
void idPlayer::Event_GetPowerTome( void ) {
idThread::ReturnFloat((float)PowerTome);
}
void idPlayer::Event_VecFacingP( void ) {
// return proper facing direction (yaw only)
idVec3 dir=viewAxis[ 0 ] * physicsObj.GetGravityAxis();
dir.Normalize();
idThread::ReturnVector(dir);
}
void idPlayer::Event_HudMessage( const char *message ) {
ShowHudMessage( message );
}
void idPlayer::Event_VecForwardP( void ) {
idThread::ReturnVector(VecForwardP());
}
idVec3 idPlayer::VecForwardP( void ) const {
// return proper forward vector for whatever way the player is looking
idVec3 dir=viewAngles.ToForward() * physicsObj.GetGravityAxis();
dir.Normalize();
return dir;
}
// HEXEN : Zeroth
void idPlayer::Event_ArtifactUseFlash( void ) {
if ( hud ) {
hud->HandleNamedEvent( "eoc_artifactUse" );
}
}

View file

@ -36,6 +36,18 @@ If you have questions concerning this license or the applicable additional terms
#include "PlayerView.h"
/*
==============
Zeroth
MakePowerOfTwo
==============
*/
static int MakePowerOfTwo( int num ) {
int pot;
for ( pot = 1 ; pot < num ; pot<<=1 ) { }
return pot;
}
const int IMPULSE_DELAY = 150;
/*
==============
@ -448,16 +460,60 @@ void idPlayerView::SingleView( idUserInterface *hud, const renderView_t *view )
return;
}
// endgame dialog
if ( player->customGuiOpen && player->customGui != NULL ) {
player->customGui->Redraw( gameLocal.time );
return;
}
// hack the shake in at the very last moment, so it can't cause any consistency problems
renderView_t hackedView = *view;
hackedView.viewaxis = hackedView.viewaxis * ShakeAxis();
gameRenderWorld->RenderScene( &hackedView );
// HEXEN : Zeroth
if ( gameLocal.portalSkyEnt.GetEntity() && gameLocal.IsPortalSkyAcive() && g_enablePortalSky.GetBool() ) {
renderView_t portalView = hackedView;
portalView.vieworg = gameLocal.portalSkyEnt.GetEntity()->GetPhysics()->GetOrigin();
// setup global fixup projection vars
if ( 1 ) {
int vidWidth, vidHeight;
idVec2 shiftScale;
renderSystem->GetGLSettings( vidWidth, vidHeight );
float pot;
int w = vidWidth;
pot = MakePowerOfTwo( w );
shiftScale.x = (float)w / pot;
int h = vidHeight;
pot = MakePowerOfTwo( h );
shiftScale.y = (float)h / pot;
hackedView.shaderParms[4] = shiftScale.x;
hackedView.shaderParms[5] = shiftScale.y;
}
gameRenderWorld->RenderScene( &portalView );
renderSystem->CaptureRenderToImage( "_currentRender" );
hackedView.forceUpdate = true; // FIX: for smoke particles not drawing when portalSky present
} //else {
gameRenderWorld->RenderScene( &hackedView );
// }
// process the frame
// HEXEN : Zeroth - d3xp, not needed for skybox? fxManager->Process( &hackedView );
if ( player->spectating ) {
return;
}
// if ( !hud ) {
// return;
// }
// draw screen blobs
if ( !pm_thirdPerson.GetBool() && !g_skipViewEffects.GetBool() ) {
for ( int i = 0 ; i < MAX_SCREEN_BLOBS ; i++ ) {