Files
SandPoot ffe55f67b1 go!!
2024-03-30 18:29:11 -03:00

99 lines
3.6 KiB
Plaintext

/obj/vehicle/sealed/car
layer = ABOVE_MOB_LAYER
anchored = TRUE
default_driver_move = FALSE
var/explode_on_death = TRUE
var/car_traits = NONE //Bitflag for special behavior such as kidnapping
var/engine_sound = 'sound/vehicles/carrev.ogg'
var/last_enginesound_time
var/engine_sound_length = 20 //Set this to the length of the engine sound
var/escape_time = 200 //Time it takes to break out of the car
/obj/vehicle/sealed/car/Initialize(mapload)
. = ..()
LoadComponent(/datum/component/riding)
/obj/vehicle/sealed/car/Destroy()
. = ..()
if(explode_on_death)
explosion(loc, 0, 1, 2, 3, 0)
/obj/vehicle/sealed/car/generate_actions()
. = ..()
initialize_controller_action_type(/datum/action/vehicle/sealed/remove_key, VEHICLE_CONTROL_DRIVE)
if(car_traits & CAN_KIDNAP)
initialize_controller_action_type(/datum/action/vehicle/sealed/dump_kidnapped_mobs, VEHICLE_CONTROL_DRIVE)
/obj/vehicle/sealed/car/driver_move(mob/user, direction)
if(key_type && !is_key(inserted_key))
to_chat(user, "<span class='warning'>[src] has no key inserted!</span>")
return FALSE
var/datum/component/riding/R = GetComponent(/datum/component/riding)
R.handle_ride(user, direction)
if(world.time < last_enginesound_time + engine_sound_length)
return
last_enginesound_time = world.time
playsound(src, engine_sound, 100, TRUE)
/obj/vehicle/sealed/car/MouseDrop_T(atom/dropping, mob/living/M)
if(!istype(M) || !CHECK_MOBILITY(M, MOBILITY_USE))
return FALSE
if(isliving(dropping) && M != dropping)
var/mob/living/L = dropping
L.visible_message("<span class='warning'>[M] starts forcing [L] into [src]!</span>")
mob_try_forced_enter(M, L)
return ..()
/obj/vehicle/sealed/car/mob_try_exit(mob/M, mob/user, silent = FALSE)
if(M == user && (LAZYACCESS(occupants, M) & VEHICLE_CONTROL_KIDNAPPED))
to_chat(user, "<span class='notice'>You push against the back of [src] trunk to try and get out.</span>")
if(!do_after(user, escape_time, target = src))
return FALSE
to_chat(user,"<span class='danger'>[user] gets out of [src]</span>")
mob_exit(M, silent)
return TRUE
mob_exit(M, silent)
return TRUE
/obj/vehicle/sealed/car/attacked_by(obj/item/I, mob/living/user, attackchain_flags = NONE, damage_multiplier = 1)
if(!I.force)
return FALSE
if(occupants[user])
to_chat(user, "<span class='notice'>Your attack bounces off of the car's padded interior.</span>")
return FALSE
return ..()
/obj/vehicle/sealed/car/on_attack_hand(mob/living/user, act_intent = user.a_intent, unarmed_attack_flags)
. = ..()
if(!(car_traits & CAN_KIDNAP))
return
if(occupants[user])
return
to_chat(user, "<span class='notice'>You start opening [src]'s trunk.</span>")
if(do_after(user, 30))
if(return_amount_of_controllers_with_flag(VEHICLE_CONTROL_KIDNAPPED))
to_chat(user, "<span class='notice'>The people stuck in [src]'s trunk all come tumbling out.</span>")
dump_specific_mobs(VEHICLE_CONTROL_KIDNAPPED)
else
to_chat(user, "<span class='notice'>It seems [src]'s trunk was empty.</span>")
/obj/vehicle/sealed/car/proc/mob_try_forced_enter(mob/forcer, mob/M, silent = FALSE)
if(!istype(M))
return FALSE
if(occupant_amount() >= max_occupants)
return FALSE
var/atom/old_loc = loc
if(do_mob(forcer, M, get_enter_delay(M), extra_checks=CALLBACK(src, TYPE_PROC_REF(/obj/vehicle/sealed/car, is_car_stationary), old_loc)))
mob_forced_enter(M, silent)
return TRUE
return FALSE
/obj/vehicle/sealed/car/proc/is_car_stationary(atom/old_loc)
return (old_loc == loc)
/obj/vehicle/sealed/car/proc/mob_forced_enter(mob/M, silent = FALSE)
if(!silent)
M.visible_message("<span class='warning'>[M] is forced into \the [src]!</span>")
M.forceMove(src)
add_occupant(M, VEHICLE_CONTROL_KIDNAPPED)