More while loop stuff, removed shitloads of unnecessary curly brackets in the map reader, fixed ED-209 projectiles

This commit is contained in:
SkyMarshal
2012-06-22 14:10:48 -07:00
parent 668f81c329
commit 616be6eed8
16 changed files with 133 additions and 194 deletions
+1 -1
View File
@@ -162,7 +162,7 @@ datum
if(!success) //Runtimed.
failed_ticks++
if(failed_ticks > 20)
world << "<font size='4' color='red'>ERROR IN ATMOS TICKER. Killing air simulation!</font>"
world << "<font color='red'><b>ERROR IN ATMOS TICKER. Killing air simulation!</font></b>"
kill_air = 1
sleep(max(5,update_delay*tick_multiplier))
@@ -53,7 +53,7 @@
affected_mob.updatehealth()
if(prob(40)) //So everyone can feel like robot Seth Brundle
if(src.gibbed != 0) return 0
var/turf/T = find_loc(affected_mob)
var/turf/T = get_turf(affected_mob)
gibs(T)
src.cure(0)
gibbed = 1
+1 -1
View File
@@ -53,7 +53,7 @@
affected_mob.updatehealth()
if(prob(40))
if(gibbed != 0) return 0
var/turf/T = find_loc(affected_mob)
var/turf/T = get_turf(affected_mob)
gibs(T)
src.cure(0)
gibbed = 1
+1 -3
View File
@@ -23,9 +23,7 @@
command_alert("Station has entered radiation cloud. Do not leave cover until it has passed.")
if(ActiveFor == 100 || ActiveFor == 150) //1/2 and 2/2 f the way after it start proper make peope be half dead mostly
for(var/mob/living/carbon/M in world)
var/area = M.loc.loc
while(!istype(area, /area))
area = area:loc
var/area = get_area(M)
if(area:radsafe)
continue
if(!M.stat)
+13 -23
View File
@@ -753,13 +753,9 @@ Auto Patrol: []"},
if(lastfired && world.time - lastfired < shot_delay)
return
lastfired = world.time
var/turf/T = loc
var/atom/U = (istype(target, /atom/movable) ? target.loc : target)
if ((!( U ) || !( T )))
return
while(!( istype(U, /turf) ))
U = U.loc
if (!( istype(T, /turf) ))
var/turf/T = get_turf(src)
var/turf/U = (istype(target, /atom/movable) ? get_turf(target) : target)
if ( !istype(T) || !istype(U) )
return
//if(lastfired && world.time - lastfired < 100)
@@ -767,31 +763,25 @@ Auto Patrol: []"},
var/obj/item/projectile/A
if(!lasercolor)
if (src.emagged)
A = new /obj/item/projectile/beam( loc )
if (emagged)
A = new /obj/item/projectile/beam( T )
else
A = new /obj/item/projectile/energy/electrode( loc )
A = new /obj/item/projectile/energy/electrode( T )
else if(lasercolor == "b")
if (src.emagged)
A = new /obj/item/projectile/energy/electrode( loc )
if (emagged)
A = new /obj/item/projectile/energy/electrode( T )
else
A = new /obj/item/projectile/bluetag( loc )
A = new /obj/item/projectile/bluetag( T )
else if(lasercolor == "r")
if (src.emagged)
A = new /obj/item/projectile/energy/electrode( loc )
if (emagged)
A = new /obj/item/projectile/energy/electrode( T )
else
A = new /obj/item/projectile/redtag( loc )
if (!( istype(U, /turf) ))
//A = null
del(A)
return
A = new /obj/item/projectile/redtag( T )
A.current = U
A.yo = U.y - T.y
A.xo = U.x - T.x
spawn( 0 )
A.process()
return
A.fired()
return
/obj/machinery/bot/ed209/attack_alien(var/mob/living/carbon/alien/user as mob)
-8
View File
@@ -105,14 +105,6 @@
src.id = t
return
/proc/find_loc(obj/R as obj)
if (!R) return null
var/turf/T = R.loc
while(!istype(T, /turf))
T = T.loc
if(!T || istype(T, /area)) return null
return T
/obj/machinery/teleport/hub/Bumped(M as mob|obj)
spawn()
if (src.icon_state == "tele1")
+15 -10
View File
@@ -477,6 +477,7 @@
var/health = 40
var/list/scan_for = list("human"=0,"cyborg"=0,"mecha"=0,"alien"=1)
var/on = 0
var/processing = 0 //So we dun get dozens of duplicate while loops
icon = 'turrets.dmi'
icon_state = "gun_turret"
@@ -567,16 +568,20 @@
process()
spawn while(on)
if(projectiles<=0)
on = 0
return
if(cur_target && !validate_target(cur_target))
cur_target = null
if(!cur_target)
cur_target = get_target()
fire(cur_target)
sleep(cooldown)
if(!processing)
spawn
while(on)
processing = 1
if(projectiles<=0)
on = 0
return
if(cur_target && !validate_target(cur_target))
cur_target = null
if(!cur_target)
cur_target = get_target()
fire(cur_target)
sleep(cooldown)
processing = 0
return
proc/get_target()
+1 -1
View File
@@ -721,7 +721,7 @@
del(src)
return 1
else
user << "\red You can't load the [src.name] while it's opened."
user << "\red You can't load \the [src] while it's opened."
return 1
if(istype(W, /obj/item/weapon/card/emag))
+9 -9
View File
@@ -36,7 +36,7 @@
if(salvage_num <= 0)
user << "You don't see anything that can be cut with [W]."
return
if (!isemptylist(welder_salvage) && WT.remove_fuel(0,user))
if (welder_salvage && welder_salvage.len && WT.remove_fuel(0,user))
var/type = prob(70)?pick(welder_salvage):null
if(type)
var/N = new type(get_turf(user))
@@ -53,7 +53,7 @@
if(salvage_num <= 0)
user << "You don't see anything that can be cut with [W]."
return
else if(!isemptylist(wirecutters_salvage))
else if(wirecutters_salvage && wirecutters_salvage.len)
var/type = prob(70)?pick(wirecutters_salvage):null
if(type)
var/N = new type(get_turf(user))
@@ -62,7 +62,7 @@
else
user << "You failed to salvage anything valuable from [src]."
if(istype(W, /obj/item/weapon/crowbar))
if(!isemptylist(crowbar_salvage))
if(crowbar_salvage && crowbar_salvage.len)
var/obj/S = pick(crowbar_salvage)
if(S)
S.loc = get_turf(user)
@@ -89,7 +89,7 @@
/obj/item/mecha_parts/part/gygax_left_leg,
/obj/item/mecha_parts/part/gygax_right_leg)
for(var/i=0;i<2;i++)
if(!isemptylist(parts) && prob(40))
if(parts.len && prob(40))
var/part = pick(parts)
welder_salvage += part
parts -= part
@@ -124,7 +124,7 @@
/obj/item/mecha_parts/part/ripley_left_leg,
/obj/item/mecha_parts/part/ripley_right_leg)
for(var/i=0;i<2;i++)
if(!isemptylist(parts) && prob(40))
if(parts && parts.len && prob(40))
var/part = pick(parts)
welder_salvage += part
parts -= part
@@ -143,7 +143,7 @@
/obj/item/mecha_parts/part/ripley_right_leg,
/obj/item/clothing/suit/fire)
for(var/i=0;i<2;i++)
if(!isemptylist(parts) && prob(40))
if(parts && parts.len && prob(40))
var/part = pick(parts)
welder_salvage += part
parts -= part
@@ -168,7 +168,7 @@
/obj/item/mecha_parts/part/honker_left_leg,
/obj/item/mecha_parts/part/honker_right_leg)
for(var/i=0;i<2;i++)
if(!isemptylist(parts) && prob(40))
if(parts && parts.len && prob(40))
var/part = pick(parts)
welder_salvage += part
parts -= part
@@ -188,7 +188,7 @@
/obj/item/mecha_parts/part/durand_left_leg,
/obj/item/mecha_parts/part/durand_right_leg)
for(var/i=0;i<2;i++)
if(!isemptylist(parts) && prob(40))
if(parts && parts.len && prob(40))
var/part = pick(parts)
welder_salvage += part
parts -= part
@@ -213,7 +213,7 @@
/obj/item/mecha_parts/part/odysseus_left_leg,
/obj/item/mecha_parts/part/odysseus_right_leg)
for(var/i=0;i<2;i++)
if(!isemptylist(parts) && prob(40))
if(parts && parts.len && prob(40))
var/part = pick(parts)
welder_salvage += part
parts -= part
+1 -1
View File
@@ -32,7 +32,7 @@
/proc/get_turf(turf/location as turf)
while (location)
if (istype(location, /turf))
if (istype(location))
return location
location = location.loc
@@ -271,8 +271,8 @@ the implant may become unstable and either pre-maturely inject the subject or si
if(istype(imp_in, /mob/))
var/mob/T = imp_in
T.gib()
explosion(find_loc(imp_in), 1, 3, 4, 6, 3)
var/turf/t = find_loc(imp_in)
explosion(get_turf(imp_in), 1, 3, 4, 6, 3)
var/turf/t = get_turf(imp_in)
if(t)
t.hotspot_expose(3500,125)
del(src)
+5 -6
View File
@@ -229,12 +229,11 @@
step(src, get_dir(user, src))
if (src.health <= 0)
if (src.dir == SOUTHWEST)
var/index = null
index = 0
while(index < 2)
new /obj/item/weapon/shard( src.loc )
if(reinf) new /obj/item/stack/rods( src.loc)
index++
new /obj/item/weapon/shard( src.loc )
new /obj/item/weapon/shard( src.loc )
if(reinf)
new /obj/item/stack/rods( src.loc)
new /obj/item/stack/rods( src.loc)
else
new /obj/item/weapon/shard( src.loc )
if(reinf) new /obj/item/stack/rods( src.loc)
+1 -1
View File
@@ -1894,7 +1894,7 @@ var/global/BSACooldown = 0
//feedback_add_details("admin_secrets_fun_used","PW")
message_admins("\blue [key_name_admin(usr)] teleported all players to the prison station.", 1)
for(var/mob/living/carbon/human/H in world)
var/turf/loc = find_loc(H)
var/turf/loc = get_turf(H)
var/security = 0
if(loc.z > 1 || prisonwarped.Find(H))
//don't warp them if they aren't ready or are already there
+4 -10
View File
@@ -165,16 +165,10 @@ var/intercom_range_display_status = 0
for(var/atom/A in world)
if(istype(A,type_path))
var/atom/B = A
while(!(isturf(B.loc)))
if(B && B.loc)
B = B.loc
else
break
if(B)
if(B.z == num_level)
count++
atom_list += A
var/turf/B = get_turf(A)
if(istype(B) && B.z == num_level)
count++
atom_list += A
/*
var/atom/temp_atom
for(var/i = 0; i <= (atom_list.len/10); i++)
+74 -108
View File
@@ -1,60 +1,59 @@
dmm_suite{
load_map(var/dmm_file as file, var/z_offset as num){
if(!z_offset){
dmm_suite
load_map(var/dmm_file as file, var/z_offset as num)
if(!z_offset)
z_offset = world.maxz+1
}
var/quote = ascii2text(34)
var/tfile = file2text(dmm_file)
var/tfile_len = length(tfile)
var/list/grid_models[0]
var/key_len = length(copytext(tfile,2,findtext(tfile,quote,2,0)))
for(var/lpos=1;lpos<tfile_len;lpos=findtext(tfile,"\n",lpos,0)+1){
for(var/lpos=1;lpos<tfile_len;lpos=findtext(tfile,"\n",lpos,0)+1)
var/tline = copytext(tfile,lpos,findtext(tfile,"\n",lpos,0))
if(copytext(tline,1,2)!=quote){break}
if(copytext(tline,1,2)!=quote)
break
var/model_key = copytext(tline,2,findtext(tfile,quote,2,0))
var/model_contents = copytext(tline,findtext(tfile,"=")+3,length(tline))
grid_models[model_key] = model_contents
sleep(-1)
}
var/zcrd=-1
var/ycrd=0
var/xcrd=0
for(var/zpos=findtext(tfile,"\n(1,1,");TRUE;zpos=findtext(tfile,"\n(1,1,",zpos+1,0)){
for(var/zpos=findtext(tfile,"\n(1,1,");TRUE;zpos=findtext(tfile,"\n(1,1,",zpos+1,0))
zcrd++
world.maxz = max(world.maxz, zcrd+z_offset)
ycrd=0
var/zgrid = copytext(tfile,findtext(tfile,quote+"\n",zpos,0)+2,findtext(tfile,"\n"+quote,zpos,0)+1)
for(var/gpos=1;gpos!=0;gpos=findtext(zgrid,"\n",gpos,0)+1){
for(var/gpos=1;gpos!=0;gpos=findtext(zgrid,"\n",gpos,0)+1)
var/grid_line = copytext(zgrid,gpos,findtext(zgrid,"\n",gpos,0)+1)
var/y_depth = length(zgrid)/(length(grid_line))
if(world.maxy<y_depth){world.maxy=y_depth}
if(world.maxy<y_depth)
world.maxy=y_depth
grid_line=copytext(grid_line,1,length(grid_line))
if(!ycrd){
if(!ycrd)
ycrd = y_depth
}
else{ycrd--}
else
ycrd--
xcrd=0
for(var/mpos=1;mpos<=length(grid_line);mpos+=key_len){
for(var/mpos=1;mpos<=length(grid_line);mpos+=key_len)
xcrd++
if(world.maxx<xcrd){world.maxx=xcrd}
if(world.maxx<xcrd)
world.maxx=xcrd
var/model_key = copytext(grid_line,mpos,mpos+key_len)
parse_grid(grid_models[model_key],xcrd,ycrd,zcrd+z_offset)
}
if(gpos+length(grid_line)+1>length(zgrid)){break}
if(gpos+length(grid_line)+1>length(zgrid))
break
sleep(-1)
}
if(findtext(tfile,quote+"}",zpos,0)+2==tfile_len){break}
if(findtext(tfile,quote+"}",zpos,0)+2==tfile_len)
break
sleep(-1)
}
}
proc{
parse_grid(var/model as text,var/xcrd as num,var/ycrd as num,var/zcrd as num){
proc
parse_grid(var/model as text,var/xcrd as num,var/ycrd as num,var/zcrd as num)
/*Method parse_grid()
- Accepts a text string containing a comma separated list of type paths of the
same construction as those contained in a .dmm file, and instantiates them.
*/
var/list/text_strings[0]
for(var/index=1;findtext(model,quote);index++){
for(var/index=1;findtext(model,quote);index++)
/*Loop: Stores quoted portions of text in text_strings, and replaces them with an
index to that list.
- Each iteration represents one quoted section of text.
@@ -63,7 +62,6 @@ dmm_suite{
text_strings[index] = copytext(model,findtext(model,quote)+1,findtext(model,quote,findtext(model,quote)+1,0))
model = copytext(model,1,findtext(model,quote))+"~[index]"+copytext(model,findtext(model,quote,findtext(model,quote)+1,0)+1,0)
sleep(-1)
}
var/list/old_turf_underlays[0]
var/old_turf_density
var/old_turf_opacity
@@ -71,118 +69,104 @@ dmm_suite{
This is done to approximate the layered turf effect of DM's map editor.
An image of each turf is stored in old_turf_underlays[], and is later added to the new turf's underlays.
*/
for(var/dpos=1;dpos!=0;dpos=findtext(model,",",dpos,0)+1){
for(var/dpos=1;dpos!=0;dpos=findtext(model,",",dpos,0)+1)
/*Loop: Identifies each object's data, instantiates it, and reconstitues it's fields.
- Each iteration represents one object's data, including type path and field values.
*/
var/full_def = copytext(model,dpos,findtext(model,",",dpos,0))
var/atom_def = text2path(copytext(full_def,1,findtext(full_def,"{")))
var/list/attributes[0]
if(findtext(full_def,"{")){
if(findtext(full_def,"{"))
full_def = copytext(full_def,1,length(full_def))
for(var/apos=findtext(full_def,"{")+1;apos!=0;apos=findtext(full_def,";",apos,0)+1){
for(var/apos=findtext(full_def,"{")+1;apos!=0;apos=findtext(full_def,";",apos,0)+1)
//Loop: Identifies each attribute/value pair, and stores it in attributes[].
attributes.Add(copytext(full_def,apos,findtext(full_def,";",apos,0)))
if(!findtext(copytext(full_def,apos,0),";")){break}
if(!findtext(copytext(full_def,apos,0),";"))
break
sleep(-1)
}
}
//Construct attributes associative list
var/list/fields = new(0)
for(var/index=1;index<=attributes.len;index++){
for(var/index=1;index<=attributes.len;index++)
var/trim_left = trim_text(copytext(attributes[index],1,findtext(attributes[index],"=")))
var/trim_right = trim_text(copytext(attributes[index],findtext(attributes[index],"=")+1,0))
//Check for string
if(findtext(trim_right,"~")){
if(findtext(trim_right,"~"))
var/reference_index = copytext(trim_right,findtext(trim_right,"~")+1,0)
trim_right=text_strings[text2num(reference_index)]
}
//Check for number
else if(isnum(text2num(trim_right))){
else if(isnum(text2num(trim_right)))
trim_right = text2num(trim_right)
}
//Check for file
else if(copytext(trim_right,1,2) == "'"){
else if(copytext(trim_right,1,2) == "'")
trim_right = file(copytext(trim_right,2,length(trim_right)))
}
fields[trim_left] = trim_right
}
//End construction
//Begin Instanciation
var/atom/instance
var/dmm_suite/preloader/_preloader = new(fields)
if(ispath(atom_def,/area)){
if(ispath(atom_def,/area))
instance = locate(atom_def)
instance.contents.Add(locate(xcrd,ycrd,zcrd))
}
else if(ispath(atom_def,/turf)){
else if(ispath(atom_def,/turf))
var/turf/old_turf = locate(xcrd,ycrd,zcrd)
if(old_turf.density){old_turf_density = 1}
if(old_turf.opacity){old_turf_opacity = 1}
if(old_turf.icon){
if(old_turf.icon)
var/image/old_turf_image = image(old_turf.icon,null,old_turf.icon_state,old_turf.layer,old_turf.dir)
old_turf_underlays.Add(old_turf_image)
}
instance = new atom_def(old_turf, _preloader)
for(var/inverse_index=old_turf_underlays.len;inverse_index;inverse_index--){
for(var/inverse_index=old_turf_underlays.len;inverse_index;inverse_index--)
var/image/image_underlay = old_turf_underlays[inverse_index]
image_underlay.loc = instance
instance.underlays.Add(image_underlay)
}
if(!instance.density){instance.density = old_turf_density}
if(!instance.opacity){instance.opacity = old_turf_opacity}
}
if(!instance.density)
instance.density = old_turf_density
if(!instance.opacity)
instance.opacity = old_turf_opacity
if(_preloader && instance){
if(_preloader && instance)
_preloader.load(instance)
}
//End Instanciation
if(!findtext(copytext(model,dpos,0),",")){break}
if(!findtext(copytext(model,dpos,0),","))
break
sleep(-1)
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
for(var/dpos=1;dpos!=0;dpos=findtext(model,",",dpos,0)+1)
{
/*Loop: Identifies each object's data, instantiates it, and reconstitues it's fields.
- Each iteration represents one object's data, including type path and field values.
*/
var/full_def = copytext(model,dpos,findtext(model,",",dpos,0))
var/atom_def = text2path(copytext(full_def,1,findtext(full_def,"{")))
var/list/attributes[0]
if(findtext(full_def,"{")){
if(findtext(full_def,"{"))
full_def = copytext(full_def,1,length(full_def))
for(var/apos=findtext(full_def,"{")+1;apos!=0;apos=findtext(full_def,";",apos,0)+1){
for(var/apos=findtext(full_def,"{")+1;apos!=0;apos=findtext(full_def,";",apos,0)+1)
//Loop: Identifies each attribute/value pair, and stores it in attributes[].
attributes.Add(copytext(full_def,apos,findtext(full_def,";",apos,0)))
if(!findtext(copytext(full_def,apos,0),";")){break}
if(!findtext(copytext(full_def,apos,0),";"))
break
sleep(-1)
}
}
//Construct attributes associative list
var/list/fields = new(0)
for(var/index=1;index<=attributes.len;index++){
for(var/index=1;index<=attributes.len;index++)
var/trim_left = trim_text(copytext(attributes[index],1,findtext(attributes[index],"=")))
var/trim_right = trim_text(copytext(attributes[index],findtext(attributes[index],"=")+1,0))
//Check for string
if(findtext(trim_right,"~")){
if(findtext(trim_right,"~"))
var/reference_index = copytext(trim_right,findtext(trim_right,"~")+1,0)
trim_right=text_strings[text2num(reference_index)]
}
//Check for number
else if(isnum(text2num(trim_right))){
else if(isnum(text2num(trim_right)))
trim_right = text2num(trim_right)
}
//Check for file
else if(copytext(trim_right,1,2) == "'"){
else if(copytext(trim_right,1,2) == "'")
trim_right = file(copytext(trim_right,2,length(trim_right)))
}
fields[trim_left] = trim_right
}
//End construction
@@ -190,60 +174,42 @@ dmm_suite{
var/atom/instance
var/dmm_suite/preloader/_preloader = new(fields)
if(!ispath(atom_def,/area) && !ispath(atom_def,/turf))
{
instance = new atom_def(locate(xcrd,ycrd,zcrd), _preloader)
}
if(_preloader && instance)
{
_preloader.load(instance)
}
//End Instanciation
if(!findtext(copytext(model,dpos,0),",")){break}
if(!findtext(copytext(model,dpos,0),","))
break
sleep(-1)
}
}
trim_text(var/what as text){
while(length(what) && findtext(what," ",1,2)){
trim_text(var/what as text)
while(length(what) && findtext(what," ",1,2))
what=copytext(what,2,0)
}
while(length(what) && findtext(what," ",length(what),0)){
while(length(what) && findtext(what," ",length(what),0))
what=copytext(what,1,length(what))
}
return what
}
}
}
atom/New(atom/loc, dmm_suite/preloader/_dmm_preloader){
if(istype(_dmm_preloader, /dmm_suite/preloader)){
atom/New(atom/loc, dmm_suite/preloader/_dmm_preloader)
if(istype(_dmm_preloader, /dmm_suite/preloader))
_dmm_preloader.load(src)
}
. = ..()
}
dmm_suite{
preloader{
parent_type = /datum
var{
list/attributes
}
New(list/the_attributes){
.=..()
if(!the_attributes.len){ Del()}
attributes = the_attributes
}
proc{
load(atom/what){
for(var/attribute in attributes){
what.vars[attribute] = attributes[attribute]
}
Del()
}
}
}
}
dmm_suite
preloader
parent_type = /datum
var
list/attributes
New(list/the_attributes)
.=..()
if(!the_attributes.len)
Del()
attributes = the_attributes
proc
load(atom/what)
for(var/attribute in attributes)
what.vars[attribute] = attributes[attribute]
Del()
@@ -167,20 +167,15 @@
if ((O.client && !( O.blinded )))
O << "\red [src] spits neurotoxin at [target]!"
//I'm not motivated enough to revise this. Prjectile code in general needs update.
var/turf/T = loc
var/turf/U = (istype(target, /atom/movable) ? target.loc : target)
var/turf/T = get_turf(src)
var/turf/U = (istype(target, /atom/movable) ? get_turf(target) : target)
if(!U || !T)
return
while(U && !istype(U,/turf))
U = U.loc
if(!istype(T, /turf))
if(!istype(T, /turf) || !istype(U,/turf))
return
if (U == T)
usr.bullet_act(src, src.get_organ_target())
return
if(!istype(U, /turf))
return
var/obj/item/projectile/energy/dart/A = new /obj/item/projectile/energy/dart(usr.loc)