mirror of
https://github.com/SPLURT-Station/S.P.L.U.R.T-Station-13.git
synced 2025-12-10 18:02:57 +00:00
Fix pAI shenanigans
This commit is contained in:
@@ -10,6 +10,9 @@
|
||||
if(!ai)
|
||||
balloon_alert(user, "no AI in suit!")
|
||||
return
|
||||
if(!isAI(ai))
|
||||
balloon_alert(user, "onboard AI cannot fit in this card!")
|
||||
return
|
||||
balloon_alert(user, "transferring to card...")
|
||||
if(!do_after(user, 5 SECONDS, target = src))
|
||||
balloon_alert(user, "interrupted!")
|
||||
@@ -65,7 +68,7 @@
|
||||
ai = new_ai
|
||||
balloon_alert(new_ai, "transferred to a suit")
|
||||
for(var/datum/action/action as anything in actions)
|
||||
action.Grant(new_ai)
|
||||
action.Grant(ai)
|
||||
|
||||
/**
|
||||
* Simple proc to insert the pAI into the MODsuit.
|
||||
@@ -75,8 +78,8 @@
|
||||
*/
|
||||
|
||||
/obj/item/mod/control/proc/insert_pai(mob/user, obj/item/paicard/card)
|
||||
if(mod_pai)
|
||||
balloon_alert(user, "pAI already installed!")
|
||||
if(ai)
|
||||
balloon_alert(user, "AI already installed!")
|
||||
return
|
||||
if(!card.pai || !card.pai.mind)
|
||||
balloon_alert(user, "pAI unresponsive!")
|
||||
@@ -88,13 +91,13 @@
|
||||
if(!user.transferItemToLoc(card, src))
|
||||
return
|
||||
|
||||
mod_pai = card.pai
|
||||
card.pai.canholo = FALSE
|
||||
ai = card.pai
|
||||
balloon_alert(user, "pAI transferred to suit")
|
||||
balloon_alert(mod_pai, "transferred to a suit")
|
||||
mod_pai.canholo = FALSE
|
||||
mod_pai.remote_control = src
|
||||
balloon_alert(ai, "transferred to a suit")
|
||||
ai.remote_control = src
|
||||
for(var/datum/action/action as anything in actions)
|
||||
action.Grant(mod_pai)
|
||||
action.Grant(ai)
|
||||
return TRUE
|
||||
|
||||
/**
|
||||
@@ -106,10 +109,14 @@
|
||||
* feedback - Whether to give feedback via balloon alerts or not. Defaults to TRUE.
|
||||
*/
|
||||
/obj/item/mod/control/proc/extract_pai(mob/user, forced = FALSE, feedback = TRUE)
|
||||
if(!mod_pai)
|
||||
if(!ai)
|
||||
if(user && feedback)
|
||||
balloon_alert(user, "no pAI to remove!")
|
||||
return
|
||||
if(!ispAI(ai))
|
||||
if(user && feedback)
|
||||
balloon_alert(user, "onboard AI cannot fit in this card!")
|
||||
return
|
||||
if(!forced)
|
||||
if(!open)
|
||||
if(user && feedback)
|
||||
@@ -129,41 +136,48 @@
|
||||
* Simple proc that handles the safe removal of the pAI from a MOD control unit.
|
||||
*
|
||||
* Arguments:
|
||||
* * feedback - Whether or not we want to give balloon alert feedback to the mod_pai. Defaults to FALSE.
|
||||
* * feedback - Whether or not we want to give balloon alert feedback to the ai. Defaults to FALSE.
|
||||
*/
|
||||
/obj/item/mod/control/proc/remove_pai(feedback = FALSE)
|
||||
if(!ispAI(ai))
|
||||
return
|
||||
var/mob/living/silicon/pai/pai = ai
|
||||
var/turf/drop_off = get_turf(src)
|
||||
if(drop_off) // In case there's no drop_off, the pAI will simply get deleted.
|
||||
mod_pai.card.forceMove(drop_off)
|
||||
pai.card.forceMove(drop_off)
|
||||
|
||||
for(var/datum/action/action as anything in actions)
|
||||
if(action.owner == mod_pai)
|
||||
action.Remove(mod_pai)
|
||||
if(action.owner == pai)
|
||||
action.Remove(pai)
|
||||
|
||||
if(feedback)
|
||||
balloon_alert(mod_pai, "removed from a suit")
|
||||
mod_pai.remote_control = null
|
||||
mod_pai.canholo = TRUE
|
||||
mod_pai = null
|
||||
balloon_alert(pai, "removed from a suit")
|
||||
pai.remote_control = null
|
||||
pai.canholo = TRUE
|
||||
pai = null
|
||||
|
||||
#define MOVE_DELAY 2
|
||||
#define WEARER_DELAY 1
|
||||
#define LONE_DELAY 5
|
||||
#define CELL_PER_STEP (DEFAULT_CHARGE_DRAIN * 2.5)
|
||||
#define AI_FALL_TIME (1 SECONDS)
|
||||
|
||||
/obj/item/mod/control/relaymove(mob/user, direction)
|
||||
if((!active && wearer) || !cell || cell.charge < CELL_PER_STEP || user != ai || !COOLDOWN_FINISHED(src, cooldown_mod_move) || (wearer?.pulledby?.grab_state > GRAB_PASSIVE))
|
||||
return FALSE
|
||||
if(wearer && (wearer.pulledby?.grab_state || wearer.incapacitated() || wearer.stat))
|
||||
return FALSE
|
||||
var/timemodifier = MOVE_DELAY * (ISDIAGONALDIR(direction) ? SQRT_2 : 1) * (wearer ? WEARER_DELAY : LONE_DELAY)
|
||||
COOLDOWN_START(src, cooldown_mod_move, movedelay * timemodifier + slowdown)
|
||||
playsound(src, 'sound/mecha/mechmove01.ogg', 25, TRUE)
|
||||
cell.charge = max(0, cell.charge - CELL_PER_STEP)
|
||||
if(ismovable(wearer?.loc))
|
||||
return wearer.loc.relaymove(wearer, direction)
|
||||
if(wearer && !wearer.Process_Spacemove(direction))
|
||||
return FALSE
|
||||
else if(!wearer && (!has_gravity() || !isturf(loc)))
|
||||
return FALSE
|
||||
COOLDOWN_START(src, cooldown_mod_move, movedelay * timemodifier + slowdown)
|
||||
cell.charge = max(0, cell.charge - CELL_PER_STEP)
|
||||
playsound(src, 'sound/mecha/mechmove01.ogg', 25, TRUE)
|
||||
if(ismovable(wearer?.loc))
|
||||
return wearer.loc.relaymove(wearer, direction)
|
||||
else if(wearer)
|
||||
ADD_TRAIT(wearer, TRAIT_MOBILITY_NOREST, MOD_TRAIT)
|
||||
addtimer(CALLBACK(src, .proc/ai_fall), AI_FALL_TIME, TIMER_UNIQUE | TIMER_OVERRIDE)
|
||||
var/atom/movable/mover = wearer || src
|
||||
return step(mover, direction)
|
||||
|
||||
@@ -171,8 +185,14 @@
|
||||
#undef WEARER_DELAY
|
||||
#undef LONE_DELAY
|
||||
#undef CELL_PER_STEP
|
||||
#undef AI_FALL_TIME
|
||||
|
||||
/obj/item/mod/control/proc/ai_fall()
|
||||
if(!wearer)
|
||||
return
|
||||
REMOVE_TRAIT(wearer, TRAIT_MOBILITY_NOREST, MOD_TRAIT)
|
||||
|
||||
/obj/item/mod/control/ui_state(mob/user)
|
||||
if(user == mod_pai)
|
||||
if(user == ai)
|
||||
return GLOB.contained_state
|
||||
return ..()
|
||||
|
||||
Reference in New Issue
Block a user