From 19cf6b3b47f85c9e38c3c237a7d9e29fa04791af Mon Sep 17 00:00:00 2001 From: Ren Erthilo Date: Mon, 9 Apr 2012 14:35:18 +0100 Subject: [PATCH] TG: Adds a new special object (stop) that can be used when you need someone to stop moving right away, even before the next life(). Used in door crushing to prevent people from inertiaing through. Checks for /obj/special/stop in loc every move. Compared to the number of other checks, I don't expect this to be an undo burden, but can be commented out in case of OH SHIT LAG under heavy load. Moves /area/entered to its own file. Adds a new area var called has_gravity. Determines if floor tiles count for movement control (planning on adding more, currently can only be badmined) Adds a new mob var called lastarea that is updated with the area you're in every time /area/entered is called. r2917 Moves /obj/special/stop into /obj/effect/stop. Thunks people when gravity changes. r2918 --- code/game/area/areas.dm | 96 ++++++++++++++++++++++- code/game/objects/items.dm | 7 +- code/game/sound.dm | 41 ---------- code/game/throwing.dm | 22 +++++- code/game/turf.dm | 10 +++ code/modules/admin/admin_verbs.dm | 6 +- code/modules/admin/verbs/randomverbs.dm | 30 +++++++ code/modules/mob/mob_movement.dm | 33 +++++++- code/modules/mob/new_player/new_player.dm | 2 + code/setup.dm | 13 +-- 10 files changed, 200 insertions(+), 60 deletions(-) diff --git a/code/game/area/areas.dm b/code/game/area/areas.dm index 2b541c16587..758df9b4fd3 100644 --- a/code/game/area/areas.dm +++ b/code/game/area/areas.dm @@ -1,3 +1,7 @@ +// Areas.dm + + + // === /area/ var/global/global_uid = 0 @@ -5,6 +9,7 @@ /area/New() + master = src //moved outside the spawn(1) to avoid runtimes in lighting.dm when it references src.loc.loc.master ~Carn src.icon = 'alert.dmi' uid = ++global_uid spawn(1) @@ -14,7 +19,6 @@ if(sd_created) related += src return - master = src related = list(src) src.icon = 'alert.dmi' @@ -27,6 +31,7 @@ power_light = 0 power_equip = 0 power_environ = 0 + //has_gravity = 0 // Space has gravity. Because.. because. if(!requires_power) power_light = 0//rastaf0 @@ -40,6 +45,8 @@ //sd_SetLuminosity(0) // *DAL* + + /*spawn(5) for(var/turf/T in src) // count the number of turfs (for lighting calc) if(no_air) @@ -269,3 +276,90 @@ master.used_light += amount if(ENVIRON) master.used_environ += amount + + +/area/Entered(A) + + var/sound = null + var/musVolume = 25 + sound = 'ambigen1.ogg' + + + if (ismob(A)) + + if (istype(A, /mob/dead/observer)) return + if (!A:ckey) + return + + if(istype(A,/mob/living)) + if(!A:lastarea) + A:lastarea = get_area(A:loc) + //world << "Entered new area [get_area(A:loc)]" + var/area/newarea = get_area(A:loc) + var/area/oldarea = A:lastarea + if((oldarea.has_gravity == 0) && (newarea.has_gravity == 1) && (A:m_intent == "run")) // Being ready when you change areas gives you a chance to avoid falling all together. + thunk(A) + + A:lastarea = newarea + + //if (A:ear_deaf) return + + if (A && A:client && !A:client:ambience_playing && !A:client:no_ambi) // Ambience goes down here -- make sure to list each area seperately for ease of adding things in later, thanks! Note: areas adjacent to each other should have the same sounds to prevent cutoff when possible.- LastyScratch + A:client:ambience_playing = 1 + A << sound('shipambience.ogg', repeat = 1, wait = 0, volume = 35, channel = 2) + + switch(src.name) + if ("Chapel") sound = pick('ambicha1.ogg','ambicha2.ogg','ambicha3.ogg','ambicha4.ogg') + if ("Morgue") sound = pick('ambimo1.ogg','ambimo2.ogg','title2.ogg') + if ("Space") sound = pick('ambispace.ogg','title2.ogg',) + if ("Engine Control", "Engineering", "Engineering SMES") sound = pick('ambisin1.ogg','ambisin2.ogg','ambisin3.ogg','ambisin4.ogg') + if ("AI Satellite Teleporter Room") sound = pick('ambimalf.ogg') + if ("AI Upload Foyer") sound = pick('ambimalf.ogg') + if ("AI Upload Chamber") sound = pick('ambimalf.ogg') + if ("Mine") + sound = pick('ambimine.ogg') + musVolume = 25 + else + sound = pick('ambigen1.ogg','ambigen3.ogg','ambigen4.ogg','ambigen5.ogg','ambigen6.ogg','ambigen7.ogg','ambigen8.ogg','ambigen9.ogg','ambigen10.ogg','ambigen11.ogg','ambigen12.ogg','ambigen14.ogg') + + if(findtext(src.name, "Telecommunications")) + sound = pick('ambisin2.ogg', 'signal.ogg', 'signal.ogg', 'ambigen10.ogg') + + if (prob(35)) + if(A && A:client && !A:client:played) + A << sound(sound, repeat = 0, wait = 0, volume = musVolume, channel = 1) + A:client:played = 1 + spawn(600) + if(A && A:client) + A:client:played = 0 + + +/area/proc/gravitychange(var/gravitystate = 0, var/area/A) + + A.has_gravity = gravitystate + + for(var/area/SubA in A.related) + SubA.has_gravity = gravitystate + + if(gravitystate) + for(var/mob/living/carbon/human/M in SubA) + thunk(M) + +/area/proc/thunk(mob) + if(istype(mob,/mob/living/carbon/human/)) // Only humans can wear magboots, so we give them a chance to. + if((istype(mob:shoes, /obj/item/clothing/shoes/magboots) && (mob:shoes.flags & NOSLIP))) + return + + if(istype(get_turf(mob), /turf/space)) // Can't fall onto nothing. + return + + if((istype(mob,/mob/living/carbon/human/)) && (mob:m_intent == "run")) // Only clumbsy humans can fall on their asses. + mob:AdjustStunned(5) + mob:AdjustWeakened(5) + + else if (istype(mob,/mob/living/carbon/human/)) + mob:AdjustStunned(2) + mob:AdjustWeakened(2) + + mob << "Gravity!" + diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm index 0afdfc6d502..9b77697bb57 100644 --- a/code/game/objects/items.dm +++ b/code/game/objects/items.dm @@ -145,10 +145,15 @@ if(W.loc == my_target) break sleep(2) - if(istype(usr.loc, /turf/space)|| (user.flags & NOGRAV)) + if((istype(usr.loc, /turf/space)) || (usr.lastarea.has_gravity == 0)) user.inertia_dir = get_dir(target, user) step(user, user.inertia_dir) + /* + if(istype(usr.loc, /turf/space)|| (user.flags & NOGRAV)) + user.inertia_dir = get_dir(target, user) + step(user, user.inertia_dir) + */ else return ..() return diff --git a/code/game/sound.dm b/code/game/sound.dm index 518c72c97c7..c017981a917 100644 --- a/code/game/sound.dm +++ b/code/game/sound.dm @@ -77,44 +77,3 @@ client/verb/Toggle_Soundscape() //All new ambience should be added here so it wo return -/area/Entered(A) - var/sound = null - var/musVolume = 25 - sound = 'ambigen1.ogg' - - if (ismob(A)) - - if (istype(A, /mob/dead/observer)) return - if (!A:client) return - //if (A:ear_deaf) return - -// if (A && A:client && !A:client:ambience_playing && !A:client:no_ambi) // Ambience goes down here -- make sure to list each area seperately for ease of adding things in later, thanks! Note: areas next to each other should have the same sounds to prevent cutoff when possible.- LastyScratch -// A:client:ambience_playing = 1 -// A << sound('shipambience.ogg', repeat = 1, wait = 0, volume = 35, channel = 2) - - switch(src.name) - if ("Chapel") sound = pick('ambicha1.ogg','ambicha2.ogg','ambicha3.ogg','ambicha4.ogg') - if ("Morgue") sound = pick('ambimo1.ogg','ambimo2.ogg','title2.ogg') - if ("Space") sound = pick('ambispace.ogg','title2.ogg',) - if ("Engine Control") sound = pick('ambisin1.ogg','ambisin2.ogg','ambisin3.ogg','ambisin4.ogg') - if ("Atmospherics") sound = pick('ambiatm1.ogg') - if ("AI Sat Ext") sound = pick('ambiruntime.ogg','ambimalf.ogg') - if ("AI Satellite") sound = pick('ambimalf.ogg') - if ("AI Satellite Teleporter Room") sound = pick('ambiruntime.ogg','ambimalf.ogg') - if ("Bar") sound = pick('null.ogg') - if ("AI Upload Foyer") sound = pick('ambimalf.ogg', 'null.ogg') - if ("AI Upload Chamber") sound = pick('ambimalf.ogg','null.ogg') - if ("Mine") - sound = pick('ambimine.ogg') - musVolume = 25 - else - sound = pick('ambiruntime.ogg','ambigen1.ogg','ambigen3.ogg','ambigen4.ogg','ambigen5.ogg','ambigen6.ogg','ambigen7.ogg','ambigen8.ogg','ambigen9.ogg','ambigen10.ogg','ambigen11.ogg','ambigen12.ogg','ambigen14.ogg') - - - if (prob(35)) - if(A && A:client && !A:client:played) - A << sound(sound, repeat = 0, wait = 0, volume = musVolume, channel = 1) - A:client:played = 1 - spawn(600) - if(A && A:client) - A:client:played = 0 diff --git a/code/game/throwing.dm b/code/game/throwing.dm index 670664103f5..4ae8d2c2698 100644 --- a/code/game/throwing.dm +++ b/code/game/throwing.dm @@ -64,10 +64,20 @@ item.layer = initial(item.layer) src.visible_message("\red [src] has thrown [item].") + var/area/a = get_area(src.loc) + if((istype(src.loc, /turf/space)) || (a.has_gravity == 0)) + src.inertia_dir = get_dir(target, src) + step(src, inertia_dir) + +/* if(istype(src.loc, /turf/space) || (src.flags & NOGRAV)) //they're in space, move em one space in the opposite direction src.inertia_dir = get_dir(target, src) step(src, inertia_dir) +*/ + + + item.throw_at(target, item.throw_range, item.throw_speed) @@ -150,10 +160,14 @@ dy = SOUTH var/dist_travelled = 0 var/dist_since_sleep = 0 + var/area/a = get_area(src.loc) var/turf/target_turf = get_turf(target) if(dist_x > dist_y) var/error = dist_x/2 - dist_y - while(((((src.x < target.x && dx == EAST) || (src.x > target.x && dx == WEST)) && dist_travelled < range) || istype(src.loc, /turf/space)) && src.throwing && istype(src.loc, /turf)) + + + + while(((((src.x < target.x && dx == EAST) || (src.x > target.x && dx == WEST)) && dist_travelled < range) || (a.has_gravity == 0) || istype(src.loc, /turf/space)) && src.throwing && istype(src.loc, /turf)) // only stop when we've gone the whole distance (or max throw range) and are on a non-space tile, or hit something, or hit the end of the map, or someone picks it up if(error < 0) var/atom/step = get_step(src, dy) @@ -179,9 +193,11 @@ if(dist_since_sleep >= speed) dist_since_sleep = 0 sleep(1) + + a = get_area(src.loc) else var/error = dist_y/2 - dist_x - while(src && target &&((((src.y < target.y && dy == NORTH) || (src.y > target.y && dy == SOUTH)) && dist_travelled < range) || istype(src.loc, /turf/space)) && src.throwing && istype(src.loc, /turf)) + while(src && target &&((((src.y < target.y && dy == NORTH) || (src.y > target.y && dy == SOUTH)) && dist_travelled < range) || (a.has_gravity == 0) || istype(src.loc, /turf/space)) && src.throwing && istype(src.loc, /turf)) // only stop when we've gone the whole distance (or max throw range) and are on a non-space tile, or hit something, or hit the end of the map, or someone picks it up if(error < 0) var/atom/step = get_step(src, dx) @@ -208,6 +224,8 @@ dist_since_sleep = 0 sleep(1) + a = get_area(src.loc) + //done throwing, either because it hit something or it finished moving src.throwing = 0 if(isobj(src)) src:throw_impact(get_turf(src)) diff --git a/code/game/turf.dm b/code/game/turf.dm index ec297ce5ae3..2294d2a21bd 100644 --- a/code/game/turf.dm +++ b/code/game/turf.dm @@ -81,8 +81,18 @@ /turf/Entered(atom/movable/M as mob|obj) if(ismob(M)) + if(!M:lastarea) + M:lastarea = get_area(M.loc) + if(M:lastarea.has_gravity == 0) + inertial_drift(M) + + /* if(M.flags & NOGRAV) inertial_drift(M) + */ + + + else if(!istype(src, /turf/space)) M:inertia_dir = 0 ..() diff --git a/code/modules/admin/admin_verbs.dm b/code/modules/admin/admin_verbs.dm index 69986b0da07..e9749719099 100644 --- a/code/modules/admin/admin_verbs.dm +++ b/code/modules/admin/admin_verbs.dm @@ -25,7 +25,7 @@ holder.rank = rank if(!holder.state) - var/state = alert("Which state do you the admin to begin in?", "Admin-state", "Play", "Observe", "Neither") + var/state = alert("Which state do you want the admin to begin in?", "Admin-state", "Play", "Observe", "Neither") if(state == "Play") holder.state = 1 admin_play() @@ -169,6 +169,8 @@ verbs += /client/proc/restartcontroller //Can call via aproccall --I_hate_easy_things.jpg, Mport --Agouri verbs += /client/proc/Blobize//I need to remember to move/remove this later verbs += /client/proc/toggle_clickproc //TODO ERRORAGE (Temporary proc while the enw clickproc is being tested) + verbs += /client/proc/toggle_gravity_on + verbs += /client/proc/toggle_gravity_off // Moved over from tg's Game Master: verbs += /client/proc/colorooc verbs += /obj/admins/proc/toggle_aliens //toggle aliens @@ -420,6 +422,8 @@ verbs -= /client/proc/toggle_hear_deadcast verbs -= /client/proc/toggle_hear_radio verbs -= /client/proc/tension_report + verbs -= /client/proc/toggle_gravity_on + verbs -= /client/proc/toggle_gravity_off verbs -= /client/proc/cmd_admin_change_custom_event verbs -= /client/proc/admin_invis verbs -= /client/proc/callprocgen diff --git a/code/modules/admin/verbs/randomverbs.dm b/code/modules/admin/verbs/randomverbs.dm index 5b73512598c..ee874c11aa8 100644 --- a/code/modules/admin/verbs/randomverbs.dm +++ b/code/modules/admin/verbs/randomverbs.dm @@ -873,6 +873,36 @@ Traitors and the like can also be revived with the previous role mostly intact. ticker.random_players = 1 +/client/proc/toggle_gravity_on() + set category = "Debug" + set name = "Toggle station gravity on" + set desc = "Toggles all gravity to active on the station." + + if (!(ticker && ticker.mode)) + usr << "Please wait until the game starts! Not sure how it will work otherwise." + return + + + for(var/area/A in world) + A.gravitychange(1,A) + + command_alert("CentComm is now beaming gravitons to your station. We appoligize for any inconvience.") + +/client/proc/toggle_gravity_off() + set category = "Debug" + set name = "Toggle station gravity off" + set desc = "Toggles all gravity to inactive on the station." + + if (!(ticker && ticker.mode)) + usr << "Please wait until the game starts! Not sure how it will work otherwise." + return + + + for(var/area/A in world) + A.gravitychange(0,A) + + command_alert("For budget reasons, Centcomm is no longer beaming gravitons to your station. We appoligize for any inconvience.") + /client/proc/rnd_check_designs() set category = "Debug" set name = "Check RnD Designs" diff --git a/code/modules/mob/mob_movement.dm b/code/modules/mob/mob_movement.dm index 5d9fb6c4f70..ce643abc99d 100644 --- a/code/modules/mob/mob_movement.dm +++ b/code/modules/mob/mob_movement.dm @@ -133,6 +133,7 @@ /client/Move(n, direct) + if(mob.control_object) Move_object(direct) if(isobserver(mob)) return mob.Move(n,direct) @@ -143,6 +144,11 @@ if(!mob) return + if(locate(/obj/effect/stop/, mob.loc)) + for(var/obj/effect/stop/S in mob.loc) + if(S.victim == mob) + return + if(mob.stat==2) return if(isAI(mob)) return AIMove(n,direct,mob) @@ -162,9 +168,15 @@ else mob.canmove = 1 - if(istype(mob.loc, /turf/space) || (mob.flags & NOGRAV)) + + //if(istype(mob.loc, /turf/space) || (mob.flags & NOGRAV)) + // if(!mob.Process_Spacemove(0)) return 0 + + var/area/a = get_area(mob.loc) + if((istype(mob.loc, /turf/space)) || (a.has_gravity == 0)) if(!mob.Process_Spacemove(0)) return 0 + if(isobj(mob.loc) || ismob(mob.loc))//Inside an object, tell it we moved var/atom/O = mob.loc return O.relaymove(mob, direct) @@ -332,8 +344,25 @@ for(var/turf/turf in oview(1,src)) if(istype(turf,/turf/space)) continue - if(istype(turf,/turf/simulated/floor) && (flags & NOGRAV)) + + + var/area/a = get_area(turf) + + if(istype(src,/mob/living/carbon/human/)) // Only humans can wear magboots, so we give them a chance to. + if((istype(turf,/turf/simulated/floor)) && (a.has_gravity == 0) && !(istype(src:shoes, /obj/item/clothing/shoes/magboots) && (src:shoes:flags & NOSLIP))) + continue + + + else + if((istype(turf,/turf/simulated/floor)) && (a.has_gravity == 0)) // No one else gets a chance. + continue + + /* + if(istype(turf,/turf/simulated/floor) && (src.flags & NOGRAV)) continue + */ + + dense_object++ break diff --git a/code/modules/mob/new_player/new_player.dm b/code/modules/mob/new_player/new_player.dm index 5395d00f18b..5cfb45af9e8 100644 --- a/code/modules/mob/new_player/new_player.dm +++ b/code/modules/mob/new_player/new_player.dm @@ -265,6 +265,7 @@ job_master.EquipRank(character, rank, 1) EquipCustomItems(character) character.loc = pick(latejoin) + character.lastarea = get_area(loc) if(character.client) character.client.be_syndicate = preferences.be_special ticker.mode.latespawn(character) @@ -369,6 +370,7 @@ proc/create_character() spawning = 1 var/mob/living/carbon/human/new_character = new(loc) + new_character.lastarea = get_area(loc) close_spawn_windows() diff --git a/code/setup.dm b/code/setup.dm index 43a73c5fdc0..ff3a761dd9b 100644 --- a/code/setup.dm +++ b/code/setup.dm @@ -142,17 +142,6 @@ var/MAX_EXPLOSION_RANGE = 14 //turf-only flags #define NOJAUNT 1 -//Bit flags for the flags_inv variable, which determine when a piece of clothing hides another. IE a helmet hiding glasses. -#define HIDEGLOVES 1 //APPLIES ONLY TO THE EXTERIOR SUIT!! -#define HIDESUITSTORAGE 2 //APPLIES ONLY TO THE EXTERIOR SUIT!! -#define HIDEJUMPSUIT 4 //APPLIES ONLY TO THE EXTERIOR SUIT!! -#define HIDESHOES 8 //APPLIES ONLY TO THE EXTERIOR SUIT!! -#define HIDEMASK 1 //APPLIES ONLY TO HELMETS!! -#define HIDEEARS 2 //APPLIES ONLY TO HELMETS!! -#define HIDEEYES 4 //APPLIES ONLY TO HELMETS!! - -//Cant seem to find a mob bitflags area other than the powers one -#define NOGRAV 1 //Bit flags for the flags_inv variable, which determine when a piece of clothing hides another. IE a helmet hiding glasses. #define HIDEGLOVES 1 //APPLIES ONLY TO THE EXTERIOR SUIT!! @@ -288,4 +277,4 @@ var/static/list/scarySounds = list('thudswoosh.ogg','Taser.ogg','armbomb.ogg','h #define SEC_LEVEL_GREEN 0 #define SEC_LEVEL_BLUE 1 #define SEC_LEVEL_RED 2 -#define SEC_LEVEL_DELTA 3 +#define SEC_LEVEL_DELTA 3