mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 10:43:20 +00:00
Cleaning up machine process()s
But first! Unrelated to process():
- Only humans and monkeys can move into sleepers.
- Immovable rods no longer delete themselves if they hit a shuttle. Instead they act as if the shuttle doesn't exist. This should help cut down on rods deleting themselves before going through the station.
And now back to our regularly scheduled programming...
Removed process() that were doing nothing from:
- Dispenser(the one that dispenses O2 and Plasma tanks)
- Robotic Fabricators
- Crew Monitoring computer
Reworked hydroponic's process().
- Merged if statements together since most of them lacked "else if"s or were duplicate checks.
- Changed a while loop into a for loop as sloppy coding or an admin var-editing could cause an infinite loop.
Removed a sleep(100) { process() } from the operating table's constructor as the MC will call process() regardless.
Cleaned up shieldgen.dm
- Changed a while loop into an if statement. The loop was unnecessary
- Moved some stuff around so it's not nearly as confusing.
- Standardized the proc and variable definitions.
- These are not currently in-game but they are amazing items. I'll see about sorting out their bugs and getting them in proper working order.
Removed a for(var in world) from
- cleanbot process()
- floorbot process()
Removed computer/engine/process() from robot/computer code
- /obj/machinery/computer/engine does not exist in the first place...
Note: These are only some of the machinery process()s. I didn't want to potentially break too much at once. More to come.
git-svn-id: http://tgstation13.googlecode.com/svn/trunk@4017 316c924e-a436-60f5-8080-3fe189b3f50e
This commit is contained in:
@@ -17,7 +17,9 @@ In my current plan for it, 'solid' will be defined as anything with density == 1
|
||||
anchored = 1
|
||||
|
||||
Bump(atom/clong)
|
||||
if (istype(clong, /turf) && !istype(clong, /turf/simulated/shuttle) && !istype(clong, /turf/unsimulated))
|
||||
if(istype(clong, /turf/simulated/shuttle)) //Skip shuttles without actually deleting the rod
|
||||
return
|
||||
if (istype(clong, /turf) && !istype(clong, /turf/unsimulated))
|
||||
if(clong.density)
|
||||
clong.ex_act(2)
|
||||
for (var/mob/O in hearers(src, null))
|
||||
@@ -35,7 +37,6 @@ In my current plan for it, 'solid' will be defined as anything with density == 1
|
||||
else del(src)
|
||||
|
||||
/proc/immovablerod()
|
||||
|
||||
var/startx = 0
|
||||
var/starty = 0
|
||||
var/endy = 0
|
||||
|
||||
@@ -17,10 +17,10 @@
|
||||
..()
|
||||
for(dir in list(NORTH,EAST,SOUTH,WEST))
|
||||
computer = locate(/obj/machinery/computer/operating, get_step(src, dir))
|
||||
if (!isnull(computer))
|
||||
if (computer)
|
||||
break
|
||||
spawn(100)
|
||||
process()
|
||||
// spawn(100) //Wont the MC just call this process() before and at the 10 second mark anyway?
|
||||
// process()
|
||||
|
||||
/obj/machinery/optable/ex_act(severity)
|
||||
|
||||
|
||||
@@ -361,8 +361,9 @@
|
||||
set category = "Object"
|
||||
set src in oview(1)
|
||||
|
||||
if(usr.stat != 0)
|
||||
if(usr.stat != 0 || !(ishuman(usr) || ismonkey(usr)))
|
||||
return
|
||||
|
||||
if(src.occupant)
|
||||
usr << "\blue <B>The sleeper is already occupied!</B>"
|
||||
return
|
||||
|
||||
@@ -166,12 +166,8 @@ text("<A href='?src=\ref[src];operation=oddbutton'>[src.oddbutton ? "Yes" : "No"
|
||||
if(src.cleaning)
|
||||
return
|
||||
var/list/cleanbottargets = list()
|
||||
if(!src.target || src.target == null)
|
||||
for(var/obj/machinery/bot/cleanbot/bot in world)
|
||||
if(bot != src)
|
||||
cleanbottargets += bot.target
|
||||
|
||||
if(prob(5) && !src.screwloose && !src.oddbutton)
|
||||
if(!src.screwloose && !src.oddbutton && prob(5))
|
||||
for(var/mob/O in viewers(src, null))
|
||||
O.show_message(text("[src] makes an excited beeping booping sound!"), 1)
|
||||
|
||||
@@ -236,8 +232,6 @@ text("<A href='?src=\ref[src];operation=oddbutton'>[src.oddbutton ? "Yes" : "No"
|
||||
src.patrol_path = reverselist(src.patrol_path)
|
||||
else
|
||||
patrol_move()
|
||||
spawn(5)
|
||||
patrol_move()
|
||||
|
||||
return
|
||||
|
||||
|
||||
@@ -163,10 +163,6 @@
|
||||
if(src.repairing)
|
||||
return
|
||||
var/list/floorbottargets = list()
|
||||
if(!src.target || src.target == null)
|
||||
for(var/obj/machinery/bot/floorbot/bot in world)
|
||||
if(bot != src)
|
||||
floorbottargets += bot.target
|
||||
if(src.amount <= 0 && ((src.target == null) || !src.target))
|
||||
if(src.eattiles)
|
||||
for(var/obj/item/stack/tile/plasteel/T in view(7, src))
|
||||
|
||||
@@ -252,7 +252,7 @@
|
||||
src.path = new()
|
||||
|
||||
if(!src.patient)
|
||||
if(prob(1) && (!src.shut_up))
|
||||
if(!src.shut_up && prob(1))
|
||||
var/message = pick("Radar, put a mask on!","There's always a catch, and it's the best there is.","I knew it, I should've been a plastic surgeon.","What kind of medbay is this? Everyone's dropping like dead flies.","Delicious!")
|
||||
src.speak(message)
|
||||
|
||||
|
||||
@@ -111,7 +111,6 @@
|
||||
if(stat & (NOPOWER|BROKEN))
|
||||
return
|
||||
|
||||
|
||||
src.updateDialog()
|
||||
return
|
||||
|
||||
|
||||
@@ -26,10 +26,6 @@
|
||||
interact(user)
|
||||
|
||||
|
||||
process()
|
||||
return
|
||||
|
||||
|
||||
power_change()
|
||||
if(stat & BROKEN)
|
||||
icon_state = "broken"
|
||||
|
||||
@@ -97,12 +97,13 @@
|
||||
onclose(user, "computer")
|
||||
return
|
||||
|
||||
/obj/machinery/computer/engine/process()
|
||||
//Why is this in robot/computer and why does it exist when /obj/machinery/computer/engine does not? -Nodrak
|
||||
/*/obj/machinery/computer/engine/process()
|
||||
if(stat & (NOPOWER|BROKEN))
|
||||
return
|
||||
use_power(500)
|
||||
src.updateDialog()
|
||||
return
|
||||
return*/
|
||||
|
||||
/obj/machinery/computer/robotics/Topic(href, href_list)
|
||||
if(..())
|
||||
|
||||
@@ -50,9 +50,6 @@
|
||||
del(src)
|
||||
return
|
||||
|
||||
/obj/machinery/dispenser/process()
|
||||
return
|
||||
|
||||
/obj/machinery/dispenser/attack_ai(mob/user as mob)
|
||||
return src.attack_hand(user)
|
||||
|
||||
|
||||
@@ -41,99 +41,100 @@ obj/machinery/hydroponics/process()
|
||||
// Advance age
|
||||
src.age++
|
||||
|
||||
// Drink random amount of water
|
||||
src.waterlevel -= rand(1,6)
|
||||
|
||||
//Nutrients//////////////////////////////////////////////////////////////
|
||||
// Nutrients deplete slowly
|
||||
if(src.nutrilevel > 0)
|
||||
if(prob(50))
|
||||
src.nutrilevel -= 1
|
||||
|
||||
// Lack of nutrients hurts non-weeds
|
||||
if(src.nutrilevel == 0 && src.myseed.plant_type != 1)
|
||||
if(src.nutrilevel <= 0 && src.myseed.plant_type != 1)
|
||||
src.health -= rand(1,3)
|
||||
|
||||
// Adjust the water level so it can't go negative
|
||||
if(src.waterlevel < 0)
|
||||
src.waterlevel = 0
|
||||
//Water//////////////////////////////////////////////////////////////////
|
||||
// Drink random amount of water
|
||||
src.waterlevel -= rand(1,6)
|
||||
|
||||
// If the plant is dry, it loses health pretty fast, unless mushroom
|
||||
if(src.waterlevel <= 0 && src.myseed.plant_type != 2)
|
||||
src.health -= rand(1,3)
|
||||
else if(src.waterlevel <= 10 && src.myseed.plant_type != 2)
|
||||
if(src.waterlevel <= 10 && src.myseed.plant_type != 2)
|
||||
src.health -= rand(0,1)
|
||||
if(src.waterlevel <= 0)
|
||||
src.health -= rand(0,2)
|
||||
if(src.waterlevel < 0) //Dont let it drop below 0
|
||||
src.waterlevel = 0
|
||||
|
||||
// Sufficient water level and nutrient level = plant healthy
|
||||
else if(src.waterlevel > 10 && src.nutrilevel > 0)
|
||||
src.health += rand(1,2)
|
||||
if(prob(5)) //5 percent chance the weed population will increase
|
||||
src.weedlevel += 1
|
||||
//Toxins/////////////////////////////////////////////////////////////////
|
||||
|
||||
// Too much toxins cause harm, but when the plant drinks the contaiminated water, the toxins disappear slowly
|
||||
if(src.toxic >= 40 && src.toxic < 80)
|
||||
src.health -= 1
|
||||
src.toxic -= rand(1,10)
|
||||
if(src.toxic >= 80) // I don't think it ever gets here tbh unless above is commented out
|
||||
else if(src.toxic >= 80) // I don't think it ever gets here tbh unless above is commented out
|
||||
src.health -= 3
|
||||
src.toxic -= rand(1,10)
|
||||
else if(src.toxic < 0) // Make sure it won't go overoboard
|
||||
src.toxic = 0
|
||||
|
||||
// Sufficient water level and nutrient level = plant healthy
|
||||
if(src.waterlevel > 10 && src.nutrilevel > 0)
|
||||
src.health += rand(1,2)
|
||||
//Pests & Weeds//////////////////////////////////////////////////////////
|
||||
|
||||
// Too many pests cause the plant to be sick
|
||||
if(src.pestlevel >= 5)
|
||||
if (src.pestlevel > 10 ) // Make sure it won't go overoboard
|
||||
src.pestlevel = 10
|
||||
|
||||
else if(src.pestlevel >= 5)
|
||||
src.health -= 1
|
||||
|
||||
// If it's a weed, it doesn't stunt the growth
|
||||
if(src.weedlevel >= 5 && src.myseed.plant_type != 1 )
|
||||
src.health -= 1
|
||||
|
||||
|
||||
//Health & Age///////////////////////////////////////////////////////////
|
||||
// Don't go overboard with the health
|
||||
if(src.health > src.myseed.endurance)
|
||||
src.health = src.myseed.endurance
|
||||
|
||||
// Plant dies if health <= 0
|
||||
else if(src.health <= 0)
|
||||
src.dead = 1
|
||||
src.harvest = 0
|
||||
src.weedlevel += 1 // Weeds flourish
|
||||
src.pestlevel = 0 // Pests die
|
||||
|
||||
// If the plant is too old, lose health fast
|
||||
if(src.age > src.myseed.lifespan)
|
||||
src.health -= rand(1,5)
|
||||
|
||||
// Plant dies if health = 0
|
||||
if(src.health <= 0)
|
||||
src.dead = 1
|
||||
src.harvest = 0
|
||||
src.weedlevel += 1 // Weeds flourish
|
||||
//src.toxic = 0 // Water is still toxic
|
||||
src.pestlevel = 0 // Pests die
|
||||
|
||||
// Harvest code
|
||||
if(src.age > src.myseed.production && (src.age - src.lastproduce) > src.myseed.production && (!src.harvest && !src.dead))
|
||||
var/m_count = 0
|
||||
while(m_count < src.mutmod)
|
||||
if(mutmod && src.age > src.myseed.production && (src.age - src.lastproduce) > src.myseed.production && (!src.harvest && !src.dead))
|
||||
for(var/i = 0; i < mutmod; i++)
|
||||
if(prob(85))
|
||||
src.mutate()
|
||||
else if(prob(30))
|
||||
src.hardmutate()
|
||||
else if(prob(5))
|
||||
src.mutatespecie()
|
||||
m_count++;
|
||||
|
||||
if(src.yieldmod > 0 && src.myseed.yield != -1) // Unharvestable shouldn't be harvested
|
||||
src.harvest = 1
|
||||
else
|
||||
src.lastproduce = src.age
|
||||
if(prob(5)) // On each tick, there's a 5 percent chance the pest population will increase
|
||||
src.pestlevel += 1
|
||||
if(prob(5) && src.waterlevel > 10 && src.nutrilevel > 0) // On each tick, there's a 5 percent chance the weed
|
||||
src.weedlevel += 1 //population will increase, but there needs to be water/nuts for that!
|
||||
else
|
||||
if(prob(10) && src.waterlevel > 10 && src.nutrilevel > 0) // If there's no plant, the percentage chance is 10%
|
||||
if(src.waterlevel > 10 && src.nutrilevel > 0 && prob(10)) // If there's no plant, the percentage chance is 10%
|
||||
src.weedlevel += 1
|
||||
|
||||
// These (v) wouldn't be necessary if additional checks were made earlier (^)
|
||||
|
||||
if (src.weedlevel > 10) // Make sure it won't go overoboard
|
||||
src.weedlevel = 10
|
||||
if (src.toxic < 0) // Make sure it won't go overoboard
|
||||
src.toxic = 0
|
||||
if (src.pestlevel > 10 ) // Make sure it won't go overoboard
|
||||
src.pestlevel = 10
|
||||
if(src.weedlevel > 10)
|
||||
src.weedlevel = 10
|
||||
|
||||
// Weeeeeeeeeeeeeeedddssss
|
||||
|
||||
if (prob(50) && src.weedlevel == 10) // At this point the plant is kind of fucked. Weeds can overtake the plant spot.
|
||||
if (src.weedlevel >= 10 && prob(50)) // At this point the plant is kind of fucked. Weeds can overtake the plant spot.
|
||||
if(src.planted)
|
||||
if(src.myseed.plant_type == 0) // If a normal plant
|
||||
src.weedinvasion()
|
||||
|
||||
@@ -40,10 +40,6 @@
|
||||
else
|
||||
stat |= NOPOWER
|
||||
|
||||
/obj/machinery/robotic_fabricator/process()
|
||||
if (stat & (NOPOWER | BROKEN))
|
||||
return
|
||||
|
||||
/obj/machinery/robotic_fabricator/attack_paw(user as mob)
|
||||
return src.attack_hand(user)
|
||||
|
||||
|
||||
@@ -1,41 +1,3 @@
|
||||
/obj/machinery/shieldgen
|
||||
name = "Shield generator"
|
||||
desc = "Used to seal minor hull breaches."
|
||||
icon = 'objects.dmi'
|
||||
icon_state = "shieldoff"
|
||||
var/active = 0
|
||||
var/health = 100
|
||||
var/malfunction = 0
|
||||
density = 1
|
||||
opacity = 0
|
||||
anchored = 0
|
||||
pressure_resistance = 2*ONE_ATMOSPHERE
|
||||
|
||||
#define maxstoredpower 500
|
||||
/obj/machinery/shieldwallgen
|
||||
name = "Shield Generator"
|
||||
desc = "A shield generator."
|
||||
icon = 'stationobjs.dmi'
|
||||
icon_state = "Shield_Gen"
|
||||
anchored = 0
|
||||
density = 1
|
||||
req_access = list(access_security)
|
||||
var/active = 0
|
||||
var/power = 0
|
||||
var/state = 0
|
||||
var/steps = 0
|
||||
var/last_check = 0
|
||||
var/check_delay = 10
|
||||
var/recalc = 0
|
||||
var/locked = 1
|
||||
var/destroyed = 0
|
||||
var/directwired = 1
|
||||
// var/maxshieldload = 200
|
||||
var/obj/structure/cable/attached // the attached cable
|
||||
var/storedpower = 0
|
||||
flags = FPRINT | CONDUCT
|
||||
use_power = 0
|
||||
|
||||
/obj/machinery/shield
|
||||
name = "shield"
|
||||
desc = "An energy shield."
|
||||
@@ -64,49 +26,61 @@
|
||||
var/obj/machinery/shieldwallgen/gen_secondary
|
||||
|
||||
|
||||
/obj/machinery/shieldgen
|
||||
name = "Shield generator"
|
||||
desc = "Used to seal minor hull breaches."
|
||||
icon = 'objects.dmi'
|
||||
icon_state = "shieldoff"
|
||||
density = 1
|
||||
opacity = 0
|
||||
anchored = 0
|
||||
pressure_resistance = 2*ONE_ATMOSPHERE
|
||||
var/active = 0
|
||||
var/health = 100
|
||||
var/malfunction = 0
|
||||
var/list/obj/machinery/shield/deployed_shields
|
||||
|
||||
/obj/machinery/shieldgen/Del()
|
||||
for(var/obj/machinery/shield/shield_tile in deployed_shields)
|
||||
del(shield_tile)
|
||||
|
||||
..()
|
||||
|
||||
/obj/machinery/shieldgen/var/list/obj/machinery/shield/deployed_shields
|
||||
|
||||
/obj/machinery/shieldgen/proc
|
||||
shields_up()
|
||||
if(active) return 0
|
||||
/obj/machinery/shieldgen/proc/shields_up()
|
||||
if(active) return 0
|
||||
|
||||
for(var/turf/target_tile in range(2, src))
|
||||
if (istype(target_tile,/turf/space) && !(locate(/obj/machinery/shield) in target_tile))
|
||||
if (malfunction && prob(33) || !malfunction)
|
||||
deployed_shields += new /obj/machinery/shield(target_tile)
|
||||
for(var/turf/target_tile in range(2, src))
|
||||
if (istype(target_tile,/turf/space) && !(locate(/obj/machinery/shield) in target_tile))
|
||||
if (malfunction && prob(33) || !malfunction)
|
||||
deployed_shields += new /obj/machinery/shield(target_tile)
|
||||
|
||||
src.anchored = 1
|
||||
src.active = 1
|
||||
src.icon_state = malfunction ? "shieldonbr":"shieldon"
|
||||
src.anchored = 1
|
||||
src.active = 1
|
||||
src.icon_state = malfunction ? "shieldonbr":"shieldon"
|
||||
|
||||
spawn src.process()
|
||||
spawn src.process()
|
||||
|
||||
shields_down()
|
||||
if(!active) return 0
|
||||
/obj/machinery/shieldgen/proc/shields_down()
|
||||
if(!active) return 0
|
||||
|
||||
for(var/obj/machinery/shield/shield_tile in deployed_shields)
|
||||
del(shield_tile)
|
||||
for(var/obj/machinery/shield/shield_tile in deployed_shields)
|
||||
del(shield_tile)
|
||||
|
||||
src.anchored = 0
|
||||
src.active = 0
|
||||
src.icon_state = malfunction ? "shieldoffbr":"shieldoff"
|
||||
src.anchored = 0
|
||||
src.active = 0
|
||||
src.icon_state = malfunction ? "shieldoffbr":"shieldoff"
|
||||
|
||||
/obj/machinery/shieldgen/process()
|
||||
if(active)
|
||||
src.icon_state = malfunction ? "shieldonbr":"shieldon"
|
||||
|
||||
if(malfunction)
|
||||
while(prob(10))
|
||||
if(prob(10) || deployed_shields)
|
||||
del(pick(deployed_shields))
|
||||
|
||||
spawn(30)
|
||||
src.process()
|
||||
//spawn(30) //The MC does this for us...
|
||||
// src.process()
|
||||
return
|
||||
|
||||
/obj/machinery/shieldgen/proc/checkhp()
|
||||
@@ -173,6 +147,30 @@
|
||||
src.shields_up()
|
||||
|
||||
////FIELD GEN START //shameless copypasta from fieldgen, powersink, and grille
|
||||
#define maxstoredpower 500
|
||||
/obj/machinery/shieldwallgen
|
||||
name = "Shield Generator"
|
||||
desc = "A shield generator."
|
||||
icon = 'stationobjs.dmi'
|
||||
icon_state = "Shield_Gen"
|
||||
anchored = 0
|
||||
density = 1
|
||||
req_access = list(access_security)
|
||||
var/active = 0
|
||||
var/power = 0
|
||||
var/state = 0
|
||||
var/steps = 0
|
||||
var/last_check = 0
|
||||
var/check_delay = 10
|
||||
var/recalc = 0
|
||||
var/locked = 1
|
||||
var/destroyed = 0
|
||||
var/directwired = 1
|
||||
// var/maxshieldload = 200
|
||||
var/obj/structure/cable/attached // the attached cable
|
||||
var/storedpower = 0
|
||||
flags = FPRINT | CONDUCT
|
||||
use_power = 0
|
||||
|
||||
/obj/machinery/shieldwallgen/proc/power()
|
||||
if(!anchored)
|
||||
|
||||
@@ -317,12 +317,12 @@
|
||||
src.seconds_electrified--
|
||||
|
||||
//Pitch to the people! Really sell it!
|
||||
if(prob(5) && ((src.last_slogan + src.slogan_delay) <= world.time) && (src.slogan_list.len > 0) && (!src.shut_up))
|
||||
if(((src.last_slogan + src.slogan_delay) <= world.time) && (src.slogan_list.len > 0) && (!src.shut_up) && prob(5))
|
||||
var/slogan = pick(src.slogan_list)
|
||||
src.speak(slogan)
|
||||
src.last_slogan = world.time
|
||||
|
||||
if((prob(2)) && (src.shoot_inventory))
|
||||
if(src.shoot_inventory && prob(2))
|
||||
src.throw_item()
|
||||
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user