Skip to content

Commit

Permalink
add: Added nice presents positioning around Christmas trees (#4146)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladisvell authored Dec 29, 2023
1 parent c6f8bf1 commit a51286a
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 6 deletions.
5 changes: 4 additions & 1 deletion code/game/objects/structures/flora.dm
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,18 @@
name = "pine tree"
icon = 'icons/obj/flora/pinetrees.dmi'
icon_state = "pine_1"
var/randomize_tree = TRUE

/obj/structure/flora/tree/pine/Initialize(mapload)
. = ..()
icon_state = "pine_[rand(1, 3)]"
if(randomize_tree)
icon_state = "pine_[rand(1, 3)]"

/obj/structure/flora/tree/pine/xmas
name = "xmas tree"
icon = 'icons/obj/flora/pinetrees.dmi'
icon_state = "pine_c"
randomize_tree = FALSE

/obj/structure/flora/tree/dead
icon = 'icons/obj/flora/deadtrees.dmi'
Expand Down
50 changes: 45 additions & 5 deletions code/modules/holiday/christmas.dm
Original file line number Diff line number Diff line change
@@ -1,18 +1,58 @@
/datum/holiday/xmas/handle_event()
for(var/obj/structure/flora/tree/pine/xmas in world)
for(var/obj/structure/flora/tree/pine/xmas/xmas in world)
if(!is_station_level(xmas.z)) continue
for(var/turf/simulated/floor/T in orange(1,xmas))
for(var/turf/simulated/floor/T in (xmas.get_all_adjacent_turfs() - get_turf(xmas)))
var/direction = get_dir(xmas, T)
for(var/i=1,i<=rand(1,5),i++)
new /obj/item/a_gift(T)
var/obj/item/a_gift/gift = new(T)
handle_present_location(gift, direction, 16)

for(var/mob/living/simple_animal/pet/dog/corgi/Ian/Ian in GLOB.mob_list)
Ian.place_on_head(new /obj/item/clothing/head/helmet/space/santahat)
for(var/datum/crafting_recipe/snowman/S in GLOB.crafting_recipes)
S.always_availible = TRUE
break
var/datum/supply_packs/misc/snow_machine/xmas = SSshuttle.supply_packs["[/datum/supply_packs/misc/snow_machine]"]
xmas.special = FALSE
if(prob(eventChance))
spawnTree()

//As fun at it is sounds, peacefulness is better
//if(prob(eventChance))
// spawnTree()

/**
* Offsets pixel location for presents to move visually closer to direction
*/
/datum/holiday/xmas/proc/handle_present_location(obj/present, center_direction, offset)
var/pixel_x_offset = 0
var/pixel_y_offset = 0
switch(center_direction)
if(NORTH)
pixel_x_offset = rand(-offset, offset)
pixel_y_offset = rand(-offset, 0)
if(SOUTH)
pixel_x_offset = rand(-offset, offset)
pixel_y_offset = rand(0, offset)
if(EAST)
pixel_x_offset = rand(-offset, 0)
pixel_y_offset = rand(-offset, offset)
if(WEST)
pixel_x_offset = rand(0, offset)
pixel_y_offset = rand(-offset, offset)
if(NORTHEAST)
pixel_x_offset = rand(-offset, 0)
pixel_y_offset = rand(-offset, 0)
if(NORTHWEST)
pixel_x_offset = rand(0, offset)
pixel_y_offset = rand(-offset, 0)
if(SOUTHEAST)
pixel_x_offset = rand(-offset, 0)
pixel_y_offset = rand(0, offset)
if(SOUTHWEST)
pixel_x_offset = rand(0, offset)
pixel_y_offset = rand(0, offset)

present.pixel_x = pixel_x_offset
present.pixel_y = pixel_y_offset

/datum/holiday/xmas/proc/spawnTree()
for(var/obj/structure/flora/tree/pine/xmas in world)
Expand Down

0 comments on commit a51286a

Please sign in to comment.