mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-13 11:43:31 +00:00
do_after/do_mob code cleanup.
Cleans up the code a bit and makes do_mob() make regular checks, similar to do_after().
This commit is contained in:
@@ -698,17 +698,26 @@ proc/anim(turf/location as turf,target as mob|obj,a_icon,a_icon_state as text,fl
|
|||||||
|
|
||||||
else return get_step(ref, base_dir)
|
else return get_step(ref, base_dir)
|
||||||
|
|
||||||
/proc/do_mob(var/mob/user , var/mob/target, var/time = 30) //This is quite an ugly solution but i refuse to use the old request system.
|
/proc/do_mob(var/mob/user, var/mob/target, var/delay, var/numticks = 5, var/needhand = 1) //This is quite an ugly solution but i refuse to use the old request system.
|
||||||
if(!user || !target) return 0
|
if(!user || !target) return 0
|
||||||
var/user_loc = user.loc
|
if(numticks == 0) return 0
|
||||||
var/target_loc = target.loc
|
|
||||||
|
var/delayfraction = round(delay/numticks)
|
||||||
|
var/original_user_loc = user.loc
|
||||||
|
var/original_target_loc = target.loc
|
||||||
var/holding = user.get_active_hand()
|
var/holding = user.get_active_hand()
|
||||||
sleep(time)
|
|
||||||
if(!user || !target) return 0
|
for(var/i = 0, i<numticks, i++)
|
||||||
if ( user.loc == user_loc && target.loc == target_loc && user.get_active_hand() == holding && !( user.stat ) && ( !user.stunned && !user.weakened && !user.paralysis && !user.lying ) )
|
sleep(delayfraction)
|
||||||
return 1
|
|
||||||
else
|
if(!user || user.stat || user.weakened || user.stunned || user.loc != original_user_loc)
|
||||||
return 0
|
return 0
|
||||||
|
if(!target || target.loc != original_target_loc)
|
||||||
|
return 0
|
||||||
|
if(needhand && !(user.get_active_hand() == holding)) //Sometimes you don't want the user to have to keep their active hand
|
||||||
|
return 0
|
||||||
|
|
||||||
|
return 1
|
||||||
|
|
||||||
/proc/do_after(var/mob/user as mob, delay as num, var/numticks = 5, var/needhand = 1)
|
/proc/do_after(var/mob/user as mob, delay as num, var/numticks = 5, var/needhand = 1)
|
||||||
if(!user || isnull(user))
|
if(!user || isnull(user))
|
||||||
@@ -718,14 +727,12 @@ proc/anim(turf/location as turf,target as mob|obj,a_icon,a_icon_state as text,fl
|
|||||||
|
|
||||||
var/delayfraction = round(delay/numticks)
|
var/delayfraction = round(delay/numticks)
|
||||||
var/original_loc = user.loc
|
var/original_loc = user.loc
|
||||||
var/original_turf = get_turf(user)
|
|
||||||
var/holding = user.get_active_hand()
|
var/holding = user.get_active_hand()
|
||||||
|
|
||||||
for(var/i = 0, i<numticks, i++)
|
for(var/i = 0, i<numticks, i++)
|
||||||
sleep(delayfraction)
|
sleep(delayfraction)
|
||||||
|
|
||||||
|
if(!user || user.stat || user.weakened || user.stunned || user.loc != original_loc)
|
||||||
if(!user || user.stat || user.weakened || user.stunned || user.loc != original_loc || get_turf(user) != original_turf)
|
|
||||||
return 0
|
return 0
|
||||||
if(needhand && !(user.get_active_hand() == holding)) //Sometimes you don't want the user to have to keep their active hand
|
if(needhand && !(user.get_active_hand() == holding)) //Sometimes you don't want the user to have to keep their active hand
|
||||||
return 0
|
return 0
|
||||||
@@ -1389,4 +1396,4 @@ var/list/WALLITEMS = list(
|
|||||||
if(length(temp_col )<2)
|
if(length(temp_col )<2)
|
||||||
temp_col = "0[temp_col]"
|
temp_col = "0[temp_col]"
|
||||||
colour += temp_col
|
colour += temp_col
|
||||||
return colour
|
return colour
|
||||||
|
|||||||
Reference in New Issue
Block a user