diff --git a/code/game/atom_procs.dm b/code/game/atom_procs.dm index c6e11693fd0..7b390a14da8 100644 --- a/code/game/atom_procs.dm +++ b/code/game/atom_procs.dm @@ -309,24 +309,33 @@ var/using_new_click_proc = 0 //TODO ERRORAGE (This is temporary, while the DblCl W.attack_self(usr) return - //Attackby can only be done once every 1 second, unless an object has the NODELAY flag - if ( W && !(W.flags & NODELAY) ) - if(W.flags & USEDELAY) - //Objects that use the USEDELAY flag can only attack once every 2 seconds - if (usr.next_move < world.time) - usr.prev_move = usr.next_move - usr.next_move = world.time + 20 - else - return //An item with the USEDELAY flag's already been used this tick + //Attackby, attack_hand, afterattack, etc. can only be done once every 1 second, unless an object has the NODELAY or USEDELAY flags set + //This segment of code determins this. + if(W) + if( !( (src.loc && src.loc == usr) || (src.loc.loc && src.loc.loc == usr) ) ) + //The check above checks that you are not targeting an item which you are holding. + //If you are, (example clicking a backpack), the delays are ignored. + if(W.flags & USEDELAY) + //Objects that use the USEDELAY flag can only attack once every 2 seconds + if (usr.next_move < world.time) + usr.prev_move = usr.next_move + usr.next_move = world.time + 20 + else + return //A click has recently been handled already, you need to wait until the anti-spam delay between clicks passes + else if(!(W.flags & NODELAY)) + //Objects with NODELAY don't have a delay between uses, while most objects have the standard 1 second delay. + if (usr.next_move < world.time) + usr.prev_move = usr.next_move + usr.next_move = world.time + 10 + else + return //A click has recently been handled already, you need to wait until the anti-spam delay between clicks passes + else + //Empty hand + if (usr.next_move < world.time) + usr.prev_move = usr.next_move + usr.next_move = world.time + 10 else - //Objects that don't have NODELAY and don't have USEDELAY flags set, can attack once every 1 second, which is the standard. - if (usr.next_move < world.time) - usr.prev_move = usr.next_move - usr.next_move = world.time + 10 - else - return //An item with the USEDELAY flag's already been used this tick - - + return //A click has recently been handled already, you need to wait until the anti-spam delay between clicks passes //Is the object in a valid place? var/valid_place = 0 @@ -344,9 +353,9 @@ var/using_new_click_proc = 0 //TODO ERRORAGE (This is temporary, while the DblCl //clicking targets for guns and such. If you are clicking on a target that's not in range //with an item in your hands only afterattack() needs to be performed. //If the range is valid, afterattack() will be handled in the separate mob-type - //sections below, just after attackby(). Attack_hand and simmilar procs are handled + //sections below, however only after attackby(). Attack_hand and simmilar procs are handled //in the mob-type sections below, as some require you to be in range to work (human, monkey..) while others don't (ai, cyborg) - //Also note that afterattack does not differentiate between mob-types. + //Also note that afterattack does not differentiate between the holder/attacker's mob-type. if( W && !valid_place) W.afterattack(src, usr, (valid_place ? 1 : 0)) return diff --git a/code/setup.dm b/code/setup.dm index 8f8c115954b..e5156e5f461 100644 --- a/code/setup.dm +++ b/code/setup.dm @@ -93,7 +93,7 @@ #define SUITSPACE 8 // suit protects against space #define USEDELAY 16 // 1 second extra delay on use (Can be used once every 2s) -#define NODELAY 32768 // 1 second attackby delay skipped (Can be used once every 0.2s). Most objects have a 1s attackby delay, which doesn't require a flag. +#define NODELAY 32768 // 1 second attackby delay skipped (Can be used once every 0.2s). Most objects have a 1s attackby delay, which doesn't require a flag. #define NOSHIELD 32 // weapon not affected by shield #define CONDUCT 64 // conducts electricity (metal etc.) #define ONBELT 128 // can be put in belt slot