mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-07-12 07:33:34 +01:00
Committing work on away missions.
Standardised cigs_lighters.dm a bit. Removed the SORD, and some unused and shit flasks. git-svn-id: http://tgstation13.googlecode.com/svn/trunk@4609 316c924e-a436-60f5-8080-3fe189b3f50e
This commit is contained in:
@@ -1423,20 +1423,21 @@ proc/process_ghost_teleport_locs()
|
||||
|
||||
|
||||
|
||||
// Away Missions
|
||||
/area/awaymission
|
||||
name = "\improper Strange Location"
|
||||
icon_state = "away"
|
||||
|
||||
/area/awaymission/example
|
||||
name = "\improper Strange Station"
|
||||
icon_state = "away"
|
||||
|
||||
/area/awaymission/desert
|
||||
name = "Mars"
|
||||
icon_state = "away"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/area/turret_protected/AssistantRoom
|
||||
name = "\improper Assistant Room"
|
||||
icon_state = "storage"
|
||||
lighting_use_dynamic = 0
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
/*
|
||||
Lists of areas to be used with is_type_in_list.
|
||||
|
||||
@@ -76,18 +76,6 @@
|
||||
throwforce = 10
|
||||
w_class = 1
|
||||
|
||||
/obj/item/weapon/sord
|
||||
name = "\improper SORD"
|
||||
desc = "This thing is so unspeakably shitty you are having a hard time even holding it."
|
||||
icon_state = "sord"
|
||||
item_state = "sord"
|
||||
flags = FPRINT | TABLEPASS
|
||||
slot_flags = SLOT_BELT
|
||||
force = 2
|
||||
throwforce = 1
|
||||
w_class = 3
|
||||
attack_verb = list("attacked", "slashed", "stabbed", "sliced", "torn", "ripped", "diced", "cut")
|
||||
|
||||
/obj/item/weapon/sord/attack(mob/living/carbon/M as mob, mob/living/carbon/user as mob)
|
||||
playsound(loc, 'sound/weapons/bladeslice.ogg', 50, 1, -1)
|
||||
return ..()
|
||||
@@ -721,28 +709,6 @@
|
||||
icon_state = "fcardholder0"
|
||||
item_state = "clipboard"
|
||||
|
||||
/obj/item/weapon/flasks
|
||||
name = "flask"
|
||||
icon = 'icons/obj/Cryogenic2.dmi'
|
||||
var/oxygen = 0.0
|
||||
var/plasma = 0.0
|
||||
var/coolant = 0.0
|
||||
|
||||
/obj/item/weapon/flasks/coolant
|
||||
name = "light blue flask"
|
||||
icon_state = "coolant-c"
|
||||
coolant = 1000.0
|
||||
|
||||
/obj/item/weapon/flasks/oxygen
|
||||
name = "blue flask"
|
||||
icon_state = "oxygen-c"
|
||||
oxygen = 500.0
|
||||
|
||||
/obj/item/weapon/flasks/plasma
|
||||
name = "orange flask"
|
||||
icon_state = "plasma-c"
|
||||
plasma = 500.0
|
||||
|
||||
/*
|
||||
/obj/item/weapon/game_kit
|
||||
name = "Gaming Kit"
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
//This file was auto-corrected by findeclaration.exe on 25.5.2012 20:42:32
|
||||
|
||||
/*
|
||||
CONTAINS:
|
||||
MATCHES
|
||||
@@ -7,6 +5,7 @@ CIGARETTES
|
||||
CIGARS
|
||||
SMOKING PIPES
|
||||
CIG PACKET
|
||||
CHEAP LIGHTERS
|
||||
ZIPPO
|
||||
*/
|
||||
|
||||
@@ -14,8 +13,8 @@ ZIPPO
|
||||
//MATCHES//
|
||||
///////////
|
||||
/obj/item/weapon/match
|
||||
name = "Match"
|
||||
desc = "A simple match stick, used for lighting tobacco"
|
||||
name = "match"
|
||||
desc = "A simple match stick, used for lighting fine smokables."
|
||||
icon = 'icons/obj/cigarettes.dmi'
|
||||
icon_state = "match_unlit"
|
||||
var/lit = 0
|
||||
@@ -27,10 +26,10 @@ ZIPPO
|
||||
|
||||
process()
|
||||
var/turf/location = get_turf(src)
|
||||
src.smoketime--
|
||||
if(src.smoketime < 1)
|
||||
src.icon_state = "match_burnt"
|
||||
src.lit = -1
|
||||
smoketime--
|
||||
if(smoketime < 1)
|
||||
icon_state = "match_burnt"
|
||||
lit = -1
|
||||
processing_objects.Remove(src)
|
||||
return
|
||||
if(location)
|
||||
@@ -39,20 +38,18 @@ ZIPPO
|
||||
|
||||
|
||||
dropped(mob/user as mob)
|
||||
if(src.lit == 1)
|
||||
src.lit = -1
|
||||
src.damtype = "brute"
|
||||
src.icon_state = "match_burnt"
|
||||
src.item_state = "cigoff"
|
||||
src.name = "Burnt match"
|
||||
src.desc = "A match that has been burnt"
|
||||
if(lit == 1)
|
||||
lit = -1
|
||||
damtype = "brute"
|
||||
icon_state = "match_burnt"
|
||||
item_state = "cigoff"
|
||||
name = "burnt match"
|
||||
desc = "A match. This one has seen better days."
|
||||
return ..()
|
||||
|
||||
|
||||
///////////////////////
|
||||
//CIGARETTES + CIGARS//
|
||||
///////////////////////
|
||||
|
||||
//////////////////
|
||||
//FINE SMOKABLES//
|
||||
//////////////////
|
||||
/obj/item/clothing/mask/cigarette
|
||||
name = "cigarette"
|
||||
desc = "A roll of tobacco and nicotine."
|
||||
@@ -115,37 +112,37 @@ ZIPPO
|
||||
|
||||
/obj/item/clothing/mask/cigarette/afterattack(obj/item/weapon/reagent_containers/glass/glass, mob/user as mob)
|
||||
..()
|
||||
if(istype(glass)) // you can dip cigarettes into beakers
|
||||
if(istype(glass)) //you can dip cigarettes into beakers
|
||||
var/transfered = glass.reagents.trans_to(src, chem_volume)
|
||||
if(transfered) // if reagents were transfered, show the message
|
||||
user << "\blue You dip \the [src] into \the [glass]."
|
||||
else // if not, either the beaker was empty, or the cigarette was full
|
||||
if(transfered) //if reagents were transfered, show the message
|
||||
user << "<span class='notice'>You dip \the [src] into \the [glass].</span>"
|
||||
else //if not, either the beaker was empty, or the cigarette was full
|
||||
if(!glass.reagents.total_volume)
|
||||
user << "\red [glass] is empty."
|
||||
user << "<span class='notice'>[glass] is empty.</span>"
|
||||
else
|
||||
user << "\red [src] is full."
|
||||
user << "<span class='notice'>[src] is full.</span>"
|
||||
|
||||
|
||||
/obj/item/clothing/mask/cigarette/proc/light(var/flavor_text = "[usr] lights the [name].")
|
||||
if(!src.lit)
|
||||
src.lit = 1
|
||||
src.damtype = "fire"
|
||||
if(!lit)
|
||||
lit = 1
|
||||
damtype = "fire"
|
||||
if(reagents.get_reagent_amount("plasma")) // the plasma explodes when exposed to fire
|
||||
var/datum/effect/effect/system/reagents_explosion/e = new()
|
||||
e.set_up(round (src.reagents.get_reagent_amount("plasma")/2.5, 1), get_turf(src), 0, 0)
|
||||
e.set_up(round (reagents.get_reagent_amount("plasma")/2.5, 1), get_turf(src), 0, 0)
|
||||
e.start()
|
||||
del(src)
|
||||
return
|
||||
if(reagents.get_reagent_amount("fuel")) // the fuel explodes, too, but much less violently
|
||||
var/datum/effect/effect/system/reagents_explosion/e = new()
|
||||
e.set_up(round (src.reagents.get_reagent_amount("fuel")/5, 1), get_turf(src), 0, 0)
|
||||
e.set_up(round (reagents.get_reagent_amount("fuel")/5, 1), get_turf(src), 0, 0)
|
||||
e.start()
|
||||
del(src)
|
||||
return
|
||||
src.flags &= ~NOREACT // allowing reagents to react after being lit
|
||||
src.reagents.handle_reactions()
|
||||
src.icon_state = icon_on
|
||||
src.item_state = icon_on
|
||||
flags &= ~NOREACT // allowing reagents to react after being lit
|
||||
reagents.handle_reactions()
|
||||
icon_state = icon_on
|
||||
item_state = icon_on
|
||||
for(var/mob/O in viewers(usr, null))
|
||||
O.show_message(flavor_text, 1)
|
||||
processing_objects.Add(src)
|
||||
@@ -153,13 +150,13 @@ ZIPPO
|
||||
|
||||
/obj/item/clothing/mask/cigarette/process()
|
||||
var/turf/location = get_turf(src)
|
||||
src.smoketime--
|
||||
if(src.smoketime < 1)
|
||||
smoketime--
|
||||
if(smoketime < 1)
|
||||
new type_butt(location)
|
||||
processing_objects.Remove(src)
|
||||
if(ismob(src.loc))
|
||||
var/mob/living/M = src.loc
|
||||
M << "\red Your [src.name] goes out."
|
||||
if(ismob(loc))
|
||||
var/mob/living/M = loc
|
||||
M << "\red Your [name] goes out."
|
||||
M.u_equip(src) //un-equip it so the overlays can update
|
||||
M.update_icons()
|
||||
del(src)
|
||||
@@ -167,7 +164,7 @@ ZIPPO
|
||||
if(location)
|
||||
location.hotspot_expose(700, 5)
|
||||
if(reagents && reagents.total_volume) // check if it has any reagents at all
|
||||
if( iscarbon(src.loc) && (src == loc:wear_mask) ) // if it's in the human/monkey mouth, transfer reagents to the mob
|
||||
if( iscarbon(loc) && (src == loc:wear_mask) ) // if it's in the human/monkey mouth, transfer reagents to the mob
|
||||
var/mob/living/carbon/C = loc
|
||||
if(prob(15)) // so it's not an instarape in case of acid
|
||||
reagents.reaction(C, INGEST)
|
||||
@@ -178,9 +175,9 @@ ZIPPO
|
||||
|
||||
|
||||
/obj/item/clothing/mask/cigarette/dropped(mob/user as mob)
|
||||
if(src.lit == 1)
|
||||
if(lit == 1)
|
||||
for(var/mob/O in viewers(user, null))
|
||||
O.show_message(text("\red [] calmly drops and treads on the lit [], putting it out instantly.", user,src.name), 1)
|
||||
O.show_message(text("\red [] calmly drops and treads on the lit [], putting it out instantly.", user,name), 1)
|
||||
new type_butt(loc)
|
||||
processing_objects.Remove(src)
|
||||
del(src)
|
||||
@@ -283,26 +280,26 @@ ZIPPO
|
||||
light("\red [user] lights their [name] with their [W].")
|
||||
|
||||
light(var/flavor_text = "[usr] lights the [name].")
|
||||
if(!src.lit)
|
||||
src.lit = 1
|
||||
src.damtype = "fire"
|
||||
src.icon_state = icon_on
|
||||
src.item_state = icon_on
|
||||
if(!lit)
|
||||
lit = 1
|
||||
damtype = "fire"
|
||||
icon_state = icon_on
|
||||
item_state = icon_on
|
||||
for(var/mob/O in viewers(usr, null))
|
||||
O.show_message(flavor_text, 1)
|
||||
processing_objects.Add(src)
|
||||
|
||||
process()
|
||||
var/turf/location = get_turf(src)
|
||||
src.smoketime--
|
||||
if(src.smoketime < 1)
|
||||
smoketime--
|
||||
if(smoketime < 1)
|
||||
new /obj/effect/decal/cleanable/ash(location)
|
||||
if(ismob(src.loc))
|
||||
var/mob/living/M = src.loc
|
||||
M << "\red Your [src.name] goes out, and you empty the ash."
|
||||
src.lit = 0
|
||||
src.icon_state = icon_off
|
||||
src.item_state = icon_off
|
||||
if(ismob(loc))
|
||||
var/mob/living/M = loc
|
||||
M << "\red Your [name] goes out, and you empty the ash."
|
||||
lit = 0
|
||||
icon_state = icon_off
|
||||
item_state = icon_off
|
||||
processing_objects.Remove(src)
|
||||
return
|
||||
if(location)
|
||||
@@ -310,17 +307,16 @@ ZIPPO
|
||||
return
|
||||
|
||||
dropped(mob/user as mob)
|
||||
if(src.lit == 1)
|
||||
for(var/mob/O in viewers(user, null))
|
||||
O.show_message(text("\red [] puts out the [].", user,src.name), 1)
|
||||
src.lit = 0
|
||||
src.icon_state = icon_off
|
||||
src.item_state = icon_off
|
||||
if(lit == 1)
|
||||
user.visible_message("<span class='notice'>[user] puts out [src].</span>")
|
||||
lit = 0
|
||||
icon_state = icon_off
|
||||
item_state = icon_off
|
||||
processing_objects.Remove(src)
|
||||
return ..()
|
||||
|
||||
/obj/item/clothing/mask/pipe/attack_self(mob/user as mob) //Refills the pipe. Can be changed to an attackby later, if loose tobacco is added to vendors or something.
|
||||
if(src.smoketime <= 0)
|
||||
if(smoketime <= 0)
|
||||
user << "\blue You refill the pipe with tobacco."
|
||||
smoketime = maxsmoketime
|
||||
return
|
||||
@@ -371,13 +367,13 @@ ZIPPO
|
||||
attack_hand(mob/user as mob)
|
||||
if(user.r_hand == src || user.l_hand == src)
|
||||
if(cigcount == 0)
|
||||
user << "\red You're out of cigs, shit! How you gonna get through the rest of the day..."
|
||||
user << "<span class='notice'>You're out of cigs, shit! How you gonna get through the rest of the day...</span>"
|
||||
return
|
||||
else
|
||||
var/obj/item/clothing/mask/cigarette/W = new /obj/item/clothing/mask/cigarette(user)
|
||||
reagents.trans_to(W, (reagents.total_volume/cigcount))
|
||||
user.put_in_active_hand(W)
|
||||
src.reagents.maximum_volume = 15*cigcount
|
||||
reagents.maximum_volume = 15*cigcount
|
||||
cigcount--
|
||||
else
|
||||
return ..()
|
||||
@@ -428,10 +424,10 @@ ZIPPO
|
||||
|
||||
attack_self(mob/living/user)
|
||||
if(user.r_hand == src || user.l_hand == src)
|
||||
if(!src.lit)
|
||||
src.lit = 1
|
||||
src.icon_state = icon_on
|
||||
src.item_state = icon_on
|
||||
if(!lit)
|
||||
lit = 1
|
||||
icon_state = icon_on
|
||||
item_state = icon_on
|
||||
if( istype(src,/obj/item/weapon/lighter/zippo) )
|
||||
for(var/mob/O in viewers(user, null))
|
||||
O.show_message(text("\red Without even breaking stride, [] flips open and lights the [] in one smooth movement.", user, src), 1)
|
||||
@@ -448,9 +444,9 @@ ZIPPO
|
||||
user.SetLuminosity(user.luminosity + 2)
|
||||
processing_objects.Add(src)
|
||||
else
|
||||
src.lit = 0
|
||||
src.icon_state = icon_off
|
||||
src.item_state = icon_off
|
||||
lit = 0
|
||||
icon_state = icon_off
|
||||
item_state = icon_off
|
||||
if( istype(src,/obj/item/weapon/lighter/zippo) )
|
||||
for(var/mob/O in viewers(user, null))
|
||||
O.show_message(text("\red You hear a quiet click, as [] shuts off the [] without even looking at what they're doing. Wow.", user, src), 1)
|
||||
@@ -469,11 +465,11 @@ ZIPPO
|
||||
if(!istype(M, /mob))
|
||||
return
|
||||
|
||||
if(istype(M.wear_mask,/obj/item/clothing/mask/cigarette) && user.zone_sel.selecting == "mouth" && src.lit)
|
||||
if(istype(M.wear_mask,/obj/item/clothing/mask/cigarette) && user.zone_sel.selecting == "mouth" && lit)
|
||||
if(M == user)
|
||||
M.wear_mask:light("\red With a single flick of their wrist, [user] smoothly lights their [M.wear_mask.name] with their [src.name]. Damn they're cool.")
|
||||
M.wear_mask:light("\red With a single flick of their wrist, [user] smoothly lights their [M.wear_mask.name] with their [name]. Damn they're cool.")
|
||||
else
|
||||
M.wear_mask:light("\red [user] whips the [src.name] out and holds it for [M]. Their arm is as steady as the unflickering flame they light the [M.wear_mask.name] with.")
|
||||
M.wear_mask:light("\red [user] whips the [name] out and holds it for [M]. Their arm is as steady as the unflickering flame they light the [M.wear_mask.name] with.")
|
||||
else
|
||||
..()
|
||||
|
||||
@@ -487,7 +483,7 @@ ZIPPO
|
||||
|
||||
pickup(mob/user)
|
||||
if(lit)
|
||||
src.SetLuminosity(0)
|
||||
SetLuminosity(0)
|
||||
user.SetLuminosity(user.luminosity+2)
|
||||
return
|
||||
|
||||
@@ -495,5 +491,5 @@ ZIPPO
|
||||
dropped(mob/user)
|
||||
if(lit)
|
||||
user.SetLuminosity(user.luminosity-2)
|
||||
src.SetLuminosity(2)
|
||||
SetLuminosity(2)
|
||||
return
|
||||
|
||||
@@ -169,6 +169,9 @@ var/list/AAlarmWireColorToIndex
|
||||
#define shuttle_time_in_station 1800 // 3 minutes in the station
|
||||
#define shuttle_time_to_arrive 6000 // 10 minutes to arrive
|
||||
|
||||
//away missions
|
||||
var/list/awaydestinations = list()
|
||||
|
||||
|
||||
|
||||
// MySQL configuration
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
/obj/machinery/gateway
|
||||
name = "gateway"
|
||||
desc = "It's a Nanotrasen approved one-way experimental teleporter that will take you places. Still has the pricetag on it."
|
||||
icon = 'icons/obj/machines/gateway.dmi'
|
||||
density = 1
|
||||
anchored = 1
|
||||
var/active = 0
|
||||
|
||||
/obj/machinery/gateway/initialize()
|
||||
update_icon()
|
||||
if(dir == 2)
|
||||
density = 0
|
||||
|
||||
/obj/machinery/gateway/update_icon()
|
||||
if(active)
|
||||
icon_state = "on[dir]"
|
||||
return
|
||||
icon_state = "off[dir]"
|
||||
|
||||
/obj/machinery/gateway/attack_hand(mob/user as mob)
|
||||
update_icon()
|
||||
|
||||
|
||||
|
||||
//this is da important part wot makes things go
|
||||
/obj/machinery/gateway/center
|
||||
density = 1
|
||||
dir = 3 //this doesn't work for some reason? see below
|
||||
var/list/linked = list() //a list of the connected gateway chunks
|
||||
var/ready = 0
|
||||
|
||||
/obj/machinery/gateway/center/initialize()
|
||||
dir = 3 //see above
|
||||
update_icon()
|
||||
|
||||
/obj/machinery/gateway/center/proc/detect()
|
||||
linked = list() //clear the list
|
||||
var/turf/T = loc
|
||||
|
||||
for(var/i in alldirs)
|
||||
T = get_step(loc, i)
|
||||
var/obj/machinery/gateway/G = locate(/obj/machinery/gateway) in T
|
||||
if(G)
|
||||
linked.Add(G)
|
||||
continue
|
||||
|
||||
//this is only done if we fail to find a part
|
||||
ready = 0
|
||||
toggleoff()
|
||||
break
|
||||
|
||||
if(linked.len == 8)
|
||||
ready = 1
|
||||
|
||||
/obj/machinery/gateway/center/proc/toggleon()
|
||||
if(!ready) return
|
||||
if(linked.len != 8) return
|
||||
|
||||
for(var/obj/machinery/gateway/G in linked)
|
||||
G.active = 1
|
||||
G.update_icon()
|
||||
active = 1
|
||||
update_icon()
|
||||
density = 0
|
||||
|
||||
/obj/machinery/gateway/center/proc/toggleoff()
|
||||
for(var/obj/machinery/gateway/G in linked)
|
||||
G.active = 0
|
||||
G.update_icon()
|
||||
active = 0
|
||||
update_icon()
|
||||
density = 1
|
||||
|
||||
/obj/machinery/gateway/center/attack_hand(mob/user as mob)
|
||||
if(!ready)
|
||||
detect()
|
||||
return
|
||||
if(!active)
|
||||
toggleon()
|
||||
return
|
||||
toggleoff()
|
||||
|
||||
//okay, here's the good teleporting stuff
|
||||
/obj/machinery/gateway/center/HasEntered(mob/user as mob)
|
||||
if(!ready) return
|
||||
if(!active) return
|
||||
|
||||
var/obj/effect/landmark/dest = pick(awaydestinations)
|
||||
if(dest)
|
||||
user.loc = dest.loc
|
||||
return
|
||||
@@ -0,0 +1,17 @@
|
||||
/obj/effect/spawner/lootdrop
|
||||
icon = 'icons/mob/screen1.dmi'
|
||||
icon_state = "x2"
|
||||
var/lootcount = 1 //how many items will be spawned
|
||||
var/lootdoubles = 0 //if the same item can be spawned twice
|
||||
var/loot = "" //a list of possible items to spawn- a string of paths
|
||||
|
||||
/obj/effect/spawner/lootdrop/initialize()
|
||||
var/list/things = params2list(loot)
|
||||
if(things && things.len)
|
||||
for(var/i = lootcount, i > 0, i--)
|
||||
var/lootspawn = text2path(pick(things))
|
||||
if(!lootdoubles)
|
||||
things.Remove(lootspawn)
|
||||
|
||||
new lootspawn(get_turf(src))
|
||||
del(src)
|
||||
@@ -0,0 +1,7 @@
|
||||
/obj/effect/step_trigger/message
|
||||
var/message //the message to give to the mob
|
||||
|
||||
/obj/effect/step_trigger/message/Trigger(mob/M as mob)
|
||||
if(M.client)
|
||||
M << "<span class='info'>[message]</span>"
|
||||
del(src)
|
||||
@@ -7,7 +7,7 @@ proc/createRandomZlevel()
|
||||
if (!text) // No random Z-levels for you.
|
||||
return
|
||||
|
||||
world << "\red \b Reticulating Splines"
|
||||
world << "\red \b Searching for away missions..."
|
||||
|
||||
var/list/CL = dd_text2list(text, "\n")
|
||||
|
||||
@@ -38,10 +38,20 @@ proc/createRandomZlevel()
|
||||
|
||||
|
||||
if(potentialRandomZlevels.len)
|
||||
world << "\red \b Loading away mission..."
|
||||
|
||||
var/map = pick(potentialRandomZlevels)
|
||||
var/file = file(map)
|
||||
if(isfile(file))
|
||||
maploader.load_map(file)
|
||||
|
||||
for(var/obj/effect/landmark/L in world)
|
||||
if (L.name != "awaystart")
|
||||
continue
|
||||
awaydestinations.Add(L)
|
||||
|
||||
world << "\red \b Away mission loaded."
|
||||
|
||||
else
|
||||
world << "\red \b No away missions found."
|
||||
return
|
||||
@@ -1,237 +0,0 @@
|
||||
/*
|
||||
DMP to swapmap converter
|
||||
version 1.0
|
||||
|
||||
by Lummox JR
|
||||
*/
|
||||
|
||||
mob/verb/Convert(filename as file)
|
||||
dmp2swapmap(filename)
|
||||
|
||||
proc/d2sm_prepmap(filename)
|
||||
var/txt = file2text(filename)
|
||||
if(!txt) return
|
||||
var/i,j
|
||||
i=findText(txt,ascii2text(13)) // eliminate carriage returns
|
||||
while(i)
|
||||
txt=copytext(txt,1,i)+copytext(txt,i+1)
|
||||
i=findText(txt,ascii2text(13),i)
|
||||
i=findText(txt,"\\\n")
|
||||
while(i)
|
||||
for(j=i+2,j<=length(txt),++j) if(text2ascii(txt,j)>32) break
|
||||
txt=copytext(txt,1,i)+copytext(txt,j)
|
||||
i=findText(txt,"\\\n",i)
|
||||
return txt
|
||||
|
||||
proc/dmp2swapmap(filename)
|
||||
//var/txt = file2text(filename)
|
||||
//if(!txt) return
|
||||
var/txt = d2sm_prepmap(filename)
|
||||
var/mapname="[filename]"
|
||||
var/i,j,k
|
||||
i=findtext(mapname,".dmp")
|
||||
while(i && i+4<length(mapname)) i=findtext(mapname,".dmp",i+1)
|
||||
mapname=copytext(mapname,1,i)
|
||||
/* i=findText(txt,ascii2text(13))
|
||||
while(i)
|
||||
txt=copytext(txt,1,i)+copytext(txt,i+1)
|
||||
i=findText(txt,ascii2text(13),i)
|
||||
i=findText(txt,"\\\n")
|
||||
while(i)
|
||||
for(j=i+2,j<=length(txt),++j) if(text2ascii(txt,j)>32) break
|
||||
txt=copytext(txt,1,i)+copytext(txt,j)
|
||||
i=findText(txt,"\\\n",i) */
|
||||
var/list/codes=new
|
||||
var/codelen=1
|
||||
var/list/areas
|
||||
var/mode=34
|
||||
var/z=0
|
||||
var/X=0,Y=0,Z=0
|
||||
while(txt)
|
||||
if(text2ascii(txt)==34)
|
||||
if(mode!=34)
|
||||
world << "Corrupt map file [filename]: Unexpected code found after z-level [z]"
|
||||
return
|
||||
// standard line:
|
||||
// "a" = (/obj, /obj, /turf, /area)
|
||||
i=findtext(txt,"\"",2)
|
||||
var/code=copytext(txt,2,i)
|
||||
codelen=length(code)
|
||||
i=findtext(txt,"(",i)
|
||||
if(!i)
|
||||
world << "Corrupt map file [filename]: No type list follows \"[code]\""
|
||||
return
|
||||
k=findtext(txt,"\n",++i)
|
||||
j=(k || length(txt+1))
|
||||
while(--j>=i && text2ascii(txt,j)!=41)
|
||||
if(j<i)
|
||||
world << "Corrupt map file [filename]: Type list following \"[code]\" is incomplete"
|
||||
return
|
||||
var/list/L = d2sm_ParseCommaList(copytext(txt,i,j))
|
||||
if(istext(L))
|
||||
world << "Corrupt map file [filename]: [L]"
|
||||
return
|
||||
if(L.len<2)
|
||||
world << "Corrupt map file [filename]: Type list following \"[code]\" has only 1 item"
|
||||
return
|
||||
txt=k?copytext(txt,k+1):null
|
||||
if(L[L.len] == "[world.area]") L[L.len]=0
|
||||
else
|
||||
if(!areas) areas=list()
|
||||
i=areas.Find(L[L.len])
|
||||
if(i) L[L.len]=i
|
||||
else
|
||||
areas+=L[L.len]
|
||||
L[L.len]=areas.len
|
||||
var/codetrans=d2sm_ConvertType(L[L.len-1],"\t\t\t\t")
|
||||
if(L[L.len]) codetrans+="\t\t\t\tAREA = [L[L.len]]\n"
|
||||
if(L.len>2) codetrans+=d2sm_Contents(L,L.len-2,"\t\t\t\t")
|
||||
codes[code]=copytext(codetrans,1,length(codetrans))
|
||||
else if(text2ascii(txt)==40)
|
||||
mode=40
|
||||
// standard line (top-down, left-right symbol order):
|
||||
// (1,1,1) = {"
|
||||
// abcde
|
||||
// bcdef
|
||||
// "}
|
||||
i=d2sm_MatchBrace(txt,1,40)
|
||||
if(!i)
|
||||
world << "Corrupt map file [filename]: No matching ) for coordinates: [copytext(txt,1,findtext(txt,"\n"))]"
|
||||
return
|
||||
var/list/coords=d2sm_ParseCommaList(copytext(txt,2,i))
|
||||
if(istext(coords) || coords.len!=3)
|
||||
world << "Corrupt map file [filename]: [istext(coords)?(coords):"[copytext(txt,1,i+1)] is not a valid (x,y,z) coordinate"]"
|
||||
return
|
||||
j=findtext(txt,"{",i+1)
|
||||
if(!j)
|
||||
world << "Corrupt map file [filename]: No braces {} following [copytext(txt,1,i+1)]"
|
||||
return
|
||||
k=d2sm_MatchBrace(txt,j,123)
|
||||
if(!k)
|
||||
world << "Corrupt map file [filename]: No closing brace } following [copytext(txt,1,i+1)]"
|
||||
return
|
||||
var/mtxt=copytext(txt,j+1,k)
|
||||
if(findText(mtxt,"\"\n")!=1 || !findText(mtxt,"\n\"",length(mtxt)-1))
|
||||
world << findText(mtxt,"\"\n")
|
||||
world << findText(mtxt,"\n\"",length(mtxt)-1)
|
||||
world << "Corrupt map file [filename]: No quotes in braces following [copytext(txt,1,i+1)]"
|
||||
return
|
||||
mtxt=copytext(mtxt,2,length(mtxt))
|
||||
var/_x=0,_y=0
|
||||
for(i=1,,++_y)
|
||||
j=findText(mtxt,"\n",i+1)
|
||||
if(!j) break
|
||||
_x=max(_x,(j-i-1)/codelen)
|
||||
i=j
|
||||
X=max(X,_x)
|
||||
Y=max(Y,_y)
|
||||
z=text2num(coords[3])
|
||||
Z=max(Z,z)
|
||||
txt=copytext(txt,k+1)
|
||||
else
|
||||
i=findtext(txt,"\n")
|
||||
txt=i?copytext(txt,i+1):null
|
||||
world << "Map size: [X],[Y],[Z]"
|
||||
//for(var/code in codes)
|
||||
// world << "Code \"[code]\":\n[codes[code]]"
|
||||
fdel("map_[mapname].txt")
|
||||
var/F = file("map_[mapname].txt")
|
||||
F << ". = object(\".0\")\n.0\n\ttype = /swapmap\n\tid = \"[mapname]\"\n\tz = [Z]\n\ty = [Y]\n\tx = [X]"
|
||||
if(areas)
|
||||
txt=""
|
||||
for(i=0,i<areas.len,++i)
|
||||
txt+="[i?", ":""]object(\".[i]\")"
|
||||
F << "\tareas = list([txt])"
|
||||
for(i=0,i<areas.len,++i)
|
||||
F << "\t\t.[i]"
|
||||
txt=d2sm_ConvertType(areas[i+1],"\t\t\t")
|
||||
F << copytext(txt,1,length(txt))
|
||||
|
||||
// 2nd pass
|
||||
txt=d2sm_prepmap(filename)
|
||||
while(txt)
|
||||
// skip all non-data sections
|
||||
if(text2ascii(txt)!=40)
|
||||
i=findText(txt,"\n")
|
||||
if(i) txt=copytext(txt,i+1)
|
||||
else txt=null
|
||||
continue
|
||||
i=d2sm_MatchBrace(txt,1,40)
|
||||
var/list/coords=d2sm_ParseCommaList(copytext(txt,2,i))
|
||||
j=findtext(txt,"{",i+1)
|
||||
k=d2sm_MatchBrace(txt,j,123)
|
||||
var/mtxt=copytext(txt,j+2,k-1)
|
||||
var/_x=0,_y=0
|
||||
for(i=1,,++_y)
|
||||
j=findText(mtxt,"\n",i+1)
|
||||
if(!j) break
|
||||
_x=max(_x,(j-i-1)/codelen)
|
||||
i=j
|
||||
// print out this z-level now
|
||||
F << "\t[coords[3]]"
|
||||
i=1
|
||||
for(var/y=_y,y>0,--y) // map is top-down
|
||||
++i
|
||||
F << "\t\t[y]"
|
||||
for(var/x in 1 to _x)
|
||||
F << "\t\t\t[x]"
|
||||
j=i+codelen
|
||||
F << codes[copytext(mtxt,i,j)]
|
||||
i=j
|
||||
txt=copytext(txt,k+1)
|
||||
/* for(z in 1 to Z)
|
||||
F << "\t[z]"
|
||||
for(var/y in 1 to Y)
|
||||
F << "\t\t[y]"
|
||||
for(var/x in 1 to X)
|
||||
F << "\t\t\t[x]"
|
||||
F << codes[pick(codes)] */
|
||||
|
||||
proc/d2sm_ParseCommaList(txt)
|
||||
var/list/L=new
|
||||
var/i,ch
|
||||
for(i=1,i<=length(txt),++i)
|
||||
if(text2ascii(txt,i)>32) break
|
||||
for(,i<=length(txt),++i)
|
||||
ch=text2ascii(txt,i)
|
||||
if(ch==44)
|
||||
L+=copytext(txt,1,i)
|
||||
for(++i,i<=length(txt),++i) if(text2ascii(txt,i)>32) break
|
||||
txt=copytext(txt,i)
|
||||
i=0;continue
|
||||
if(ch==40 || ch==91 || ch==123)
|
||||
i=d2sm_MatchBrace(txt,i,ch)
|
||||
if(!i) return "No matching brace found for [ascii2text(ch)]"
|
||||
if(i>1) L+=copytext(txt,1,i)
|
||||
return L
|
||||
|
||||
proc/d2sm_MatchBrace(txt, i, which)
|
||||
if(which==40) ++which
|
||||
else which+=2
|
||||
var/j,ch
|
||||
for(j=i+1,j<=length(txt),++j)
|
||||
ch=text2ascii(txt,j)
|
||||
if(ch==which) return j
|
||||
if(ch==40 || ch==91 || ch==123)
|
||||
j=d2sm_MatchBrace(txt,j,ch)
|
||||
if(!j) return 0
|
||||
|
||||
proc/d2sm_ConvertType(tt,tabs="")
|
||||
var/i=findText(tt,"{")
|
||||
if(!i) return "[tabs]type = [tt]\n"
|
||||
.="[tabs]type = [copytext(tt,1,i)]\n"
|
||||
var/list/L=d2sm_ParseCommaList(copytext(tt,i+1,d2sm_MatchBrace(tt,i,123)))
|
||||
if(istext(L)) return
|
||||
for(var/pair in L)
|
||||
.="[.][tabs][pair]\n"
|
||||
|
||||
proc/d2sm_Contents(list/conts,n,tabs="")
|
||||
.="[tabs]contents = list("
|
||||
var/i
|
||||
for(i=0,i<n,++i)
|
||||
.+="[i?", ":""]object(\".[i]\")"
|
||||
.+=")\n"
|
||||
tabs+="\t"
|
||||
for(i=0,i<n,++i)
|
||||
.+="[tabs].[i]\n"
|
||||
.+=d2sm_ConvertType(conts[i+1],tabs+"\t")
|
||||
Reference in New Issue
Block a user