var/list/regions = list()
region
var
list/areas
list/initializers
list/players
list/lights = list()
observers = 0
proc
Initialize()
for(var/atom/movable/o in initializers)
o.onInitialize()
Deactivate()
for(var/atom/movable/o in initializers)
o.onDeactivate()
Entered(mob/player/p,atom/oldloc)
if(++observers==1) Initialize()
for(var/atom/movable/o in initializers)
o.onShow(p)
if(!players) players = list()
players += p
p.client.images += lights
Exited(mob/player/p,atom/newloc)
p.client.images -= lights
players -= p
if(!players.len) players = null
for(var/atom/movable/o in initializers)
o.onHide(p)
if(observers&&--observers<=0) Deactivate()
AddLight(mob/player/p)
lights += p.luminosity_img
for(var/mob/player/n in players-p)
n.client.images += p.luminosity_img
RemoveLight(mob/player/p)
lights -= p.luminosity_img
for(var/mob/player/n in players-p)
n.client.images -= p.luminosity_img
area
var
tmp/region/region = "default"
New()
var/region/r = regions[region]
if(r)
region = r
r.areas += src
else
r = new/region()
regions[region] = r
region = r
region.areas = list(src)
atom
movable
var
initialize = 0
proc
onInitialize()
onDeactivate()
onShow(mob/player/p)
onHide(mob/player/p)
New()
..()
if(loc&&isturf(loc)&&initialize)
var/region/r = loc:loc:region
if(!r.initializers) r.initializers = list(src)
else r.initializers += src
obj
door
icon = 'map.dmi'
icon_state = "16"
density = 1
interactable = 1
initialize = 1
onShow(mob/player/p)
if(p.unlocked_doors[name])
var/image/i = new()
i.invisibility = 101
i.override = 1
i.loc = src
p.unlocked_doors[name] = i
p.client.images += i
onHide(mob/player/p)
var/image/i = p.unlocked_doors[name]
if(i)
p.unlocked_doors[name] = 1
i.loc = null
p.client.images -= i
Cross(atom/movable/o)
if(istype(o,/mob/player))
var/mob/player/p = o
return p.unlocked_doors[name] ? 1 : 0
else
return 0
Crossed(atom/movable/o)
if(istype(o,/mob/player)) invisibility = 101
Uncrossed(atom/movable/o)
if(istype(o,/mob/player)) invisibility = 0
onInteract(mob/player/p)
if(!p.unlocked_doors[name])
if(p.TakeItem("magic_key",1))
p.chatbox.Message(p,"You unlock the door with a magic key.",sound='SFX_Text.ogg')
p.chatbox.Hide(p.client)
p.client.playSFX('SFX_Door.ogg')
var/image/i = new()
i.invisibility = 101
i.override = 1
i.loc = src
p.unlocked_doors[name] = i
p.client.images += i
else
p.chatbox.Message(p,"The door is locked!",sound='SFX_Text.ogg')
p.chatbox.Hide(p.client)
else
return 0
New()
if(loc&&name=="door")
name = "door:([x],[y],[z])"
..()
obj
chest
icon = 'map.dmi'
icon_state = "17"
density = 1
interactable = 1
initialize = 1
var
list/inventory
respawn = 0
onShow(mob/player/p)
if(p.opened_chests[name]&&!respawn)
var/image/i = new()
i.invisibility = 101
i.override = 1
i.loc = src
p.opened_chests[name] = i
p.client.images += i
onHide(mob/player/p)
var/image/i = p.opened_chests[name]
if(i)
i.loc = null
p.client.images -= i
p.opened_chests[name] = 1
Cross(atom/movable/o)
if(istype(o,/mob/player))
var/mob/player/p = o
return p.opened_chests[name] ? 1 : 0
else
return 0
onInteract(mob/player/p)
var/val = p.opened_chests[name]
if(istype(val,/image))
return 0
else
p.client.playSFX('SFX_Chest.ogg')
var/oldinterface = p.client.interface
p.client.setInterface(null)
var/list/l = list()
var/obj/item/i
var/item/item
var/gold = 0
var/msg = "You open the chest and find"
if(inventory.len)
if(val)
for(var/count in 1 to inventory.len)
i = inventory[count]
if(i.respawn)
if(i.item_id=="gold")
val = i.amount
if(i.amount_range) val += rand(0,i.amount_range)
gold += val
msg += "[count>1 ? (count==inventory.len ? ", and " : ", ") : " "][val] gold"
else
val = i.amount
if(i.amount_range) val += rand(0,i.amount_range)
item = items[i.item_id]
l += i.item_id
l += val
msg += "[count>1 ? (count==inventory.len ? ", and " : ", ") : " "][item.Pluralize("a",val)]"
else
for(var/count in 1 to inventory.len)
i = inventory[count]
if(i.respawn!=2)
if(i.item_id=="gold")
val = i.amount
if(i.amount_range) val += rand(0,i.amount_range)
gold += val
msg += "[count>1 ? (count==inventory.len ? ", and " : ", ") : " "][val] gold"
else
val = i.amount
if(i.amount_range) val += rand(0,i.amount_range)
item = items[i.item_id]
l += i.item_id
l += val
msg += "[count>1 ? (count==inventory.len ? ", and " : ", ") : " "][item.Pluralize("a",val)]"
msg += "."
else
p.chatbox.Message(p,"You open the chest, but it is empty.",sound='SFX_Text.ogg')
. = 1
if(l.len)
if(p.canGive(arglist(l)))
if(gold) p.GainGold(gold)
var/count = 0
while(count<l.len)
p.GiveItem(l[++count],l[++count])
p.chatbox.Message(p,msg,sound='SFX_Text.ogg')
. = 1
else
p.chatbox.Message(p,list(msg,"\nBut you cannot carry it all!"),sound='SFX_Text.ogg')
. = 0
else if(gold)
p.GainGold(gold)
p.chatbox.Message(p,msg,sound='SFX_Text.ogg')
. = 1
else
p.chatbox.Message(p,"You open the chest, but it is empty.",sound='SFX_Text.ogg')
. = 1
if(.)
var/image/im = new()
im.invisibility = 101
im.override = 1
im.loc = src
p.opened_chests[name] = im
p.client.images += im
p.chatbox.Hide(p.client)
p.client.setInterface(oldinterface)
return .
New()
if(loc&&name=="chest")
name = "chest:([x],[y],[z])"
..()
obj
teleporter
invisibility = 101
icon = 'editor_sprites.dmi'
icon_state = "a"
density = 1
var
link
outside_point = 0
sfx = 'SFX_Stairs.ogg'
Crossed(atom/movable/o)
if(istype(o,/mob/player)&&o.density&&!o:teleporting)
var/mob/player/p = o
var/atom/endpoint = locate(link)
while(endpoint&&!istype(endpoint,/turf)) endpoint = endpoint.loc
if(endpoint)
p.client.setInterface(null)
if(outside_point)
p.outside_link = tag
spawn(0)
p.Teleport(endpoint,dir,sfx)
Cross(atom/movable/o)
if(istype(o,/mob/player))
return 1
return 0
mob
player
var
list/quest_memory = list()
tmp
list/unlocked_doors = list()
list/opened_chests = list()
teleporting = 0
npc
icon = 'sprites.dmi'
interactable = 1
initialize = 1
var
list/conversation
behavior = BEHAVIOR_NONE
behavior_chance = 100
behavior_delay = 0
behavior_jitter = 10
tmp
origin
initial_look
activated = -1#INF
busy = 0
proc
WanderLoop()
set waitfor = 0
var/time = activated
var/list/l = list()
var/turf/t
sleep(rand()*behavior_jitter)
while(activated==time)
if(!busy&&next_move+behavior_delay<=world.time)
if(rand()*100<behavior_chance)
t = get_step(src,NORTH)
if(loc.Exit(src,t)&&t.Enter(src,loc)) l += t
t = get_step(src,SOUTH)
if(loc.Exit(src,t)&&t.Enter(src,loc)) l += t
t = get_step(src,EAST)
if(loc.Exit(src,t)&&t.Enter(src,loc)) l += t
t = get_step(src,WEST)
if(loc.Exit(src,t)&&t.Enter(src,loc)) l += t
if(l.len)
Move(pick(l),0,0,src)
l.len = 0
else
next_move = world.time+rand()*behavior_jitter
sleep(TICK_LAG)
New()
..()
initial_look = appearance
onInitialize()
origin = loc
activated = world.time
if(behavior==BEHAVIOR_WANDER)
WanderLoop()
onDeactivate()
loc = origin
initial_look = appearance
activated = -1#INF
onInteract(mob/player/p)
if(conversation)
busy++
var/pos = 0, cmd, arg1, arg2, arg3, arg4, len = conversation.len, showing = 0
var/msgdelay=-1,msglastdelay=-1,continues=0,cancel
try
while(++pos<=len)
cmd = conversation[pos]
switch(cmd)
if("if")
arg1 = p.quest_memory[conversation[++pos]]
arg2 = conversation[++pos]
arg3 = conversation[++pos]
switch(arg2)
if("is")
if(arg1) pos = conversation.Find("label:[arg3]")||pos
if("not")
if(!arg1) pos = conversation.Find("label:[arg3]")||pos
if("==")
arg4 = conversation[++pos]
if(arg1==arg3) pos = conversation.Find("label:[arg4]")||pos
if("!=")
arg4 = conversation[++pos]
if(arg1!=arg3) pos = conversation.Find("label:[arg4]")||pos
if(">=")
arg4 = conversation[++pos]
if(arg1>=arg3) pos = conversation.Find("label:[arg4]")||pos
if("<=")
arg4 = conversation[++pos]
if(arg1<=arg3) pos = conversation.Find("label:[arg4]")||pos
if(">")
arg4 = conversation[++pos]
if(arg1>arg3) pos = conversation.Find("label:[arg4]")||pos
if("<")
arg4 = conversation[++pos]
if(arg1<arg3) pos = conversation.Find("label:[arg4]")||pos
if("&")
arg4 = conversation[++pos]
if(arg1&arg3) pos = conversation.Find("label:[arg4]")||pos
if("|")
arg4 = conversation[++pos]
if(arg1|arg3) pos = conversation.Find("label:[arg4]")||pos
if("^")
arg4 = conversation[++pos]
if(arg1^arg3) pos = conversation.Find("label:[arg4]")||pos
if("switch")
arg1 = conversation[++pos]
arg2 = conversation[++pos][arg1]
if(arg2) pos = conversation.Find("label:[arg2]")||pos
if("goto")
arg1 = conversation[++pos]
pos = conversation.Find("label:[arg1]")||pos
if("message","msg")
arg1 = conversation[++pos]
showing |= 1
p.chatbox.Message(p,arg1,continues,msgdelay,msglastdelay,0,sound='SFX_Text.ogg')
if("choice")
arg1 = conversation[++pos]
if(!istype(arg1,/list))
arg1 = list(arg1)
else
arg1 = arg1:Copy()
arg1:Insert(1,p)
p.quest_memory["choice"] = p.chatchoice.Pick(arglist(arg1))||cancel
p.chatchoice.Hide(p.client)
if("branch")
arg1 = conversation[++pos]
arg2 = 2
for(var/v in arg1)
arg2 = max(arg2,length("[v]")+2)
p.chatchoice.Resize(200+(5-arg2)*8,p.chatchoice.y,arg2,length(arg1)*2)
arg1 = p.chatchoice.Pick(p,null,arg1,sound='SFX_MenuConfirm.ogg')||cancel
pos = conversation.Find("label:[arg1]")||pos
p.chatchoice.Hide(p.client)
if("set")
arg1 = conversation[++pos]
arg2 = conversation[++pos]
arg3 = conversation[++pos]
if(istext(arg3))
arg4 = length(arg3)
if(text2ascii(arg3,1)=="&"&&text2ascii(arg3,len)==";")
arg3 = p.quest_memory[copytext(arg3,1,len)]
switch(arg2)
if("=")
p.quest_memory[arg1] = arg3
if("+=")
p.quest_memory[arg1] += arg3
if("-=")
p.quest_memory[arg1] -= arg3
if("*=")
p.quest_memory[arg1] *= arg3
if("/=")
p.quest_memory[arg1] /= arg3
if("|=")
p.quest_memory[arg1] |= arg3
if("&=")
p.quest_memory[arg1] &= arg3
if("^=")
p.quest_memory[arg1] ^= arg3
if("face")
arg1 = conversation[++pos]
switch(arg1)
if("player","p","P",0)
dir = get_dir(src,p)
if("north","n","N",1)
dir = NORTH
if("south","s","S",2)
dir = SOUTH
if("east","e","E",4)
dir = EAST
if("west","w","W",8)
dir = WEST
if("setdelay")
msgdelay = conversation[++pos]
msglastdelay = conversation[++pos]
if("startspeech")
continues = 1
if("endspeech")
continues = 0
if("setcancel")
cancel = conversation[++pos]
if("clearmsg","clearmessage")
p.chatbox.Clear()
if("end")
pos = conversation.len+1
catch(var/exception/e)
world.log << "[e] on [e.file]:[e.line]"
if(showing&1)
p.chatbox.Hide(p.client)
p.client.setInterface(p)
p.chatbox.Clear()
busy--
return 1
Cross(mob/player/p)
. = ..()
if(!.&&behavior==1&&istype(p))
if(busy)
return 1
else if(!(p.move_flags&2))
var/list/l = list()
var/turf/t = get_step(src,NORTH)
if(loc.Exit(src,t)&&t.Enter(src,loc)) l += t
t = get_step(src,SOUTH)
if(loc.Exit(src,t)&&t.Enter(src,loc)) l += t
t = get_step(src,EAST)
if(loc.Exit(src,t)&&t.Enter(src,loc)) l += t
t = get_step(src,WEST)
if(loc.Exit(src,t)&&t.Enter(src,loc)) l += t
if(l.len)
t = pick(l)
. = Move(t,0,p.moving_speed,p)
else
return 0
ID:2066259
Apr 7 2016, 5:57 pm
|
|