Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds a plantable UA flag in the CIC armoury #6492

Merged
merged 14 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
135 changes: 135 additions & 0 deletions code/game/objects/items/stacks/flags.dm
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,138 @@
newflag.icon_state = "[newflag.base_state]_open"
newflag.visible_message("<b>[user]</b> plants [newflag] firmly in the ground.")
src.use(1)


/// PLANTABLE FLAG

/obj/structure/flag/plantable
name = "flag"
desc = "A flag of something. This one looks like you could dismantle it."
icon = 'icons/obj/structures/plantable_flag.dmi'
pixel_x = 9 // All flags need to be offset to the right by 9 to be centered.
layer = ABOVE_MOB_LAYER

var/flag_type = /obj/item/flag/plantable /// The typepath for the flag item that gets spawned when the flag is taken down.
COOLDOWN_DECLARE(warcry_cooldown_struc) /// Used to limit the spam of the warcry_extra_sound
VileBeggar marked this conversation as resolved.
Show resolved Hide resolved

/obj/structure/flag/plantable/attack_hand(mob/user)
..()
disassemble(user, flag_type)

/obj/structure/flag/plantable/proc/disassemble(mob/user, flag_type)
VileBeggar marked this conversation as resolved.
Show resolved Hide resolved
if(user.action_busy)
return

user.visible_message(SPAN_NOTICE("[user] starts taking [src] down..."), SPAN_NOTICE("You start taking [src] down..."))

playsound(user, 'sound/effects/flag_raising.ogg', 30)
if(!do_after(user, 6 SECONDS, INTERRUPT_ALL, BUSY_ICON_GENERIC))
return

playsound(user, 'sound/effects/flag_raised.ogg', 30)
user.visible_message(SPAN_NOTICE("[user] starts takes [src] down!"), SPAN_NOTICE("You take [src] down!"))
var/obj/item/flag/plantable/flag_item = new flag_type(src.loc)
VileBeggar marked this conversation as resolved.
Show resolved Hide resolved
user.put_in_hands(flag_item)
COOLDOWN_START(flag_item, warcry_cooldown_item, COOLDOWN_TIMELEFT(src, warcry_cooldown_struc))
qdel(src)

/obj/item/flag/plantable
name = "plantable flag"
desc = "A flag of something. This one looks ready to be planted into the ground."
w_class = SIZE_LARGE
throw_range = 2
icon = 'icons/obj/structures/plantable_flag.dmi'
inhand_x_dimension = 64
inhand_y_dimension = 64
item_icons = list(
WEAR_L_HAND = 'icons/mob/humans/onmob/items_lefthand_64.dmi',
WEAR_R_HAND = 'icons/mob/humans/onmob/items_righthand_64.dmi'
)

var/flag_type = /obj/structure/flag/plantable /// The typepath of the flag structure that gets spawned when the flag is planted.
var/faction /// Used to check if nearby mobs belong to a faction when calculating for the stronger warcry.
var/play_warcry = FALSE /// Does the flag play a unique warcry when planted? (Only while on harm intent.)
var/warcry_sound /// The warcry's sound path.
var/warcry_extra_sound /// When there are more than 14 allies nearby, play this stronger warcry.
COOLDOWN_DECLARE(warcry_cooldown_item) /// Used to limit the spam of the warcry_extra_sound
VileBeggar marked this conversation as resolved.
Show resolved Hide resolved

/obj/item/flag/plantable/get_examine_text()
. = ..()
if(play_warcry)
. += SPAN_NOTICE("Planting the flag while in <b>HARM</b> intent will cause you to bellow out a rallying warcry!")

/obj/item/flag/plantable/proc/plant_flag(mob/living/user, play_warcry = FALSE, warcry_sound, warcry_extra_sound, faction)
VileBeggar marked this conversation as resolved.
Show resolved Hide resolved
if(user.action_busy)
return

if(SSinterior.in_interior(user))
to_chat(usr, SPAN_WARNING("There's no way to plant [src] in here!"))
return

var/turf/turf_to_plant = get_step(user, user.dir)
for(var/obj/object in turf_to_plant)
if(object.density)
to_chat(usr, SPAN_WARNING("You need a clear, open area to plant [src], something is blocking the way in front of you!"))
return

user.visible_message(SPAN_NOTICE("[user] starts planting [src] into the ground..."), SPAN_NOTICE("You start planting [src] into the ground..."))
playsound(user, 'sound/effects/flag_raising.ogg', 30)
if(!do_after(user, 6 SECONDS, INTERRUPT_ALL, BUSY_ICON_GENERIC))
return

user.visible_message(SPAN_NOTICE("[user] plants [src] into the ground!"), SPAN_NOTICE("You plant [src] into the ground!"))
var/obj/structure/flag/plantable/planted_flag = new flag_type(turf_to_plant)

// If there are more than 14 allies nearby, play a stronger rallying cry.
// Otherwise, play the default warcry sound if there is one. If not, play a generic flag raising sfx.
if(play_warcry && user.faction == faction && user.a_intent == INTENT_HARM)
var/allies_nearby = 0
if(COOLDOWN_FINISHED(src, warcry_cooldown_item))
for (var/mob/living/carbon/human in orange(planted_flag, 7))
if (human.stat == DEAD)
continue
if (human.faction != faction)
continue
VileBeggar marked this conversation as resolved.
Show resolved Hide resolved
allies_nearby++
if (prob(40) && human != user)
human.emote("warcry")

user.show_speech_bubble("warcry")
if(allies_nearby > 14)
playsound(user, warcry_extra_sound, 30)
// Start a cooldown on the flag structure. This way we can keep track of the cooldown when the flag is hoisted and taken down.
COOLDOWN_START(planted_flag, warcry_cooldown_struc, 90 SECONDS)
user.say("*me shouts an invigorating rallying cry!")
VileBeggar marked this conversation as resolved.
Show resolved Hide resolved
else
playsound(user, warcry_sound, 30)
user.say("*me shouts an inspiring cry!")
VileBeggar marked this conversation as resolved.
Show resolved Hide resolved
// Ditto. If the cooldown isn't finished we have to transfer the leftover time to the structure.
COOLDOWN_START(planted_flag, warcry_cooldown_struc, COOLDOWN_TIMELEFT(src, warcry_cooldown_item))
else
playsound(user, 'sound/effects/flag_raised.ogg', 30)

qdel(src)

/obj/item/flag/plantable/attack_self(mob/user)
..()
plant_flag(user, play_warcry, warcry_sound, warcry_extra_sound, faction)

// UNITED AMERICAS FLAG //
//////////////////////////

/obj/item/flag/plantable/ua
name = "\improper United Americas flag"
desc = "The flag of the United Americas. Your forefathers died to raise this flag. Are you ready to do the same?"
icon = 'icons/obj/structures/plantable_flag.dmi'
icon_state = "flag_ua"
flag_type = /obj/structure/flag/plantable/ua
faction = FACTION_MARINE
play_warcry = TRUE
warcry_sound = 'sound/effects/flag_warcry_ua.ogg'
warcry_extra_sound = 'sound/effects/flag_warcry_ua_extra.ogg'

/obj/structure/flag/plantable/ua
name = "\improper United Americas flag"
desc = "The flag of the United Americas. Semper fi, marine."
icon_state = "flag_ua_planted"
flag_type = /obj/item/flag/plantable/ua
2 changes: 1 addition & 1 deletion code/game/objects/objs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@

var/offset_x = worn_x_dimension
var/offset_y = worn_y_dimension
if(inhands)
if(inhands == 1 || inhands == 0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the purpose of this

Copy link
Contributor Author

@VileBeggar VileBeggar Jun 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the 64x64 right inhands are broken because if(ifhands) is only valid for the value 1 and having an item in your right hand sets the inhands variable to 0

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no point to this if check then. It can only ever possibly be 1 or 0

offset_x = inhand_x_dimension
offset_y = inhand_y_dimension

Expand Down
Binary file modified icons/mob/humans/onmob/items_lefthand_64.dmi
Binary file not shown.
Binary file modified icons/mob/humans/onmob/items_righthand_64.dmi
Binary file not shown.
Binary file added icons/obj/structures/plantable_flag.dmi
Binary file not shown.
1 change: 1 addition & 0 deletions maps/map_files/USS_Almayer/USS_Almayer.dmm
Original file line number Diff line number Diff line change
Expand Up @@ -3241,6 +3241,7 @@
/obj/item/device/radio/marine,
/obj/item/device/radio/marine,
/obj/item/folded_tent/cmd,
/obj/item/flag/plantable/ua,
/turf/open/floor/almayer{
icon_state = "redfull"
},
Expand Down
Binary file added sound/effects/.wav
Binary file not shown.
Binary file added sound/effects/flag_lowering.ogg
Binary file not shown.
Binary file added sound/effects/flag_raised.ogg
Binary file not shown.
Binary file added sound/effects/flag_raising.ogg
Binary file not shown.
Binary file added sound/effects/flag_warcry_ua.ogg
Binary file not shown.
Binary file added sound/effects/flag_warcry_ua_extra.ogg
Binary file not shown.
Loading