Skip to content

Commit

Permalink
Windows airbag (#509)
Browse files Browse the repository at this point in the history
<!-- Пишите **НИЖЕ** заголовков и **ВЫШЕ** комментариев, иначе что то
может пойти не так. -->
<!-- Вы можете прочитать Contributing.MD, если хотите узнать больше. -->

## Что этот PR делает

<!-- Вкратце опишите изменения, которые вносите. -->
<!-- Опишите **все** изменения, так как противное может сказаться на
рассмотрении этого PR'а! -->
<!-- Если вы исправляете Issue, добавьте "Fixes #1234" (где 1234 - номер
Issue) где-нибудь в описании PR'а. Это автоматически закроет Issue после
принятия PR'а. -->

Добавляет в укрепленные фулл-тайл окна элемент Airbag, который при
взрыве окна ставит воздушную подушку.

## Почему это хорошо для игры

<!-- Опишите, почему, по вашему, следует добавить эти изменения в игру.
-->

Меньше разгерм, больше логики (окна на станции не защищены от поломки)

## Изображения изменений
<!-- Если вы не меняли карту или спрайты, можете опустить эту секцию.
Если хотите, можете вставить видео. -->


https://github.com/ss220club/Paradise-SS220/assets/31931237/e4721526-b34a-4a3d-8759-7ab536a6dd35


## Changelog

:cl:
add: Добавлена воздушная подушка в укрепленные окна. Появляются при
установке такого окна. Обратно установить нельзя.
/:cl:

<!-- Оба :cl:'а должны быть на месте, что-бы чейнджлог работал! Вы
можете написать свой ник справа от первого :cl:, если хотите. Иначе
будет использован ваш ник на ГитХабе. -->
<!-- Вы можете использовать несколько записей с одинаковым префиксом
(Они используются только для иконки в игре) и удалить ненужные. Помните,
что чейнджлог должен быть понятен обычным игроком. -->
<!-- Если чейнджлог не влияет на игроков(например, это рефактор), вы
можете исключить всю секцию. -->
  • Loading branch information
larentoun authored Nov 13, 2023
1 parent 9f11f38 commit 82aa318
Show file tree
Hide file tree
Showing 11 changed files with 151 additions and 0 deletions.
1 change: 1 addition & 0 deletions modular_ss220/_defines220/_defines220.dme
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "code/signals_mob/signals_mob_silicon.dm"
#include "code/signals_mob/signals_mob_simple.dm"
#include "code/signals_keybindings.dm"
#include "code/signals_obj.dm"
#include "code/cult_defines_ss220.dm"
#include "code/hud_ss220.dm"
#include "code/layers_ss220.dm"
2 changes: 2 additions & 0 deletions modular_ss220/_defines220/code/signals_obj.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/// from base of [/obj/proc/atom_destruction]: (damage_flag)
#define COMSIG_OBJ_DESTRUCTION "atom_destruction"
1 change: 1 addition & 0 deletions modular_ss220/_signals220/_signals220.dme
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
#include "code/signals_mob/signals_mob_main.dm"
#include "code/signals_mob/signals_mob_silicon.dm"
#include "code/signals_mob/signals_mob_simple.dm"
#include "code/signals_obj.dm"
3 changes: 3 additions & 0 deletions modular_ss220/_signals220/code/signals_obj.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/obj/obj_destruction(damage_flag)
SEND_SIGNAL(src, COMSIG_OBJ_DESTRUCTION, damage_flag)
. = ..()
1 change: 1 addition & 0 deletions modular_ss220/modular_ss220.dme
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "silicons/_silicons.dme"
#include "silicon_hats/_silicon_hats.dme"
#include "hampter/_hampter.dme"
#include "windows_airbag/_windows_airbag.dme"

// --- MISC --- //
#include "administration/_administration.dme"
Expand Down
4 changes: 4 additions & 0 deletions modular_ss220/windows_airbag/_windows_airbag.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/datum/modpack/windows_airbag
name = "Windows airbag"
desc = "Добавляет в укрепленные фулл-тайл окна воздушную подушку."
author = "larentoun"
3 changes: 3 additions & 0 deletions modular_ss220/windows_airbag/_windows_airbag.dme
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include "_windows_airbag.dm"

#include "code/windows_airbag.dm"
136 changes: 136 additions & 0 deletions modular_ss220/windows_airbag/code/windows_airbag.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
#define DISARM_TIME (3 SECONDS)

/obj/structure/window/full/reinforced/Initialize(mapload, direct)
. = ..()
AddElement(/datum/element/airbag)

/**
* Airbag Element
*
* Basically a fancy create on destroy.
*/
/datum/element/airbag
/// The type we spawn when our parent is destroyed
var/airbag_type = /obj/item/airbag/immediate_arm
/// The type we spawn when we are disarmed.
var/disarmed_type = /obj/item/airbag

/datum/element/airbag/Attach(datum/target)
. = ..()
if(!ismovable(target))
return ELEMENT_INCOMPATIBLE

RegisterSignal(target, COMSIG_OBJ_DESTRUCTION, PROC_REF(deploy_airbag))
RegisterSignal(target, COMSIG_PARENT_EXAMINE, PROC_REF(on_examine))
RegisterSignal(target, COMSIG_CLICK_ALT, PROC_REF(on_altclick))

/datum/element/airbag/Detach(datum/target)
. = ..()
UnregisterSignal(target, list(COMSIG_OBJ_DESTRUCTION, COMSIG_PARENT_EXAMINE, COMSIG_CLICK_ALT))

/datum/element/airbag/proc/deploy_airbag(atom/movable/destroying_atom, damage_flag)
SIGNAL_HANDLER

new airbag_type(get_turf(destroying_atom))

/datum/element/airbag/proc/on_examine(datum/source, mob/user, list/examine_text)
SIGNAL_HANDLER

examine_text += span_warning("It has a blinking red light indicating an airbag is installed. <b>Alt+click</b> to disarm.")

/datum/element/airbag/proc/on_altclick(atom/movable/clicked_atom, mob/living/clicker)
SIGNAL_HANDLER

if(get_dist(clicker, clicked_atom) > 1)
return
INVOKE_ASYNC(src, PROC_REF(disarm_airbag), clicked_atom, clicker)

/datum/element/airbag/proc/disarm_airbag(atom/movable/clicked_atom, mob/living/clicker)
clicker.visible_message(span_notice("[clicker] starts disarming the airbag..."), span_notice("You start disarming the airbag..."))
clicked_atom.add_fingerprint(clicker)
if(do_after_once(clicker, DISARM_TIME, target = clicked_atom, progress = TRUE))
new disarmed_type(get_turf(clicked_atom))
Detach(clicked_atom)

// A fun little gadget!
/obj/item/airbag
name = "airbag"
desc = "A small package with an explosive attached. Stand clear!"
icon = 'modular_ss220/windows_airbag/icons/windows_airbag.dmi'
icon_state = "airbag"
max_integrity = 10
/// The time in which we deploy
var/detonate_time = 2 SECONDS
/// The item we drop on detonation
var/drop_type = /obj/structure/inflatable/window_airbag
/// Are we immediately armed?
var/immediate_arm = FALSE
/// Are we currently armed?
var/armed = FALSE
/// The sound we play when armed
var/armed_sound = 'modular_ss220/windows_airbag/sound/airbag_arm.ogg'
/// The sound we play when we go bang
var/bang_sound = 'modular_ss220/windows_airbag/sound/airbag_bang.ogg'

/obj/item/airbag/Initialize(mapload)
. = ..()
if(immediate_arm)
arm()
anchored = TRUE
update_icon()

/obj/item/airbag/update_icon_state()
icon_state = "[initial(icon_state)]_[armed ? "armed" : "safe"]"

/obj/item/airbag/attack_self(mob/user, modifiers)
. = ..()
arm()

/obj/item/airbag/proc/arm()
if(armed)
return
if(!anchored)
addtimer(CALLBACK(src, PROC_REF(deploy_anchor)), 1 SECONDS)
addtimer(CALLBACK(src, PROC_REF(airbag_bang)), detonate_time)
armed = TRUE
playsound(src, armed_sound, 50)
update_icon()

// Anchors the airbag to the ground, namely to prevent air movement.
/obj/item/airbag/proc/deploy_anchor()
if(!isturf(loc) || anchored)
return
anchored = TRUE

// Detonates the airbag, dropping the item and playing the sound.
/obj/item/airbag/proc/airbag_bang()
var/obj/created_object = new drop_type(get_turf(src))
playsound(src, bang_sound, 50)
var/datum/effect_system/smoke_spread/smoke = new
smoke.set_up(1, TRUE, get_turf(created_object.loc))
smoke.start()
qdel(src)

/obj/item/airbag/torn
name = "torn window airbag"
desc = "A quick deploying airbag that seals holes when a window is broken! It is too torn to be usable."
icon = 'modular_ss220/windows_airbag/icons/windows_airbag.dmi'

/obj/item/airbag/torn/update_icon_state()
icon_state = "[initial(icon_state)]_folded_torn"

/obj/item/airbag/torn/arm()
return

/obj/item/airbag/immediate_arm
immediate_arm = TRUE

/obj/structure/inflatable/window_airbag
name = "window airbag"
desc = "A quick deploying airbag that seals holes when a window is broken!"
icon = 'modular_ss220/windows_airbag/icons/windows_airbag.dmi'
icon_state = "airbag_wall"
torn = /obj/item/airbag/torn
intact = /obj/item/airbag/torn

#undef DISARM_TIME
Binary file not shown.
Binary file added modular_ss220/windows_airbag/sound/airbag_arm.ogg
Binary file not shown.
Binary file not shown.

0 comments on commit 82aa318

Please sign in to comment.