From: Mario Date: Mon, 28 Sep 2015 05:33:46 +0000 (+1000) Subject: Port hmg X-Git-Tag: xonotic-v0.8.2~1874^2~71 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=8a87299cb1f427c1cffa4b83398dabe4eea8bf08;p=xonotic%2Fxonotic-data.pk3dir.git Port hmg --- diff --git a/qcsrc/common/weapons/weapon/hmg.qc b/qcsrc/common/weapons/weapon/hmg.qc index 919eef592..8e5398745 100644 --- a/qcsrc/common/weapons/weapon/hmg.qc +++ b/qcsrc/common/weapons/weapon/hmg.qc @@ -1,19 +1,21 @@ #ifndef IMPLEMENTATION -REGISTER_WEAPON( -/* WEP_##id */ HMG, -/* function */ W_HeavyMachineGun, -/* ammotype */ ammo_nails, -/* impulse */ 3, -/* flags */ WEP_FLAG_MUTATORBLOCKED | WEP_FLAG_HIDDEN | WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_TYPE_HITSCAN | WEP_FLAG_SUPERWEAPON, -/* rating */ BOT_PICKUP_RATING_HIGH, -/* color */ '0.5 0.5 0', -/* modelname */ "ok_hmg", -/* model */ MDL_HMG_ITEM, -/* crosshair */ "gfx/crosshairuzi 0.6", -/* wepimg */ "weaponhmg", -/* refname */ "hmg", -/* wepname */ _("Heavy Machine Gun") -); +CLASS(HeavyMachineGun, Weapon) +/* ammotype */ ATTRIB(HeavyMachineGun, ammo_field, .int, ammo_nails) +/* impulse */ ATTRIB(HeavyMachineGun, impulse, int, 3) +/* flags */ ATTRIB(HeavyMachineGun, spawnflags, int, WEP_FLAG_MUTATORBLOCKED | WEP_FLAG_HIDDEN | WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_TYPE_HITSCAN | WEP_FLAG_SUPERWEAPON); +/* rating */ ATTRIB(HeavyMachineGun, bot_pickupbasevalue, float, BOT_PICKUP_RATING_HIGH); +/* color */ ATTRIB(HeavyMachineGun, wpcolor, vector, '0.5 0.5 0'); +/* modelname */ ATTRIB(HeavyMachineGun, mdl, string, "ok_hmg"); +#ifndef MENUQC +/* model */ ATTRIB(HeavyMachineGun, m_model, Model, MDL_HMG_ITEM); +#endif +/* crosshair */ ATTRIB(HeavyMachineGun, w_crosshair, string, "gfx/crosshairuzi"); +/* crosshair */ ATTRIB(HeavyMachineGun, w_crosshair_size, float, 0.6); +/* wepimg */ ATTRIB(HeavyMachineGun, model2, string, "weaponhmg"); +/* refname */ ATTRIB(HeavyMachineGun, netname, string, "hmg"); +/* wepname */ ATTRIB(HeavyMachineGun, message, string, _("Heavy Machine Gun")); +ENDCLASS(HeavyMachineGun) +REGISTER_WEAPON(HMG, NEW(HeavyMachineGun)); #define HMG_SETTINGS(w_cvar,w_prop) HMG_SETTINGS_LIST(w_cvar, w_prop, HMG, hmg) #define HMG_SETTINGS_LIST(w_cvar,w_prop,id,sn) \ @@ -86,12 +88,7 @@ void W_HeavyMachineGun_Attack_Auto() weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(hmg, refire), W_HeavyMachineGun_Attack_Auto); } -bool W_HeavyMachineGun(entity thiswep, int req) -{SELFPARAM(); - float ammo_amount; - switch(req) - { - case WR_AIM: + METHOD(HeavyMachineGun, wr_aim, bool(entity thiswep)) { if(vlen(self.origin-self.enemy.origin) < 3000 - bound(0, skill, 10) * 200) self.BUTTON_ATCK = bot_aim(1000000, 0, 0.001, false); @@ -100,7 +97,7 @@ bool W_HeavyMachineGun(entity thiswep, int req) return true; } - case WR_THINK: + METHOD(HeavyMachineGun, wr_think, bool(entity thiswep)) { if(WEP_CVAR(hmg, reload_ammo) && self.clip_load < WEP_CVAR(hmg, ammo)) // forced reload _WEP_ACTION(self.weapon, WR_RELOAD); @@ -116,60 +113,55 @@ bool W_HeavyMachineGun(entity thiswep, int req) return true; } - case WR_INIT: + METHOD(HeavyMachineGun, wr_init, bool(entity thiswep)) { HMG_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP); return true; } - case WR_CHECKAMMO1: + METHOD(HeavyMachineGun, wr_checkammo1, bool(entity thiswep)) { - ammo_amount = self.ammo_nails >= WEP_CVAR(hmg, ammo); + float ammo_amount = self.ammo_nails >= WEP_CVAR(hmg, ammo); if(autocvar_g_balance_hmg_reload_ammo) ammo_amount += self.(weapon_load[WEP_HMG.m_id]) >= WEP_CVAR(hmg, ammo); return ammo_amount; } - case WR_CHECKAMMO2: + METHOD(HeavyMachineGun, wr_checkammo2, bool(entity thiswep)) { - ammo_amount = self.ammo_nails >= WEP_CVAR(hmg, ammo); + float ammo_amount = self.ammo_nails >= WEP_CVAR(hmg, ammo); if(autocvar_g_balance_hmg_reload_ammo) ammo_amount += self.(weapon_load[WEP_HMG.m_id]) >= WEP_CVAR(hmg, ammo); return ammo_amount; } - case WR_CONFIG: + METHOD(HeavyMachineGun, wr_config, bool(entity thiswep)) { HMG_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS); return true; } - case WR_RELOAD: + METHOD(HeavyMachineGun, wr_reload, bool(entity thiswep)) { W_Reload(WEP_CVAR(hmg, ammo), SND(RELOAD)); return true; } - case WR_SUICIDEMESSAGE: + METHOD(HeavyMachineGun, wr_suicidemessage, bool(entity thiswep)) { return WEAPON_THINKING_WITH_PORTALS; } - case WR_KILLMESSAGE: + METHOD(HeavyMachineGun, wr_killmessage, bool(entity thiswep)) { if(w_deathtype & HITTYPE_SECONDARY) return WEAPON_HMG_MURDER_SNIPE; else return WEAPON_HMG_MURDER_SPRAY; } - } - return false; -} + #endif #ifdef CSQC -bool W_HeavyMachineGun(entity thiswep, int req) -{SELFPARAM(); - switch(req) - { - case WR_IMPACTEFFECT: + + METHOD(HeavyMachineGun, wr_impacteffect, bool(entity thiswep)) { vector org2; org2 = w_org + w_backoff * 2; @@ -184,17 +176,15 @@ bool W_HeavyMachineGun(entity thiswep, int req) return true; } - case WR_INIT: + METHOD(HeavyMachineGun, wr_init, bool(entity thiswep)) { return true; } - case WR_ZOOMRETICLE: + METHOD(HeavyMachineGun, wr_zoomreticle, bool(entity thiswep)) { // no weapon specific image for this weapon return false; } - } - return false; -} + #endif #endif