Merge tgstation r4633 into bs12_with_tgport

Conflicts:
	code/defines/obj/costume.dm
	code/game/gamemodes/cult/runes.dm
	code/game/machinery/computer/communications.dm
	code/game/machinery/telecomms/broadcaster.dm
	code/game/objects/structures/crates_lockers/closets/fitness.dm
	code/modules/mob/living/simple_animal/life.dm
	code/modules/mob/living/simple_animal/parrot.dm
	code/modules/power/power.dm
	code/modules/power/switch.dm

Signed-off-by: Cael_Aislinn <cael_aislinn@yahoo.com.au>
This commit is contained in:
Cael_Aislinn
2012-09-06 13:13:57 +10:00
84 changed files with 9014 additions and 8406 deletions
+21 -5
View File
@@ -142,8 +142,8 @@ var/global/BSACooldown = 0
M.change_mob_type( /mob/living/simple_animal/crab/Coffee , null, null, delmob)
if("parrot")
M.change_mob_type( /mob/living/simple_animal/parrot , null, null, delmob)
if("drprofessor")
M.change_mob_type( /mob/living/simple_animal/parrot/DrProfessor , null, null, delmob)
if("polyparrot")
M.change_mob_type( /mob/living/simple_animal/parrot/Poly , null, null, delmob)
if("constructarmoured")
M.change_mob_type( /mob/living/simple_animal/constructarmoured , null, null, delmob)
if("constructbuilder")
@@ -802,10 +802,11 @@ var/global/BSACooldown = 0
if ((src.rank in list( "Trial Admin", "Badmin", "Game Admin", "Game Master" )))
var/mob/M = locate(href_list["forcespeech"])
if (ismob(M))
var/speech = copytext(sanitize(input("What will [key_name(M)] say?.", "Force speech", "")),1,MAX_MESSAGE_LEN)
var/speech = input("What will [key_name(M)] say?.", "Force speech", "")// Don't need to sanitize, since it does that in say(), we also trust our admins.
if(!speech)
return
M.say(speech)
speech = sanitize(speech) // Nah, we don't trust them
log_admin("[key_name(usr)] forced [key_name(M)] to say: [speech]")
message_admins("\blue [key_name_admin(usr)] forced [key_name_admin(M)] to say: [speech]")
else
@@ -2041,6 +2042,20 @@ var/global/BSACooldown = 0
for(var/obj/machinery/light/L in world)
L.fix()
message_admins("[key_name_admin(usr)] fixed all lights", 1)
if("friendai")
feedback_inc("admin_secrets_fun_used",1)
feedback_add_details("admin_secrets_fun_used","FA")
for(var/mob/aiEye/aE in mob_list)
aE.icon_state = "ai_friend"
for(var/obj/machinery/M in machines)
if(istype(M, /obj/machinery/ai_status_display))
var/obj/machinery/ai_status_display/A = M
A.emotion = "Friend Computer"
else if(istype(M, /obj/machinery/status_display))
var/obj/machinery/status_display/A = M
A.friendc = 1
message_admins("[key_name_admin(usr)] turned all AIs into best friends.", 1)
if("virus")
feedback_inc("admin_secrets_fun_used",1)
feedback_add_details("admin_secrets_fun_used","V")
@@ -2574,7 +2589,7 @@ var/global/BSACooldown = 0
body += "<A href='?src=\ref[src];simplemake=crab;mob=\ref[M]'>Crab</A> | "
body += "<A href='?src=\ref[src];simplemake=coffee;mob=\ref[M]'>Coffee</A> | "
//body += "<A href='?src=\ref[src];simplemake=parrot;mob=\ref[M]'>Parrot</A> | "
//body += "<A href='?src=\ref[src];simplemake=drprofessor;mob=\ref[M]'>DrProfessor</A> | "
//body += "<A href='?src=\ref[src];simplemake=polyparrot;mob=\ref[M]'>Poly</A> | "
body += "\[ Construct: <A href='?src=\ref[src];simplemake=constructarmoured;mob=\ref[M]'>Armoured</A> , "
body += "<A href='?src=\ref[src];simplemake=constructbuilder;mob=\ref[M]'>Builder</A> , "
body += "<A href='?src=\ref[src];simplemake=constructwraith;mob=\ref[M]'>Wraith</A> \] "
@@ -2939,7 +2954,8 @@ var/global/BSACooldown = 0
<A href='?src=\ref[src];secretsfun=movealienship'>Move Alien Dinghy</A><BR>
<A href='?src=\ref[src];secretsfun=moveminingshuttle'>Move Mining Shuttle</A><BR>
<A href='?src=\ref[src];secretsfun=blackout'>Break all lights</A><BR>
<A href='?src=\ref[src];secretsfun=whiteout'>Fix all lights</A><BR>"}
<A href='?src=\ref[src];secretsfun=whiteout'>Fix all lights</A><BR>
<A href='?src=\ref[src];secretsfun=friendai'>Best Friend AI</A><BR>"}
//<A href='?src=\ref[src];secretsfun=shockwave'>Station Shockwave</A><BR>
if(lvl >= 6)
+4 -4
View File
@@ -25,7 +25,7 @@
O.loc = src
update_icon()
else if(istype(O, /obj/item/weapon/pen))
var/newname = copytext(sanitize(input("What would you like to title this bookshelf?") as text|null),1,MAX_MESSAGE_LEN)
var/newname = stripped_input(usr, "What would you like to title this bookshelf?")
if(!newname)
return
else
@@ -140,7 +140,7 @@
var/choice = input("What would you like to change?") in list("Title", "Contents", "Author", "Cancel")
switch(choice)
if("Title")
var/newtitle = copytext(reject_bad_text(input("Write a new title:") as text|null),1,MAX_MESSAGE_LEN)
var/newtitle = reject_bad_text(stripped_input(usr, "Write a new title:"))
if(!newtitle)
usr << "The title is invalid."
return
@@ -148,14 +148,14 @@
src.name = newtitle
src.title = newtitle
if("Contents")
var/content = strip_html(input("Write your book's contents (HTML NOT allowed):"),8192) as message|null
var/content = strip_html(input(usr, "Write your book's contents (HTML NOT allowed):"),8192) as message|null
if(!content)
usr << "The content is invalid."
return
else
src.dat += content
if("Author")
var/newauthor = copytext(sanitize(input("Write the author's name:") as text|null),1,MAX_NAME_LEN)
var/newauthor = stripped_input(usr, "Write the author's name:")
if(!newauthor)
usr << "The name is invalid."
return
+18 -16
View File
@@ -261,7 +261,7 @@
if (prob(30))
switch(pick(1,2))
if(1)
core()
view_core()
if(2)
ai_call_shuttle()
..()
@@ -445,7 +445,7 @@
return 0
if(!src.eyeobj)
core()
view_core()
return
// ok, we're alive, camera is good and in our network...
eyeobj.setLoc(get_turf(C))
@@ -510,9 +510,9 @@
/mob/living/silicon/ai/cancel_camera()
set category = "AI Commands"
set name = "Cancel Camera View"
//reset_view(null)
//machine = null
src.cameraFollow = null
//src.cameraFollow = null
src.view_core()
//Replaces /mob/living/silicon/ai/verb/change_network() in ai.dm & camera.dm
@@ -547,7 +547,7 @@
network = input(U, "Which network would you like to view?") as null|anything in cameralist
if(!U.eyeobj)
U.core()
U.view_core()
return
if(isnull(network))
@@ -578,16 +578,18 @@
return
var/list/ai_emotions = list("Very Happy", "Happy", "Neutral", "Unsure", "Confused", "Sad", "BSOD", "Blank", "Problems?", "Awesome", "Facepalm", "Friend Computer")
var/emote = input("Please, select a status!", "AI Status", null, null) in ai_emotions
for (var/obj/machinery/ai_status_display/AISD in world) //change status
spawn( 0 )
AISD.emotion = emote
for (var/obj/machinery/status_display/SD in world) //if Friend Computer, change ALL displays
if(emote=="Friend Computer")
spawn(0)
SD.friendc = 1
else
spawn(0)
SD.friendc = 0
for (var/obj/machinery/M in machines) //change status
if(istype(M, /obj/machinery/ai_status_display))
var/obj/machinery/ai_status_display/AISD = M
AISD.emotion = emote
//if Friend Computer, change ALL displays
else if(istype(M, /obj/machinery/status_display))
var/obj/machinery/status_display/SD = M
if(emote=="Friend Computer")
SD.friendc = 1
else
SD.friendc = 0
return
//I am the icon meister. Bow fefore me. //>fefore
@@ -5,10 +5,12 @@
/mob/aiEye
name = "Inactive AI Eye"
icon = 'icons/obj/status_display.dmi' // For AI friend secret shh :o
var/list/visibleCameraChunks = list()
var/mob/living/silicon/ai/ai = null
density = 0
nodamage = 1 // You can't damage it.
mouse_opacity = 0
// Movement code. Returns 0 to stop air movement from moving it.
/mob/aiEye/Move()
@@ -40,6 +42,11 @@
if(ai)
if(ai.client)
ai.client.eye = src
//Holopad
if(istype(ai.current, /obj/machinery/hologram/holopad))
var/obj/machinery/hologram/holopad/H = ai.current
H.move_hologram()
// AI MOVEMENT
@@ -103,11 +110,17 @@
/mob/living/silicon/ai/verb/core()
set category = "AI Commands"
set name = "AI Core"
view_core()
/mob/living/silicon/ai/proc/view_core()
current = null
cameraFollow = null
machine = null
if(src.eyeobj)
if(src.eyeobj && src.loc)
src.eyeobj.loc = src.loc
else
src << "ERROR: Eyeobj not found. Please report this to Giacom. Creating new eye..."
@@ -33,6 +33,19 @@
if(ticker)
cameranet.updateVisibility(src)
// EFFECTS
/obj/effect/Del()
if(ticker)
cameranet.updateVisibility(src)
..()
/obj/effect/New()
..()
if(ticker)
cameranet.updateVisibility(src)
// DOORS
// Simply updates the visibility of the area when it opens/closes/destroyed.
+1 -1
View File
@@ -22,5 +22,5 @@
if(O)
O.mode = 1
O.emotion = "Neutral"
src.core()
src.view_core()
return
+1 -1
View File
@@ -6,5 +6,5 @@
if (client)
client.eye = loc
client.perspective = EYE_PERSPECTIVE
src.core()
src.view_core()
return
@@ -56,7 +56,6 @@
var/speed = 0 //LETS SEE IF I CAN SET SPEEDS FOR SIMPLE MOBS WITHOUT DESTROYING EVERYTHING. Higher speed is slower, negative speed is faster
var/obj/item/device/radio/headset/ears = null
/mob/living/simple_animal/New()
..()
verbs -= /mob/verb/observe
+555 -59
View File
@@ -1,36 +1,107 @@
/* Parrots!
* Contains
* Defines
* Inventory (headset stuff)
* Attack responces
* AI
* Procs / Verbs (usable by players)
* Sub-types
*/
/*
* Defines
*/
//Only a maximum of one action and one intent should be active at any given time.
//Actions
#define PARROT_PERCH 1 //Sitting/sleeping, not moving
#define PARROT_SWOOP 2 //Moving towards or away from a target
#define PARROT_WANDER 4 //Moving without a specific target in mind
//Intents
#define PARROT_STEAL 8 //Flying towards a target to steal it/from it
#define PARROT_ATTACK 16 //Flying towards a target to attack it
#define PARROT_RETURN 32 //Flying towards its perch
#define PARROT_FLEE 64 //Flying away from its attacker
/mob/living/simple_animal/parrot
name = "\improper Parrot"
desc = "It's a parrot! No dirty words!"
icon = 'icons/mob/mob.dmi'
icon_state = "parrot"
icon_living = "parrot"
icon_dead = "parrot_dead"
speak = list("Hi","Hello!","Cracker?","BAWWWWK george mellons griffing me")
desc = "The parrot squacks, \"It's a Parrot! BAWWK!\""
icon = 'icons/mob/animal.dmi'
icon_state = "chick"
icon_living = "chick"
icon_dead = "chick_dead"
pass_flags = PASSTABLE
speak = list("Hi","Hello!","Cracker?","BAWWWWK george mellons griffing me") //TODO: make it pick up on what people are saying.
speak_emote = list("squawks","says","yells")
emote_hear = list("squawks","bawks")
emote_see = list("flutters its wings", "glares at you")
emote_see = list("flutters its wings")
speak_chance = 1
turns_per_move = 5
meat_type = /obj/item/weapon/reagent_containers/food/snacks/cracker/
response_help = "pets the"
response_disarm = "gently moves aside the"
response_harm = "swats the"
min_oxy = 16 //Require atleast 16kPA oxygen
minbodytemp = 223 //Below -50 Degrees Celcius
maxbodytemp = 323 //Above 50 Degrees Celcius
stop_automated_movement = 1
ears = new /obj/item/device/radio/headset/heads/ce()
/mob/living/simple_animal/parrot/DrProfessor
name = "Doctor Professor Parrot, PhD"
desc = "That's the Doctor Professor. He has more degrees than all of the engineering team put together, and has several published papers on quantum cracker theory."
speak = list(":e Check the singlo, you chucklefucks!",":e Wire the solars, you lazy bums!",":e WHO TOOK THE DAMN RIG SUIT?",":e OH GOD ITS FREE CALL THE SHUTTLE",":e Open secure storage please.",":e I think something happened to the containment field...")
response_harm = "is attacked in the face by"
var/parrot_state = PARROT_WANDER //Hunt for a perch when created
var/parrot_sleep_max = 25 //The time the parrot sits while perched before looking around. Mosly a way to avoid the parrot's AI in life() being run every single tick.
var/parrot_sleep_dur = 25 //Same as above, this is the var that physically counts down
var/parrot_dam_zone = list("chest", "head", "l_arm", "l_leg", "r_arm", "r_leg") //For humans, select a bodypart to attack TODO: pecking out a mob's eyes
/obj/item/weapon/reagent_containers/food/snacks/cracker/
name = "Cracker"
desc = "It's a salted cracker."
//Headset for Poly to yell at engineers :)
var/obj/item/device/radio/headset/ears = null
//The thing the parrot is currently interested in. This gets used for items the parrot wants to pick up, mobs it wants to steal from,
//mobs it wants to attack or mobs that have attacked it
var/atom/movable/parrot_interest = null
//Parrots will generally sit on their pertch unless something catches their eye.
//These vars store their preffered perch and if they dont have one, what they can use as a perch
var/obj/parrot_perch = null
var/obj/desired_perches = list(/obj/structure/computerframe, /obj/structure/displaycase, \
/obj/structure/closet, /obj/structure/filingcabinet, \
/obj/machinery/computer, /obj/machinery/clonepod, \
/obj/machinery/dna_scanner, /obj/machinery/dna_scannernew, \
/obj/machinery/nuclearbomb, /obj/machinery/particle_accelerator, \
/obj/machinery/recharge_station, /obj/machinery/smartfridge, \
/obj/machinery/suit_storage_unit, /obj/machinery/telecomms, \
/obj/machinery/teleport)
//Parrots are kleptomaniacs. These vars a used for just that.. holding items and storing items the parrot wants to steal.
var/obj/item/held_item = null
var/list/desired_items = list(/obj/item/weapon/reagent_containers/food/snacks/cracker/, \
/obj/item/smallDelivery, /obj/item/weapon/gift, \
/obj/item/weapon/soap, /obj/item/toy/spinningtoy, \
/obj/item/weapon/coin, /obj/item/weapon/stamp,\
/obj/item/weapon/grenade)
/mob/living/simple_animal/parrot/New()
usr << "\red <B>Sorry parrots are not ready yet!</B>"
del(src)
/*
..()
parrot_sleep_dur = parrot_sleep_max //In case someone decides to change the max without changing the duration var
ears = new /obj/item/device/radio/headset/headset_eng(src)
verbs.Add(/mob/living/simple_animal/parrot/proc/steal_from_ground, \
/mob/living/simple_animal/parrot/proc/steal_from_mob, \
/mob/living/simple_animal/parrot/proc/drop_held_item)
*/
/mob/living/simple_animal/parrot/Die()
if(held_item)
held_item.loc = src.loc
held_item = null
..()
/*
* Inventory
*/
/mob/living/simple_animal/parrot/show_inv(mob/user as mob)
user.machine = src
if(user.stat) return
@@ -45,50 +116,475 @@
onclose(user, "mob[real_name]")
return
/mob/living/simple_animal/parrot/Topic(href, href_list)
if(usr.stat) return
//Removing from inventory
if(href_list["remove_inv"])
if(get_dist(src,usr) > 1 || !(ishuman(usr) || ismonkey(usr) || isrobot(usr) || isalienadult(usr)))
return
var/remove_from = href_list["remove_inv"]
switch(remove_from)
if("ears")
if(ears)
src.say(":e BAWWWWWK LEAVE THE HEADSET BAWKKKKK!")
ears.loc = src.loc
ears = null
else
usr << "\red There is nothing to remove from its [remove_from]."
return
//Can the usr physically do this?
if(!usr.canmove || usr.stat || usr.restrained() || !in_range(loc, usr))
return
//Adding things to inventory
else if(href_list["add_inv"])
if(get_dist(src,usr) > 1 || !(ishuman(usr) || ismonkey(usr) || isrobot(usr) || isalienadult(usr)))
return
var/add_to = href_list["add_inv"]
if(!usr.get_active_hand())
usr << "\red You have nothing in your hand to put on its [add_to]."
return
switch(add_to)
if("ears")
if(ears)
usr << "\red It's already wearing something."
return
else
var/obj/item/item_to_add = usr.get_active_hand()
if(!item_to_add)
//Is the usr's mob type able to do this? (lolaliens)
if(ishuman(usr) || ismonkey(usr) || isrobot(usr) || isalienadult(usr))
//Removing from inventory
if(href_list["remove_inv"])
var/remove_from = href_list["remove_inv"]
switch(remove_from)
if("ears")
if(ears)
src.say(":e BAWWWWWK LEAVE THE HEADSET BAWKKKKK!")
ears.loc = src.loc
ears = null
else
usr << "\red There is nothing to remove from its [remove_from]."
return
if( !istype(item_to_add, /obj/item/device/radio/headset) )
usr << "\red This object won't fit."
//Adding things to inventory
else if(href_list["add_inv"])
var/add_to = href_list["add_inv"]
if(!usr.get_active_hand())
usr << "\red You have nothing in your hand to put on its [add_to]."
return
switch(add_to)
if("ears")
if(ears)
usr << "\red It's already wearing something."
return
else
var/obj/item/item_to_add = usr.get_active_hand()
if(!item_to_add)
return
usr.drop_item()
item_to_add.loc = src
src.ears = item_to_add
else
..()
if( !istype(item_to_add, /obj/item/device/radio/headset) )
usr << "\red This object won't fit."
return
usr.drop_item()
item_to_add.loc = src
src.ears = item_to_add
else
..()
/*
* Attack responces
*/
//Humans, monkeys, aliens
/mob/living/simple_animal/parrot/attack_hand(mob/living/carbon/M as mob)
..()
if(client) return
if(!stat && M.a_intent == "hurt")
if(parrot_state == PARROT_PERCH)
parrot_sleep_dur = parrot_sleep_max //Reset it's sleep timer if it was perched
parrot_interest = M
parrot_state = PARROT_SWOOP //The parrot just got hit, it WILL move, now to pick a direction..
if(M.getMaxHealth() - M.health < 50) //Weakened mob? Fight back!
parrot_state |= PARROT_ATTACK
else
parrot_state |= PARROT_FLEE //Otherwise, fly like a bat out of hell!
drop_held_item(0)
return
/mob/living/simple_animal/parrot/attack_paw(mob/living/carbon/monkey/M as mob)
attack_hand(M)
/mob/living/simple_animal/parrot/attack_alien(mob/living/carbon/monkey/M as mob)
attack_hand(M)
//Simple animals
/mob/living/simple_animal/parrot/attack_animal(mob/living/simple_animal/M as mob)
if(client) return
if(parrot_state == PARROT_PERCH)
parrot_sleep_dur = parrot_sleep_max //Reset it's sleep timer if it was perched
if(M.melee_damage_upper > 0)
parrot_interest = M
parrot_state = PARROT_SWOOP | PARROT_ATTACK //Attack other animals regardless
//Mobs with objects
/mob/living/simple_animal/parrot/attackby(var/obj/item/O as obj, var/mob/user as mob)
..()
if(!stat && !client && !istype(O, /obj/item/stack/medical))
if(O.force)
if(parrot_state == PARROT_PERCH)
parrot_sleep_dur = parrot_sleep_max //Reset it's sleep timer if it was perched
parrot_interest = user
parrot_state = PARROT_SWOOP | PARROT_FLEE
drop_held_item(0)
return
//Bullets
/mob/living/simple_animal/parrot/bullet_act(var/obj/item/projectile/Proj)
..()
if(!stat && !client)
if(parrot_state == PARROT_PERCH)
parrot_sleep_dur = parrot_sleep_max //Reset it's sleep timer if it was perched
parrot_interest = null
parrot_state = PARROT_WANDER //OWFUCK, Been shot! RUN LIKE HELL!
drop_held_item(0)
return
/*
* AI - Not really intelligent, but I'm calling it AI anyway.
*/
/mob/living/simple_animal/parrot/Life()
..()
if(client)
return //Lets not force players to move
if(!isturf(src.loc) || !canmove || buckled || pulledby)
return //If it can't move, dont let it move. (The buckled check probably isn't necessary)
world << "State: [parrot_state]"
//Alright, here we go... down the slope
//-----SLEEPING
if(parrot_state == PARROT_PERCH)
world << "Perched"
if(parrot_perch.loc != src.loc) //Make sure someone hasnt moved our perch on us
if(parrot_perch in view(src))
parrot_state = PARROT_SWOOP | PARROT_RETURN
return
else
parrot_state = PARROT_WANDER
return
if(--parrot_sleep_dur) //Zzz
world << "Perched: sleeping"
return
else
world << "Perched: looking around"
parrot_sleep_dur = parrot_sleep_max //This way we only call the loop below once every [sleep_max] ticks.
parrot_interest = search_for_item()
if(parrot_interest)
emote("[src] looks in [parrot_interest]'s direction and takes flight.")
parrot_state = PARROT_SWOOP | PARROT_STEAL
return
//-----WANDERING - This is basically a 'I dont know what to do yet' state
else if(parrot_state == PARROT_WANDER)
world << "Wander"
//Stop movement, we'll set it later
walk(src, 0)
parrot_interest = null
//Wander around aimlessly. This will help keep the loops from searches down
//and possibly move the mob into a new are in view of something they can use
if(prob(90))
world << "Wander: randomly"
step(src, pick(cardinal))
return
if(!held_item && !parrot_perch) //If we've got nothing to do.. look for something to do.
world << "Wander: looking for perch or item"
world << parrot_interest
var/atom/movable/AM = search_for_perch_and_item() //This handles checking through lists so we know it's either a perch or stealable item
if(AM)
if(istype(AM, /obj/item) || isliving(AM)) //If stealable item
parrot_interest = AM
emote("[src] turns and flies towards [parrot_interest].")
parrot_state = PARROT_SWOOP | PARROT_STEAL
world << parrot_interest
return
else //Else it's a perch
parrot_perch = AM
parrot_state = PARROT_SWOOP | PARROT_RETURN
world << parrot_interest
return
return
if(parrot_interest)
if(parrot_interest in view(src)) //Putting this in a seperate if so it doesnt run the 'in view' loop as often
parrot_state = PARROT_SWOOP | PARROT_STEAL
return
if(parrot_perch)
world << "Wander: returning to perch"
parrot_state = PARROT_SWOOP | PARROT_RETURN
return
else //Have an item but no perch? Find one!
world << "Wander: looking for perch, holding item"
parrot_perch = search_for_perch()
if(parrot_perch)
parrot_state = PARROT_SWOOP | PARROT_RETURN
return
//-----STEALING
else if(parrot_state == (PARROT_SWOOP | PARROT_STEAL))
world << "Steal"
walk(src,0)
if(!parrot_interest || held_item)
world << "Steal: lost interest or holding an item"
parrot_state = PARROT_SWOOP | PARROT_RETURN
return
if(!(parrot_interest in view(src)))
world << "Steal: interest not in view"
parrot_state = PARROT_SWOOP | PARROT_RETURN
return
if(in_range(src, parrot_interest))
world << "Steal: stealing item"
if(isliving(parrot_interest))
steal_from_mob()
else
steal_from_ground()
parrot_interest = null
parrot_state = PARROT_SWOOP | PARROT_RETURN
return
world << "Steal: swooping closer to target"
var/oldloc = src.loc
step_towards(src, get_step_towards(src,parrot_interest))
if(src.loc == oldloc) //Check if the mob is stuck
parrot_state = PARROT_WANDER //and demonstrate your amazing obstical avoidance AI
return
//-----RETURNING TO PERCH
else if(parrot_state == (PARROT_SWOOP | PARROT_RETURN))
world << "Return"
walk(src, 0)
if(!parrot_perch || !isturf(parrot_perch.loc)) //Make sure the perch exists and somehow isnt inside of something else.
world << "Return: no perch?"
parrot_perch = null
parrot_state = PARROT_WANDER
return
if(in_range(src, parrot_perch))
world << "Return: landing"
src.loc = parrot_perch.loc
drop_held_item()
parrot_state = PARROT_PERCH
return
world << "Return: returning to perch"
var/oldloc = src.loc
step_towards(src, get_step_towards(src,parrot_perch))
if(src.loc == oldloc) //Check if the mob is stuck
parrot_state = PARROT_WANDER //and demonstrate your amazing obstical avoidance AI
return
//-----FLEEING
else if(parrot_state == (PARROT_SWOOP | PARROT_FLEE))
world << "Flee"
walk(src,0)
if(!parrot_interest || !isliving(parrot_interest)) //Sanity
world << "Flee: lost interest"
parrot_state = PARROT_WANDER
world << "Flee: fleeing"
var/oldloc = src.loc
step(src, get_step_away(src, parrot_interest))
if(src.loc == oldloc) //Check if the mob is stuck
parrot_state = PARROT_WANDER //and demonstrate your amazing obstical avoidance AI
//-----ATTACKING
else if(parrot_state == (PARROT_SWOOP | PARROT_ATTACK))
world << "Attack"
//If we're attacking a nothing, an object, a turf or a ghost for some stupid reason, switch to wander
if(!parrot_interest || !isliving(parrot_interest))
world << "Attack: lost interest"
parrot_interest = null
parrot_state = PARROT_WANDER
return
var/mob/living/L = parrot_interest
//If the mob is close enough to interact with
if(in_range(src, parrot_interest))
//If the mob we've been chasing/attacking dies or falls into crit, check for loot!
if(L.stat)
world << "Attack: looting body"
parrot_interest = null
if(!held_item)
held_item = steal_from_ground()
if(!held_item)
held_item = steal_from_mob() //Apparently it's possible for dead mobs to hang onto items in certain circumstances.
if(parrot_perch in view(src)) //If we have a home nearby, go to it, otherwise find a new home
parrot_state = PARROT_SWOOP | PARROT_RETURN
else
parrot_state = PARROT_WANDER
return
//Time for the hurt to begin!
var/damage = rand(5,10)
if(ishuman(parrot_interest))
world << "Attack: attacking human"
var/mob/living/carbon/human/H = parrot_interest
var/datum/organ/external/affecting = H.get_organ(ran_zone(pick(parrot_dam_zone)))
H.apply_damage(damage, BRUTE, affecting, H.run_armor_check(affecting, "melee"))
emote(pick("pecks [H]'s [affecting]", "cuts [H]'s [affecting] with its talons"))
else
world << "Attack: attacking non-human"
L.adjustBruteLoss(damage)
emote(pick("pecks at [L]", "claws [L]"))
return
//Otherwise, fly towards the mob!
else
world << "Attack: swooping towards the mob"
var/oldloc = src.loc
step_towards(src, get_step_towards(src,parrot_interest))
if(src.loc == oldloc) //Check if the mob is stuck
parrot_state = PARROT_WANDER //and demonstrate your amazing obstical avoidance AI
//-----STATE MISHAP
else //This should not happen. If it does lets reset everything and try again
world << "Unknown state: resetting to wander"
walk(src,0)
parrot_interest = null
parrot_perch = null
drop_held_item()
parrot_state = PARROT_WANDER
return
/*
* Procs
*/
/mob/living/simple_animal/parrot/proc/search_for_item()
for(var/atom/movable/AM in view(src))
for(var/path in desired_items)
if(parrot_perch && AM.loc == parrot_perch.loc) //Skip items we already stole
continue
if(istype(AM, path))
return AM
if(iscarbon(AM))
var/mob/living/carbon/C = AM
if(istype(C.l_hand, path) || istype(C.r_hand, path))
return C
return null
/mob/living/simple_animal/parrot/proc/search_for_perch()
for(var/obj/O in view(src))
for(var/path in desired_perches)
if(istype(O, path))
return O
return null
//This proc was made to save on doing two 'in view' loops seperatly
/mob/living/simple_animal/parrot/proc/search_for_perch_and_item()
for(var/atom/movable/AM in view(src))
for(var/perch_path in desired_perches)
if(istype(AM, perch_path))
return AM
for(var/item_path in desired_items)
if(parrot_perch && AM.loc == parrot_perch.loc) //Skip items we already stole
continue
if(istype(AM, item_path))
return AM
if(iscarbon(AM))
var/mob/living/carbon/C = AM
if(istype(C.l_hand, item_path) || istype(C.r_hand, item_path))
return AM
return null
/*
* Verbs - These are actually procs, but can be used as verbs by player-controlled parrots.
*/
/mob/living/simple_animal/parrot/proc/steal_from_ground()
set name = "Steal from ground"
set category = "Parrot"
set desc = "Grabs a nearby item."
if(stat)
return -1
if(held_item)
usr << "\red You are already holding the [held_item]"
return 1
for(var/obj/item/I in view(1,src))
for(var/path in desired_items)
if(istype(I, path))
held_item = I
I.loc = src
visible_message("[src] grabs the [held_item]!", "\blue You grab the [held_item]!", "You hear the sounds of wings flapping furiously.")
return held_item
usr << "\red There is nothing of interest to take."
return 0
/mob/living/simple_animal/parrot/proc/steal_from_mob()
set name = "Steal from mob"
set category = "Parrot"
set desc = "Steals an item right out of a person's hand!"
if(stat)
return -1
if(held_item)
usr << "\red You are already holding the [held_item]"
return 1
var/obj/item/stolen_item = null
for(var/mob/living/carbon/C in view(1,src))
for(var/path in desired_items)
if(istype(C.l_hand, path))
stolen_item = C.l_hand
if(istype(C.r_hand, path))
stolen_item = C.r_hand
if(stolen_item)
C.u_equip(stolen_item)
held_item = stolen_item
stolen_item.loc = src
visible_message("[src] grabs the [held_item] out of [C]'s hand!", "\blue You snag the [held_item] out of [C]'s hand!", "You hear the sounds of wings flapping furiously.")
return held_item
usr << "\red There is nothing of interest to take."
return 0
/mob/living/simple_animal/parrot/proc/drop_held_item(var/drop_gently = 1)
set name = "Drop held item"
set category = "Parrot"
set desc = "Drop the item you're holding."
if(stat)
return -1
if(!held_item)
usr << "\red You have nothing to drop!"
return 0
if(!drop_gently)
if(istype(held_item, /obj/item/weapon/grenade))
var/obj/item/weapon/grenade/G = held_item
G.loc = get_turf(src)
G.prime()
held_item = null
usr << "You drop the [held_item]."
held_item.loc = src.loc
held_item = null
return 1
/*
* Sub-types
*/
/mob/living/simple_animal/parrot/Poly
name = "Poly"
desc = "Poly the Parrot. An expert on quantum cracker theory."
speak = list("Poly wanna cracker!", ":e Check the singlo, you chucklefucks!",":e Wire the solars, you lazy bums!",":e WHO TOOK THE DAMN HARDSUITS?",":e OH GOD ITS FREE CALL THE SHUTTLE")
+1 -1
View File
@@ -46,7 +46,7 @@
var/main_status = 0
var/wiresexposed = 0
var/apcwires = 15
netnum = -1 // set so that APCs aren't found as powernet nodes
powernet = 0 // set so that APCs aren't found as powernet nodes //Hackish, Horrible, was like this before I changed it :(
var/malfhack = 0 //New var for my changes to AI malf. --NeoFite
var/mob/living/silicon/ai/malfai = null //See above --NeoFite
// luminosity = 1
+66 -108
View File
@@ -35,21 +35,13 @@
NC.mergeConnectedNetworks(NC.d2)
NC.mergeConnectedNetworksOnTurf()
if(netnum == 0 && NC.netnum == 0)
var/datum/powernet/PN = new()
PN.number = powernets.len + 1
powernets += PN
NC.netnum = PN.number
netnum = PN.number
PN.cables += NC
PN.nodes += src
powernet = PN
else if(netnum == 0)
netnum = NC.netnum
var/datum/powernet/PN = powernets[netnum]
powernet = PN
PN.nodes += src
if(powernet==null)
if(NC.powernet == null)
NC.powernet = new()
powernets += NC.powernet
NC.powernet.cables += NC
powernet = NC.powernet
NC.powernet.nodes += src
NC.mergeConnectedNetworksOnTurf()
coil.use(1)
@@ -82,15 +74,11 @@
cable_list += src
/obj/structure/cable/Del() // called when a cable is deleted
if(!defer_powernet_rebuild) // set if network will be rebuilt manually
if(netnum && powernets && (powernets.len >= netnum) && (netnum >= 1) ) // make sure cable & powernet data is valid
var/datum/powernet/PN = powernets[netnum]
PN.cut_cable(src) // updated the powernets
/obj/structure/cable/Del() // called when a cable is deleted
if(!defer_powernet_rebuild) // set if network will be rebuilt manually
if(powernet)
powernet.cut_cable(src) // update the powernets
cable_list -= src
// else
// if(Debug) diary << "Defered cable deletion at [x],[y]: #[netnum]"
..() // then go ahead and delete the cable
/obj/structure/cable/hide(var/i)
@@ -107,11 +95,8 @@
// returns the powernet this cable belongs to
/obj/structure/cable/proc/get_powernet()
var/datum/powernet/PN // find the powernet
if(netnum && powernets && powernets.len >= netnum)
PN = powernets[netnum]
return PN
/obj/structure/cable/proc/get_powernet() //TODO: remove this as it is obsolete
return powernet
/obj/structure/cable/attack_hand(mob/user)
if(ishuman(user))
@@ -127,9 +112,9 @@
if(istype(W, /obj/item/weapon/wirecutters))
if(power_switch)
user << "\red This piece of cable is tied to a power switch. Flip the switch to remove it."
return
// if(power_switch)
// user << "\red This piece of cable is tied to a power switch. Flip the switch to remove it."
// return
if (shock(user, 50))
return
@@ -174,7 +159,7 @@
/obj/structure/cable/proc/shock(mob/user, prb, var/siemens_coeff = 1.0)
if(!prob(prb))
return 0
if (electrocute_mob(user, powernets[src.netnum], src, siemens_coeff))
if (electrocute_mob(user, powernet, src, siemens_coeff))
var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
s.set_up(5, 1, src)
s.start()
@@ -334,11 +319,9 @@
C.add_fingerprint(user)
C.updateicon()
var/datum/powernet/PN = new()
PN.number = powernets.len + 1
powernets += PN
C.netnum = PN.number
PN.cables += C
C.powernet = new()
powernets += C.powernet
C.powernet.cables += C
C.mergeConnectedNetworks(C.d2)
C.mergeConnectedNetworksOnTurf()
@@ -399,11 +382,11 @@
NC.add_fingerprint()
NC.updateicon()
NC.netnum = C.netnum
var/datum/powernet/PN = powernets[C.netnum]
PN.cables += NC
NC.mergeConnectedNetworks(NC.d2)
NC.mergeConnectedNetworksOnTurf()
if(C.powernet)
NC.powernet = C.powernet
NC.powernet.cables += NC
NC.mergeConnectedNetworks(NC.d2)
NC.mergeConnectedNetworksOnTurf()
use(1)
if (NC.shock(user, 50))
if (prob(50)) //fail
@@ -453,7 +436,7 @@
/obj/structure/cable/proc/mergeConnectedNetworks(var/direction)
var/turf/TB
if((d1 == direction || d2 == direction) != 1)
if(!(d1 == direction || d2 == direction))
return
TB = get_step(src, direction)
@@ -469,79 +452,54 @@
if(TC.d1 == fdir || TC.d2 == fdir)
if(!netnum)
var/datum/powernet/PN = powernets[TC.netnum]
netnum = TC.netnum
PN = powernets[netnum]
PN.cables += src
continue
if(!TC.powernet)
TC.powernet = new()
powernets += TC.powernet
TC.powernet.cables += TC
if(powernet)
merge_powernets(powernet,TC.powernet)
else
powernet = TC.powernet
powernet.cables += src
if(TC.netnum != netnum)
var/datum/powernet/PN = powernets[netnum]
var/datum/powernet/TPN = powernets[TC.netnum]
PN.merge_powernets(TPN)
/obj/structure/cable/proc/mergeConnectedNetworksOnTurf()
if(!powernet)
powernet = new()
powernets += powernet
powernet.cables += src
for(var/AM in loc)
if(istype(AM,/obj/structure/cable))
var/obj/structure/cable/C = AM
if(C.powernet == powernet) continue
if(C.powernet)
merge_powernets(powernet, C.powernet)
else
C.powernet = powernet
powernet.cables += C
for(var/obj/structure/cable/C in loc)
else if(istype(AM,/obj/machinery/power/apc))
var/obj/machinery/power/apc/N = AM
if(!N.terminal) continue
if(N.terminal.powernet)
merge_powernets(powernet, N.terminal.powernet)
else
N.terminal.powernet = powernet
powernet.nodes += N.terminal
else if(istype(AM,/obj/machinery/power))
var/obj/machinery/power/M = AM
if(M.powernet == powernet) continue
if(M.powernet)
merge_powernets(powernet, M.powernet)
else
M.powernet = powernet
powernet.nodes += M
if(!C)
continue
if(C == src)
continue
if(netnum == 0)
var/datum/powernet/PN = powernets[C.netnum]
netnum = C.netnum
PN.cables += src
continue
var/datum/powernet/PN = powernets[netnum]
var/datum/powernet/TPN = powernets[C.netnum]
PN.merge_powernets(TPN)
for(var/obj/machinery/power/M in loc)
if(!M)
continue
if(!M.netnum)
var/datum/powernet/PN = powernets[netnum]
PN.nodes += M
M.netnum = netnum
M.powernet = powernets[M.netnum]
if(M.netnum < 0)
continue
var/datum/powernet/PN = powernets[netnum]
var/datum/powernet/TPN = powernets[M.netnum]
PN.merge_powernets(TPN)
for(var/obj/machinery/power/apc/N in loc)
if(!N) continue
var/obj/machinery/power/M
M = N.terminal
if(!M) continue
if(!M.netnum)
if(!netnum)continue
var/datum/powernet/PN = powernets[netnum]
PN.nodes += M
M.netnum = netnum
M.powernet = powernets[M.netnum]
continue
var/datum/powernet/PN = powernets[netnum]
var/datum/powernet/TPN = powernets[M.netnum]
PN.merge_powernets(TPN)
obj/structure/cable/proc/cableColor(var/colorC)
var/color_n = "red"
+166 -213
View File
@@ -3,7 +3,6 @@
icon = 'icons/obj/power.dmi'
anchored = 1.0
var/datum/powernet/powernet = null
var/netnum = 0
var/directwired = 1 // by default, power machines are connected by a cable in a neighbouring turf
// if set to 0, requires a 0-X cable on this turf
use_power = 0
@@ -43,7 +42,7 @@
if(!A || !isarea(A) || !A.master)
return 0 // if not, then not powered
return A.master.powered(power_channel) // return power status of the area
return A.master.powered(chan) // return power status of the area
// increment the power usage stats for an area
@@ -72,263 +71,213 @@
// rebuild all power networks from scratch
/proc/makepowernets()
var/netcount = 0
powernets = list()
for(var/datum/powernet/PN in powernets)
del(PN)
powernets.Cut()
for(var/obj/structure/cable/PC in cable_list)
PC.netnum = 0
for(var/obj/machinery/power/M in machines)
if(M.netnum >=0)
M.netnum = 0
for(var/obj/structure/cable/PC in cable_list)
if(!PC.netnum)
PC.netnum = ++netcount
if(Debug) world.log << "Starting mpn at [PC.x],[PC.y] ([PC.d1]/[PC.d2]) #[netcount]"
powernet_nextlink(PC, PC.netnum)
if(Debug) world.log << "[netcount] powernets found"
for(var/L = 1 to netcount)
var/datum/powernet/PN = new()
powernets += PN
PN.number = L
if(!PC.powernet)
PC.powernet = new()
powernets += PC.powernet
// if(Debug) world.log << "Starting mpn at [PC.x],[PC.y] ([PC.d1]/[PC.d2])"
powernet_nextlink(PC,PC.powernet)
// if(Debug) world.log << "[powernets.len] powernets found"
for(var/obj/structure/cable/C in cable_list)
var/datum/powernet/PN = powernets[C.netnum]
PN.cables += C
if(!C.powernet) continue
C.powernet.cables += C
for(var/obj/machinery/power/M in machines)
if(M.netnum<=0) // APCs have netnum=-1 so they don't count as network nodes directly
continue
M.powernet = powernets[M.netnum]
if(!M.powernet) continue // APCs have powernet=0 so they don't count as network nodes directly
M.powernet.nodes += M
// returns a list of all power-related objects (nodes, cable, junctions) in turf,
// excluding source, that match the direction d
// if unmarked==1, only return those with netnum==0
// if unmarked==1, only return those with no powernet
/proc/power_list(var/turf/T, var/source, var/d, var/unmarked=0)
var/list/result = list()
var/fdir = (!d)? 0 : turn(d, 180) // the opposite direction to d (or 0 if d==0)
. = list()
var/fdir = (!d)? 0 : turn(d, 180) // the opposite direction to d (or 0 if d==0)
// world.log << "d=[d] fdir=[fdir]"
for(var/AM in T)
if(AM == source) continue //we don't want to return source
for(var/obj/machinery/power/P in T)
if(P.netnum < 0) // exclude APCs
continue
if(istype(AM,/obj/machinery/power))
var/obj/machinery/power/P = AM
if(P.powernet == 0) continue // exclude APCs which have powernet=0
if(P.directwired) // true if this machine covers the whole turf (so can be joined to a cable on neighbour turf)
if(!unmarked || !P.netnum)
result += P
else if(d == 0) // otherwise, need a 0-X cable on same turf to connect
if(!unmarked || !P.netnum)
result += P
if(!unmarked || !P.powernet) //if unmarked=1 we only return things with no powernet
if(P.directwired || (d == 0))
. += P
else if(istype(AM,/obj/structure/cable))
var/obj/structure/cable/C = AM
for(var/obj/structure/cable/C in T)
if(C.d1 == fdir || C.d2 == fdir)
if(!unmarked || !C.netnum)
result += C
result -= source
return result
if(!unmarked || !C.powernet)
if(C.d1 == fdir || C.d2 == fdir)
. += C
return .
/obj/structure/cable/proc/get_connections()
. = list() // this will be a list of all connected power objects
var/turf/T = loc
var/list/res = list() // this will be a list of all connected power objects
var/turf/T
if(!d1)
T = src.loc // if d1=0, same turf as src
else
T = get_step(src, d1)
res += power_list(T, src , d1, 1)
if(d1) T = get_step(src, d1)
if(T) . += power_list(T, src, d1, 1)
T = get_step(src, d2)
if(T) . += power_list(T, src, d2, 1)
res += power_list(T, src, d2, 1)
return res
return .
/obj/machinery/power/proc/get_connections()
if(!directwired) return get_indirect_connections()
if(!directwired)
return get_indirect_connections()
var/list/res = list()
. = list()
var/cdir
for(var/turf/T in orange(1, src))
cdir = get_dir(T, src)
for(var/card in cardinal)
var/turf/T = get_step(loc,card)
cdir = get_dir(T,loc)
for(var/obj/structure/cable/C in T)
if(C.netnum)
continue
if(C.powernet) continue
if(C.d1 == cdir || C.d2 == cdir)
res += C
return res
. += C
return .
/obj/machinery/power/proc/get_indirect_connections()
var/list/res = list()
for(var/obj/structure/cable/C in src.loc)
if(C.netnum)
continue
. = list()
for(var/obj/structure/cable/C in loc)
if(C.powernet) continue
if(C.d1 == 0)
res += C
return res
. += C
return .
/proc/powernet_nextlink(var/obj/O, var/num)
/proc/powernet_nextlink(var/obj/O, var/datum/powernet/PN)
var/list/P
//world.log << "start: [O] at [O.x].[O.y]"
while(1)
if( istype(O, /obj/structure/cable) )
if( istype(O,/obj/structure/cable) )
var/obj/structure/cable/C = O
C.netnum = num
C.powernet = PN
P = C.get_connections()
else if( istype(O, /obj/machinery/power) )
else if( istype(O,/obj/machinery/power) )
var/obj/machinery/power/M = O
M.netnum = num
M.powernet = PN
P = M.get_connections()
if(P.len == 0)
//world.log << "end1"
return
if(P.len == 0) return
O = P[1]
for(var/L = 2 to P.len)
powernet_nextlink(P[L], num)
//world.log << "next: [O] at [O.x].[O.y]"
powernet_nextlink(P[L], PN)
// cut a powernet at this cable object
/datum/powernet/proc/cut_cable(var/obj/structure/cable/C)
var/turf/T1 = C.loc
if(C.d1)
T1 = get_step(C, C.d1)
if(!T1) return
var/turf/T2
if(C.d2) T2 = get_step(T1, C.d2)
if(C.d1) T1 = get_step(T1, C.d1)
var/turf/T2 = get_step(C, C.d2)
var/list/P1 = power_list(T1, C, C.d1) // what joins on to cut cable in dir1
var/list/P2 = power_list(T2, C, C.d2) // what joins on to cut cable in dir2
if(Debug)
for(var/obj/O in P1)
world.log << "P1: [O] at [O.x] [O.y] : [istype(O, /obj/structure/cable) ? "[O:d1]/[O:d2]" : null] "
for(var/obj/O in P2)
world.log << "P2: [O] at [O.x] [O.y] : [istype(O, /obj/structure/cable) ? "[O:d1]/[O:d2]" : null] "
// if(Debug)
// for(var/obj/O in P1)
// world.log << "P1: [O] at [O.x] [O.y] : [istype(O, /obj/structure/cable) ? "[O:d1]/[O:d2]" : null] "
// for(var/obj/O in P2)
// world.log << "P2: [O] at [O.x] [O.y] : [istype(O, /obj/structure/cable) ? "[O:d1]/[O:d2]" : null] "
if(P1.len == 0 || P2.len ==0) // if nothing in either list, then the cable was an endpoint
// no need to rebuild the powernet, just remove cut cable from the list
cables -= C
if(Debug) world.log << "Was end of cable"
if(P1.len == 0 || P2.len == 0)//if nothing in either list, then the cable was an endpoint no need to rebuild the powernet,
cables -= C //just remove cut cable from the list
// if(Debug) world.log << "Was end of cable"
return
// zero the netnum of all cables & nodes in this powernet
for(var/obj/structure/cable/OC in cables)
OC.netnum = 0
for(var/obj/machinery/power/OM in nodes)
OM.netnum = 0
//null the powernet reference of all cables & nodes in this powernet
var/i=1
while(i<=cables.len)
var/obj/structure/cable/Cable = cables[i]
if(Cable)
Cable.powernet = null
if(Cable == C)
cables.Cut(i,i+1)
continue
i++
i=1
while(i<=nodes.len)
var/obj/machinery/power/Node = nodes[i]
if(Node) Node.powernet = null
i++
// remove the cut cable from the network
C.netnum = -1
// C.netnum = -1
C.loc = null
cables -= C
powernet_nextlink(P1[1], number) // propagate network from 1st side of cable, using current netnum
powernet_nextlink(P1[1], src) // propagate network from 1st side of cable, using current netnum //TODO?
// now test to see if propagation reached to the other side
// if so, then there's a loop in the network
var/notlooped = 0
for(var/obj/O in P2)
for(var/O in P2)
if( istype(O, /obj/machinery/power) )
var/obj/machinery/power/OM = O
if(OM.netnum != number)
var/obj/machinery/power/Machine = O
if(Machine.powernet != src)
notlooped = 1
break
else if( istype(O, /obj/structure/cable) )
var/obj/structure/cable/OC = O
if(OC.netnum != number)
var/obj/structure/cable/Cable = O
if(Cable.powernet != src)
notlooped = 1
break
if(notlooped)
// not looped, so make a new powernet
var/datum/powernet/PN = new()
powernets += PN
PN.number = powernets.len
if(Debug) world.log << "Was not looped: spliting PN#[number] ([cables.len];[nodes.len])"
// if(Debug) world.log << "Was not looped: spliting PN#[number] ([cables.len];[nodes.len])"
for(var/obj/structure/cable/OC in cables)
i=1
while(i<=cables.len)
var/obj/structure/cable/Cable = cables[i]
if(Cable && !Cable.powernet) // non-connected cables will have powernet=null, since they weren't reached by propagation
Cable.powernet = PN
cables.Cut(i,i+1) // remove from old network & add to new one
PN.cables += Cable
continue
i++
if(!OC.netnum) // non-connected cables will have netnum==0, since they weren't reached by propagation
i=1
while(i<=nodes.len)
var/obj/machinery/power/Node = nodes[i]
if(Node && !Node.powernet)
Node.powernet = PN
nodes.Cut(i,i+1)
PN.nodes += Node
continue
i++
OC.netnum = PN.number
cables -= OC
PN.cables += OC // remove from old network & add to new one
for(var/obj/machinery/power/OM in nodes)
if(!OM.netnum)
OM.netnum = PN.number
OM.powernet = PN
nodes -= OM
PN.nodes += OM // same for power machines
if(Debug)
world.log << "Old PN#[number] : ([cables.len];[nodes.len])"
world.log << "New PN#[PN.number] : ([PN.cables.len];[PN.nodes.len])"
else
if(Debug)
world.log << "Was looped."
//there is a loop, so nothing to be done
return
return
// if(Debug)
// world.log << "Old PN#[number] : ([cables.len];[nodes.len])"
// world.log << "New PN#[PN.number] : ([PN.cables.len];[PN.nodes.len])"
//
// else
// if(Debug)
// world.log << "Was looped."
// //there is a loop, so nothing to be done
// return
@@ -379,52 +328,57 @@
return min(rand(10,20),rand(10,20))*/
if (1000000 to INFINITY)
return min(rand(50,160),rand(50,160))
if (200000 to 1000000-1)
if (200000 to 1000000)
return min(rand(25,80),rand(25,80))
if (100000 to 200000-1)//Ave powernet
if (100000 to 200000)//Ave powernet
return min(rand(20,60),rand(20,60))
if (50000 to 100000-1)
if (50000 to 100000)
return min(rand(15,40),rand(15,40))
if (1000 to 50000-1)
if (1000 to 50000)
return min(rand(10,20),rand(10,20))
else
return 0
/datum/powernet/proc/merge_powernets(var/datum/powernet/P)
// The powernet that calls this proc will consume the other powernet - Rockdtben
//The powernet that calls this proc will consume the other powernet - Rockdtben
//TODO: rewrite so the larger net absorbs the smaller net
/proc/merge_powernets(var/datum/powernet/net1, var/datum/powernet/net2)
if(!net1 || !net2) return
if(net1 == net2) return
if(src == P)
return
//We assume net1 is larger. If net2 is in fact larger we are just going to make them switch places to reduce on code.
if(net1.cables.len < net2.cables.len) //net2 is larger than net1. Let's switch them around
var/temp = net1
net1 = net2
net2 = temp
if(nodes.len >= P.nodes.len)
nodes += P.nodes
else
P.nodes += nodes
nodes = P.nodes
for(var/obj/machinery/power/M in nodes)
M.netnum = number
M.powernet = powernets[M.netnum] // Thanks to Derp__
for(var/i=1,i<=net2.nodes.len,i++) //merge net2 into net1
var/obj/machinery/power/Node = net2.nodes[i]
if(Node)
Node.powernet = net1
net1.nodes += Node
for(var/i=1,i<=net2.cables.len,i++)
var/obj/structure/cable/Cable = net2.cables[i]
if(Cable)
Cable.powernet = net1
net1.cables += Cable
del(net2)
return net1
if(cables.len >= P.cables.len)
cables += P.cables
else
P.cables += cables
cables = P.cables
for(var/obj/structure/cable/C in cables)
C.netnum = number
del P
/obj/machinery/power/proc/connect_to_network()
var/turf/T = src.loc
var/obj/structure/cable/C = T.get_cable_node()
if (!C || !C.netnum)
return
makepowernets() //TODO: find fast way
if(!C || !C.powernet) return
// makepowernets() //TODO: find fast way //EWWWW what are you doing!?
powernet = C.powernet
powernet.nodes += src
/obj/machinery/power/proc/disconnect_from_network()
//TODO: dunno how to do that
return
if(!powernet) return
powernet.nodes -= src
powernet = null
/turf/proc/get_cable_node()
if(!istype(src, /turf/simulated/floor))
@@ -447,31 +401,29 @@
//source is an object caused electrocuting (airlock, grille, etc)
//No animations will be performed by this proc.
/proc/electrocute_mob(mob/living/carbon/M as mob, var/power_source, var/obj/source, var/siemens_coeff = 1.0)
if(istype(M.loc,/obj/mecha))
return 0
if(istype(M.loc,/obj/mecha)) return 0 //feckin mechs are dumb
if(istype(M,/mob/living/carbon/human))
var/mob/living/carbon/human/H = M
if(H.gloves)
var/obj/item/clothing/gloves/G = H.gloves
var/siem_coef = G.siemens_coefficient
if(siem_coef == 0) //to avoid spamming with insulated glvoes on
return 0
if(G.siemens_coefficient == 0) return 0 //to avoid spamming with insulated glvoes on
var/area/source_area
if (istype(power_source,/area))
if(istype(power_source,/area))
source_area = power_source
power_source = source_area.get_apc()
if (istype(power_source,/obj/structure/cable))
var/obj/structure/cable/tmp = power_source
power_source = powernets[tmp.netnum]
if(istype(power_source,/obj/structure/cable))
var/obj/structure/cable/Cable = power_source
power_source = Cable.powernet
var/datum/powernet/PN
var/obj/item/weapon/cell/cell
if (istype(power_source,/datum/powernet))
if(istype(power_source,/datum/powernet))
PN = power_source
else if (istype(power_source,/obj/item/weapon/cell))
else if(istype(power_source,/obj/item/weapon/cell))
cell = power_source
else if (istype(power_source,/obj/machinery/power/apc))
else if(istype(power_source,/obj/machinery/power/apc))
var/obj/machinery/power/apc/apc = power_source
cell = apc.cell
if (apc.terminal)
@@ -506,4 +458,5 @@
PN.newload+=drained_power
else if (istype(power_source, /obj/item/weapon/cell))
cell.use(drained_energy)
return drained_energy
return drained_energy
+3 -2
View File
@@ -2,7 +2,7 @@
//After it knows this it creates the number of cables from the center to each of the cables attempting to conenct. These cables cannot be removed
//with wirecutters. When the switch is turned off it removes all the cables on the tile it's on.
//The switch uses a 5s delay to prevent powernet change spamming.
/*
/obj/structure/powerswitch
name = "power switch"
desc = "A switch that controls power."
@@ -81,4 +81,5 @@
else
icon_state = icon_state_off
for(var/obj/structure/cable/C in src.loc)
del(C)
del(C)
*/