Skip to content

Commit 5fe0242

Browse files
Addressing some comments on beewrite PR.
1 parent bb16e71 commit 5fe0242

File tree

9 files changed

+64
-39
lines changed

9 files changed

+64
-39
lines changed

code/__defines/misc.dm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,3 +407,4 @@
407407
// In theory, one pollen every 5 seconds (at time of writing)
408408
#define POLLEN_PER_SECOND 0.2
409409
#define POLLEN_PRODUCTION_MULT (POLLEN_PER_SECOND * (SSplants.wait / 10))
410+
#define MAX_POLLEN_PER_FLOWER 10

code/game/objects/items/devices/chameleonproj.dm

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
density = FALSE
103103
anchored = TRUE
104104
is_spawnable_type = FALSE
105-
movement_handlers = list(/datum/movement_handler/delay/chameleon_projector)
105+
movement_handlers = list(/datum/movement_handler/delay/chameleon_projector = list(2.5 SECONDS))
106106
var/obj/item/chameleon/master = null
107107

108108
/obj/effect/dummy/chameleon/Initialize(mapload, var/obj/item/chameleon/projector)
@@ -152,9 +152,6 @@
152152
if(!my_turf.get_supporting_platform() && !(locate(/obj/structure/lattice) in loc))
153153
disrupted()
154154

155-
/datum/movement_handler/delay/chameleon_projector
156-
delay = 2.5 SECONDS
157-
158155
/datum/movement_handler/delay/chameleon_projector/MayMove(mob/mover, is_external)
159156
return host.loc?.has_gravity() ? ..() : MOVEMENT_STOP
160157

code/game/objects/structures/flora/plant.dm

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
var/dead = FALSE
88
var/sampled = FALSE
99
var/datum/seed/plant
10-
var/harvestable = 0
10+
var/harvestable = 0 // Note that this is a counter, not a bool.
1111
var/pollen = 0
1212

1313
/obj/structure/flora/plant/large
@@ -17,7 +17,7 @@
1717
/obj/structure/flora/plant/Process()
1818
if(plant?.produces_pollen <= 0)
1919
return PROCESS_KILL
20-
if(pollen < 10)
20+
if(pollen < MAX_POLLEN_PER_FLOWER)
2121
pollen += plant.produces_pollen * POLLEN_PRODUCTION_MULT
2222

2323
/* Notes for future work moving logic off hydrotrays onto plants themselves:
@@ -164,6 +164,7 @@
164164
icon_state = "flower5"
165165
is_spawnable_type = TRUE
166166

167+
// Only contains roundstart plants, this is meant to be a mapping helper.
167168
/obj/structure/flora/plant/random_flower/proc/get_flower_variants()
168169
var/static/list/flower_variants
169170
if(isnull(flower_variants))

code/modules/hydroponics/trays/tray_process.dm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,9 @@
6565
mutate((rand(100) < 15) ? 2 : 1)
6666
mutation_level = 0
6767

68-
if(pollen < 10)
68+
if(pollen < MAX_POLLEN_PER_FLOWER)
6969
pollen += seed?.produces_pollen * POLLEN_PRODUCTION_MULT
70+
to_world("\ref[src] has pollen [pollen] ([seed?.produces_pollen] * [POLLEN_PRODUCTION_MULT])")
7071

7172
// Maintain tray nutrient and water levels.
7273
if(seed.get_trait(TRAIT_REQUIRES_NUTRIENTS) && seed.get_trait(TRAIT_NUTRIENT_CONSUMPTION) > 0 && nutrilevel > 0 && prob(25))

code/modules/mob/living/living.dm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2005,3 +2005,6 @@ default behaviour is:
20052005

20062006
/mob/living/is_cloaked()
20072007
return has_mob_modifier(/decl/mob_modifier/cloaked)
2008+
2009+
/mob/living/proc/is_playing_dead()
2010+
return stat || current_posture?.prone || (status_flags & FAKEDEATH)

code/modules/mob/mob_automove.dm

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
/mob/failed_automove()
2626
..()
2727
stop_automove()
28-
_automove_target = null
2928
return FALSE
3029

3130
/mob/start_automove(target, movement_type, datum/automove_metadata/metadata)

mods/content/beekeeping/hives/hive_swarm.dm

Lines changed: 42 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
default_pixel_z = 8
77
layer = ABOVE_HUMAN_LAYER
88
pass_flags = PASS_FLAG_TABLE
9-
movement_handlers = list(/datum/movement_handler/delay/insect_swarm)
9+
movement_handlers = list(/datum/movement_handler/delay/insect_swarm = list(1 SECOND))
1010

1111
/// Current movement target for automove (ie. hive, flowers or victim)
1212
VAR_PRIVATE/atom/move_target
@@ -18,16 +18,11 @@
1818
var/swarm_agitation = 0
1919
/// Percentage value; if it drops to 0, the swarm will be destroyed.
2020
var/swarm_intensity = 1
21-
/// if more states are added to swarm.dmi, increase this
22-
var/const/MAX_SWARM_STATE = 6
2321
/// Cooldown timer for next tick.
2422
VAR_PRIVATE/next_work = 0
2523
/// Time that smoke will wear off.
2624
var/smoked_until = 0
2725

28-
/datum/movement_handler/delay/insect_swarm
29-
delay = 1 SECOND
30-
3126
/datum/movement_handler/delay/insect_swarm/DoMove(direction, mob/mover, is_external)
3227
..()
3328
step(host, direction)
@@ -46,8 +41,7 @@
4641
if(!istype(owner))
4742
PRINT_STACK_TRACE("Insect swarm created with invalid hive: '[owner]'")
4843
return INITIALIZE_HINT_QDEL
49-
color = insect_type.swarm_color
50-
icon = insect_type.swarm_icon
44+
update_transform()
5145
update_swarm()
5246
LAZYDISTINCTADD(owner.swarms, src)
5347
START_PROCESSING(SSobj, src)
@@ -61,9 +55,29 @@
6155
STOP_PROCESSING(SSobj, src)
6256
return ..()
6357

58+
// Resolves the current swarm amount to a coarser value used for icon state selection.
59+
/obj/effect/insect_swarm/proc/get_swarm_state()
60+
return ceil((swarm_intensity / insect_type.max_swarm_intensity) * insect_type.max_swarm_state)
61+
62+
/obj/effect/insect_swarm/on_update_icon()
63+
. = ..()
64+
color = insect_type.swarm_color
65+
icon = insect_type.swarm_icon
66+
icon_state = num2text(get_swarm_state())
67+
if(is_smoked())
68+
icon_state = "[icon_state]_smoked"
69+
70+
/obj/effect/insect_swarm/update_transform()
71+
. = ..()
72+
// Some icon variation via transform.
73+
if(prob(75))
74+
var/matrix/swarm_transform = transform || matrix()
75+
swarm_transform.Turn(pick(90, 180, 270))
76+
transform = swarm_transform
77+
6478
/obj/effect/insect_swarm/proc/update_swarm()
65-
icon_state = num2text(ceil((swarm_intensity / insect_type.max_swarm_intensity) * MAX_SWARM_STATE))
66-
if(icon_state == "1")
79+
update_icon()
80+
if(get_swarm_state() == 1)
6781
SetName(insect_type.name_singular)
6882
desc = insect_type.insect_desc
6983
gender = NEUTER
@@ -72,21 +86,13 @@
7286
desc = insect_type.swarm_desc
7387
gender = PLURAL
7488

75-
// Some icon variation via transform.
76-
if(prob(75))
77-
var/matrix/swarm_transform = matrix()
78-
swarm_transform.Turn(pick(90, 180, 270))
79-
8089
/obj/effect/insect_swarm/proc/is_agitated()
8190
return QDELETED(owner) || (swarm_agitation > 0 && !is_smoked())
8291

8392
/obj/effect/insect_swarm/proc/find_sting_target()
8493
for(var/mob/living/victim in view(7, src))
85-
if(!victim.simulated || victim.stat || victim.current_posture?.prone)
86-
continue
87-
if(victim.isSynthetic())
88-
continue
89-
return victim
94+
if(victim.simulated && !victim.is_playing_dead())
95+
return victim
9096

9197
/obj/effect/insect_swarm/proc/merge(obj/effect/insect_swarm/other_swarm)
9298

@@ -189,23 +195,24 @@
189195
break
190196
return FALSE
191197

198+
/obj/effect/insect_swarm/failed_automove()
199+
..()
200+
stop_automove()
201+
return FALSE
202+
192203
/obj/effect/insect_swarm/get_automove_target(datum/automove_metadata/metadata)
193204
return move_target
194205

195206
/obj/effect/insect_swarm/stop_automove()
196-
SHOULD_CALL_PARENT(FALSE)
197207
move_target = null
198-
//. = ..() // TODO work out why they're not automoving
199-
walk(src, 0)
208+
. = ..()
209+
210+
/obj/effect/insect_swarm/can_do_automated_move(variant_move_delay)
211+
return !is_smoked()
200212

201213
/obj/effect/insect_swarm/start_automove(target, movement_type, datum/automove_metadata/metadata)
202-
SHOULD_CALL_PARENT(FALSE)
203214
move_target = target
204-
//. = ..() // TODO work out why they're not automoving
205-
if(move_target)
206-
walk_to(src, move_target, 0, 7)
207-
else
208-
walk(src, 0)
215+
. = ..()
209216

210217
/obj/effect/insect_swarm/proc/handle_hive_behavior()
211218

@@ -272,6 +279,10 @@
272279
merge(other_swarm)
273280
return
274281

282+
/obj/effect/insect_swarm/DoMove(direction, mob/mover, is_external)
283+
. = ..()
284+
to_world("swarm tried to move: [.]")
285+
275286
/obj/effect/insect_swarm/pollinator
276287
var/pollen = 0
277288

@@ -349,10 +360,10 @@
349360
else
350361
start_automove(owner.holder)
351362

352-
// TODO: update icon (twitching on ground?)
353-
// TODO: lower agitation
354363
/obj/effect/insect_swarm/proc/was_smoked(smoke_time = 10 SECONDS)
355364
smoked_until = max(smoked_until, world.time + smoke_time)
365+
swarm_agitation = round(swarm_agitation * 0.75)
366+
addtimer(CALLBACK(src, TYPE_PROC_REF(/atom, update_icon), TRUE), smoke_time, (TIMER_UNIQUE|TIMER_OVERRIDE))
356367

357368
/obj/effect/insect_swarm/proc/is_smoked()
358369
return world.time < smoked_until

mods/content/beekeeping/hives/insect_species/_insects.dm

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
var/swarm_type = /obj/effect/insect_swarm
2323
var/max_swarm_growth_intensity = 50
2424
var/max_swarm_intensity = 100
25+
var/max_swarm_state = 6
2526

2627
// Venom delivered by swarms whens stinging a victim.
2728
var/sting_reagent
@@ -72,6 +73,17 @@
7273
if(!istype(produce_material, /decl/material))
7374
. += "non-material product material type: '[produce_material]'"
7475

76+
if(!swarm_icon)
77+
. += "null swarm icon"
78+
else
79+
for(var/i = 0 to max_swarm_state)
80+
var/check_state = num2text(i)
81+
if(!check_state_in_icon(check_state, swarm_icon))
82+
. += "missing active icon_state '[check_state]'"
83+
check_state = "[check_state]_smoked"
84+
if(!check_state_in_icon(check_state, swarm_icon))
85+
. += "missing smoked icon_state '[check_state]'"
86+
7587
/decl/insect_species/proc/fill_hive_frame(obj/item/frame)
7688

7789
if(!istype(frame) || QDELETED(frame))
108 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)