It's the bees

This commit is contained in:
TheDZD
2016-04-14 20:30:30 -04:00
parent 985ab85aae
commit eba294357a
26 changed files with 695 additions and 269 deletions
@@ -0,0 +1,247 @@
#define BEEBOX_MAX_FRAMES 3 //Max frames per box
#define BEES_RATIO 0.5 //Multiplied by the max number of honeycombs to find the max number of bees
#define BEE_PROB_NEW_BEE 20 //The chance for spare bee_resources to be turned into new bees
#define BEE_RESOURCE_HONEYCOMB_COST 100 //The amount of bee_resources for a new honeycomb to be produced, percentage cost 1-100
#define BEE_RESOURCE_NEW_BEE_COST 50 //The amount of bee_resources for a new bee to be produced, percentage cost 1-100
/mob/proc/bee_friendly()
return 0
/mob/living/simple_animal/hostile/poison/bees/bee_friendly()
return 1
/mob/living/carbon/human/bee_friendly()
if(get_species() == "Diona") //bees pollinate plants, duh.
return 1
if((wear_suit && (wear_suit.flags & THICKMATERIAL)) && (head && (head.flags & THICKMATERIAL)))
return 1
return 0
/obj/structure/beebox
name = "apiary"
desc = "Dr Miles Manners is just your average Wasp themed super hero by day, but by night he becomes DR BEES!"
icon = 'icons/obj/apiary_bees.dmi'
icon_state = "beebox"
anchored = 1
density = 1
var/mob/living/simple_animal/hostile/poison/bees/queen/queen_bee = null
var/list/bees = list() //bees owned by the box, not those inside it
var/list/honeycombs = list()
var/list/honey_frames = list()
var/bee_resources = 0
/obj/structure/beebox/New()
..()
processing_objects.Add(src)
/obj/structure/beebox/Destroy()
processing_objects.Remove(src)
bees.Cut()
bees = null
honeycombs.Cut()
honeycombs = null
queen_bee = null
return ..()
//Premade apiaries can spawn with a random reagent
/obj/structure/beebox/premade
var/random_reagent = FALSE
/obj/structure/beebox/premade/New()
..()
var/datum/reagent/R = null
if(random_reagent)
R = pick(subtypesof(/datum/reagent))
R = chemical_reagents_list[initial(R.id)]
queen_bee = new(src)
queen_bee.beehome = src
bees += queen_bee
queen_bee.assign_reagent(R)
for(var/i in 1 to BEEBOX_MAX_FRAMES)
var/obj/item/honey_frame/HF = new(src)
honey_frames += HF
for(var/i in 1 to get_max_bees())
var/mob/living/simple_animal/hostile/poison/bees/B = new(src)
bees += B
B.beehome = src
B.assign_reagent(R)
/obj/structure/beebox/premade/random
random_reagent = TRUE
/obj/structure/beebox/process()
if(queen_bee)
if(bee_resources >= BEE_RESOURCE_HONEYCOMB_COST)
if(honeycombs.len < get_max_honeycomb())
bee_resources = max(bee_resources-BEE_RESOURCE_HONEYCOMB_COST, 0)
var/obj/item/weapon/reagent_containers/honeycomb/HC = new(src)
if(queen_bee.beegent)
HC.set_reagent(queen_bee.beegent.id)
honeycombs += HC
if(bees.len < get_max_bees())
var/freebee = FALSE //a freebee, geddit?, hahaha HAHAHAHA
if(bees.len <= 1) //there's always one set of worker bees, this isn't colony collapse disorder its 2d spessmen
freebee = TRUE
if((bee_resources >= BEE_RESOURCE_NEW_BEE_COST && prob(BEE_PROB_NEW_BEE)) || freebee)
if(!freebee)
bee_resources = max(bee_resources - BEE_RESOURCE_NEW_BEE_COST, 0)
var/mob/living/simple_animal/hostile/poison/bees/B = new(src)
B.beehome = src
B.assign_reagent(queen_bee.beegent)
bees += B
/obj/structure/beebox/proc/get_max_honeycomb()
. = 0
for(var/hf in honey_frames)
var/obj/item/honey_frame/HF = hf
. += HF.honeycomb_capacity
/obj/structure/beebox/proc/get_max_bees()
. = get_max_honeycomb() * BEES_RATIO
/obj/structure/beebox/examine(mob/user)
..()
if(!queen_bee)
user << "<span class='warning'>There is no queen bee! There won't bee any honeycomb without a queen!</span>"
var/half_bee = get_max_bees()*0.5
if(half_bee && (bees.len >= half_bee))
user << "<span class='notice'>This place is a BUZZ with activity... there are lots of bees!</span>"
user << "<span class='notice'>[bee_resources]/100 resource supply.</span>"
user << "<span class='notice'>[bee_resources]% towards a new honeycomb.</span>"
user << "<span class='notice'>[bee_resources*2]% towards a new bee.</span>"
if(honeycombs.len)
var/plural = honeycombs.len > 1
user << "<span class='notice'>There [plural? "are" : "is"] [honeycombs.len] uncollected honeycomb[plural ? "s":""] in the apiary.</span>"
if(honeycombs.len >= get_max_honeycomb())
user << "<span class='warning'>there's no room for more honeycomb!</span>"
/obj/structure/beebox/attackby(obj/item/I, mob/user, params)
if(istype(I, /obj/item/honey_frame))
var/obj/item/honey_frame/HF = I
if(honey_frames.len < BEEBOX_MAX_FRAMES)
visible_message("<span class='notice'>[user] adds a frame to the apiary.</span>")
user.unEquip(HF)
HF.loc = src
honey_frames += HF
else
user << "<span class='warning'>There's no room for anymore frames in the apiary!</span>"
if(istype(I, /obj/item/weapon/wrench))
if(default_unfasten_wrench(user, I, time = 20))
return
if(istype(I, /obj/item/queen_bee))
if(queen_bee)
user << "<span class='warning'>This hive already has a queen!</span>"
return
var/obj/item/queen_bee/qb = I
user.unEquip(qb)
qb.queen.loc = src
bees += qb.queen
queen_bee = qb.queen
qb.queen = null
if(queen_bee)
visible_message("<span class='notice'>[user] sets [qb] down inside the apiary, making it their new home.</span>")
var/relocated = 0
for(var/b in bees)
var/mob/living/simple_animal/hostile/poison/bees/B = b
if(B.reagent_incompatible(queen_bee))
bees -= B
B.beehome = null
if(B.loc == src)
B.loc = get_turf(src)
relocated++
if(relocated)
user << "<span class='warning'>This queen has a different reagent to some of the bees who live here, those bees will not return to this apiary!</span>"
else
user << "<span class='warning'>The queen bee disappeared! bees disappearing has been in the news lately...</span>"
qdel(qb)
/obj/structure/beebox/attack_hand(mob/user)
if(ishuman(user))
if(!user.bee_friendly())
//Time to get stung!
var/bees = FALSE
for(var/b in bees) //everyone who's ever lived here now instantly hates you, suck it assistant!
var/mob/living/simple_animal/hostile/poison/bees/B = b
if(B.isqueen)
continue
if(B.loc == src)
B.loc = get_turf(src)
B.target = user
bees = TRUE
if(bees)
visible_message("<span class='danger'>[user] disturbs the bees!</span>")
else
var/option = alert(user, "What Action do you wish to perform?","Apiary","Remove a Honey Frame","Remove the Queen Bee")
if(!Adjacent(user))
return
switch(option)
if("Remove a Honey Frame")
if(!honey_frames.len)
user << "<span class='warning'>There are no honey frames to remove!</span>"
return
var/obj/item/honey_frame/HF = pick_n_take(honey_frames)
if(HF)
if(!user.put_in_active_hand(HF))
HF.loc = get_turf(src)
visible_message("<span class='notice'>[user] removes a frame from the apiary.</span>")
var/amtH = HF.honeycomb_capacity
var/fallen = 0
while(honeycombs.len && amtH) //let's pretend you always grab the frame with the most honeycomb on it
var/obj/item/weapon/reagent_containers/honeycomb/HC = pick_n_take(honeycombs)
if(HC)
HC.loc = get_turf(user)
amtH--
fallen++
if(fallen)
var/multiple = fallen > 1
visible_message("<span class='notice'>[user] scrapes [multiple ? "[fallen]" : "a"] honeycomb[multiple ? "s" : ""] off of the frame.</span>")
if("Remove the Queen Bee")
if(!queen_bee || queen_bee.loc != src)
user << "<span class='warning'>There is no queen bee to remove!</span>"
return
var/obj/item/queen_bee/QB = new()
queen_bee.loc = QB
bees -= queen_bee
QB.queen = queen_bee
QB.name = queen_bee.name
if(!user.put_in_active_hand(QB))
QB.loc = get_turf(src)
visible_message("<span class='notice'>[user] removes the queen from the apiary.</span>")
queen_bee = null
@@ -0,0 +1,16 @@
/obj/item/clothing/head/beekeeper_head
name = "beekeeper hat"
desc = "keeps the lil buzzing buggers out of your eyes"
icon_state = "beekeeper"
item_state = "beekeeper"
flags = THICKMATERIAL
/obj/item/clothing/suit/beekeeper_suit
name = "beekeeper suit"
desc = "keeps the lil buzzing buggers away from your squishy bits"
icon_state = "beekeeper"
item_state = "beekeeper"
flags = THICKMATERIAL
@@ -0,0 +1,12 @@
/obj/item/honey_frame
name = "honey frame"
desc = "a scaffold for bees to build honeycomb on"
icon = 'icons/obj/apiary_bees.dmi'
icon_state = "honey_frame"
var/honeycomb_capacity = 10 //10 Honeycomb per frame by default, researchable frames perhaps?
/obj/item/honey_frame/New()
pixel_x = rand(8,-8)
pixel_y = rand(8,-8)
@@ -0,0 +1,40 @@
/obj/item/weapon/reagent_containers/honeycomb
name = "honeycomb"
desc = "a hexagonal mesh of honeycomb"
icon = 'icons/obj/apiary_bees.dmi'
icon_state = "honeycomb"
possible_transfer_amounts = list()
disease_amount = 0
volume = 10
amount_per_transfer_from_this = 0
list_reagents = list("honey" = 5)
var/honey_color = ""
/obj/item/weapon/reagent_containers/honeycomb/New()
..()
pixel_x = rand(8,-8)
pixel_y = rand(8,-8)
update_icon()
/obj/item/weapon/reagent_containers/honeycomb/update_icon()
overlays.Cut()
var/image/honey
if(honey_color)
honey = image(icon = 'icons/obj/apiary_bees.dmi', icon_state = "greyscale_honey")
honey.color = honey_color
else
honey = image(icon = 'icons/obj/apiary_bees.dmi', icon_state = "honey")
overlays += honey
/obj/item/weapon/reagent_containers/honeycomb/proc/set_reagent(reagent)
var/datum/reagent/R = chemical_reagents_list[reagent]
if(istype(R))
name = "honeycomb ([R.name])"
honey_color = R.color
reagents.add_reagent(R.id,5)
else
honey_color = ""
update_icon()
+42 -54
View File
@@ -49,6 +49,8 @@
var/last_plant_ikey //This is for debugging reference, and is otherwise useless. --FalseIncarnate
var/recent_bee_visit = FALSE //Have we been visited by a bee recently, so bees dont overpolinate one plant
/*
* process() can be found in \code\modules\hydroponics\tray\tray_process.dm
* reagent handling can be found in \code\modules\hydroponics\tray\tray_reagents.dm
@@ -163,8 +165,7 @@
return
if(closed_system)
if(user)
to_chat(user, "You can't harvest from the plant while the lid is shut.")
if(user) user << "You can't harvest from the plant while the lid is shut."
return
if(user)
@@ -197,7 +198,7 @@
if(!user || !dead) return
if(closed_system)
to_chat(user, "You can't remove the dead plant while the lid is shut.")
user << "You can't remove the dead plant while the lid is shut."
return
seed = null
@@ -209,7 +210,7 @@
yield_mod = 0
mutation_mod = 0
to_chat(user, "You remove the dead plant.")
user << "You remove the dead plant."
check_health()
return
@@ -337,11 +338,11 @@
set src in view(1)
if(labelled)
to_chat(usr, "You remove the label.")
usr << "You remove the label."
labelled = null
update_icon()
else
to_chat(usr, "There is no label to remove.")
usr << "There is no label to remove."
return
/obj/machinery/portable_atmospherics/hydroponics/verb/setlight()
@@ -352,7 +353,7 @@
var/new_light = input("Specify a light level.") as null|anything in list(0,1,2,3,4,5,6,7,8,9,10)
if(new_light)
tray_light = new_light
to_chat(usr, "You set the tray to a light level of [tray_light] lumens.")
usr << "You set the tray to a light level of [tray_light] lumens."
/obj/machinery/portable_atmospherics/hydroponics/proc/check_level_sanity()
//Make sure various values are sane.
@@ -399,7 +400,7 @@
if(istype(O, /obj/item/weapon/crowbar))
if(anchored==2)
to_chat(user, "Unscrew the hoses first!")
user << "Unscrew the hoses first!"
return
default_deconstruction_crowbar(O, 1)
@@ -411,11 +412,11 @@
var/obj/item/weapon/reagent_containers/glass/C = O
//Check if container is empty
if(!C.reagents.total_volume)
to_chat(user, "\red [C] is empty.")
user << "\red [C] is empty."
return
//Container not empty, transfer contents to tray
var/trans = C.reagents.trans_to(src, C.amount_per_transfer_from_this)
to_chat(user, "\blue You transfer [trans] units of the solution to [src].")
user << "\blue You transfer [trans] units of the solution to [src]."
check_level_sanity()
process_reagents()
@@ -428,7 +429,7 @@
toxins += P.toxicity
pestlevel -= P.pest_kill_str
weedlevel -= P.weed_kill_str
to_chat(user, "You spray [src] with [O].")
user << "You spray [src] with [O]."
playsound(loc, 'sound/effects/spray3.ogg', 50, 1, -6)
qdel(O)
@@ -441,7 +442,7 @@
user.drop_item(O)
toxins += W.toxicity
weedlevel -= W.weed_kill_str
to_chat(user, "You spray [src] with [O].")
user << "You spray [src] with [O]."
playsound(loc, 'sound/effects/spray3.ogg', 50, 1, -6)
qdel(O)
@@ -454,7 +455,7 @@
//Check if there is a plant in the tray
if(seed)
if(!S.reagents.total_volume)
to_chat(user, "\red [S] is empty.")
user << "\red [S] is empty."
return
//Container not empty, transfer contents to tray
S.reagents.trans_to(src, S.amount_per_transfer_from_this)
@@ -463,20 +464,20 @@
check_level_sanity()
update_icon()
else
to_chat(user, "There's nothing in [src] to spray!")
user << "There's nothing in [src] to spray!"
else if(istype(O, /obj/item/weapon/screwdriver) && unwrenchable) //THIS NEED TO BE DONE DIFFERENTLY, SOMEONE REFACTOR THE TRAY CODE ALREADY
if(anchored)
if(anchored == 2)
playsound(src.loc, 'sound/items/Screwdriver.ogg', 50, 1)
anchored = 1
to_chat(user, "You unscrew the [src]'s hoses.")
user << "You unscrew the [src]'s hoses."
panel_open = 0
else if(anchored == 1)
playsound(src.loc, 'sound/items/Screwdriver.ogg', 50, 1)
anchored = 2
to_chat(user, "You screw in the [src]'s hoses.")
user << "You screw in the [src]'s hoses."
panel_open = 1
for(var/obj/machinery/portable_atmospherics/hydroponics/h in range(1,src))
@@ -486,15 +487,15 @@
if(istype(O, /obj/item/weapon/wirecutters) || istype(O, /obj/item/weapon/scalpel))
if(!seed)
to_chat(user, "There is nothing to take a sample from in \the [src].")
user << "There is nothing to take a sample from in \the [src]."
return
if(sampled)
to_chat(user, "You have already sampled from this plant.")
user << "You have already sampled from this plant."
return
if(dead)
to_chat(user, "The plant is dead.")
user << "The plant is dead."
return
// Create a sample.
@@ -519,14 +520,14 @@
if(seed)
return ..()
else
to_chat(user, "There's no plant to inject.")
user << "There's no plant to inject."
return 1
else
if(seed)
//Leaving this in in case we want to extract from plants later.
to_chat(user, "You can't get any extract out of this plant.")
user << "You can't get any extract out of this plant."
else
to_chat(user, "There's nothing to draw something from.")
user << "There's nothing to draw something from."
return 1
else if (istype(O, /obj/item/seeds))
@@ -537,11 +538,11 @@
user.drop_item(O)
if(!S.seed)
to_chat(user, "The packet seems to be empty. You throw it away.")
user << "The packet seems to be empty. You throw it away."
qdel(O)
return
to_chat(user, "You plant the [S.seed.seed_name] [S.seed.seed_noun].")
user << "You plant the [S.seed.seed_name] [S.seed.seed_noun]."
seed = S.seed //Grab the seed datum.
dead = 0
age = 1
@@ -555,7 +556,7 @@
check_health()
else
to_chat(user, "<span class='danger'>\The [src] already has seeds in it!</span>")
user << "<span class='danger'>\The [src] already has seeds in it!</span>"
else if (istype(O, /obj/item/weapon/minihoe)) // The minihoe
@@ -564,7 +565,7 @@
weedlevel = 0
update_icon()
else
to_chat(user, "<span class='danger'>This plot is completely devoid of weeds. It doesn't need uprooting.</span>")
user << "<span class='danger'>This plot is completely devoid of weeds. It doesn't need uprooting.</span>"
else if (istype(O, /obj/item/weapon/storage/bag/plants))
@@ -584,24 +585,11 @@
playsound(loc, 'sound/items/Ratchet.ogg', 50, 1)
anchored = !anchored
to_chat(user, "You [anchored ? "wrench" : "unwrench"] \the [src].")
user << "You [anchored ? "wrench" : "unwrench"] \the [src]."
else if(istype(O, /obj/item/apiary))
if(seed)
to_chat(user, "<span class='danger'>[src] is already occupied!</span>")
else
user.drop_item()
qdel(O)
var/obj/machinery/apiary/A = new(src.loc)
A.icon = src.icon
A.icon_state = src.icon_state
A.hydrotray_type = src.type
qdel(src)
else if ((istype(O, /obj/item/weapon/tank) && !( src.destroyed )))
if (src.holding)
to_chat(user, "\blue There is alreadu a tank loaded into the [src].")
user << "\blue There is alreadu a tank loaded into the [src]."
return
var/obj/item/weapon/tank/T = O
user.drop_item()
@@ -636,26 +624,26 @@
..(user)
if(!seed)
to_chat(user, "[src] is empty.")
user << "[src] is empty."
return
to_chat(user, "<span class='notice'>[seed.display_name]</span> are growing here.</span>")
user << "<span class='notice'>[seed.display_name]</span> are growing here.</span>"
if(!Adjacent(user))
return
to_chat(user, "Water: [round(waterlevel,0.1)]/[maxwater]")
to_chat(user, "Nutrient: [round(nutrilevel,0.1)]/[maxnutri]")
user << "Water: [round(waterlevel,0.1)]/[maxwater]"
user << "Nutrient: [round(nutrilevel,0.1)]/[maxnutri]"
if(weedlevel >= 5)
to_chat(user, "\The [src] is <span class='danger'>infested with weeds</span>!")
user << "\The [src] is <span class='danger'>infested with weeds</span>!"
if(pestlevel >= 5)
to_chat(user, "\The [src] is <span class='danger'>infested with tiny worms</span>!")
user << "\The [src] is <span class='danger'>infested with tiny worms</span>!"
if(dead)
to_chat(user, "<span class='danger'>The plant is dead.</span>")
user << "<span class='danger'>The plant is dead.</span>"
else if(health <= (seed.get_trait(TRAIT_ENDURANCE)/ 2))
to_chat(user, "The plant looks <span class='danger'>unhealthy</span>.")
user << "The plant looks <span class='danger'>unhealthy</span>."
if(mechanical)
var/turf/T = loc
@@ -683,7 +671,7 @@
light_available = 5
light_string = "a light level of [light_available] lumens"
to_chat(user, "The tray's sensor suite is reporting [light_string] and a temperature of [environment.temperature]K.")
user << "The tray's sensor suite is reporting [light_string] and a temperature of [environment.temperature]K."
/obj/machinery/portable_atmospherics/hydroponics/verb/close_lid_verb()
set name = "Toggle Tray Lid"
@@ -696,7 +684,7 @@
return
closed_system = !closed_system
to_chat(user, "You [closed_system ? "close" : "open"] the tray's lid.")
user << "You [closed_system ? "close" : "open"] the tray's lid."
update_icon()
/obj/machinery/portable_atmospherics/hydroponics/verb/eject_tank_verb()
@@ -710,9 +698,9 @@
return
if(!holding)
to_chat(usr, "\red There is no tank loaded into [src] to eject.")
usr << "\red There is no tank loaded into [src] to eject."
if(istype(holding, /obj/item/weapon/tank))
to_chat(usr, "\blue You eject [holding.name] from [src].")
usr << "\blue You eject [holding.name] from [src]."
holding.loc = loc
holding = null
holding = null