Removes click cooldowns almost everywhere.

Still have: doors, windoors, cameras, windows, grilles, blobs, resisting, alien stuff, mechas, spray bottles.
Setting changeNextMove is now responsibility of the item being attacked.
Adds a config option to eliminate click cooldowns completely. Intended to be used by devs.
This commit is contained in:
Kelenius
2015-05-09 17:27:19 +03:00
parent 538ce2f3ea
commit 3fa79f8d51
33 changed files with 110 additions and 144 deletions

View File

@@ -15,7 +15,6 @@
return
if(control_disabled || stat) return
next_move = world.time + 9
if(ismob(A))
ai_actual_track(A)
@@ -52,9 +51,8 @@
CtrlClickOn(A)
return
if(world.time <= next_move)
if(!canClick())
return
next_move = world.time + 9
if(aiCamera.in_camera_mode)
aiCamera.camera_mode_off()

View File

@@ -4,7 +4,7 @@
*/
// 1 decisecond click delay (above and beyond mob/next_move)
/mob/var/next_click = 0
/mob/var/next_click = 0
/*
Before anything else, defer these calls to a per-mobtype handler. This allows us to
@@ -15,12 +15,14 @@
Note that this proc can be overridden, and is in the case of screen objects.
*/
/atom/Click(location,control,params)
/atom/Click(var/location, var/control, var/params) // This is their reaction to being clicked on (standard proc)
if(src)
usr.ClickOn(src, params)
/atom/DblClick(location,control,params)
/atom/DblClick(var/location, var/control, var/params)
if(src)
usr.DblClickOn(src,params)
usr.DblClickOn(src, params)
/*
Standard mob ClickOn()
@@ -35,8 +37,8 @@
* item/afterattack(atom,user,adjacent,params) - used both ranged and adjacent
* mob/RangedAttack(atom,params) - used only ranged, only used for tk and laser eyes but could be changed
*/
/mob/proc/ClickOn( var/atom/A, var/params )
if(world.time <= next_click)
/mob/proc/ClickOn(var/atom/A, var/params)
if(world.time <= next_click) // Hard check, before anything else, to avoid crashing
return
next_click = world.time + 1
@@ -66,16 +68,17 @@
face_atom(A) // change direction to face what you clicked on
if(next_move > world.time) // in the year 2000...
if(!canClick()) // in the year 2000...
return
if(istype(loc,/obj/mecha))
if(!locate(/turf) in list(A,A.loc)) // Prevents inventory from being drilled
if(istype(loc, /obj/mecha))
if(!locate(/turf) in list(A, A.loc)) // Prevents inventory from being drilled
return
var/obj/mecha/M = loc
return M.click_action(A,src)
return M.click_action(A, src)
if(restrained())
changeNextMove(10)
RestrainedClickOn(A)
return
@@ -83,79 +86,65 @@
throw_item(A)
return
if(!istype(A,/obj/item/weapon/gun) && !isturf(A) && !istype(A,/obj/screen))
if(!istype(A, /obj/item/weapon/gun) && !isturf(A) && !istype(A, /obj/screen))
last_target_click = world.time
var/obj/item/W = get_active_hand()
if(W == A)
next_move = world.time + 6
if(W.flags&USEDELAY)
next_move += 5
if(W == A) // Handle attack_self
W.attack_self(src)
if(hand)
update_inv_l_hand(0)
else
update_inv_r_hand(0)
return
// operate two STORAGE levels deep here (item in backpack in src; NOT item in box in backpack in src)
var/sdepth = A.storage_depth(src)
if(A == loc || (A in loc) || (sdepth != -1 && sdepth <= 1))
// faster access to objects already on you
if(A in contents)
next_move = world.time + 6 // on your person
else
next_move = world.time + 8 // in a box/bag or in your square
// No adjacency needed
// A is your location but is not a turf; or is on you (backpack); or is on something on you (box in backpack); but not next to you and not in a box in a backpack on you
if(!isturf(A) && A == loc || (A in contents) || (A.loc in contents))
if(W)
if(W.flags&USEDELAY)
next_move += 5
var/resolved = A.attackby(W,src)
var/resolved = A.attackby(W, src)
if(!resolved && A && W)
W.afterattack(A,src,1,params) // 1 indicates adjacency
W.afterattack(A, src, 1, params) // 1 indicates adjacency
else
if(ismob(A)) // No instant mob attacking
changeNextMove(8)
UnarmedAttack(A, 1)
return
if(!isturf(loc)) // This is going to stop you from telekinesing from inside a closet, but I don't shed many tears for that
return
// Allows you to click on a box's contents, if that box is on the ground, but no deeper than that
sdepth = A.storage_depth_turf()
if(isturf(A) || isturf(A.loc) || (sdepth != -1 && sdepth <= 1))
next_move = world.time + 10
// A is a turf or is on a turf, or in something on a turf (pen in a box); but not something in something on a turf (pen in a box in a backpack)
if(isturf(A) || isturf(A.loc) || isturf(A.loc.loc))
if(A.Adjacent(src)) // see adjacent.dm
if(W)
if(W.flags&USEDELAY)
next_move += 5
// Return 1 in attackby() to prevent afterattack() effects (when safely moving items for example)
var/resolved = A.attackby(W,src)
var/resolved = A.attackby(W, src) // Return 1 in attackby() to prevent afterattack() effects (when safely moving items for example)
if(!resolved && A && W)
W.afterattack(A,src,1,params) // 1: clicking something Adjacent
W.afterattack(A, src, 1, params) // 1: clicking something Adjacent
else
if(ismob(A)) // No instant mob attacking
changeNextMove(8)
UnarmedAttack(A, 1)
return
else // non-adjacent click
if(W)
W.afterattack(A,src,0,params) // 0: not Adjacent
W.afterattack(A, src, 0, params) // 0: not Adjacent
else
RangedAttack(A, params)
return
/mob/proc/changeNext_move(num)
/mob/proc/changeNextMove(var/num)
next_move = world.time + num
// Default behavior: ignore double clicks, consider them normal clicks instead
/mob/proc/canClick()
if(config.no_click_cooldown || next_move <= world.time)
return 1
return 0
// Default behavior: ignore double clicks, the second click that makes the doubleclick call already calls for a normal click
/mob/proc/DblClickOn(var/atom/A, var/params)
ClickOn(A,params)
return
/*
Translates into attack_hand, etc.
@@ -198,17 +187,6 @@
if((LASER in mutations) && a_intent == I_HURT)
LaserEyes(A) // moved into a proc below
else if(TK in mutations)
switch(get_dist(src,A))
if(0)
;
if(1 to 5) // not adjacent may mean blocked by window
next_move += 2
if(5 to 7)
next_move += 5
if(8 to tk_maxrange)
next_move += 10
else
return
A.attack_tk(src)
/*
Restrained ClickOn
@@ -234,8 +212,7 @@
if(back)
var/obj/item/weapon/rig/rig = back
if(istype(rig) && rig.selected_module)
if(world.time <= next_move) return
next_move = world.time + 8
if(!canClick()) return
rig.selected_module.engage(A)
return
@@ -316,7 +293,7 @@
return
/mob/living/LaserEyes(atom/A)
next_move = world.time + 6
changeNextMove(4)
var/turf/T = get_turf(src)
var/turf/U = get_turf(A)

View File

@@ -35,7 +35,7 @@
if(stat || lockcharge || weakened || stunned || paralysis)
return
if(next_move >= world.time)
if(!canClick())
return
face_atom(A) // change direction to face what you clicked on
@@ -68,9 +68,6 @@
return
if(W == A)
next_move = world.time + 8
if(W.flags&USEDELAY)
next_move += 5
W.attack_self(src)
return
@@ -78,9 +75,6 @@
// cyborgs are prohibited from using storage items so we can I think safely remove (A.loc in contents)
if(A == loc || (A in loc) || (A in contents))
// No adjacency checks
next_move = world.time + 8
if(W.flags&USEDELAY)
next_move += 5
var/resolved = A.attackby(W,src)
if(!resolved && A && W)
@@ -93,16 +87,12 @@
// cyborgs are prohibited from using storage items so we can I think safely remove (A.loc && isturf(A.loc.loc))
if(isturf(A) || isturf(A.loc))
if(A.Adjacent(src)) // see adjacent.dm
next_move = world.time + 10
if(W.flags&USEDELAY)
next_move += 5
var/resolved = A.attackby(W, src)
if(!resolved && A && W)
W.afterattack(A, src, 1, params)
return
else
next_move = world.time + 10
W.afterattack(A, src, 0, params)
return
return

View File

@@ -48,9 +48,8 @@
/obj/screen/item_action/Click()
if(!usr || !owner)
return 1
if(usr.next_move >= world.time)
if(!usr.canClick())
return
usr.next_move = world.time + 6
if(usr.stat || usr.restrained() || usr.stunned || usr.lying)
return 1
@@ -85,7 +84,7 @@
name = "storage"
/obj/screen/storage/Click()
if(world.time <= usr.next_move)
if(!usr.canClick())
return 1
if(usr.stat || usr.paralysis || usr.stunned || usr.weakened)
return 1
@@ -95,7 +94,6 @@
var/obj/item/I = usr.get_active_hand()
if(I)
usr.ClickOn(master)
usr.next_move = world.time+2
return 1
/obj/screen/gun
@@ -481,7 +479,7 @@
/obj/screen/inventory/Click()
// At this point in client Click() code we have passed the 1/10 sec check and little else
// We don't even know if it's a middle click
if(world.time <= usr.next_move)
if(!usr.canClick())
return 1
if(usr.stat || usr.paralysis || usr.stunned || usr.weakened)
return 1
@@ -492,12 +490,10 @@
if(iscarbon(usr))
var/mob/living/carbon/C = usr
C.activate_hand("r")
usr.next_move = world.time+2
if("l_hand")
if(iscarbon(usr))
var/mob/living/carbon/C = usr
C.activate_hand("l")
usr.next_move = world.time+2
if("swap")
usr:swap_hand()
if("hand")
@@ -506,5 +502,4 @@
if(usr.attack_ui(slot_id))
usr.update_inv_l_hand(0)
usr.update_inv_r_hand(0)
usr.next_move = world.time+6
return 1

View File

@@ -6,11 +6,13 @@
// No comment
/atom/proc/attackby(obj/item/W, mob/user)
return
/atom/movable/attackby(obj/item/W, mob/user)
if(!(W.flags&NOBLUDGEON))
visible_message("<span class='danger'>[src] has been hit by [user] with [W].</span>")
/mob/living/attackby(obj/item/I, mob/user)
user.changeNextMove(8)
if(istype(I) && ismob(user))
I.attack(src, user)

View File

@@ -32,8 +32,8 @@
if(client.buildmode)
build_click(src, client.buildmode, params, A)
return
if(world.time <= next_move) return
next_move = world.time + 8
if(!canClick()) return
changeNextMove(4)
// You are responsible for checking config.ghost_interaction when you override this function
// Not all of them require checking, see below
A.attack_ghost(src)

View File

@@ -38,15 +38,6 @@
return
else if(TK in mutations)
switch(get_dist(src,A))
if(1 to 5) // not adjacent may mean blocked by window
next_move += 2
if(5 to 7)
next_move += 5
if(8 to 15)
next_move += 10
if(16 to 128)
return
A.attack_tk(src)
/mob/living/RestrainedClickOn(var/atom/A)

View File

@@ -108,20 +108,12 @@ var/const/tk_maxrange = 15
return
var/d = get_dist(user, target)
if(focus) d = max(d,get_dist(user,focus)) // whichever is further
switch(d)
if(0)
;
if(1 to 5) // not adjacent may mean blocked by window
if(!proximity)
user.next_move += 2
if(5 to 7)
user.next_move += 5
if(8 to tk_maxrange)
user.next_move += 10
else
user << "\blue Your mind won't reach that far."
return
if(focus)
d = max(d,get_dist(user,focus)) // whichever is further
if(d > tk_maxrange)
user << "<span class='notice'>Your mind won't reach that far.</span>"
return
if(!focus)
focus_object(target, user)