From: Rudolf Polzer Date: Sat, 1 Oct 2011 14:39:57 +0000 (+0200) Subject: rewrite the use key system to always rely on the impulse for impulse actions, and... X-Git-Tag: xonotic-v0.6.0~74^2~275^2~8^2~4 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=2ab37e6c5b9742c6561cebd084822ea70f7dfb49;p=xonotic%2Fxonotic-data.pk3dir.git rewrite the use key system to always rely on the impulse for impulse actions, and use the button state for stuff that needs to know whether the button is held --- diff --git a/defaultXonotic.cfg b/defaultXonotic.cfg index a0d50e3e7a..a290a0b4fe 100644 --- a/defaultXonotic.cfg +++ b/defaultXonotic.cfg @@ -53,6 +53,8 @@ alias asay_drop "say_team (%l) dropped %w ; impulse 17" alias +hook +button6 alias -hook -button6 alias use "impulse 21" +alias +usekey "use; +button10" +alias -usekey "-button10" alias ready "cmd ready" alias lockteams "sv_cmd lockteams" alias unlockteams "sv_cmd unlockteams" @@ -1039,7 +1041,7 @@ bind r reload bind BACKSPACE dropweapon bind g dropweapon // TODO change this to "use" once we can -bind f +use +bind f +usekey // misc bind e +hook diff --git a/qcsrc/server/bot/bot.qc b/qcsrc/server/bot/bot.qc index 351625bb55..0693dc9138 100644 --- a/qcsrc/server/bot/bot.qc +++ b/qcsrc/server/bot/bot.qc @@ -79,7 +79,7 @@ void bot_think() self.BUTTON_INFO = 0; self.button8 = 0; self.BUTTON_CHAT = 0; - self.BUTTON_USE = 0; + self.BUTTON_USELEGACY = 0; if (time < game_starttime) { diff --git a/qcsrc/server/bot/scripting.qc b/qcsrc/server/bot/scripting.qc index 63151cac1b..fe6212e1f1 100644 --- a/qcsrc/server/bot/scripting.qc +++ b/qcsrc/server/bot/scripting.qc @@ -889,7 +889,7 @@ float bot_presskeys() self.BUTTON_CROUCH = FALSE; self.BUTTON_ATCK = FALSE; self.BUTTON_ATCK2 = FALSE; - self.BUTTON_USE = FALSE; + self.BUTTON_USELEGACY = FALSE; self.BUTTON_HOOK = FALSE; self.BUTTON_CHAT = FALSE; @@ -919,7 +919,7 @@ float bot_presskeys() self.BUTTON_ATCK2 = TRUE; if(self.bot_cmd_keys & BOT_CMD_KEY_USE) - self.BUTTON_USE = TRUE; + self.BUTTON_USELEGACY = TRUE; if(self.bot_cmd_keys & BOT_CMD_KEY_HOOK) self.BUTTON_HOOK = TRUE; @@ -1047,15 +1047,15 @@ float bot_cmd_releasekey() float bot_cmd_pause() { - self.button1 = 0; - self.button8 = 0; - self.BUTTON_USE = 0; - self.BUTTON_ATCK = 0; - self.BUTTON_JUMP = 0; - self.BUTTON_HOOK = 0; - self.BUTTON_CHAT = 0; - self.BUTTON_ATCK2 = 0; - self.BUTTON_CROUCH = 0; + self.button1 = 0; + self.button8 = 0; + self.BUTTON_USELEGACY = 0; + self.BUTTON_ATCK = 0; + self.BUTTON_JUMP = 0; + self.BUTTON_HOOK = 0; + self.BUTTON_CHAT = 0; + self.BUTTON_ATCK2 = 0; + self.BUTTON_CROUCH = 0; self.movement = '0 0 0'; self.bot_cmd_keys = BOT_CMD_KEY_NONE; diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index bddb593323..b1a2ef0503 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -2327,7 +2327,7 @@ void SpectateCopy(entity spectatee) { self.dmg_save = spectatee.dmg_save; self.dmg_inflictor = spectatee.dmg_inflictor; self.angles = spectatee.v_angle; - if(!self.BUTTON_USE) + if(!(self.BUTTON_USELEGACY || self.BUTTON_USEPRESSED)) self.fixangle = TRUE; setorigin(self, spectatee.origin); setsize(self, spectatee.mins, spectatee.maxs); @@ -2605,7 +2605,7 @@ void ObserverThink() self.classname = "spectator"; } } else { - prefered_movetype = ((!self.BUTTON_USE ? self.cvar_cl_clippedspectating : !self.cvar_cl_clippedspectating) ? MOVETYPE_FLY_WORLDONLY : MOVETYPE_NOCLIP); + prefered_movetype = ((!(self.BUTTON_USELEGACY || self.BUTTON_USEPRESSED) ? self.cvar_cl_clippedspectating : !self.cvar_cl_clippedspectating) ? MOVETYPE_FLY_WORLDONLY : MOVETYPE_NOCLIP); if (self.movetype != prefered_movetype) self.movetype = prefered_movetype; } @@ -2774,9 +2774,9 @@ void PlayerPreThink (void) MUTATOR_CALLHOOK(PlayerPreThink); - if(self.BUTTON_USE && !self.usekeypressed) + if(self.BUTTON_USELEGACY && !self.usekeypressed) PlayerUseKey(); - self.usekeypressed = self.BUTTON_USE; + self.usekeypressed = self.BUTTON_USELEGACY; PrintWelcomeMessage(); @@ -2860,7 +2860,7 @@ void PlayerPreThink (void) { if(frametime) player_anim(); - button_pressed = (self.BUTTON_ATCK || self.BUTTON_JUMP || self.BUTTON_ATCK2 || self.BUTTON_HOOK || self.BUTTON_USE); + button_pressed = (self.BUTTON_ATCK || self.BUTTON_JUMP || self.BUTTON_ATCK2 || self.BUTTON_HOOK || self.BUTTON_USELEGACY || self.BUTTON_USEPRESSED); force_respawn = (g_lms || g_ca || g_cts || autocvar_g_forced_respawn); if (self.deadflag == DEAD_DYING) { diff --git a/qcsrc/server/cl_physics.qc b/qcsrc/server/cl_physics.qc index b7e8bc2264..f629297cce 100644 --- a/qcsrc/server/cl_physics.qc +++ b/qcsrc/server/cl_physics.qc @@ -752,7 +752,7 @@ void SV_PlayerPhysics() anticheat_physics(); - buttons = self.BUTTON_ATCK + 2 * self.BUTTON_JUMP + 4 * self.BUTTON_ATCK2 + 8 * self.BUTTON_ZOOM + 16 * self.BUTTON_CROUCH + 32 * self.BUTTON_HOOK + 64 * self.BUTTON_USE + 128 * (self.movement_x < 0) + 256 * (self.movement_x > 0) + 512 * (self.movement_y < 0) + 1024 * (self.movement_y > 0); + buttons = self.BUTTON_ATCK + 2 * self.BUTTON_JUMP + 4 * self.BUTTON_ATCK2 + 8 * self.BUTTON_ZOOM + 16 * self.BUTTON_CROUCH + 32 * self.BUTTON_HOOK + 64 * (self.BUTTON_USELEGACY || self.BUTTON_USEPRESSED) + 128 * (self.movement_x < 0) + 256 * (self.movement_x > 0) + 512 * (self.movement_y < 0) + 1024 * (self.movement_y > 0); if(!buttons) c = "x"; @@ -799,7 +799,7 @@ void SV_PlayerPhysics() { // slight annoyance for nick change scripts self.movement = -1 * self.movement; - self.BUTTON_ATCK = self.BUTTON_JUMP = self.BUTTON_ATCK2 = self.BUTTON_ZOOM = self.BUTTON_CROUCH = self.BUTTON_HOOK = self.BUTTON_USE = 0; + self.BUTTON_ATCK = self.BUTTON_JUMP = self.BUTTON_ATCK2 = self.BUTTON_ZOOM = self.BUTTON_CROUCH = self.BUTTON_HOOK = self.BUTTON_USELEGACY = self.BUTTON_USEPRESSED = 0; if(self.nickspamcount >= autocvar_g_nick_flood_penalty_red) // if you are persistent and the slight annoyance above does not stop you, I'll show you! { diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index bc05d1b048..a71df8f2e0 100644 --- a/qcsrc/server/defs.qh +++ b/qcsrc/server/defs.qh @@ -10,9 +10,10 @@ float require_spawnfunc_prefix; // if this float exists, only functions with spa #define BUTTON_HOOK button6 #define BUTTON_INFO button7 #define BUTTON_CHAT buttonchat -#define BUTTON_USE buttonuse +#define BUTTON_USELEGACY buttonuse #define BUTTON_DRAG button8 #define BUTTON_ZOOMSCRIPT button9 +#define BUTTON_USEPRESSED button10 // Globals diff --git a/qcsrc/server/g_world.qc b/qcsrc/server/g_world.qc index 09daa245ac..a5e3a080c9 100644 --- a/qcsrc/server/g_world.qc +++ b/qcsrc/server/g_world.qc @@ -1356,7 +1356,7 @@ void IntermissionThink() return; if(!mapvote_initialized) - if (time < intermission_exittime + 10 && !self.BUTTON_ATCK && !self.BUTTON_JUMP && !self.BUTTON_ATCK2 && !self.BUTTON_HOOK && !self.BUTTON_USE) + if (time < intermission_exittime + 10 || !(self.BUTTON_ATCK || self.BUTTON_JUMP || self.BUTTON_ATCK2 || self.BUTTON_HOOK || self.BUTTON_USELEGACY || self.BUTTON_USEPRESSED)) return; MapVote_Start(); diff --git a/qcsrc/server/playerdemo.qc b/qcsrc/server/playerdemo.qc index 631c10dcbb..e334de72e8 100644 --- a/qcsrc/server/playerdemo.qc +++ b/qcsrc/server/playerdemo.qc @@ -49,6 +49,7 @@ void playerdemo_open_write(string f) PLAYERDEMO_FIELD(func,string,playermodel) \ PLAYERDEMO_FIELD(func,float,skin) \ PLAYERDEMO_FIELD(func,string,playerskin) \ + PLAYERDEMO_FIELD(func,float,impulse) \ PLAYERDEMO_FIELD(func,float,frame) \ PLAYERDEMO_FIELD(func,float,effects) \ PLAYERDEMO_FIELD(func,float,switchweapon) \ @@ -56,7 +57,6 @@ void playerdemo_open_write(string f) PLAYERDEMO_FIELD(func,float,BUTTON_ATCK2) \ PLAYERDEMO_FIELD(func,float,BUTTON_CROUCH) \ PLAYERDEMO_FIELD(func,float,BUTTON_HOOK) \ - PLAYERDEMO_FIELD(func,float,BUTTON_USE) \ PLAYERDEMO_FIELD(func,float,flags) \ // end of list diff --git a/qcsrc/server/vehicles/vehicles.qc b/qcsrc/server/vehicles/vehicles.qc index 6006dcf92e..dd59ebb989 100644 --- a/qcsrc/server/vehicles/vehicles.qc +++ b/qcsrc/server/vehicles/vehicles.qc @@ -606,7 +606,7 @@ void vehicles_exit(float eject) self.owner.event_damage = PlayerDamage; self.owner.hud = HUD_NORMAL; self.owner.switchweapon = self.switchweapon; - //self.owner.BUTTON_USE = 0; + //self.owner.BUTTON_USELEGACY = 0; } if(self.deadflag == DEAD_NO)