-
Notifications
You must be signed in to change notification settings - Fork 1
/
mind.dm
113 lines (91 loc) · 3.38 KB
/
mind.dm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/datum/mind
var/key
var/ckey
var/name //replaces mob/var/original_name
var/mob/living/current
var/mob/living/original //TODO: remove.not used in any meaningful way ~Carn. First I'll need to tweak the way silicon-mobs handle minds.
var/mob/dead/observer/ghost_mob = null // If we're in a ghost, a reference to it
var/active = FALSE
var/roundstart_picked = FALSE
var/memory
var/datum/entity/player_entity/player_entity = null
//put this here for easier tracking ingame
var/datum/money_account/initial_account
/datum/mind/New(var/key, var/ckey)
src.key = key
src.ckey = ckey
player_entity = setup_player_entity(ckey)
/datum/mind/proc/transfer_to(mob/living/new_character, var/force = FALSE)
if(QDELETED(new_character))
msg_admin_niche("[key]/[ckey] has tried to transfer to deleted [new_character].")
return
if(current)
current.mind = null //remove ourself from our old body's mind variable
nanomanager.user_transferred(current, new_character) // transfer active NanoUI instances to new user
if(key)
if(new_character.key != key)
new_character.ghostize(TRUE)
else
key = new_character.key
if(new_character.mind)
new_character.mind.current = null //remove any mind currently in our new body's mind variable
current = new_character //link ourself to our new body
original = new_character
new_character.mind = src //and link our new body to ourself
if(active || force)
new_character.key = key //now transfer the key to link the client to our new body
SSround_recording.recorder.update_key(new_character)
if(new_character.client)
new_character.client.init_statbrowser()
new_character.client.change_view(world_view_size) //reset view range to default.
new_character.client.pixel_x = 0
new_character.client.pixel_y = 0
if(usr && usr.open_uis)
for(var/datum/nanoui/ui in usr.open_uis)
if(ui.allowed_user_stat == -1)
ui.close()
continue
player_entity = setup_player_entity(ckey)
new_character.refresh_huds(current) //inherit the HUDs from the old body
/datum/mind/proc/store_memory(new_text)
memory += "[new_text]<BR>"
/datum/mind/proc/show_memory(mob/recipient)
var/output = memory
show_browser(recipient, output, "[current.real_name]'s Memory", "memory")
/datum/mind/Topic(href, href_list)
if(!check_rights(R_ADMIN))
return
else if (href_list["memory_edit"])
var/new_memo = copytext(sanitize(input("Write new memory", "Memory", memory) as null|message),1,MAX_MESSAGE_LEN)
if (isnull(new_memo)) return
memory = new_memo
else if (href_list["common"])
switch(href_list["common"])
if("undress")
for(var/obj/item/W in current)
current.drop_inv_item_on_ground(W)
/datum/mind/proc/setup_human_stats()
if(!player_entity)
player_entity = setup_player_entity(ckey)
if(!player_entity)
return
return player_entity.setup_human_stats()
/datum/mind/proc/setup_xeno_stats()
if(!player_entity)
player_entity = setup_player_entity(ckey)
if(!player_entity)
return
return player_entity.setup_xeno_stats()
/datum/mind/proc/wipe_entity()
player_entity = null
//Initialisation procs
/mob/proc/mind_initialize()
if(mind) mind.key = key
else
mind = new /datum/mind(key, ckey)
mind.original = src
if(SSticker) SSticker.minds += mind
else world.log << "## DEBUG: mind_initialize(): No ticker ready yet! Please inform Carn"
. = 1 //successfully created a new mind
if(!mind.name) mind.name = real_name
mind.current = src