From 163e7d0f3a71fb78e3abd1eeea3a1d5408105dca Mon Sep 17 00:00:00 2001 From: div0 Date: Sun, 9 Nov 2008 10:11:56 +0000 Subject: [PATCH] new weapon arena menu controls, enjoy! Original code by MirceaKitsune git-svn-id: svn://svn.icculus.org/nexuiz/trunk@5022 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- data/qcsrc/client/progs.src | 2 + data/qcsrc/common/constants.qh | 53 -------- data/qcsrc/common/items.qc | 115 ++++++++++++++++++ data/qcsrc/common/items.qh | 77 ++++++++++++ data/qcsrc/common/util.qc | 79 ++++++++++++ data/qcsrc/common/util.qh | 3 + data/qcsrc/menu/menu.qc | 2 + .../dialog_multiplayer_create_mutators.c | 87 +++++++++++-- data/qcsrc/menu/nexuiz/weaponslist.c | 32 ++--- data/qcsrc/menu/progs.src | 2 + data/qcsrc/server/cl_weapons.qc | 26 ---- data/qcsrc/server/cl_weaponsystem.qc | 82 ------------- data/qcsrc/server/miscfunctions.qc | 85 +------------ data/qcsrc/server/progs.src | 8 +- data/qcsrc/server/sys.qh | 1 + 15 files changed, 372 insertions(+), 282 deletions(-) create mode 100644 data/qcsrc/common/items.qc create mode 100644 data/qcsrc/common/items.qh diff --git a/data/qcsrc/client/progs.src b/data/qcsrc/client/progs.src index 82dcaebd5..920f8cc45 100644 --- a/data/qcsrc/client/progs.src +++ b/data/qcsrc/client/progs.src @@ -7,6 +7,7 @@ csqc_constants.qc ../common/constants.qh csqc_builtins.qc ../common/util.qh +../common/items.qh ../common/mapinfo.qh interpolate.qh @@ -37,3 +38,4 @@ waypointsprites.qc ../common/util.qc ../common/gamecommand.qc ../common/mapinfo.qc +../common/items.qc diff --git a/data/qcsrc/common/constants.qh b/data/qcsrc/common/constants.qh index 9ce48f560..bd5df3f1d 100644 --- a/data/qcsrc/common/constants.qh +++ b/data/qcsrc/common/constants.qh @@ -298,56 +298,3 @@ const float RACE_NET_CHECKPOINT_NEXT_SPEC_QUALIFYING = 5; // byte nextcheckpoint #define SP_SUICIDES 2 #define SP_SCORE 3 // game mode specific indices are not in common/, but in server/scores_rules.qc! - -// Weapon indexes -// %weaponaddpoint -float WEP_FIRST = 1; -float WEP_LASER = 1; float WEPBIT_LASER = 1; // always: 2^(w-1) -float WEP_SHOTGUN = 2; float WEPBIT_SHOTGUN = 2; -float WEP_UZI = 3; float WEPBIT_UZI = 4; -float WEP_GRENADE_LAUNCHER = 4; float WEPBIT_GRENADE_LAUNCHER = 8; -float WEP_ELECTRO = 5; float WEPBIT_ELECTRO = 16; -float WEP_CRYLINK = 6; float WEPBIT_CRYLINK = 32; -float WEP_NEX = 7; float WEPBIT_NEX = 64; -float WEP_HAGAR = 8; float WEPBIT_HAGAR = 128; -float WEP_ROCKET_LAUNCHER = 9; float WEPBIT_ROCKET_LAUNCHER = 256; -float WEP_PORTO = 10; float WEPBIT_PORTO = 512; -float WEP_MINSTANEX = 11; float WEPBIT_MINSTANEX = 1024; -float WEP_HOOK = 12; float WEPBIT_HOOK = 2048; -float WEP_HLAC = 13; float WEPBIT_HLAC = 4096; -float WEP_SEEKER = 14; float WEPBIT_SEEKER = 8192; -float WEP_LAST = 14; float WEPBIT_ALL = 16383; -float WEP_COUNT = 15; - -float IT_UNLIMITED_WEAPON_AMMO = 1; -// when this bit is set, using a weapon does not reduce ammo. Checkpoints can give this powerup. -float IT_UNLIMITED_SUPERWEAPONS = 2; -// when this bit is set, using a superweapon does not throw it away. Checkpoints can give this powerup. -float IT_UNLIMITED_AMMO = 3; -// both of these combined -float IT_CTF_SHIELDED = 4; // set for the flag shield -float IT_SHELLS = 256; -float IT_NAILS = 512; -float IT_ROCKETS = 1024; -float IT_CELLS = 2048; -float IT_SUPERWEAPON = 4096; -float IT_AMMO = 7936; -float IT_STRENGTH = 8192; -float IT_INVINCIBLE = 16384; -float IT_HEALTH = 32768; -// union: - // for items: - float IT_KEY1 = 131072; - float IT_KEY2 = 262144; - // for players: - float IT_RED_FLAG_TAKEN = 32768; - float IT_RED_FLAG_LOST = 65536; - float IT_RED_FLAG_CARRING = 98304; - float IT_BLUE_FLAG_TAKEN = 131072; - float IT_BLUE_FLAG_LOST = 262144; - float IT_BLUE_FLAG_CARRING = 393216; -// end -float IT_5HP = 524288; -float IT_25HP = 1048576; -float IT_ARMOR_SHARD = 2097152; -float IT_ARMOR = 4194304; diff --git a/data/qcsrc/common/items.qc b/data/qcsrc/common/items.qc new file mode 100644 index 000000000..2accc94cc --- /dev/null +++ b/data/qcsrc/common/items.qc @@ -0,0 +1,115 @@ +// WEAPON PLUGIN SYSTEM +entity weapon_info[24]; +entity dummy_weapon_info; + +void register_weapon_real(float id, float(float) func, float ammotype, float i, float normalweapon, float canclimb, float pickupbasevalue, string modelname, string shortname, string wname) +{ + entity e; + weapon_info[id - 1] = e = spawn(); + e.classname = "weapon_info"; + e.weapon = id; + e.weapons = power2of(id - 1); + e.netname = shortname; + e.message = wname; + e.items = ammotype; + e.weapon_func = func; + e.mdl = modelname; + e.model = strzone(strcat("models/weapons/g_", modelname, ".md3")); + e.spawnflags = 0; + if(normalweapon) + e.spawnflags |= WEPSPAWNFLAG_NORMAL; + if(canclimb) + e.spawnflags |= WEPSPAWNFLAG_CANCLIMB; + e.impulse = i; + e.bot_pickupbasevalue = pickupbasevalue; +} +float w_null(float dummy) +{ + return 0; +} +void register_weapons_done() +{ + entity wi; + + dummy_weapon_info = spawn(); + dummy_weapon_info.classname = "weapon_info"; + dummy_weapon_info.weapon = 0; + dummy_weapon_info.weapons = 0; + dummy_weapon_info.netname = "@!#%'n Tuba"; + dummy_weapon_info.items = 0; + dummy_weapon_info.weapon_func = w_null; + dummy_weapon_info.mdl = ""; + dummy_weapon_info.model = ""; + dummy_weapon_info.spawnflags = 0; + dummy_weapon_info.impulse = -1; + dummy_weapon_info.bot_pickupbasevalue = 0; + + float i; + weaponpriority_hudselector_0 = ""; + for(i = 24; i >= 1; --i) + if(weapon_info[i-1]) + weaponpriority_hudselector_0 = strcat(weaponpriority_hudselector_0, " ", ftos(i)); + + float imp; + weaponpriority_hudselector_1 = ""; + for(i = 1; i <= 24; ++i) + { + wi = weapon_info[i-1]; + if(wi && wi.impulse == 0) + weaponpriority_hudselector_1 = strcat(weaponpriority_hudselector_1, " ", ftos(i)); + } + for(imp = 9; imp > 0; --imp) + for(i = 1; i <= 24; ++i) + { + wi = weapon_info[i-1]; + if(wi && wi.impulse == imp) + weaponpriority_hudselector_1 = strcat(weaponpriority_hudselector_1, " ", ftos(i)); + } + + weaponpriority_hudselector_0 = strzone(substring(weaponpriority_hudselector_0, 1, strlen(weaponpriority_hudselector_0) - 1)); + weaponpriority_hudselector_1 = strzone(substring(weaponpriority_hudselector_1, 1, strlen(weaponpriority_hudselector_1) - 1)); +} +entity get_weaponinfo(float id) +{ + entity w; + if(id < WEP_FIRST || id > WEP_LAST) + return dummy_weapon_info; + w = weapon_info[id - 1]; + if(w) + return w; + return dummy_weapon_info; +} +string W_FixWeaponOrder(string order, float complete) +{ + return fixPriorityList(order, WEP_FIRST, WEP_LAST, complete); +} + +#ifdef SVQC +#define register_weapon(id,func,ammotype,i,normalweapon,canclimb,pickupbasevalue,modelname,shortname,wname) \ + register_weapon_real(id,func,ammotype,i,normalweapon,canclimb,pickupbasevalue,modelname,shortname,wname) +#else +// no weapon funcs here! +#define register_weapon(id,func,ammotype,i,normalweapon,canclimb,pickupbasevalue,modelname,shortname,wname) \ + register_weapon_real(id,w_null,ammotype,i,normalweapon,canclimb,pickupbasevalue,modelname,shortname,wname) +#endif + +void RegisterWeapons() +{ + // %weaponaddpoint + register_weapon(WEP_LASER, w_laser, 0, 1, 1, 1, 0, "laser", "laser", "Laser"); + register_weapon(WEP_SHOTGUN, w_shotgun, IT_SHELLS, 2, 1, 0, 2500, "shotgun", "shotgun", "Shotgun"); + register_weapon(WEP_UZI, w_uzi, IT_NAILS, 3, 1, 0, 5000, "uzi", "uzi", "Machine Gun"); + register_weapon(WEP_GRENADE_LAUNCHER, w_glauncher, IT_ROCKETS, 4, 1, 1, 5000, "gl", "grenadelauncher", "Mortar"); + register_weapon(WEP_ELECTRO, w_electro, IT_CELLS, 5, 1, 0, 5000, "electro", "electro", "Electro"); + register_weapon(WEP_CRYLINK, w_crylink, IT_CELLS, 6, 1, 0, 5000, "crylink", "crylink", "Crylink"); + register_weapon(WEP_NEX, w_nex, IT_CELLS, 7, 1, 0, 10000, "nex", "nex", "Nex"); + register_weapon(WEP_HAGAR, w_hagar, IT_ROCKETS, 8, 1, 1, 5000, "hagar", "hagar", "Hagar"); + register_weapon(WEP_ROCKET_LAUNCHER, w_rlauncher, IT_ROCKETS, 9, 1, 1, 10000, "rl", "rocketlauncher", "Rocket Launcher"); + register_weapon(WEP_PORTO, w_porto, IT_SUPERWEAPON, 0, 0, 0, 0, "porto" , "porto", "Port-O-Launch"); + register_weapon(WEP_MINSTANEX, w_minstanex, IT_CELLS, 7, 0, 1, 10000, "minstanex", "minstanex", "MinstaNex"); + register_weapon(WEP_HOOK, w_hook, IT_CELLS, 0, 0, 1, 0, "hookgun", "hook", "Grappling Hook"); + register_weapon(WEP_SEEKER, w_seeker, IT_ROCKETS, 8, 1, 0, 0, "seeker", "seeker", "T.A.G. Seeker"); + register_weapon(WEP_HLAC, w_hlac, IT_CELLS, 6, 1, 0, 0, "hlac", "hlac", "Heavy Laser Assault Cannon"); + + register_weapons_done(); +} diff --git a/data/qcsrc/common/items.qh b/data/qcsrc/common/items.qh new file mode 100644 index 000000000..12c451030 --- /dev/null +++ b/data/qcsrc/common/items.qh @@ -0,0 +1,77 @@ +// Weapon indexes +// %weaponaddpoint +float WEP_FIRST = 1; +float WEP_LASER = 1; float WEPBIT_LASER = 1; // always: 2^(w-1) +float WEP_SHOTGUN = 2; float WEPBIT_SHOTGUN = 2; +float WEP_UZI = 3; float WEPBIT_UZI = 4; +float WEP_GRENADE_LAUNCHER = 4; float WEPBIT_GRENADE_LAUNCHER = 8; +float WEP_ELECTRO = 5; float WEPBIT_ELECTRO = 16; +float WEP_CRYLINK = 6; float WEPBIT_CRYLINK = 32; +float WEP_NEX = 7; float WEPBIT_NEX = 64; +float WEP_HAGAR = 8; float WEPBIT_HAGAR = 128; +float WEP_ROCKET_LAUNCHER = 9; float WEPBIT_ROCKET_LAUNCHER = 256; +float WEP_PORTO = 10; float WEPBIT_PORTO = 512; +float WEP_MINSTANEX = 11; float WEPBIT_MINSTANEX = 1024; +float WEP_HOOK = 12; float WEPBIT_HOOK = 2048; +float WEP_HLAC = 13; float WEPBIT_HLAC = 4096; +float WEP_SEEKER = 14; float WEPBIT_SEEKER = 8192; +float WEP_LAST = 14; float WEPBIT_ALL = 16383; +float WEP_COUNT = 15; + +float IT_UNLIMITED_WEAPON_AMMO = 1; +// when this bit is set, using a weapon does not reduce ammo. Checkpoints can give this powerup. +float IT_UNLIMITED_SUPERWEAPONS = 2; +// when this bit is set, using a superweapon does not throw it away. Checkpoints can give this powerup. +float IT_UNLIMITED_AMMO = 3; +// both of these combined +float IT_CTF_SHIELDED = 4; // set for the flag shield +float IT_SHELLS = 256; +float IT_NAILS = 512; +float IT_ROCKETS = 1024; +float IT_CELLS = 2048; +float IT_SUPERWEAPON = 4096; +float IT_AMMO = 7936; +float IT_STRENGTH = 8192; +float IT_INVINCIBLE = 16384; +float IT_HEALTH = 32768; +// union: + // for items: + float IT_KEY1 = 131072; + float IT_KEY2 = 262144; + // for players: + float IT_RED_FLAG_TAKEN = 32768; + float IT_RED_FLAG_LOST = 65536; + float IT_RED_FLAG_CARRING = 98304; + float IT_BLUE_FLAG_TAKEN = 131072; + float IT_BLUE_FLAG_LOST = 262144; + float IT_BLUE_FLAG_CARRING = 393216; +// end +float IT_5HP = 524288; +float IT_25HP = 1048576; +float IT_ARMOR_SHARD = 2097152; +float IT_ARMOR = 4194304; + +// variables: +string weaponpriority_hudselector_0; +string weaponpriority_hudselector_1; + +// functions: +entity get_weaponinfo(float id); +string W_FixWeaponOrder(string order, float complete); +void RegisterWeapons(); + +#define WEPSPAWNFLAG_NORMAL 1 +#define WEPSPAWNFLAG_CANCLIMB 2 + +// entity properties of weaponinfo: +.float weapon; // WEP_... +.float weapons; // WEPBIT_... +.string netname; // short name +.string message; // human readable name +.float items; // IT_... +.float(float) weapon_func; // w_... +.string mdl; // modelname without g_, v_, w_ +.string model; // full name of g_ model +.float spawnflags; // WEPSPAWNFLAG_... combined +.float impulse; // weapon impulse +.float bot_pickupbasevalue; // bot weapon priority diff --git a/data/qcsrc/common/util.qc b/data/qcsrc/common/util.qc index 3e56701d2..80bc4516c 100644 --- a/data/qcsrc/common/util.qc +++ b/data/qcsrc/common/util.qc @@ -1052,3 +1052,82 @@ float tokenizebyseparator(string s, string sep) argv_end_index = func_null; return _tokenizebyseparator_builtin(s, sep); } + +float power2of(float e) +{ + return pow(2, e); +} +float log2of(float x) +{ + // NOTE: generated code + if(x > 2048) + if(x > 131072) + if(x > 1048576) + if(x > 4194304) + return 23; + else + if(x > 2097152) + return 22; + else + return 21; + else + if(x > 524288) + return 20; + else + if(x > 262144) + return 19; + else + return 18; + else + if(x > 16384) + if(x > 65536) + return 17; + else + if(x > 32768) + return 16; + else + return 15; + else + if(x > 8192) + return 14; + else + if(x > 4096) + return 13; + else + return 12; + else + if(x > 32) + if(x > 256) + if(x > 1024) + return 11; + else + if(x > 512) + return 10; + else + return 9; + else + if(x > 128) + return 8; + else + if(x > 64) + return 7; + else + return 6; + else + if(x > 4) + if(x > 16) + return 5; + else + if(x > 8) + return 4; + else + return 3; + else + if(x > 2) + return 2; + else + if(x > 1) + return 1; + else + return 0; +} diff --git a/data/qcsrc/common/util.qh b/data/qcsrc/common/util.qh index f32df285f..045f2fd5e 100644 --- a/data/qcsrc/common/util.qh +++ b/data/qcsrc/common/util.qh @@ -116,3 +116,6 @@ var float(float) argv_end_index; float tokenize_sane(string s); float tokenize_insane(string s); float tokenizebyseparator(string s, string sep); + +float power2of(float e); +float log2of(float x); diff --git a/data/qcsrc/menu/menu.qc b/data/qcsrc/menu/menu.qc index 18863851d..01f6220fd 100644 --- a/data/qcsrc/menu/menu.qc +++ b/data/qcsrc/menu/menu.qc @@ -63,6 +63,8 @@ void() m_init_delayed = menuInitialized = 1; GameCommand_Init(); + RegisterWeapons(); + fh = -1; if(cvar_string("menu_skin") != "") { diff --git a/data/qcsrc/menu/nexuiz/dialog_multiplayer_create_mutators.c b/data/qcsrc/menu/nexuiz/dialog_multiplayer_create_mutators.c index 171370bda..aa2bc40e2 100644 --- a/data/qcsrc/menu/nexuiz/dialog_multiplayer_create_mutators.c +++ b/data/qcsrc/menu/nexuiz/dialog_multiplayer_create_mutators.c @@ -6,9 +6,9 @@ CLASS(NexuizMutatorsDialog) EXTENDS(NexuizDialog) METHOD(NexuizMutatorsDialog, close, void(entity)) ATTRIB(NexuizMutatorsDialog, title, string, "Mutators") ATTRIB(NexuizMutatorsDialog, color, vector, SKINCOLOR_DIALOG_MUTATORS) - ATTRIB(NexuizMutatorsDialog, intendedWidth, float, 0.6) - ATTRIB(NexuizMutatorsDialog, rows, float, 9) - ATTRIB(NexuizMutatorsDialog, columns, float, 4) + ATTRIB(NexuizMutatorsDialog, intendedWidth, float, 0.8) + ATTRIB(NexuizMutatorsDialog, rows, float, 16) + ATTRIB(NexuizMutatorsDialog, columns, float, 6) ATTRIB(NexuizMutatorsDialog, refilterEntity, entity, NULL) ENDCLASS(NexuizMutatorsDialog) #endif @@ -16,8 +16,50 @@ ENDCLASS(NexuizMutatorsDialog) #ifdef IMPLEMENTATION void showNotifyNexuizMutatorsDialog(entity me) { - loadAllCvars(me); + loadAllCvars(me); } + +string weaponarenastring; +string weaponarenastring_cvar; +string WeaponArenaString() +{ + string s; + float n, i, j; + entity e; + s = cvar_string("g_weaponarena"); + if(s == "0") + return ""; + if(s == "all") + return "All Weapons Arena"; + if(s == "most") + return "Most Weapons Arena"; + if(s == weaponarenastring_cvar) + return weaponarenastring; + if(weaponarenastring) + strunzone(weaponarenastring); + if(weaponarenastring_cvar) + strunzone(weaponarenastring_cvar); + + weaponarenastring_cvar = strzone(s); + + n = tokenize_sane(s); + s = ""; + for(i = 0; i < n; ++i) + { + for(j = WEP_FIRST; j <= WEP_LAST; ++j) + { + e = get_weaponinfo(j); + if(argv(i) == e.netname) + s = strcat(s, " & ", e.message); + } + } + s = strcat(substring(s, 3, strlen(s) - 3), " Arena"); + + weaponarenastring = strzone(s); + + return weaponarenastring; +} + string toStringNexuizMutatorsDialog(entity me) { string s; @@ -27,7 +69,7 @@ string toStringNexuizMutatorsDialog(entity me) if(cvar("g_nixnex")) s = strcat(s, ", NixNex"); if(cvar_string("g_weaponarena") != "0") - s = strcat(s, ", ", cvar_string("g_weaponarena"), " arena"); + s = strcat(s, ", ", WeaponArenaString()); if(cvar("sv_gravity") < 800) s = strcat(s, ", Low gravity"); if(cvar("g_cloaked")) @@ -49,7 +91,9 @@ string toStringNexuizMutatorsDialog(entity me) } void fillNexuizMutatorsDialog(entity me) { - entity e, s; + entity e, s, w; + float i, j; + string str, hstr; me.TR(me); me.TD(me, 1, 2, makeNexuizTextLabel(0, "Game mutators:")); me.TR(me); @@ -66,19 +110,36 @@ void fillNexuizMutatorsDialog(entity me) me.TD(me, 1, 2, e = makeNexuizCheckBox(0, "g_vampire", "Vampire")); me.gotoRC(me, 0, 2); me.setFirstColumn(me, me.currentColumn); - me.TD(me, 1, 2, makeNexuizTextLabel(0, "Arena mutators:")); + me.TD(me, 1, 4, makeNexuizTextLabel(0, "Weapon arenas:")); + me.TR(me); + me.TD(me, 1, 4, e = makeNexuizRadioButton(1, string_null, string_null, "Regular (no arena)")); + for(i = WEP_FIRST, j = 0; i <= WEP_LAST; ++i, ++j) + { + w = get_weaponinfo(i); + if(j & 1 == 0) + me.TR(me); + str = w.netname; + hstr = w.message; + if not(w.spawnflags & WEPSPAWNFLAG_CANCLIMB) + { + str = strcat(str, " laser"); + hstr = strcat(hstr, " & Laser"); + } + me.TD(me, 1, 2, e = makeNexuizRadioButton(1, "g_weaponarena", strzone(str), strzone(hstr))); + e.cvarOffValue = "0"; + } me.TR(me); - me.TD(me, 1, 2, e = makeNexuizRadioButton(1, string_null, string_null, "Regular")); + me.TD(me, 1, 4, makeNexuizTextLabel(0, "Special arenas:")); me.TR(me); - me.TD(me, 1, 2, e = makeNexuizRadioButton(1, "g_minstagib", string_null, "MinstaGib")); + me.TD(me, 1, 4, e = makeNexuizRadioButton(1, "g_minstagib", string_null, "MinstaGib")); me.TR(me); - me.TD(me, 1, 2, e = makeNexuizRadioButton(1, "g_nixnex", string_null, "NixNex")); + me.TD(me, 1, 4, e = makeNexuizRadioButton(1, "g_nixnex", string_null, "NixNex")); me.TR(me); me.TDempty(me, 0.2); - me.TD(me, 1, 1.8, e = makeNexuizCheckBox(1, "g_nixnex_with_laser", "with laser")); + me.TD(me, 1, 3.8, e = makeNexuizCheckBox(1, "g_nixnex_with_laser", "with laser")); setDependent(e, "g_nixnex", 1, 1); me.TR(me); - me.TD(me, 1, 2, e = makeNexuizRadioButton(1, "g_weaponarena", "rocketlauncher", "Rocket launcher arena")); + me.TD(me, 1, 4, e = makeNexuizRadioButton(1, "g_weaponarena", "all", "All weapons")); e.cvarOffValue = "0"; me.gotoRC(me, me.rows - 2, 0); @@ -87,7 +148,7 @@ void fillNexuizMutatorsDialog(entity me) s.valueDisplayMultiplier = 0.125; // show gravity in percent me.TD(me, 1, 1, e = makeNexuizSliderCheckBox(800, 1, s, "Low gravity")); e.savedValue = 200; // good on silvercity - me.TD(me, 1, 3, s); + me.TD(me, 1, 5, s); me.gotoRC(me, me.rows - 1, 0); me.TD(me, 1, me.columns, e = makeNexuizButton("OK", '0 0 0')); diff --git a/data/qcsrc/menu/nexuiz/weaponslist.c b/data/qcsrc/menu/nexuiz/weaponslist.c index d364074fc..df4aaf838 100644 --- a/data/qcsrc/menu/nexuiz/weaponslist.c +++ b/data/qcsrc/menu/nexuiz/weaponslist.c @@ -76,43 +76,27 @@ float mouseDragNexuizWeaponsList(entity me, vector pos) cvar_set("cl_weaponpriority", swapInPriorityList(cvar_string("cl_weaponpriority"), me.selectedItem, i)); return f; } -string WeaponName(float w) -{ - switch(w) - { - //%weaponaddpoint - case WEP_LASER: return "Laser"; - case WEP_SHOTGUN: return "Shotgun"; - case WEP_UZI: return "Machine Gun"; - case WEP_GRENADE_LAUNCHER: return "Mortar"; - case WEP_ELECTRO: return "Electro"; - case WEP_CRYLINK: return "Crylink"; - case WEP_NEX: return "Nex"; - case WEP_HAGAR: return "Hagar"; - case WEP_ROCKET_LAUNCHER: return "Rocket Launcher"; - case WEP_PORTO: return "Port-O-Launch"; - case WEP_MINSTANEX: return "MinstaNex"; - case WEP_HOOK: return "Grappling Hook"; - case WEP_HLAC: return "Heavy Laser Assault Cannon"; - case WEP_SEEKER: return "T.A.G. Seeker"; - default: return "(fix qcsrc/menu/nexuiz/weaponslist.c)"; - } -} string toStringNexuizWeaponsList(entity me) { float n, i; string s; + entity e; n = tokenize_sane(cvar_string("cl_weaponpriority")); s = ""; for(i = 0; i < n; ++i) - s = strcat(s, WeaponName(stof(argv(i))), ", "); + { + e = get_weaponinfo(stof(argv(i))); + s = strcat(s, e.message, ", "); + } return substring(s, 0, strlen(s) - 2); } void drawListBoxItemNexuizWeaponsList(entity me, float i, vector absSize, float isSelected) { + entity e; if(isSelected) draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_SELECTED, SKINALPHA_LISTBOX_SELECTED); - draw_Text(me.realUpperMargin * eY, WeaponName(stof(argv(i))), me.realFontSize, '1 1 1', SKINALPHA_TEXT, 0); + e = get_weaponinfo(stof(argv(i))); + draw_Text(me.realUpperMargin * eY, e.message, me.realFontSize, '1 1 1', SKINALPHA_TEXT, 0); } float keyDownNexuizWeaponsList(entity me, float scan, float ascii, float shift) diff --git a/data/qcsrc/menu/progs.src b/data/qcsrc/menu/progs.src index 86b18b82d..1261c2183 100644 --- a/data/qcsrc/menu/progs.src +++ b/data/qcsrc/menu/progs.src @@ -11,6 +11,7 @@ oo/base.h ../common/constants.qh ../common/mapinfo.qh ../common/campaign_common.qh +../common/items.qh gamecommand.qh menu.qh @@ -36,3 +37,4 @@ nexuiz/util.qc ../common/campaign_file.qc ../common/campaign_setup.qc ../common/mapinfo.qc +../common/items.qc diff --git a/data/qcsrc/server/cl_weapons.qc b/data/qcsrc/server/cl_weapons.qc index 50518e3d8..12c6b7186 100644 --- a/data/qcsrc/server/cl_weapons.qc +++ b/data/qcsrc/server/cl_weapons.qc @@ -102,11 +102,6 @@ void W_PreviousWeapon(float list) W_CycleWeapon(self.cvar_cl_weaponpriority, +1); } -string W_FixWeaponOrder(string order, float complete) -{ - return fixPriorityList(order, WEP_FIRST, WEP_LAST, complete); -} - string W_FixWeaponOrder_AllowIncomplete(string order) { return W_FixWeaponOrder(order, 0); @@ -448,24 +443,3 @@ void Nixnex_GiveCurrentWeapon() W_SwitchWeapon(nixnex_weapon); } } - -void RegisterWeapons() -{ - // %weaponaddpoint - register_weapon(WEP_LASER, w_laser, 0, 1, 1, 0, "laser", "laser", "Laser"); - register_weapon(WEP_SHOTGUN, w_shotgun, IT_SHELLS, 2, 1, 2500, "shotgun", "shotgun", "Shotgun"); - register_weapon(WEP_UZI, w_uzi, IT_NAILS, 3, 1, 5000, "uzi", "uzi", "Machine Gun"); - register_weapon(WEP_GRENADE_LAUNCHER, w_glauncher, IT_ROCKETS, 4, 1, 5000, "gl", "grenadelauncher", "Mortar"); - register_weapon(WEP_ELECTRO, w_electro, IT_CELLS, 5, 1, 5000, "electro", "electro", "Electro"); - register_weapon(WEP_CRYLINK, w_crylink, IT_CELLS, 6, 1, 5000, "crylink", "crylink", "Crylink"); - register_weapon(WEP_NEX, w_nex, IT_CELLS, 7, 1, 10000, "nex", "nex", "Nex"); - register_weapon(WEP_HAGAR, w_hagar, IT_ROCKETS, 8, 1, 5000, "hagar", "hagar", "Hagar"); - register_weapon(WEP_ROCKET_LAUNCHER, w_rlauncher, IT_ROCKETS, 9, 1, 10000, "rl", "rocketlauncher", "Rocket Launcher"); - register_weapon(WEP_PORTO, w_porto, IT_SUPERWEAPON, 0, 0, 0, "porto" , "porto", "Port-O-Launch"); - register_weapon(WEP_MINSTANEX, w_minstanex, IT_CELLS, 7, 0, 10000, "minstanex", "minstanex", "MinstaNex"); - register_weapon(WEP_HOOK, w_hook, IT_CELLS, 0, 0, 0, "hookgun", "hook", "Grappling Hook"); - register_weapon(WEP_SEEKER, w_seeker, IT_ROCKETS, 8, 1, 0, "seeker", "seeker", "T.A.G. Seeker"); - register_weapon(WEP_HLAC, w_hlac, IT_CELLS, 6, 1, 0, "hlac", "hlac", "Heavy Laser Assault Cannon"); - - register_weapons_done(); -} diff --git a/data/qcsrc/server/cl_weaponsystem.qc b/data/qcsrc/server/cl_weaponsystem.qc index 6f82ba3c1..c42fbb8d5 100644 --- a/data/qcsrc/server/cl_weaponsystem.qc +++ b/data/qcsrc/server/cl_weaponsystem.qc @@ -637,85 +637,3 @@ void W_SetupProjectileVelocity(entity missile) missile.velocity = W_CalculateProjectileVelocity(missile.owner.velocity, missile.velocity); } - - -// WEAPON PLUGIN SYSTEM -entity weapon_info[24]; -entity dummy_weapon_info; -.float(float) weapon_func; -string weaponpriority_hudselector_0; -string weaponpriority_hudselector_1; - -void register_weapon(float id, float(float) func, float ammotype, float i, float normalweapon, float pickupbasevalue, string modelname, string shortname, string name) -{ - entity e; - weapon_info[id - 1] = e = spawn(); - e.classname = "weapon_info"; - e.weapon = id; - e.weapons = power2of(id - 1); - e.netname = shortname; - e.message = name; - e.items = ammotype; - e.weapon_func = func; - e.mdl = modelname; - e.model = strzone(strcat("models/weapons/g_", modelname, ".md3")); - e.spawnflags = normalweapon; - e.impulse = i; - e.bot_pickupbasevalue = pickupbasevalue; -} -float w_null(float dummy) -{ - return 0; -} -void register_weapons_done() -{ - entity wi; - - dummy_weapon_info = spawn(); - dummy_weapon_info.classname = "weapon_info"; - dummy_weapon_info.weapon = 0; - dummy_weapon_info.weapons = 0; - dummy_weapon_info.netname = "@!#%'n Tuba"; - dummy_weapon_info.items = 0; - dummy_weapon_info.weapon_func = w_null; - dummy_weapon_info.mdl = ""; - dummy_weapon_info.model = ""; - dummy_weapon_info.spawnflags = 0; - dummy_weapon_info.impulse = -1; - dummy_weapon_info.bot_pickupbasevalue = 0; - - float i; - weaponpriority_hudselector_0 = ""; - for(i = 24; i >= 1; --i) - if(weapon_info[i-1]) - weaponpriority_hudselector_0 = strcat(weaponpriority_hudselector_0, " ", ftos(i)); - - float imp; - weaponpriority_hudselector_1 = ""; - for(i = 1; i <= 24; ++i) - { - wi = weapon_info[i-1]; - if(wi && wi.impulse == 0) - weaponpriority_hudselector_1 = strcat(weaponpriority_hudselector_1, " ", ftos(i)); - } - for(imp = 9; imp > 0; --imp) - for(i = 1; i <= 24; ++i) - { - wi = weapon_info[i-1]; - if(wi && wi.impulse == imp) - weaponpriority_hudselector_1 = strcat(weaponpriority_hudselector_1, " ", ftos(i)); - } - - weaponpriority_hudselector_0 = strzone(substring(weaponpriority_hudselector_0, 1, strlen(weaponpriority_hudselector_0) - 1)); - weaponpriority_hudselector_1 = strzone(substring(weaponpriority_hudselector_1, 1, strlen(weaponpriority_hudselector_1) - 1)); -} -entity get_weaponinfo(float id) -{ - entity w; - if(id < WEP_FIRST || id > WEP_LAST) - return dummy_weapon_info; - w = weapon_info[id - 1]; - if(w) - return w; - return dummy_weapon_info; -} diff --git a/data/qcsrc/server/miscfunctions.qc b/data/qcsrc/server/miscfunctions.qc index 4cc9b8cb7..dbeabee65 100644 --- a/data/qcsrc/server/miscfunctions.qc +++ b/data/qcsrc/server/miscfunctions.qc @@ -772,7 +772,7 @@ void readplayerstartcvars() for(j = WEP_FIRST; j <= WEP_LAST; ++j) { e = get_weaponinfo(j); - if(e.spawnflags & 1) + if(e.spawnflags & WEPSPAWNFLAG_NORMAL) { g_weaponarena |= e.weapons; weapon_action(e.weapon, WR_PRECACHE); @@ -863,7 +863,7 @@ void readplayerstartcvars() e = get_weaponinfo(i); if(!(e.weapon)) continue; - if(((e.spawnflags & 1) && g_lms) || cvar(strcat("g_start_weapon_", e.netname))) + if(((e.spawnflags & WEPSPAWNFLAG_NORMAL) && g_lms) || cvar(strcat("g_start_weapon_", e.netname))) { start_weapons |= e.weapons; weapon_action(e.weapon, WR_PRECACHE); @@ -899,7 +899,7 @@ void readplayerstartcvars() e = get_weaponinfo(i); if(!(e.weapon)) continue; - if(e.spawnflags & 1) + if(e.spawnflags & WEPSPAWNFLAG_NORMAL) { warmup_start_weapons |= e.weapons; weapon_action(e.weapon, WR_PRECACHE); @@ -1454,85 +1454,6 @@ void SetCustomizer(entity e, float(void) customizer, void(void) uncustomizer) .float nottargeted; #define IFTARGETED if(!self.nottargeted && self.targetname != "") -float power2of(float e) -{ - return pow(2, e); -} -float log2of(float x) -{ - // NOTE: generated code - if(x > 2048) - if(x > 131072) - if(x > 1048576) - if(x > 4194304) - return 23; - else - if(x > 2097152) - return 22; - else - return 21; - else - if(x > 524288) - return 20; - else - if(x > 262144) - return 19; - else - return 18; - else - if(x > 16384) - if(x > 65536) - return 17; - else - if(x > 32768) - return 16; - else - return 15; - else - if(x > 8192) - return 14; - else - if(x > 4096) - return 13; - else - return 12; - else - if(x > 32) - if(x > 256) - if(x > 1024) - return 11; - else - if(x > 512) - return 10; - else - return 9; - else - if(x > 128) - return 8; - else - if(x > 64) - return 7; - else - return 6; - else - if(x > 4) - if(x > 16) - return 5; - else - if(x > 8) - return 4; - else - return 3; - else - if(x > 2) - return 2; - else - if(x > 1) - return 1; - else - return 0; -} - void Net_LinkEntity(entity e) { e.model = "net_entity"; diff --git a/data/qcsrc/server/progs.src b/data/qcsrc/server/progs.src index 762b5d78c..d064d3dff 100644 --- a/data/qcsrc/server/progs.src +++ b/data/qcsrc/server/progs.src @@ -3,11 +3,13 @@ ../common/util-pre.qh sys.qh builtins.qh +extensions.qh constants.qh ../common/constants.qh -defs.qh // Should rename this, it has fields and globals -extensions.qh ../common/util.qh +../common/items.qh + +defs.qh // Should rename this, it has fields and globals //// tZork Turrets //// tturrets/include/turrets_early.qh @@ -152,3 +154,5 @@ portals.qc target_spawn.qc func_breakable.qc + +../common/items.qc diff --git a/data/qcsrc/server/sys.qh b/data/qcsrc/server/sys.qh index e5ac12160..75a598504 100644 --- a/data/qcsrc/server/sys.qh +++ b/data/qcsrc/server/sys.qh @@ -1,4 +1,5 @@ #pragma flag off fastarrays // make dp behave with new fteqcc versions. remove when dp bug with fteqcc fastarrays is fixed +#define SVQC // DO NOT modify the contents of this file, or you will risk incompatibility with the game engine. -- 2.39.2