[go: up one dir, main page]

Menu

[897c37]: / mlib / secure / souls.h  Maximize  Restore  History

Download this file

171 lines (152 with data), 4.1 kB

  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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/*
* 950730 Hunter added call to soul_init() after all souls have
* been cloned
* 950807 Hunter added test for wiz_soul to fail loading
* 950905 Hunter added movement soul
* 950916 Hunter commented out query_soul(), as it is now in
* RO/living
* Gandalf temp hack - query soul returns wiz soul if no
* arg, otherwise behaves as hunter intended (driver
* needs fixing).
* 951017 Hunter changed location of wiz_effects soul
* 951019 Hunter removed soul_init() call, as add_soul() now does
* it via call_out.
* 991126 Jenna added a call_out to soul() to avoid errors stemming
* from the fact that destruct() has a 0.1 sec delay.
*/
query_souls () { return souls; }
restore_objects()
{
int xx, ix;
tell_object(this_object(),
"Restoring lost inventory items (if possible).\n");
xx = sizeof(inventory);
for (ix = 0; ix < xx; ix++)
if (objectp(inventory[ix]))
move_object(inventory[ix],myself);
inventory = 0;
recalc_carry(1);
command("wear all silent", this_object());
}
/* this was static , buts it hard to test it that way */
restore_souls()
{
object ws;
int i, s;
string gh;
array newSouls;
// set_this_player(myself);
if (query_ghost()) gh = "ghost/";
else gh = "";
souls = [
"obj/souls/executor", /* alias soul - not trusted or suid'd */
"obj/souls/"+gh+"emote",
"obj/souls/"+gh+"handle",
"obj/souls/"+gh+"communicate",
"obj/souls/"+gh+"perception",
"obj/souls/"+gh+"combat",
"obj/souls/"+gh+"support",
"obj/souls/"+gh+"state",
"obj/souls/movement"
];
/*
* Race soul hack.
*/
if ((gh != "ghost/") && race && (file_size("obj/souls/races/"
+race+"/"+race+".lpc") > 0) )
souls += ["obj/souls/races/" + race + "/"+race] ;
if (gh == "ghost/" && race &&
(file_size("obj/souls/races/"+race+"/ghost"+".lpc") > 0)) {
souls += [ "obj/souls/races/"+race+"/ghost" ];
}
if (query_wiz()) {
souls = [ "closed/wiz_soul",
"obj/souls/wiz/effects" ] + souls;
}
#if 1
/* out until someone fixes TEST_REG to compile */
if (TEST_REGISTER -> query_apprentice (name))
souls += [ "obj/souls/trainers"];
#endif
s = sizeof(souls);
newSouls = allocate(s);
for (i = 0; i < s; i++)
{
catch ws = clone_object(souls[i]);;
if (souls[i] == "closed/wiz_soul") {
if (intp(ws)) {
tell_object( this_object(),
"error: failed to load wiz_soul!\n");
}
else {
set_uid_me(ws, query_wiz(), name);
soul = ws;
}
}
else
{
if (ws) set_uid_me(ws, APPRENTICE, name);
}
if (ws)
{
string n = file_name(this_object()) + "/" + ws->query_soul_type();
object no = find_object(n);
if (no) {
rename_object(no, n + "/del_" + random(10000));
destruct(no);
}
rename_object(ws, n);
// move_object(ws, this_object());
add_soul(ws); // done by soul when `owner' is set.
ws->init();
}
newSouls[i] = ws;
}
}
/* resoul */
soul(a,silent)
{
int i, s, num;
array inv;
string nam;
inv = GetAliasedLS(0)[1];
if (souls)
{
if (inv)
{
s = sizeof(inv);
for (i = 0; i < s; i++)
{
if (inv[i] && inv[i]->id("soul") && !(inv[i]->id("guild_soul")))
{
move_object(inv[i], "room/storage");
destruct(inv[i]);
}
}
}
}
restore_souls();
inv = contents(myself);
call_out("restore_items", 0.2, inv, silent);
if (environment(this_object()) && !silent)
tell_object(myself, "You feel momentarily blank, as if you have lost your soul...\n");
return 1;
}
restore_items(inv, silent) /* Jenna Nov 99 */
{
int i;
// set_this_player(myself);
for (i = 0; i < sizeof(inv); i ++)
{
if (inv[i]) move_object(inv[i], myself);
}
if (environment(this_object()) && !silent)
tell_object(myself, "You have been re-souled.\n");
return 1;
}
static object combat_soul;
set_combat_soul(object arg) { combat_soul = arg; }
query_combat_soul() { return combat_soul; }
/*
* Delete this again after we fix the driver - G.
*/