diff --git a/base/src/client/progs.src b/base/src/client/progs.src index 70274ec5..a6b92e41 100644 --- a/base/src/client/progs.src +++ b/base/src/client/progs.src @@ -3,6 +3,7 @@ #define CSQC #define CLIENT +#define NEW_INVENTORY #includelist /* first the engine, then nuclide headers for client/shared */ diff --git a/base/src/server/player.qc b/base/src/server/player.qc index 07d8c64d..b6e10ae2 100644 --- a/base/src/server/player.qc +++ b/base/src/server/player.qc @@ -97,7 +97,7 @@ Player_UseUp(void) { } } -void Weapons_Draw(player); +void Weapons_Draw(NSClientPlayer); void CSEv_PlayerSwitchWeapon_i(int w) diff --git a/base/src/server/progs.src b/base/src/server/progs.src index e4659f56..249c1f94 100644 --- a/base/src/server/progs.src +++ b/base/src/server/progs.src @@ -3,6 +3,7 @@ #define QWSSQC #define SERVER +#define NEW_INVENTORY #includelist /* engine, then nuclide headers & functions */ diff --git a/base/src/shared/weapon_common.h b/base/src/shared/weapon_common.h index d6af29cc..1aac488d 100644 --- a/base/src/shared/weapon_common.h +++ b/base/src/shared/weapon_common.h @@ -14,6 +14,7 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef NEW_INVENTORY /* for AI identification purposes */ typedef enum { @@ -72,7 +73,7 @@ vector Weapons_GetCameraPos(player pl); void Weapons_ViewAnimation(player pl, int); void Weapons_ViewPunchAngle(player pl, vector); int Weapons_IsPresent(player, int); -void Weapons_UpdateAmmo(NSClientPlayer, int, int, int); +void Weapons_UpdateAmmo(player, int, int, int); int Weapons_GetAnimation(player pl); void Weapons_EnableModel(void); void Weapons_DisableModel(void); @@ -94,3 +95,5 @@ void Weapons_Sound(entity, float, string); string Weapons_GetPlayermodel(player, int); void Weapons_HUDPic(player, int, int, vector, float); #endif +#else +#endif \ No newline at end of file diff --git a/base/src/shared/weapon_common.qc b/base/src/shared/weapon_common.qc index 8d4b1c1b..9112dc80 100644 --- a/base/src/shared/weapon_common.qc +++ b/base/src/shared/weapon_common.qc @@ -14,6 +14,7 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef NEW_INVENTORY var int g_weapon_weights[g_weapons.length]; #ifdef CLIENT @@ -436,7 +437,7 @@ Sets .a_ammoX fields and clamps them so they can be networked as a single byte. ================= */ void -Weapons_UpdateAmmo(NSClientPlayer pl, int a1, int a2, int a3) +Weapons_UpdateAmmo(player pl, int a1, int a2, int a3) { /* no change */ if (a1 == -1) @@ -471,3 +472,4 @@ Weapons_Sound(entity pl, float channel, string snd) #endif #endif } +#endif \ No newline at end of file diff --git a/base/src/shared/weapons.qc b/base/src/shared/weapons.qc index 58e0255e..91f6fb1a 100644 --- a/base/src/shared/weapons.qc +++ b/base/src/shared/weapons.qc @@ -14,7 +14,9 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef NEW_INVENTORY weapon_t w_null = {}; weapon_t g_weapons[] = { w_null }; +#endif diff --git a/src/botlib/bot.qc b/src/botlib/bot.qc index 83ad8393..cda9df99 100644 --- a/src/botlib/bot.qc +++ b/src/botlib/bot.qc @@ -513,12 +513,14 @@ bot::PreFrame(void) void bot::PostFrame(void) { +#ifndef NEW_INVENTORY /* we've picked something new up */ if (m_iOldItems != g_items) { Weapons_SwitchBest(this); print(sprintf("%s is now using %s (%d)\n", netname, g_weapons[activeweapon].name, activeweapon)); m_iOldItems = g_items; } +#endif } void diff --git a/src/client/NSView.h b/src/client/NSView.h new file mode 100644 index 00000000..d8f3d32a --- /dev/null +++ b/src/client/NSView.h @@ -0,0 +1,41 @@ +/* The job of a NSView is to contain a single player seat. + Boxing is important for splitscreen etc. play. + + The NSView has a target, which may or may not have prediction + run on them. Things such as stair smoothing and viewmodel handling + is done in the NSView. +*/ + +class +NSView +{ + int m_iSeat; + + /* the dimensions of our view */ + vector m_vecPosition; + vector m_vecSize; + float m_flFieldOfView; + + /* the entity we're targetting */ + NSEntity m_viewTarget; + + NSClient m_client; + + void(void) NSView; + + virtual void(void) SetupView; + virtual void(void) RenderView; + + virtual void(vector) SetViewPosition; + virtual void(vector) SetViewSize; + virtual void(NSEntity) SetViewTarget; + virtual void(NSClient) SetClientOwner; + + virtual void(vector) SetCameraOrigin; + virtual void(vector) SetCameraAngle; + virtual void(int) SetSeatID; + virtual void(float) SetAFOV; +}; + +NSView g_viewSeats[4]; +NSView g_view; \ No newline at end of file diff --git a/src/client/NSView.qc b/src/client/NSView.qc new file mode 100644 index 00000000..847e0818 --- /dev/null +++ b/src/client/NSView.qc @@ -0,0 +1,83 @@ +void +NSView::SetupView(void) +{ + setproperty(VF_DRAWENGINESBAR, 0); + setproperty(VF_DRAWCROSSHAIR, 0); + setproperty(VF_DRAWWORLD, 1); + setproperty(VF_ACTIVESEAT, m_iSeat); + setproperty(VF_MIN, m_vecPosition); + setproperty(VF_SIZE, m_vecSize); + setproperty(VF_AFOV, m_flFieldOfView); + + /* this will hide said entity */ + setproperty(VF_VIEWENTITY, num_for_edict(m_viewTarget)); + + setproperty(VF_ORIGIN, origin); + //setproperty(VF_CL_VIEWANGLES, angles); + setproperty(VF_ANGLES, angles); +} + +void +NSView::RenderView(void) +{ + renderscene(); +} + +void +NSView::SetViewPosition(vector new_pos) +{ + m_vecPosition = new_pos; +} + +void +NSView::SetViewSize(vector new_size) +{ + m_vecSize = new_size; +} + +void +NSView::SetViewTarget(NSEntity new_target) +{ + m_viewTarget = new_target; +} + +void +NSView::SetCameraOrigin(vector new_origin) +{ + origin = new_origin; +} + +void +NSView::SetCameraAngle(vector new_angle) +{ + angles = new_angle; +} + +void +NSView::SetSeatID(int new_id) +{ + m_iSeat = new_id; +} + +void +NSView::SetClientOwner(NSClient new_owner) +{ + m_client = new_owner; +} + +void +NSView::SetAFOV(float new_fov) +{ + m_flFieldOfView = new_fov; +} + +void +NSView::NSView(void) +{ + m_viewTarget = __NULL__; + m_vecPosition = [0,0]; + m_vecSize = [0,0]; + m_iSeat = 0; + m_flFieldOfView = 90.0f; + m_client = __NULL__; +} \ No newline at end of file diff --git a/src/client/entry.qc b/src/client/entry.qc index d09f82bf..eca8e27a 100644 --- a/src/client/entry.qc +++ b/src/client/entry.qc @@ -105,7 +105,11 @@ CSQC_RendererRestarted(string rstr) /* View */ Chat_Init(); + +#ifndef NEW_INVENTORY Weapons_Init(); +#endif + Scores_Init(); View_Init(); ClientGame_RendererRestart(rstr); diff --git a/src/server/entry.qc b/src/server/entry.qc index 13a5eb14..d6a5680f 100644 --- a/src/server/entry.qc +++ b/src/server/entry.qc @@ -623,6 +623,13 @@ ConsoleCmd(string cmd) t.Trigger(self, TRIG_TOGGLE); } break; + case "goto_ent": + static entity finder; + finder = find(finder, ::classname, argv(1)); + + if (finder) + setorigin(pl, finder.origin); + break; case "respawn_ents": for (entity a = world; (a = findfloat(a, ::identity, 1));) { NSEntity ent = (NSEntity)a; @@ -630,7 +637,6 @@ ConsoleCmd(string cmd) } break; case "spawn": - entity unit = spawn(); unit.classname = strcat("spawnfunc_", argv(1)); self = unit; @@ -644,8 +650,6 @@ ConsoleCmd(string cmd) } traceline(pl.origin, pl.origin + (v_forward * 1024), MOVE_NORMAL, pl); setorigin(unit, trace_endpos); - - break; #ifdef BOT_INCLUDED case "way": diff --git a/src/server/weapons.h b/src/server/weapons.h index d7e0a64a..5e9445fb 100644 --- a/src/server/weapons.h +++ b/src/server/weapons.h @@ -20,7 +20,6 @@ void Weapons_SwitchBest(NSClientPlayer pl, optional float skip); int Weapons_AddItem(NSClientPlayer pl, int w, int startammo); void Weapons_RemoveItem(NSClientPlayer pl, int w); void Weapons_InitItem(int w); -void Weapons_UpdateAmmo(NSClientPlayer pl, int a1, int a2, int a3); void Weapons_ReloadWeapon(NSClientPlayer pl, .int mag, .int ammo, int max); void Weapon_DropCurrentWeapon(NSClientPlayer pl); int Weapon_GetCount(); diff --git a/src/server/weapons.qc b/src/server/weapons.qc index 7026317a..745402b3 100644 --- a/src/server/weapons.qc +++ b/src/server/weapons.qc @@ -14,6 +14,7 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef NEW_INVENTORY /* force the drawing of the first weapon that's picked up */ var int autocvar_sv_forceweapondraw = TRUE; @@ -372,3 +373,4 @@ CSEv_DropWeapon(void) player pl = (player)self; Weapon_DropCurrentWeapon(pl); } +#endif \ No newline at end of file diff --git a/src/shared/NSClientPlayer.h b/src/shared/NSClientPlayer.h index a3ff2693..8f327205 100644 --- a/src/shared/NSClientPlayer.h +++ b/src/shared/NSClientPlayer.h @@ -45,6 +45,11 @@ NSClientPlayer:NSClientSpectator PREDICTED_INT(g_items); PREDICTED_FLOAT(activeweapon); +#ifdef NEW_INVENTORY + NSWeapon m_weapons[MAX_WEAPONS]; + NSWeapon m_activeweapon; +#endif + /* vehicle info */ PREDICTED_ENT(vehicle); diff --git a/src/shared/NSMonster.qc b/src/shared/NSMonster.qc index 590d7346..6bf58e4f 100644 --- a/src/shared/NSMonster.qc +++ b/src/shared/NSMonster.qc @@ -14,8 +14,6 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -const int CONTENTBITS_MONSTER = CONTENTBIT_SOLID|CONTENTBIT_BODY|CONTENTBIT_MONSTERCLIP|CONTENTBIT_BOTCLIP; - #ifdef SERVER int NSMonster::GetTriggerCondition(void) diff --git a/src/shared/NSRenderableEntity.h b/src/shared/NSRenderableEntity.h index 63cc72cd..c25216c1 100644 --- a/src/shared/NSRenderableEntity.h +++ b/src/shared/NSRenderableEntity.h @@ -139,6 +139,11 @@ class NSRenderableEntity:NSEntity nonvirtual void(float) SetRenderMode; nonvirtual void(float) SetRenderAmt; nonvirtual void(vector) SetRenderColor; + nonvirtual void(float) SetBoneControl1; + nonvirtual void(float) SetBoneControl2; + nonvirtual void(float) SetBoneControl3; + nonvirtual void(float) SetBoneControl4; + nonvirtual void(float) SetBoneControl5; #ifdef CLIENT nonvirtual void(void) RenderFXPass; diff --git a/src/shared/NSWeapon.h b/src/shared/NSWeapon.h new file mode 100644 index 00000000..2ee59ff7 --- /dev/null +++ b/src/shared/NSWeapon.h @@ -0,0 +1,56 @@ +#define MAX_WEAPONS 32 + +class +NSWeapon:NSRenderableEntity +{ + entity m_owner; + + string m_strName; /* Full character name */ + int m_iSlot; + int m_iSlotPos; + bool m_bAllowDropping; + int m_iWeight; + + /* generic info */ + int m_iClip1; + int m_iClip2; + float m_flPrimaryNext; + float m_flSecondaryNext; + float m_flLastFired; + + /* inspired by GMOD API https://wiki.facepunch.com/gmod/Weapon */ + virtual string(void) GetPlayerModel; + virtual string(void) GetWorldModel; + virtual string(void) GetPrintName; + virtual bool(void) AllowDropping; + virtual int(void) GetPlayerAnim; /* aim anim */ + virtual string(void) GetObituaryMessage; + virtual int(void) GetType; + virtual entity(void) GetOwner; + virtual int(void) GetClip1; /* returns primary attack clip */ + virtual int(void) GetClip2; /* returns secondary attack clip */ + virtual int(void) GetMaxClip1; /* returns primary max clip size */ + virtual int(void) GetMaxClip2; /* returns secondary max clip size */ + virtual float(void) GetNextPrimaryFire; /* gets next time the primary can fire */ + virtual float(void) GetNextSecondaryFire;/* gets next time the secondary can fire */ + virtual bool(void) HasAmmo; + virtual int(void) GetSlot; + virtual int(void) GetSlotPos; + virtual int(void) GetWeight; + virtual float(void) LastFireTime; /* returns absolute time at which the weapon was last fired */ + virtual void(int) SetClip1; /* sets the primary ammo clip */ + virtual void(int) SetClip2; /* sets the secondary ammo clip */ + virtual bool(void) AllowsAutoSwitchFrom; /* whether the weapon allows to being switched from when a better weighted weapon is picked up */ + virtual bool(void) AllowsAutoSwitchTo; /* whether the weapon allows to being switched to when a better weighted weapon is picked up */ + + /* calls */ + virtual void(void) Precache; + virtual void(void) Draw; + virtual void(void) Holster; + virtual void(void) Primary; + virtual void(void) Secondary; + virtual void(void) Reload; + virtual void(void) Release; + virtual void(void) ClientPredraw; + virtual void(void) ClientPostdraw; +}; \ No newline at end of file diff --git a/src/shared/NSWeapon.qc b/src/shared/NSWeapon.qc new file mode 100644 index 00000000..37d94cdc --- /dev/null +++ b/src/shared/NSWeapon.qc @@ -0,0 +1,196 @@ +/* calls */ +void +NSWeapon::Precache(void) +{ +} + +void +NSWeapon::Draw(void) +{ +} + +void +NSWeapon::Holster(void) +{ +} + +void +NSWeapon::Primary(void) +{ +} + +void +NSWeapon::Secondary(void) +{ +} + +void +NSWeapon::Reload(void) +{ +} + +void +NSWeapon::Release(void) +{ +} + +void +NSWeapon::ClientPredraw(void) +{ +} + +void +NSWeapon::ClientPostdraw(void) +{ +} + +/* get */ +string +NSWeapon::GetPlayerModel(void) +{ + return "models/error.vvm"; +} + +string +NSWeapon::GetWorldModel(void) +{ + return "models/error.vvm"; +} + +string +NSWeapon::GetPrintName(void) +{ + return m_strName; +} + +int +NSWeapon::GetSlot(void) +{ + return m_iSlot; +} + +int +NSWeapon::GetSlotPos(void) +{ + return m_iSlotPos; +} + +bool +NSWeapon::AllowDropping(void) +{ + return false; +} + +int +NSWeapon::GetWeight(void) +{ + return 0; +} + +int +NSWeapon::GetPlayerAnim(void) +{ + return 0; +} + +bool +NSWeapon::IsEmpty(void) +{ + return false; +} + +string +NSWeapon::GetObituaryMessage(void) +{ + return "%s killed %s with Unknown"; +} + +int +NSWeapon::GetType(void) +{ + return 0; +} + +entity +NSWeapon::GetOwner(void) +{ + return m_owner; +} + +int +NSWeapon::GetClip1(void) +{ + return 0; +} + +int +NSWeapon::GetClip2(void) +{ + return 0; +} + +int +NSWeapon::GetMaxClip1(void) +{ + return 0; +} + +int +NSWeapon::GetMaxClip2(void) +{ + return 0; +} + +float +NSWeapon::GetNextPrimaryFire(void) +{ + return m_flPrimaryNext; +} + +float +NSWeapon::GetNextSecondaryFire(void) +{ + return m_flSecondaryNext; +} + +float +NSWeapon::LastFireTime(void) +{ + return m_flLastFired; +} + +void +NSWeapon::SetClip1(int new_clip) +{ + m_iClip1 = new_clip; +} + +void +NSWeapon::SetClip2(int new_clip) +{ + m_iClip1 = new_clip; +} + +bool +NSWeapon::AllowsAutoSwitchFrom(void) +{ + +} + +bool +NSWeapon::AllowsAutoSwitchTo(void) +{ + +} + +bool +NSWeapon::HasAmmo(void) +{ + return false; +} + +void +NSWeapon::NSWeapon(void) +{ + +} \ No newline at end of file diff --git a/src/shared/defs.h b/src/shared/defs.h index 5f124d49..001b1cd7 100644 --- a/src/shared/defs.h +++ b/src/shared/defs.h @@ -61,6 +61,7 @@ string __fullspawndata; #include "../xr/defs.h" #include "NSClient.h" #include "NSClientSpectator.h" +#include "NSWeapon.h" #include "NSClientPlayer.h" #include "NSVehicle.h" @@ -80,6 +81,7 @@ string __fullspawndata; #include "propdata.h" #include "surfaceproperties.h" #include "colors.h" +#include "weapons.h" #define BSPVER_PREREL 28 #define BSPVER_Q1 29 diff --git a/src/shared/include.src b/src/shared/include.src index 11a4f04a..4577d9e6 100644 --- a/src/shared/include.src +++ b/src/shared/include.src @@ -8,6 +8,7 @@ NSSurfacePropEntity.qc NSPhysicsEntity.qc NSBrushTrigger.qc NSPointTrigger.qc +NSWeapon.qc NSVehicle.qc NSNavAI.qc NSMonster.qc @@ -26,6 +27,8 @@ propdata.qc surfaceproperties.qc NSMaterial.qc util.qc +weapons.qc + ../xr/include.src ../materials/include.src #endlist diff --git a/src/shared/materials.h b/src/shared/materials.h index c5dd4034..3221eb1f 100644 --- a/src/shared/materials.h +++ b/src/shared/materials.h @@ -208,7 +208,9 @@ const int CONTENTBIT_UNUSED15 = 0x10000000i; const int CONTENTBIT_Q2LADDER = 0x20000000i; /* Q2BSP climbables */ const int CONTENTBIT_UNUSED16 = 0x40000000i; const int CONTENTBIT_SKY = 0x80000000i; /* Q1BSP only! */ - + +/* a bit content group */ +const int CONTENTBITS_MONSTER = CONTENTBIT_SOLID|CONTENTBIT_BODY|CONTENTBIT_MONSTERCLIP|CONTENTBIT_BOTCLIP; /* this is used for material-lookups using the external materials.txt file * method used in Half-Life. In that environment we have to strip any diff --git a/src/shared/weapons.h b/src/shared/weapons.h new file mode 100644 index 00000000..c09e4b94 --- /dev/null +++ b/src/shared/weapons.h @@ -0,0 +1,27 @@ +#ifdef NEW_INVENTORY +/* for AI identification purposes */ +typedef enum +{ + WPNTYPE_INVALID, /* no logic */ + WPNTYPE_RANGED, /* will want to keep their distance mostly */ + WPNTYPE_THROW, /* has to keep some distance, but not too far */ + WPNTYPE_CLOSE, /* have to get really close */ + WPNTYPE_FULLAUTO, /* for things that need to be held down */ + WPNTYPE_SEMI /* semi automatic */ +} weapontype_t; + +void Weapons_Draw(NSClientPlayer); +void Weapons_Release(NSClientPlayer); +void Weapons_Primary(NSClientPlayer); +void Weapons_Secondary(NSClientPlayer); +void Weapons_Reload(NSClientPlayer); +void Weapons_Init(void); +string Weapons_GetWorldmodel(int); +weapontype_t Weapons_GetType(NSClientPlayer, int); +int Weapons_IsEmpty(NSClientPlayer, int); +void Weapons_UpdateAmmo(NSClientPlayer, int, int, int); + +#ifdef CLIENT +void Weapons_SetGeomset(string); +#endif +#endif \ No newline at end of file diff --git a/src/shared/weapons.qc b/src/shared/weapons.qc new file mode 100644 index 00000000..e62c806e --- /dev/null +++ b/src/shared/weapons.qc @@ -0,0 +1,92 @@ +#ifdef NEW_INVENTORY +void +Weapons_Init(void) +{ + +} + +string +Weapons_GetWorldmodel(int) +{ + return ""; +} + +void +Weapons_Draw(NSClientPlayer pl) +{ + if (pl.m_activeweapon) + pl.m_activeweapon.Draw(); +} + +void +Weapons_Release(NSClientPlayer pl) +{ + if (pl.m_activeweapon) + pl.m_activeweapon.Release(); +} + +void +Weapons_Primary(NSClientPlayer pl) +{ + if (pl.m_activeweapon) + pl.m_activeweapon.Primary(); +} + +void +Weapons_Secondary(NSClientPlayer pl) +{ + if (pl.m_activeweapon) + pl.m_activeweapon.Secondary(); +} + +void +Weapons_Reload(NSClientPlayer pl) +{ + if (pl.m_activeweapon) + pl.m_activeweapon.Reload(); +} + +void +Weapons_SetGeomset(string foo) +{ + +} + +weapontype_t +Weapons_GetType(NSClientPlayer pl, int w) +{ + if (pl.m_activeweapon) + return pl.m_activeweapon.GetType(); + + return WPNTYPE_INVALID; +} + +void +Weapons_UpdateAmmo(NSClientPlayer pl, int a1, int a2, int a3) +{ + /* no change */ + if (a1 == -1) + a1 = pl.a_ammo1; + if (a2 == -1) + a2 = pl.a_ammo2; + if (a3 == -1) + a3 = pl.a_ammo3; + + /* networked as bytes, since we don't need more. Clamp to avoid errors */ + pl.a_ammo1 = a1; + pl.a_ammo2 = a2; + pl.a_ammo3 = a3; +} + +void Weapons_PickupNotify(NSClientPlayer pl, int w) {} +void Weapons_RefreshAmmo(NSClientPlayer pl) {} +void Weapons_SwitchBest(NSClientPlayer pl, optional float skip) {} +int Weapons_AddItem(NSClientPlayer pl, int w, int startammo) {} +void Weapons_RemoveItem(NSClientPlayer pl, int w) {} +void Weapons_InitItem(int w) {} +void Weapons_ReloadWeapon(NSClientPlayer pl, .int mag, .int ammo, int max) {} +void Weapon_DropCurrentWeapon(NSClientPlayer pl) {} +int Weapon_GetCount() {} +int Weapon_GetBitID(int) {} +int Weapons_IsEmpty(NSClientPlayer, int) {} +#endif \ No newline at end of file