From 51ac0cf69a7935ef67b3151bec453488af5fd8f9 Mon Sep 17 00:00:00 2001 From: Bukz Date: Thu, 14 Feb 2013 03:32:07 +0000 Subject: [PATCH] more intuitive akimboendaction (plz review/test) git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@7195 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- config/docs.cfg | 10 ++++++---- config/menus_settings.cfg | 2 +- source/src/weapon.cpp | 33 ++++++++++++++++++++++++++++++++- 3 files changed, 39 insertions(+), 6 deletions(-) diff --git a/config/docs.cfg b/config/docs.cfg index 486aeb97..f91ce20c 100644 --- a/config/docs.cfg +++ b/config/docs.cfg @@ -621,10 +621,12 @@ docident [afterinit] [If defined, this will be executed after saved.cfg is loade docident [akimboautoswitch] [Enables or disables automatic switching to the akimbo upon pickup.]; docargument [N] [enable or disable] [min 0/max 1/default 1]; docident [akimboendaction] [Sets the behavior of weapon switching upon akimbo expiration.]; -docargument [] [] [0 (none)] [0]; -docargument [] [] [1 (switch to primary)] [0]; -docargument [] [] [2 (switch to grenades, else switch to primary)] [0]; -docargument [N] [akimbo end action] [min 0/max 2/default 0]; +docargument [] [] [0 (switch to knife)] [0]; +docargument [] [] [1 (stay with pistol)] [0]; +docargument [] [] [2 (switch to grenades)] [0]; +docargument [] [] [3 (switch to primary)] [0]; +docargument [N] [akimbo end action] [min 0/max 3/default 3]; +docremark [If no ammunition is detected for the target weapon, it will fallback to the previous weapon until it finds a weapon with ammunition to use.]; docident [alive] [Returns 1 if the local player is alive.]; docexample [echo (alive)] [Output: 1]; docident [autoreload] [Indicates if the weapons should be reloaded automatically.]; diff --git a/config/menus_settings.cfg b/config/menus_settings.cfg index 5e24e16c..22cafffd 100644 --- a/config/menus_settings.cfg +++ b/config/menus_settings.cfg @@ -368,7 +368,7 @@ newmenu [Weapon Settings] menuitemcheckbox [Auto weapon reload: ] "$autoreload" [ autoreload $arg1 ] menuitemcheckbox [Hit sound: ] "$hitsound" [ hitsound $arg1 ] menuitemcheckbox [Auto switch to akimbo upon pickup: ] "$akimboautoswitch" [ akimboautoswitch $arg1 ] -menuitemslider [Akimbo end action: ] 0 2 "$akimboendaction" 1 ["Switch to pistol" "Switch to primary weapon" "Switch to grenades"] [ akimboendaction $arg1 ] +menuitemslider [Akimbo end action: ] 0 3 "$akimboendaction" 1 ["Switch to knife" "Stay with pistol" "Switch to grenades" "Switch to primary"] [ akimboendaction $arg1 ] menuitemcheckbox [SMG - Full Auto?] "(= (burstshots $SMG -1) 0)" [ if (= $arg1 0) [ burstshots $SMG (at $default_bursts 0) ] [ burstshots $SMG 0 ]; refreshWSM ] menuitemcheckbox [AR - Full Auto?] "(= (burstshots $AR -1) 0)" [ if (= $arg1 0) [ burstshots $AR (at $default_bursts 1) ] [ burstshots $AR 0 ]; refreshWSM ] menuitemcheckbox [Akimbo - Full Auto?] "(= (burstshots $AKIMBO -1) 0)" [ if (= $arg1 0) [ burstshots $AKIMBO (at $default_bursts 2) ] [ burstshots $AKIMBO 0 ]; refreshWSM ] diff --git a/source/src/weapon.cpp b/source/src/weapon.cpp index 0e701be1..4151f87c 100644 --- a/source/src/weapon.cpp +++ b/source/src/weapon.cpp @@ -6,7 +6,7 @@ VARP(autoreload, 0, 1, 1); VARP(akimboautoswitch, 0, 1, 1); -VARP(akimboendaction, 0, 1, 2); // 0: stay with pistol, 1: back to primary, 2: grenade - all fallback to previous one w/o ammo for target +VARP(akimboendaction, 0, 3, 3); // 0: switch to knife, 1: stay with pistol (if has ammo), 2: switch to grenade (if possible), 3: switch to primary (if has ammo) - all fallback to previous one w/o ammo for target sgray sgr[SGRAYS*3]; sgray pat[SGRAYS*3]; // DEBUG 2011may27 @@ -1631,6 +1631,36 @@ void checkakimbo() switch(akimboendaction) { + case 0: player1->weaponswitch(player1->weapons[GUN_KNIFE]); break; + case 1: + { + if(player1->weapons[GUN_PISTOL]->ammo) player1->weaponswitch(&p); + else player1->weaponswitch(player1->weapons[GUN_KNIFE]); + break; + } + case 2: + { + if(player1->mag[GUN_GRENADE]) player1->weaponswitch(player1->weapons[GUN_GRENADE]); + else { + if(player1->weapons[GUN_PISTOL]->ammo) player1->weaponswitch(&p); + else player1->weaponswitch(player1->weapons[GUN_KNIFE]); + } + break; + } + case 3: + { + if(player1->ammo[player1->primary]) player1->weaponswitch(player1->weapons[player1->primary]); + else { + if(player1->mag[GUN_GRENADE]) player1->weaponswitch(player1->weapons[GUN_GRENADE]); + else { + if(player1->weapons[GUN_PISTOL]->ammo) player1->weaponswitch(&p); + else player1->weaponswitch(player1->weapons[GUN_KNIFE]); + } + } + break; + } + default: break; + /* case 0: player1->weaponswitch(&p); break; case 1: { @@ -1649,6 +1679,7 @@ void checkakimbo() break; } default: break; + */ } } if(player1->state != CS_DEAD) audiomgr.playsoundc(S_AKIMBOOUT);