home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / games / vmsnet / monhl104 / part20 < prev    next >
Encoding:
Internet Message Format  |  1992-08-02  |  42.7 KB

  1. Path: uunet!mcsun!news.funet.fi!hydra!klaava!hurtta
  2. From: Kari.Hurtta@Helsinki.FI (Kari E. Hurtta)
  3. Newsgroups: vmsnet.sources.games
  4. Subject: Monster Helsinki V 1.04 - part 20/32
  5. Keywords: Monster, a multiplayer adventure game
  6. Message-ID: <1992Jun14.054853.10575@klaava.Helsinki.FI>
  7. Date: 14 Jun 92 05:48:53 GMT
  8. Sender: hurtta@klaava.Helsinki.FI (Kari Hurtta)
  9. Followup-To: vmsnet.sources.d
  10. Organization: University of Helsinki
  11. Lines: 1432
  12.  
  13. Archieve-name: monster_helsinki_104/part20
  14. Author: Kari.Hurtta@Helsinki.FI
  15. Product: Monster Helsinki V 1.04
  16. Environment: VMS, Pascal
  17. Part: 20/32
  18.  
  19. -+-+-+-+-+-+-+-+ START OF PART 20 -+-+-+-+-+-+-+-+
  20. X               real_user.idents`091i`093 := '';
  21. X               putreal_user;
  22. X            end;
  23. X        end;
  24. X        writeln ('Ready.');
  25. X     end
  26. Xend; `123 fix_clear_password `125
  27. X
  28. Xprocedure fix_clear_quotas(batch: boolean);
  29. Xvar numrooms,allow,accept: intrec;
  30. X    room,exit,player,acp,i: integer;`032
  31. X    roomindx: indexrec;
  32. Xbegin
  33. X    writeln('Scanning rooms....');
  34. X    for i := 1 to maxplayers do numrooms.int`091i`093 := 0;
  35. X    numrooms.intnum := N_NUMROOMS;
  36. X    for i := 1 to maxplayers do allow.int`091i`093 := default_allow;
  37. X    allow.intnum := N_ALLOW;
  38. X    for i := 1 to maxplayers do accept.int`091i`093 := 0;
  39. X    accept.intnum := N_ACCEPT;
  40. X    getindex(I_ROOM);
  41. X    freeindex;
  42. X    roomindx := indx;
  43. X    for room := 1 to roomindx.top do if not roomindx.free`091room`093 then b
  44. Vegin
  45. X`009gethere(room);
  46. X`009if exact_user(player,here.owner) then begin
  47. X`009    acp := 0;
  48. X`009    for exit := 1 to maxexit do`032
  49. X`009`009if here.exits`091exit`093.kind = 5 then acp := acp +1;
  50. X`009    numrooms.int`091player`093 := numrooms.int`091player`093 +1;
  51. X`009    accept.int`091player`093 := accept.int`091player`093     +acp;
  52. X`009end;
  53. X    end;
  54. X    writeln('Clearing quota database and writing results to it...');
  55. X    int_in_use(N_NUMROOMS);
  56. X    int_in_use(N_ALLOW);
  57. X    int_in_use(N_ACCEPT);
  58. X
  59. X    getint(N_NUMROOMS);
  60. X    anint := numrooms;
  61. X    putint;
  62. X
  63. X    getint(N_ALLOW);
  64. X    anint := allow;
  65. X    putint;
  66. X
  67. X    getint(N_ACCEPT);
  68. X    anint := accept;
  69. X    putint;
  70. X
  71. X    writeln('OK.');
  72. Xend;
  73. X
  74. X
  75. Xprocedure fix_repair_location(batch: boolean);
  76. Xvar id,loc,slot,code,room,true_loc,found_counter: integer;
  77. Xvar ex_indx,sleep_indx,room_indx,header_indx: indexrec;
  78. X    locs: intrec;
  79. X    temp: namrec;
  80. Xbegin
  81. X    writeln('Scanning monsters...');
  82. X    getpers;
  83. X    freepers;
  84. X    getuser;
  85. X    freeuser;
  86. X    getindex(I_PLAYER);
  87. X    freeindex;
  88. X    ex_indx := indx;
  89. X    getindex(I_ASLEEP);
  90. X    freeindex;
  91. X    sleep_indx := indx;
  92. X    getindex(I_ROOM);
  93. X    freeindex;
  94. X    room_indx := indx;
  95. X    getindex(I_HEADER);
  96. X    freeindex;
  97. X    header_indx := indx;
  98. X    getint(N_LOCATION);
  99. X    freeint;
  100. X    locs := anint;
  101. X    for id := 1 to ex_indx.top do if not ex_indx.free`091id`093 then`032
  102. X`009if user.idents`091id`093 = '' then begin
  103. X`009    writeln('Bad player username record #',id:1);
  104. X`009    writeln('    player name: ',pers.idents`091id`093);
  105. X`009end else if user.idents`091id`093`0911`093 = ':' then begin`032
  106. X`009    found_counter := 0;
  107. X`009    true_loc := 0;
  108. X`009    loc := locs.int`091id`093;
  109. X`009    for room := 1 to room_indx.top do if not room_indx.free`091room`093
  110. V then begin
  111. X`009`009gethere(room);
  112. X`009`009for slot := 1 to maxpeople do begin
  113. X`009`009    if (here.people`091slot`093.username = user.idents`091id`093) an
  114. Vd`032
  115. X`009`009`009(here.people`091slot`093.kind = P_MONSTER) then begin
  116. X`009`009`009found_counter := found_counter +1;
  117. X`009`009`009true_loc := room;
  118. X`009`009    end;
  119. X`009`009end;
  120. X`009    end;
  121. X`009    if (found_counter = 1) and (true_loc = loc) then
  122. X`009`009writeln(pers.idents`091id`093,': ok')
  123. X`009    else if found_counter = 0 then begin
  124. X`009`009writeln(pers.idents`091id`093,': not found from any room - deleted '
  125. V,
  126. X`009`009    '- can''t update code database.');
  127. X`009`009ex_indx.free`091id`093 := true;
  128. X`009`009ex_indx.inuse := ex_indx.inuse - 1;
  129. X`009`009if not sleep_indx.free`091id`093 then begin
  130. X`009`009    sleep_indx.free`091id`093 := true;
  131. X`009`009    sleep_indx.inuse := sleep_indx.inuse - 1;`032
  132. X`009`009`009`123 onkohan tarpeelista ? `125
  133. X`009`009end;
  134. X`009`009pers.idents`091id`093 := '';
  135. X`009`009user.idents`091id`093 := '';
  136. X`009`009getint(N_SELF);`009`009`123 destroy self description `125
  137. X`009`009delete_block(anint.int`091id`093);
  138. X`009`009putint;
  139. X`009    end else if (found_counter = 1) and ( loc <> true_loc) then begin
  140. X`009`009writeln(pers.idents`091id`093,': found from wrong location - updated
  141. V.');
  142. X`009`009locs.int`091id`093 := true_loc;
  143. X`009    end else if (found_counter > 1) then begin
  144. X`009`009writeln(pers.idents`091id`093,': duplicated monster - deleted.');
  145. X`009`009for room := 1 to room_indx.top do if not room_indx.free`091room`093
  146. V then begin
  147. X`009`009    code := 0;
  148. X`009`009    getroom(room); `123 locking `125
  149. X`009`009    for slot := 1 to maxpeople do begin
  150. X`009`009`009if (here.people`091slot`093.username = user.idents`091id`093) an
  151. Vd`032
  152. X`009`009`009(here.people`091slot`093.kind = P_MONSTER) then begin
  153. X`009`009`009    code := here.people`091slot`093.parm;
  154. X`009`009`009    here.people`091slot`093.username := '';
  155. X`009`009`009    here.people`091slot`093.kind     := 0;
  156. X`009`009`009    here.people`091slot`093.parm     := 0;
  157. X`009`009`009end;
  158. X`009`009    end;
  159. X`009`009    putroom;`009    `123 unlocking `125
  160. X`009`009    if code > 0 then begin
  161. X`009`009`009if not header_indx.free`091code`093 then begin
  162. X`009`009`009    header_indx.free`091code`093 := true;
  163. X`009`009`009    header_indx.inuse := sleep_indx.inuse - 1;`032
  164. X`009`009`009    delete_program(code);`009`009`009
  165. X`009`009`009end;
  166. X`009`009    end;
  167. X`009`009end; `123 end of room loop `125
  168. X`009`009ex_indx.free`091id`093 := true;
  169. X`009`009ex_indx.inuse := ex_indx.inuse - 1;
  170. X`009`009if not sleep_indx.free`091id`093 then begin
  171. X`009`009    sleep_indx.free`091id`093 := true;
  172. X`009`009    sleep_indx.inuse := sleep_indx.inuse - 1;`032
  173. X`009`009`009`123 onkohan tarpeelista ? `125
  174. X`009`009end;
  175. X`009`009pers.idents`091id`093 := '';
  176. X`009`009user.idents`091id`093 := '';
  177. X`009`009getint(N_SELF);`009`009`123 destroy self description `125
  178. X`009`009delete_block(anint.int`091id`093);
  179. X`009`009putint;
  180. X    `009    end else writeln('%',pers.idents`091id`093,': bad software error
  181. V.');
  182. X`009end;
  183. X    writeln('Updating database...');
  184. X
  185. X    temp := pers;
  186. X    getpers;
  187. X    pers := temp;
  188. X    putpers;
  189. X   `032
  190. X    temp := user;
  191. X    getuser;
  192. X    user := temp;
  193. X    putuser;
  194. X   `032
  195. X    getindex(I_PLAYER);
  196. X    indx := ex_indx;
  197. X    putindex;
  198. X    getindex(I_ASLEEP);
  199. X    indx := sleep_indx;
  200. X    putindex;
  201. X    getindex(I_ROOM);
  202. X    indx := room_indx;
  203. X    putindex;
  204. X    getindex(I_HEADER);
  205. X    indx := header_indx;
  206. X    freeindex;
  207. X    getint(N_LOCATION);
  208. X    anint := locs;
  209. X    putint;
  210. X    writeln('Ready.');
  211. Xend; `123 fix_repair_location `125
  212. X
  213. Xprocedure fix_calculate_existence(batch: boolean);
  214. Xvar table: array `0911 .. maxroom `093 of integer;
  215. X    i,room,slot,object,old_value,pslot,inv: integer;
  216. Xbegin
  217. X    writeln ('Calculate objects'' number in existence');
  218. X    for i := 1 to maxroom do table`091i`093 := 0;
  219. X    getindex(I_ROOM);
  220. X    freeindex;
  221. X    writeln ('Scan room file');
  222. X    for room := 1 to indx.top do if not indx.free`091room`093 then begin
  223. X`009gethere (room);
  224. X`009for slot := 1 to maxobjs do begin
  225. X`009    i := here.objs`091slot`093;
  226. X`009    if (i < 0) or (i > maxroom) then
  227. X`009`009writeln('Invalid object #',i:1,' entry #',slot:1,
  228. X`009`009    ' at room ',here.nicename)
  229. X`009    else if i > 0 then table`091i`093 := table`091i`093 +1;
  230. X`009end;
  231. X`009for pslot := 1 to maxpeople do begin
  232. X`009    if here.people`091pslot`093.kind > 0 then begin
  233. X`009`009for inv := 1 to maxhold do begin
  234. X`009`009    i := here.people`091pslot`093.holding`091inv`093;
  235. X`009`009    if (i < 0) or (i > maxroom) then
  236. X`009`009`009writeln('Invalid object #',i:1,' entry #',inv:1,
  237. X`009`009`009    ' at monster ',here.people`091pslot`093.name)
  238. X`009`009    else if i > 0 then table`091i`093 := table`091i`093 +1;
  239. X`009`009end;
  240. X`009    end;
  241. X`009end;
  242. X    end;
  243. X    writeln('Write result to object file');
  244. X    getindex(I_OBJECT);
  245. X    freeindex;
  246. X    for object := 1 to maxroom do begin
  247. X`009if (object > indx.top) or indx.free`091object`093 then begin
  248. X`009    if table`091object`093 > 0 then begin
  249. X`009`009writeln('Object #',object:1,' not exist but here is');
  250. X`009`009writeln('  ',table`091object`093,' entries in room file.');
  251. X`009    end;
  252. X`009end else begin
  253. X`009    getobj(object);
  254. X`009    old_value := obj.numexist;
  255. X`009    obj.numexist := table`091object`093;
  256. X`009    putobj;
  257. X`009    if old_value <> table`091object`093 then writeln(obj.oname,' fixed.'
  258. V);
  259. X`009end;
  260. X    end;
  261. X    writeln ('Ready.');
  262. Xend;`009`123 fix_calculate_existence `125
  263. X
  264. X
  265. Xprocedure fix_repair_paths(batch: boolean);
  266. Xvar room,exit,room_to,second_exit,exit2: integer;
  267. X
  268. X    procedure delete_exit(room,exit: integer);
  269. X    begin
  270. X`009getroom(room);
  271. X`009writeln('  Removing exit from ',here.nicename,
  272. X`009    ' to ',direct`091exit`093,'.');
  273. X`009here.exits`091exit`093.kind  := 0;
  274. X`009here.exits`091exit`093.toloc := 0;
  275. X`009here.exits`091exit`093.slot  := 0;
  276. X`009putroom;
  277. X    end; `123 delete_exit `125
  278. X`009
  279. Xbegin
  280. X    writeln('Repairing paths...');
  281. X   `032
  282. X    getindex(I_ROOM);
  283. X    freeindex;
  284. X    for room := 1 to indx.top do if not indx.free`091room`093 then begin
  285. X`009for exit := 1 to maxexit do begin
  286. X
  287. X`009    gethere(room);`009`123 reread here `125
  288. X`009    if not (here.exits`091exit`093.kind in `0910,5`093) then begin
  289. X`009`009room_to := here.exits`091exit`093.toloc;
  290. X`009`009second_exit := here.exits`091exit`093.slot;
  291. X
  292. X`009`009if (second_exit < 0) or (second_exit > maxexit) then begin
  293. X`009`009    writeln('Exit from ',here.nicename,' to ',direct`091exit`093,
  294. X`009`009`009' is bad: target slot is out of range');
  295. X`009`009    delete_exit(room,exit);
  296. X`009`009
  297. X`009`009end else if room_to = 0 then begin
  298. X`009`009    writeln('Exit from ',here.nicename,' to ',direct`091exit`093,
  299. X`009`009`009' is nowhere.');
  300. X
  301. X`009`009end else if (room_to < 1) or (room_to > indx.top) then begin
  302. X`009`009    writeln('Exit from ',here.nicename,' to ',direct`091exit`093,
  303. X`009`009`009' is bad: target room is out of range.');
  304. X`009`009    delete_exit(room,exit);
  305. X
  306. X`009`009end else if indx.free`091room_to`093 then begin
  307. X`009`009    writeln('Exit from ',here.nicename,' to ',direct`091exit`093,
  308. X`009`009`009' is bad: target room isn''t in use');
  309. X`009`009    delete_exit(room,exit);
  310. X
  311. X`009`009end else begin
  312. X`009`009    if room = room_to then
  313. X`009`009`009writeln('Exit from ',here.nicename,' to ',direct`091exit`093,
  314. X`009`009`009    ' is loop.');
  315. X`009`009    if second_exit = 0 then begin
  316. X`009`009`009writeln('Exit from ',here.nicename,' to ',direct`091exit`093,
  317. X`009`009`009    ' is bad: no target slot');
  318. X`009`009`009delete_exit(room,exit);
  319. X`009`009    end else begin
  320. X`009`009`009gethere(room_to);
  321. X`009`009`009if (here.exits`091second_exit`093.toloc <> room) or
  322. X`009`009`009   (here.exits`091second_exit`093.slot <> exit) then begin
  323. X`009`009`009    writeln('Exits from ',here.nicename,' to ',
  324. X`009`009`009`009direct`091second_exit`093,
  325. X`009`009`009`009' and');
  326. X`009`009`009    gethere(room);
  327. X`009`009`009    writeln(' from ',here.nicename,' to ',direct`091exit`093,
  328. X`009`009`009`009' are bad: bad link');
  329. X`009`009`009    delete_exit(room,exit);
  330. X`009`009`009end;
  331. X`009`009    end;
  332. X`009`009end;
  333. X`009    end else if here.exits`091exit`093.toloc <> 0 then begin
  334. X`009`009writeln('Exit from ',here.nicename,' to ',direct`091exit`093,
  335. X`009`009    ' isn''t exit.');
  336. X`009    end;`032
  337. X`009end;`009`123 exit `125
  338. X    end;    `123 room `125
  339. X    writeln ('Ready.');
  340. Xend;
  341. X
  342. Xprocedure fix_view_global_flags;
  343. Xbegin
  344. X    writeln('Global flags and values:');
  345. X    writeln;
  346. X    writeln('Monster active: ',view_global_value(GF_ACTIVE,TRUE));
  347. X    writeln('Database valid: ',view_global_value(GF_VALID));
  348. X    writeln('Wartime:        ',view_global_value(GF_WARTIME));
  349. X    writeln('Welcome text:   ',view_global_value(GF_STARTGAME));
  350. X    writeln('NewPlayer text: ',view_global_value(GF_NEWPLAYER));
  351. X    writeln('Global Hook:    ',view_global_value(GF_CODE));
  352. Xend;
  353. X
  354. X`091global`093
  355. Xfunction fix_system
  356. X`009(batch: string := ''):  `123 in this procedure you not have logged in `1
  357. V25
  358. X`009`009`009`009`123 system ! `125
  359. X`009boolean;
  360. Xvar s: string;
  361. X    done: boolean;
  362. X    batch_mode: boolean;
  363. Xbegin            `009
  364. X   done := batch > '';
  365. X   fix_system := true;
  366. X   repeat
  367. X      if batch > '' then begin
  368. X`009    s := batch;
  369. X`009    `123 writeln('Batch mode: ',s); `125
  370. X`009    batch_mode := true;
  371. X      end else begin
  372. X`009    write ('fix> '); readln (s); writeln;
  373. X`009    batch_mode := false;
  374. X      end;
  375. X      s := lowcase(s);
  376. X      if s = '' then writeln ('Enter h for help.')
  377. X      else case s`0911`093 of `032
  378. X`009'a'`009: fix_clear_privileges`009    (batch_mode);
  379. X`009'b'`009: fix_clear_health`009    (batch_mode);
  380. X        'c'`009: fix_initialize_event`009    (batch_mode);
  381. X        'd'     : fix_descriptions`009    (batch_mode);
  382. X        'f'     : fix_clear_experience`009    (batch_mode);
  383. X`009'g'`009:`032
  384. X`009begin
  385. X`009`009if s = 'g' then`009`009fix_calculate_existence`009(batch_mode)
  386. X`009`009else if s = 'gl' then`009fix_clear_global`009(batch_mode)
  387. X`009`009else if s = 'gs' then`009set_global_flag(GF_ACTIVE,FALSE)
  388. X`009`009else if s = 'gu' then   set_global_flag(GF_ACTIVE,TRUE)
  389. X`009`009else if s = 'g-' then`009set_global_flag(GF_VALID,FALSE)
  390. X`009`009else if s = 'g+' then   set_global_flag(GF_VALID,TRUE)
  391. X`009`009else if s = 'gv' then   fix_view_global_flags
  392. X`009`009else writeln ('Enter ? for help.');
  393. X`009end;
  394. X        'i'     : fix_repair_index`009    (batch_mode);
  395. X`009'j'`009: fix_repair_paths`009    (batch_mode);
  396. X`009'k'`009: fix_codes`009`009    (batch_mode);
  397. X`009'l'`009: fix_repair_location`009    (batch_mode);
  398. X        'm'     : fix_clear_monster`009    (batch_mode);
  399. X`009'n'`009: fix_clear_quotas`009    (batch_mode);
  400. X        'o'     :`032
  401. X`009begin
  402. X`009    if s = 'o' then fix_clear_object(batch_mode)
  403. X`009    else if s = 'ow' then fix_owner (batch_mode)
  404. X`009    else writeln('Enter ? for help.');
  405. X`009end;
  406. X        'p'     : fix_clear_player`009    (batch_mode);
  407. X        'r'     : fix_clear_room`009    (batch_mode);
  408. X        's'     :`032
  409. X`009begin
  410. X`009    if s = 's' then fix_clear_password`009    (batch_mode)
  411. X`009    else if s = 'sp' then fix_clear_spell   (batch_mode)
  412. X`009    else writeln('Enter ? for help.');
  413. X`009end;
  414. X        'v'     : system_view;
  415. X        'h','?' : fix_help;
  416. X        'e'     : done := true;
  417. X        'q'     : begin
  418. X`009`009`009fix_system := false;
  419. X`009`009`009done := true;
  420. X`009`009end;
  421. X        otherwise writeln ('Use ? for help');
  422. X      end; `123 case `125
  423. X   until done
  424. Xend;
  425. X
  426. X`123 put an object in this location
  427. X  if returns false, there were no more free object slots here:
  428. X  in other words, the room is too cluttered, and cannot hold any
  429. X  more objects
  430. X`125
  431. Xfunction place_obj(n: integer;silent:boolean := false): boolean;
  432. Xvar
  433. X`009found: boolean;
  434. X`009i: integer;
  435. Xbegin
  436. X`009if here.objdrop = 0 then getroom
  437. X`009else getroom(here.objdrop);
  438. X`009i := 1;
  439. X`009found := false;
  440. X`009while (i <= maxobjs) and (not found) do begin
  441. X`009`009if here.objs`091i`093 = 0 then found := true
  442. X`009`009else i := i + 1;
  443. X`009end;
  444. X`009place_obj := found;
  445. X`009if found then begin
  446. X`009`009here.objs`091i`093 := n;
  447. X`009`009here.objhide`091i`093 := 0;
  448. X`009`009putroom;
  449. X
  450. X`009`009gethere;
  451. X
  452. X
  453. X`009`009`123 if it bounced somewhere else then tell them `125
  454. X
  455. X`009`009if (here.objdrop <> 0) and (here.objdest <> 0) then
  456. X`009`009`009log_event(0,E_BOUNCEDIN,here.objdest,n,'',here.objdrop);
  457. X
  458. X
  459. X`009`009if not(silent) then begin
  460. X`009`009`009if here.objdesc <> 0 then
  461. X`009`009`009`009print_subs(here.objdesc,obj_part(n))
  462. X`009`009`009else
  463. X`009`009`009`009writeln('Dropped ',obj_part(n),'.');
  464. X`009`009end;
  465. X`009end else
  466. X`009`009freeroom;
  467. Xend;
  468. X
  469. X
  470. X`123 remove an object from this room `125
  471. Xfunction take_obj(objnum,slot: integer): boolean;
  472. Xbegin
  473. X`009getroom;
  474. X`009if here.objs`091slot`093 = objnum then begin
  475. X`009`009here.objs`091slot`093 := 0;
  476. X`009`009here.objhide`091slot`093 := 0;
  477. X`009`009take_obj := true;
  478. X`009end else
  479. X`009`009take_obj := false;
  480. X`009putroom;
  481. Xend;
  482. X
  483. X
  484. Xfunction can_hold: boolean;
  485. X
  486. Xbegin
  487. X`009if find_numhold < maxhold then
  488. X`009`009can_hold := true
  489. X`009else
  490. X`009`009can_hold := false;
  491. Xend;
  492. X
  493. X
  494. Xfunction can_drop: boolean;
  495. X
  496. Xbegin
  497. X`009if find_numobjs < maxobjs then
  498. X`009`009can_drop := true
  499. X`009else
  500. X`009`009can_drop := false;
  501. Xend;
  502. X
  503. X
  504. Xfunction find_hold(objnum: integer;slot:integer := 0): integer;
  505. Xvar
  506. X`009i: integer;
  507. X
  508. Xbegin
  509. X`009if slot = 0 then
  510. X`009`009slot := myslot;
  511. X`009i := 1;
  512. X`009find_hold := 0;
  513. X`009while i <= maxhold do begin
  514. X`009`009if here.people`091slot`093.holding`091i`093 = objnum then
  515. X`009`009`009find_hold := i;
  516. X`009`009i := i + 1;
  517. X`009end;
  518. Xend;
  519. X
  520. X
  521. X
  522. X`123 put object number n into the player's inventory; returns false if
  523. X  he's holding too many things to carry another `125
  524. X
  525. Xfunction hold_obj(n: integer): boolean;
  526. Xvar
  527. X`009found: boolean;
  528. X`009i: integer;
  529. X
  530. Xbegin
  531. X`009getroom;
  532. X`009i := 1;
  533. X`009found := false;
  534. X`009while (i <= maxhold) and (not found) do begin
  535. X`009`009if here.people`091myslot`093.holding`091i`093 = 0 then
  536. X`009`009`009found := true
  537. X`009`009else
  538. X`009`009`009i := i + 1;
  539. X`009end;
  540. X`009hold_obj := found;
  541. X`009if found then begin
  542. X`009`009here.people`091myslot`093.holding`091i`093 := n;
  543. X`009`009putroom;
  544. X
  545. X`009`009getobj(n);
  546. X`009`009freeobj;
  547. X`009`009hold_kind`091i`093 := obj.kind;
  548. X`009end else
  549. X`009`009freeroom;
  550. Xend;
  551. X
  552. X
  553. X
  554. X`123 remove an object (hold) from the player record, given the slot that
  555. X  the object is being held in `125
  556. X
  557. Xprocedure drop_obj(slot: integer;pslot: integer := 0);
  558. X
  559. Xbegin
  560. X`009if pslot = 0 then
  561. X`009`009pslot := myslot;
  562. X`009getroom;
  563. X`009here.people`091pslot`093.holding`091slot`093 := 0;
  564. X`009putroom;
  565. X
  566. X`009hold_kind`091slot`093 := 0;
  567. Xend;
  568. X
  569. X
  570. X
  571. X`123 maybe drop something I'm holding if I'm hit `125
  572. X
  573. Xprocedure maybe_drop;
  574. Xvar
  575. X`009i: integer;
  576. X`009objnum: integer;
  577. X`009s: string;
  578. X
  579. Xbegin
  580. X`009i := 1 + (rnd100 mod maxhold);
  581. X`009objnum := here.people`091myslot`093.holding`091i`093;
  582. X
  583. X`009if (objnum <> 0) and (mywield <> objnum) and (mywear <> objnum) then beg
  584. Vin
  585. X`009`009`123 drop something `125
  586. X
  587. X`009`009drop_obj(i);
  588. X`009`009if place_obj(objnum,TRUE) then begin
  589. X`009`009    getobj(objnum);
  590. X`009`009    freeobj;
  591. X
  592. X`009`009    writeln('The ',obj.oname,' has slipped out of your hands.');
  593. X`009`009`009
  594. X`009`009    log_event(myslot,E_SLIPPED,0,0,obj.oname);
  595. X
  596. X`009`009    if obj.actindx > 0 then
  597. X`009`009`009run_monster('',obj.actindx,'drop you','','',
  598. X`009`009`009    sysdate+' '+systime);
  599. X
  600. X`009`009end else
  601. X`009`009    writeln('%error in maybe_drop; unsuccessful place_obj; notify Mo
  602. Vnster Manager');
  603. X
  604. X`009end;
  605. Xend;
  606. X
  607. X`123 function obj_owner moved to module CUSTOM `125
  608. X
  609. Xprocedure do_duplicate(s: string);
  610. Xlabel 0; `123 for panic `125
  611. Xvar
  612. X`009objnum,oldloc: integer;
  613. X
  614. X    function action(s: shortstring; objnum: integer): boolean;
  615. X    begin
  616. X`009if obj_owner(objnum,TRUE) then begin
  617. X`009    if not(place_obj(objnum,TRUE)) then begin
  618. X`009`009`009`123 put the new object here `125
  619. X`009`009writeln('There isn''t enough room here to make that.');
  620. X`009`009goto 0; `123 leave loop `125
  621. X`009    end else begin
  622. X`123 keep track of how many there `125`009getobj(objnum);
  623. X`123 are in existence `125`009`009`009obj.numexist := obj.numexist + 1;
  624. X`009`009`009`009`009putobj;
  625. X
  626. X`009`009log_event(myslot,E_MADEOBJ,0,0,log_name + ' has created an object he
  627. Vre.');
  628. X`009`009writeln('Object ',s,' created.');
  629. X`009    end;
  630. X`009end else
  631. X`009    writeln('Power to create ',s,' belongs to someone else.');
  632. X`009action := true;
  633. X`009checkevents(true);
  634. X`009if oldloc <> location then goto 0; `123 panic `125
  635. X    end;
  636. X   `032
  637. X    function restriction (n: integer): boolean;
  638. X`009begin
  639. X`009`009restriction := true;
  640. X`009end;
  641. X
  642. X    procedure leave;
  643. X    begin
  644. X`009writeln('EXIT - no changes.');
  645. X`009goto 0;
  646. X    end;
  647. X
  648. X
  649. Xbegin
  650. X    if s = '' then grab_line('Object? ',s,eof_handler := leave);
  651. X    oldloc := location;
  652. X    if length(s) > 0 then begin
  653. X`009if not is_owner(location,TRUE) then begin
  654. X`009    `123 only let them make things if they're on their home turf `125
  655. X`009    writeln('You may only create objects when you are in one of your own
  656. V rooms.');
  657. X`009end else begin
  658. X`009    if scan_obj(action,s,,restriction) then begin
  659. X`009    end else
  660. X`009`009writeln('There is no object by that name.');
  661. X`009end;
  662. X   end else
  663. X`009writeln('To duplicate an object, type DUPLICATE <object name>.');
  664. X    0: `123 for panic `125
  665. Xend;
  666. X
  667. X
  668. X`123 make an object `125
  669. Xprocedure do_makeobj(s: string);
  670. Xlabel exit_label;
  671. Xvar
  672. X`009objnum: integer;
  673. X
  674. X    procedure leave;
  675. X    begin
  676. X`009writeln('EXIT - no changes.');
  677. X`009goto exit_label;
  678. X    end;
  679. X
  680. X
  681. Xbegin
  682. X`009if s = '' then grab_line('Object? ',s,eof_handler := leave);
  683. X
  684. X`009gethere;
  685. X`009if checkhide then begin
  686. X`009if not is_owner(location,TRUE) then begin
  687. X`009`009writeln('You may only create objects when you are in one of your own
  688. V rooms.');
  689. X`009end else if s <> '' then begin
  690. X`009`009if length(s) > shortlen then
  691. X`009`009`009writeln('Please limit your object names to ',shortlen:1,' charac
  692. Vters.')
  693. X`009`009else if exact_obj(objnum,s) then begin`009`123 object already exits
  694. V `125
  695. X`009`009`009writeln('That object already exits.  If you would like to make a
  696. Vnother copy of it,');
  697. X`009`009`009writeln('use the DUPLICATE command.');
  698. X`009`009end else begin
  699. X`009`009`009if debug then
  700. X`009`009`009`009writeln('%beggining to create object');
  701. X`009`009`009if find_numobjs < maxobjs then begin
  702. X`009`009`009`009if alloc_obj(objnum) then begin
  703. X`009`009`009`009`009if debug then
  704. X`009`009`009`009`009`009writeln('%alloc_obj successful');
  705. X`009`009`009`009`009getobjnam;
  706. X`009`009`009`009`009objnam.idents`091objnum`093 := lowcase(s);
  707. X`009`009`009`009`009putobjnam;
  708. X`009`009`009`009`009if debug then
  709. X`009`009`009`009`009`009writeln('%getobjnam completed');
  710. X`009`009`009`009`009getobjown;
  711. X`009`009`009`009`009objown.idents`091objnum`093 := userid;
  712. X`009`009`009`009`009putobjown;
  713. X`009`009`009`009`009if debug then
  714. X`009`009`009`009`009`009writeln('%getobjown completed');
  715. X
  716. X`009`009`009`009`009getobj(objnum);
  717. X`009`009`009`009`009`009obj.onum := objnum;
  718. X`009`009`009`009`009`009obj.oname := s;`009`123 name of object `125
  719. X`009`009`009`009`009`009obj.kind := 0; `123 bland object `125
  720. X`009`009`009`009`009`009obj.linedesc := DEFAULT_LINE;
  721. X`009`009`009`009`009`009obj.actindx := 0;
  722. X`009`009`009`009`009`009obj.examine := 0;
  723. X`009`009`009`009`009`009obj.numexist := 1;
  724. X`009`009`009`009`009`009obj.home := 0;
  725. X`009`009`009`009`009`009obj.homedesc := 0;
  726. X
  727. X`009`009`009`009`009`009obj.sticky := false;
  728. X`009`009`009`009`009`009obj.getobjreq := 0;
  729. X`009`009`009`009`009`009obj.getfail := 0;
  730. X`009`009`009`009`009`009obj.getsuccess := DEFAULT_LINE;
  731. X
  732. X`009`009`009`009`009`009obj.useobjreq := 0;
  733. X`009`009`009`009`009`009obj.uselocreq := 0;
  734. X`009`009`009`009`009`009obj.usefail := DEFAULT_LINE;
  735. X`009`009`009`009`009`009obj.usesuccess := DEFAULT_LINE;
  736. X
  737. X`009`009`009`009`009`009obj.usealias := '';
  738. X`009`009`009`009`009`009obj.reqalias := false;
  739. X`009`009`009`009`009`009obj.reqverb := false;
  740. X
  741. X`009`009`009if s`0911`093 in `091'a','A','e','E','i','I','o','O','u','U'`093
  742. V then
  743. X`009`009`009`009`009`009obj.particle := 2  `123 an `125
  744. X`009`009`009else
  745. X`009`009`009`009`009`009obj.particle := 1; `123 a `125
  746. X
  747. X`009`009`009`009`009`009obj.d1 := 0;
  748. X`009`009`009`009`009`009obj.d2 := 0;
  749. X`009`009`009`009`009`009obj.ap := 0;
  750. X`009`009`009`009`009`009obj.exreq := 0;
  751. X
  752. X`009`009`009`009`009`009obj.exp5 := DEFAULT_LINE;
  753. X`009`009`009`009`009`009obj.exp6 := DEFAULT_LINE;
  754. X`009`009`009`009`009putobj;
  755. X
  756. X
  757. X`009`009`009`009`009if debug then
  758. X`009`009`009`009`009`009writeln('putobj completed');
  759. X`009`009`009`009end;
  760. X`009`009`009`009`009`123 else: alloc_obj prints errors by itself `125
  761. X`009`009`009`009if not(place_obj(objnum,TRUE)) then
  762. X`009`009`009`009`009`123 put the new object here `125
  763. X`009`009`009`009`009writeln('%error in makeobj - could not place object; not
  764. Vify the Monster Manager.')
  765. X`009`009`009`009else begin
  766. X`009`009`009`009`009log_event(myslot,E_MADEOBJ,0,0,
  767. X`009`009`009`009`009`009log_name + ' has created an object here.');
  768. X`009`009`009`009`009writeln('Object created.');
  769. X`009`009`009`009end;
  770. X
  771. X`009`009`009end else
  772. X`009`009`009`009writeln('This place is too crowded to create any more object
  773. Vs.  Try somewhere else.');
  774. X`009`009end;
  775. X`009end else
  776. X`009`009writeln('To create an object, type MAKE <object name>.');
  777. X`009end;
  778. X    exit_label:
  779. Xend;
  780. X
  781. Xprocedure do_summon(s: string);
  782. Xlabel exit_label;
  783. Xvar
  784. X`009n: integer;
  785. X`009sname: string;
  786. X`009vname: string;
  787. X
  788. X`009sid: integer;
  789. X`009vslot: integer;
  790. X
  791. X    procedure leave;
  792. X    begin
  793. X`009writeln('EXIT - no changes.');
  794. X`009goto exit_label;
  795. X    end;
  796. X
  797. Xbegin
  798. X`009if s = '' then grab_line('Spell? ',s,eof_handler := leave);
  799. X`009sname := s;
  800. X`009grab_line('Victim? ',s,eof_handler := leave);
  801. X`009vname := s;
  802. X
  803. X`009if not lookup_spell(sid,sname) then writeln('Unkown spell.')
  804. X`009else if not parse_pers(vslot,vname) then writeln('Victim isn''t here.')
  805. X`009else begin
  806. X`009    getspell(mylog);
  807. X`009    freespell;
  808. X`009    if spell.level`091sid`093 = 0 then writeln('Unkown spell.')
  809. X`009    else if vslot = myslot then begin
  810. X`009`009writeln('Spell summoned.');
  811. X`009`009log_event(myslot,E_SUMMON,vslot,sid);
  812. X`009`009getint(N_SPELL);
  813. X`009`009freeint;
  814. X`009`009getspell_name;
  815. X`009`009freespell_name;
  816. X`009`009run_monster('',anint.int`091sid`093,
  817. X`009`009    'summon', '','',sysdate + ' ' + systime,
  818. X`009`009    spell_name.idents`091sid`093, here.people`091myslot`093.name);
  819. X`009    end else begin
  820. X`009`009log_event(myslot,E_SUMMON,vslot,sid);
  821. X`009`009writeln('Spell summoned.');
  822. X`009    end;
  823. X`009end;
  824. X    exit_label:
  825. Xend;
  826. X
  827. X`123 remove the type block for an object; all instances of the object must
  828. X  be destroyed first `125
  829. X
  830. Xprocedure do_unmake(s: string);
  831. Xlabel exit_label;
  832. Xvar
  833. X`009n: integer;
  834. X`009tmp: string;
  835. X
  836. X    procedure leave;
  837. X    begin
  838. X`009writeln('EXIT - no changes.');
  839. X`009goto exit_label;
  840. X    end;
  841. X
  842. Xbegin
  843. X`009if s = '' then grab_line('Object? ',s,eof_handler := leave);
  844. X
  845. X`009if not(is_owner(location,TRUE)) then
  846. X`009`009writeln('You must be in one of your own rooms to UNMAKE an object.')
  847. X`009else if lookup_obj(n,s,true) then begin
  848. X`009`009tmp := obj_part(n);
  849. X`009`009`009`123 this will do a getobj(n) for us `125
  850. X
  851. X`009`009if obj.numexist = 0 then begin
  852. X`009`009`009delete_obj(n);
  853. X                        delete_line(obj.linedesc);
  854. X                        delete_block(obj.homedesc);
  855. X`009`009`009delete_block(obj.examine);
  856. X                        delete_block(obj.getfail);
  857. X                        delete_block(obj.getsuccess);
  858. X`009`009`009delete_block(obj.usefail);
  859. X`009`009`009delete_block(obj.usesuccess);
  860. X                        delete_block(obj.d1);
  861. X                        delete_block(obj.d2);
  862. X`009`009`009if obj.actindx > 0 then begin `123 delete hook (hurtta@finuh) `1
  863. V25
  864. X`009`009`009`009delete_program(obj.actindx);
  865. X`009`009`009`009delete_general(I_HEADER,obj.actindx);
  866. X`009`009`009end;
  867. X
  868. X`009`009`009log_event(myslot,E_UNMAKE,0,0,tmp);
  869. X`009`009`009writeln('Object removed.');
  870. X`009`009end else
  871. X`009`009`009writeln('You must DESTROY all instances of the object first.');
  872. X`009end else
  873. X`009`009writeln('There is no object here by that name.');
  874. X    exit_label:
  875. Xend;
  876. X
  877. X
  878. X
  879. X`123 destroy a copy of an object `125
  880. X
  881. Xprocedure do_destroy(s: string);
  882. Xlabel 0;    `123 for panic `125
  883. Xvar
  884. X`009slot,n,oldloc: integer;
  885. X`009pub: shortstring;
  886. X
  887. X    function action(s: shortstring; n: integer): boolean;
  888. X    begin
  889. X`009getobjown;
  890. X`009freeobjown;
  891. X`009if (objown.idents`091n`093 <> userid) and (objown.idents`091n`093 <> pub
  892. Vlic_id) and
  893. X       (not owner_priv) then begin `123 minor change by leino@finuha `125
  894. X`009    writeln('You must be the owner of ',s,' or');
  895. X`009    writeln(s,' must be public to destroy it.');
  896. X`009    action := true;
  897. X`009end else if obj_hold(n) then begin
  898. X`009    if mywear = n then x_unwear;
  899. X`009    if mywield = n then x_unwield;
  900. X
  901. X`009    slot := find_hold(n);
  902. X`009    drop_obj(slot);
  903. X
  904. X`009    log_event(myslot,E_DESTROY,0,0,
  905. X`009`009log_name + ' has destroyed ' + obj_part(n) + '.');
  906. X`009    writeln('Object destroyed.');
  907. X
  908. X`009    getobj(n);
  909. X`009    obj.numexist := obj.numexist - 1;
  910. X`009    putobj;
  911. X`009    action := true;
  912. X`009end else if obj_here(n) then begin
  913. X`009    slot := find_obj(n);
  914. X`009    if not take_obj(n,slot) then
  915. X`009`009writeln('Someone picked ',s,' up before you could destroy it.')
  916. X`009    else begin
  917. X`009`009log_event(myslot,E_DESTROY,0,0,
  918. X`009`009log_name + ' has destroyed ' + obj_part(n,FALSE) + '.');
  919. X`009`009writeln('Object ',s,', destroyed.');
  920. X
  921. X`009`009getobj(n);
  922. X`009`009obj.numexist := obj.numexist - 1;
  923. X`009`009putobj;
  924. X`009    end;
  925. X`009    action := true;
  926. X`009end else action := false;
  927. X`009checkevents(TRUE);
  928. X`009if location <> oldloc then goto 0;  `123 panic `125
  929. X    end; `123 action `125
  930. X
  931. X    function restriction (n: integer): boolean;
  932. X`009begin
  933. X`009    restriction := obj_here(n,true) or obj_hold(n);
  934. X`009    `123 true = not found hidden objects `125
  935. X`009end;
  936. X
  937. X    procedure leave;
  938. X    begin
  939. X`009writeln('EXIT - no changes.');
  940. X`009goto 0;
  941. X    end;
  942. X
  943. Xbegin
  944. X`009if s = '' then grab_line('Object? ',s,eof_handler := leave);
  945. X
  946. X`009oldloc := location;
  947. X`009if length(s) = 0 then`009
  948. X`009`009writeln('To destroy an object you own, type DESTROY <object>.')
  949. X`009else if not is_owner(location,TRUE) then
  950. X`009`009writeln('You must be in one of your own rooms to destroy an object.'
  951. V)
  952. X`009else if scan_obj(action,s,,restriction) then begin
  953. X`009end else
  954. X`009`009writeln('No such thing can be seen here.');
  955. X`0090: `123 for panic `125
  956. Xend;
  957. X
  958. X
  959. Xfunction links_possible: boolean;
  960. Xvar
  961. X`009i: integer;
  962. X
  963. Xbegin
  964. X`009gethere;
  965. X`009links_possible := false;
  966. X`009if is_owner(location,TRUE) then
  967. X`009`009links_possible := true
  968. X`009else begin
  969. X`009`009for i := 1 to maxexit do
  970. X`009`009`009if (here.exits`091i`093.toloc = 0) and (here.exits`091i`093.kind
  971. V = 5) then
  972. X`009`009`009`009links_possible := true;
  973. X`009end;
  974. Xend;
  975. X
  976. X
  977. X
  978. X`123 make a room `125
  979. Xprocedure do_form(s: string);
  980. Xlabel exit_label;
  981. X    procedure leave;
  982. X    begin
  983. X`009writeln('EXIT - no changes.');
  984. X`009goto exit_label;
  985. X    end;
  986. X
  987. Xbegin
  988. X`009gethere;
  989. X`009if checkhide then begin
  990. X`009`009if (get_counter(N_NUMROOMS,mylog)`032
  991. X`009`009    >= get_counter(N_ALLOW,mylog))
  992. X`009`009    and not quota_priv then begin
  993. X`009`009    writeln('Yow haven''t room quota left.');
  994. X`009`009    writeln('Use SHOW QUOTA to check limits.');
  995. X`009`009end else if (get_counter(N_NUMROOMS,mylog) >= min_room) and`032
  996. X`009`009`009(get_counter(N_ACCEPT,mylog) < min_accept) and
  997. X`009`009`009not quota_priv then begin
  998. X`009`009    writeln('You haven''t made Accepts enaugh.');
  999. X`009`009    writeln('Use SHOW QUOTA to check limits.');
  1000. X
  1001. X`009`009end else if links_possible then begin
  1002. X`009`009`009if s = '' then begin
  1003. X`009`009`009`009grab_line('Room name? ',s,eof_handler := leave);
  1004. X`009`009`009end;
  1005. X`009`009`009s := slead(s);
  1006. X
  1007. X`009`009`009createroom(s);
  1008. X
  1009. X`009`009end else begin
  1010. X`009`009`009writeln('You may not create any new exits here.  Go to a place w
  1011. Vhere you can create');
  1012. X`009`009`009writeln('an exit before FORMing a new room.');
  1013. X`009`009end;
  1014. X`009end;
  1015. X    exit_label:
  1016. Xend;
  1017. X
  1018. X
  1019. X
  1020. X
  1021. X
  1022. Xprocedure xpoof; `123 loc: integer; forward `125
  1023. Xlabel 0; `123 panic `125
  1024. Xvar
  1025. X`009targslot: integer;
  1026. X`009oldloc: integer;
  1027. X`009prevcode: integer;
  1028. X
  1029. Xbegin
  1030. X`009getnam;`009`009`123 rooms' names `125
  1031. X`009freenam;
  1032. X
  1033. X`009oldloc := location;
  1034. X`009prevcode := here.hook;
  1035. X        if here.hook > 0 then
  1036. X           run_monster('',here.hook,'poof out','target',nam.idents`091loc`09
  1037. V3,
  1038. X               sysdate+' '+systime);
  1039. X
  1040. X        if oldloc = location then meta_run('leave','target',nam.idents`091lo
  1041. Vc`093);
  1042. X
  1043. X`009if put_token(loc,targslot,here.people`091myslot`093.hiding) then begin
  1044. X`009`009if hiding then begin
  1045. X`009`009`009log_event(myslot,E_HPOOFOUT,0,0,log_name,location);
  1046. X`009`009`009log_event(myslot,E_HPOOFIN,0,0,log_name,loc);
  1047. X`009`009end else begin
  1048. X`009`009`009log_event(myslot,E_POOFOUT,0,0,log_name,location);
  1049. X`009`009`009log_event(targslot,E_POOFIN,0,0,log_name,loc);
  1050. X`009`009end;
  1051. X
  1052. X`009`009take_token(myslot,location);
  1053. X`009`009myslot := targslot;
  1054. X`009`009location := loc;
  1055. X`009`009setevent;
  1056. X
  1057. X`009`009`123 one trap `125
  1058. X                oldloc := location;`009`009
  1059. X`009`009if prevcode > 0 then`032
  1060. X`009`009    run_monster('',prevcode,'escaped','','',
  1061. X`009`009`009sysdate+' '+systime);
  1062. X`009`009if oldloc <> location then goto 0; `123 panic `125
  1063. X
  1064. X`009`009do_look; if oldloc <> location then goto 0;
  1065. X `032
  1066. X              if here.hook > 0 then
  1067. X`009`009`009run_monster('',here.hook,'poof in','','',
  1068. X`009`009`009`009sysdate+' '+systime);
  1069. X
  1070. X`009`009if location = oldloc then meta_run('enter','','');
  1071. X
  1072. X`009end else
  1073. X`009`009writeln('There is a crackle of electricity, but the poof fails.');
  1074. X`0090: `123 for panic `125
  1075. Xend;
  1076. X
  1077. Xprocedure poof_monster(n: integer; s: string); forward;
  1078. X
  1079. Xprocedure poof_other(n: integer);
  1080. Xlabel exit_label;
  1081. Xvar
  1082. X`009loc: integer;
  1083. X`009s: string;
  1084. X
  1085. X    procedure leave;
  1086. X    begin
  1087. X`009writeln('EXIT - no changes.');
  1088. X`009goto exit_label;
  1089. X    end;
  1090. X
  1091. Xbegin
  1092. X`009if not protected(n) then begin
  1093. X`009`009grab_line('What room? ',s,eof_handler := leave);
  1094. X`009`009if here.people`091n`093.kind <> P_PLAYER then`032
  1095. X`009`009    if here.people`091n`093.kind = P_MONSTER then
  1096. X`009`009`009poof_monster(n,s)
  1097. X`009`009    else writeln('%error in poof_other.')
  1098. X`009`009else if protected(n) then writeln ('You can''t poof ',here.people`09
  1099. V1n`093.name,' now.')
  1100. X`009`009    `123   !!! necessary double checking !! `125
  1101. X`009`009else if lookup_room(loc,s) then begin
  1102. X`009`009`009log_event(myslot,E_POOFYOU,n,loc);
  1103. X`009`009`009writeln;
  1104. X`009`009`009writeln('You extend your arms, muster some energy, and ',here.pe
  1105. Vople`091n`093.name,' is');
  1106. X`009`009`009writeln('engulfed in a cloud of orange smoke.');
  1107. X`009`009`009writeln;
  1108. X`009`009end else
  1109. X`009`009`009writeln('There is no room named ',s,'.');
  1110. X`009end else writeln ('You can''t poof ',here.people`091n`093.name,' now.');
  1111. X    exit_label:
  1112. Xend;
  1113. X
  1114. Xprocedure do_poof(s: string);
  1115. Xlabel exit_label;
  1116. Xvar
  1117. X`009n,loc: integer;
  1118. X        sown,town: veryshortstring;
  1119. X
  1120. X    procedure leave;
  1121. X    begin
  1122. X`009writeln('EXIT - no changes.');
  1123. X`009goto exit_label;
  1124. X    end;
  1125. X
  1126. Xbegin
  1127. X`009if poof_priv then begin `123 minor change by leino@finuha `125
  1128. X`009`009gethere;
  1129. X`009`009if ((lookup_room(loc,s) and parse_pers(n,s)) or (s='')) then begin
  1130. X`009`009`009grab_line('Poof who? (<RETURN> for yourself) ',s,
  1131. X`009`009`009    eof_handler := leave);
  1132. X`009`009`009if s='' then begin
  1133. X`009`009`009`009grab_line('What room? ',s,
  1134. X`009`009`009`009`009eof_handler := leave);
  1135. X`009`009`009`009if lookup_room(loc,s) then
  1136. X`009`009`009`009`009xpoof(loc);
  1137. X`009`009`009end else if parse_pers(n,s) then
  1138. X`009`009`009`009`009poof_other(n)
  1139. X`009`009`009`009else
  1140. X`009`009`009`009`009writeln('I can see no-one named ',s,' here.');
  1141. X`009`009end else if lookup_room(loc,s) then
  1142. X`009`009`009xpoof(loc)
  1143. X`009`009else if parse_pers(n,s) then
  1144. X`009`009`009poof_other(n)
  1145. X`009`009else
  1146. X`009`009`009writeln('There is no room named ',s,'.');
  1147. X
  1148. X`009end else begin `123 unprivileged poof (hurtta@finuh) `125
  1149. X            gethere;
  1150. X            sown := here.owner;
  1151. X            if s = '' then grab_line('What room? ',s,eof_handler := leave);
  1152. X            if (s = '') or (s='?') then command_help('poof')
  1153. X            else if lookup_room(loc,s) then begin
  1154. X              gethere(loc);
  1155. X              town := here.owner;
  1156. X              if (sown <> userid) or (town <> userid) then
  1157. X                 writeln ('Only Monster Manager may poof in other people''s
  1158. V rooms.')
  1159. X              else xpoof(loc);
  1160. X            end else writeln ('No such room');
  1161. X`009end;`009
  1162. X    exit_label:
  1163. Xend;
  1164. X
  1165. X
  1166. X
  1167. Xprocedure link_room(origdir,targdir,targroom: integer);
  1168. Xvar owner: integer;
  1169. Xbegin
  1170. X`009`123 since exit creation involves the writing of two records,
  1171. X`009  perhaps there should be a global lock around this code,
  1172. X`009  such as a get to some obscure index field or something.
  1173. X`009  I haven't put this in because I don't believe that if this
  1174. X`009  routine fails it will seriously damage the database.
  1175. X
  1176. X`009  Actually, the lock should be on the test (do_link) but that
  1177. X`009  would be hard`009`125
  1178. X
  1179. X`009getroom;
  1180. X`009with here.exits`091origdir`093 do begin
  1181. X
  1182. X`009`009if (kind = 5) and exact_user(owner,here.owner) then
  1183. X`009`009    sub_counter(N_ACCEPT,owner);
  1184. X
  1185. X`009`009toloc := targroom;
  1186. X`009`009kind := 1; `123 type of exit, they can customize later `125
  1187. X`009`009slot := targdir; `123 exit it comes out in in target room `125
  1188. X
  1189. X`009`009init_exit(origdir);
  1190. X`009end;
  1191. X`009putroom;
  1192. X
  1193. X`009log_event(myslot,E_NEWEXIT,0,0,log_name,location);
  1194. X`009if location <> targroom then
  1195. X`009`009log_event(0,E_NEWEXIT,0,0,log_name,targroom);
  1196. X
  1197. X`009getroom(targroom);
  1198. X`009with here.exits`091targdir`093 do begin
  1199. X
  1200. X`009`009if (kind = 5) and exact_user(owner,here.owner) then
  1201. X`009`009    sub_counter(N_ACCEPT,owner);
  1202. X
  1203. X`009`009toloc := location;
  1204. X`009`009kind := 1;
  1205. X`009`009slot := origdir;
  1206. X
  1207. X`009`009init_exit(targdir);
  1208. X`009end;
  1209. X`009putroom;
  1210. X`009writeln('Exit created.  Use CUSTOM ',direct`091origdir`093,' to customiz
  1211. Ve your exit.');
  1212. Xend;
  1213. X
  1214. X
  1215. X`123
  1216. XUser procedure to link a room
  1217. X`125
  1218. Xprocedure do_link(s: string);
  1219. Xlabel exit_label;
  1220. Xvar
  1221. X`009ok: boolean;
  1222. X`009orgexitnam,targnam,trgexitnam: string;
  1223. X`009targroom,`009`123 number of target room `125
  1224. X`009targdir,`009`123 number of target exit direction `125
  1225. X`009origdir: integer;`123 number of exit direction here `125
  1226. X`009firsttime: boolean;
  1227. X
  1228. X    procedure leave;
  1229. X    begin
  1230. X`009writeln('EXIT - no changes.');
  1231. X`009goto exit_label;
  1232. X    end;
  1233. X
  1234. X
  1235. Xbegin
  1236. X
  1237. X`123`009gethere;`009! done in links_possible `125
  1238. X
  1239. X   if links_possible then begin
  1240. X`009log_action(link,0);
  1241. X`009if checkhide then begin
  1242. X`009writeln('Hit return alone at any prompt to terminate exit creation.');
  1243. X`009writeln;
  1244. X
  1245. X`009if s = '' then
  1246. X`009`009firsttime := false
  1247. X`009else begin
  1248. X`009`009orgexitnam := bite(s);
  1249. X`009`009firsttime := true;
  1250. X`009end;
  1251. X
  1252. X`009repeat
  1253. X`009`009if not(firsttime) then
  1254. X`009`009`009grab_line('Direction of exit? ',orgexitnam,
  1255. X`009`009`009`009eof_handler := leave)
  1256. X`009`009else
  1257. X`009`009`009firsttime := false;
  1258. X
  1259. X`009`009ok :=lookup_dir(origdir,orgexitnam,true);
  1260. X`009`009if ok then
  1261. X`009`009`009ok := can_make(origdir);
  1262. X`009until (orgexitnam = '') or ok;
  1263. X
  1264. X`009if ok then begin
  1265. X`009`009if s = '' then
  1266. X`009`009`009firsttime := false
  1267. X`009`009else begin
  1268. X`009`009`009targnam := s;
  1269. X`009`009`009firsttime := true;
  1270. X`009`009end;
  1271. X
  1272. X`009`009repeat
  1273. X`009`009`009if not(firsttime) then
  1274. X`009`009`009`009grab_line('Room to link to? ',targnam,
  1275. X`009`009`009`009    eof_handler := leave)
  1276. X`009`009`009else
  1277. X`009`009`009`009firsttime := false;
  1278. X
  1279. X`009`009`009ok := lookup_room(targroom,targnam,true);
  1280. X`009`009until (targnam = '') or ok;
  1281. X`009end;
  1282. X
  1283. X`009if ok then begin
  1284. X`009`009repeat
  1285. X`009`009`009writeln('Exit comes out in target room');
  1286. X`009`009`009grab_line('from what direction? ',trgexitnam,
  1287. X`009`009`009`009eof_handler := leave);
  1288. X`009`009`009ok := lookup_dir(targdir,trgexitnam,true);
  1289. X`009`009`009if ok then
  1290. X`009`009`009`009ok := can_make(targdir,targroom);
  1291. X`009`009until (trgexitnam='') or ok;
  1292. X`009end;
  1293. X
  1294. X`009if ok then begin `123 actually create the exit `125
  1295. X`009`009link_room(origdir,targdir,targroom);
  1296. X`009end;
  1297. X`009end;
  1298. X   end else
  1299. X`009writeln('No links are possible here.');
  1300. X    exit_label:
  1301. Xend;
  1302. X
  1303. X
  1304. Xprocedure relink_room(origdir,targdir,targroom: integer);
  1305. Xvar
  1306. X`009tmp: exit;
  1307. X`009copyslot,
  1308. X`009copyloc,owner: integer;
  1309. X
  1310. Xbegin
  1311. X`009gethere;
  1312. X`009tmp := here.exits`091origdir`093;
  1313. X`009copyloc := tmp.toloc;
  1314. X`009copyslot := tmp.slot;
  1315. X
  1316. X`009getroom(targroom);
  1317. X`009here.exits`091targdir`093 := tmp;
  1318. X`009putroom;
  1319. X
  1320. X`009getroom(copyloc);
  1321. X`009here.exits`091copyslot`093.toloc := targroom;
  1322. X`009here.exits`091copyslot`093.slot := targdir;
  1323. X`009putroom;
  1324. X
  1325. X`009getroom;
  1326. X`009here.exits`091origdir`093.toloc := 0;
  1327. X`009init_exit(origdir);
  1328. X`009putroom;
  1329. Xend;
  1330. X
  1331. X
  1332. Xprocedure do_relink(s: string);
  1333. Xlabel exit_label;
  1334. Xvar
  1335. X`009ok: boolean;
  1336. X`009orgexitnam,targnam,trgexitnam: string;
  1337. X`009targroom,`009`123 number of target room `125
  1338. X`009targdir,`009`123 number of target exit direction `125
  1339. X`009origdir: integer;`123 number of exit direction here `125
  1340. X`009firsttime: boolean;
  1341. X
  1342. X    procedure leave;
  1343. X    begin
  1344. X`009writeln('EXIT - no changes.');
  1345. X`009goto exit_label;
  1346. X    end;
  1347. X
  1348. Xbegin
  1349. X`009log_action(c_relink,0);
  1350. X`009gethere;
  1351. X`009if checkhide then begin
  1352. X`009writeln('Hit return alone at any prompt to terminate exit relinking.');
  1353. X`009writeln;
  1354. X
  1355. X`009if s = '' then
  1356. X`009`009firsttime := false
  1357. X`009else begin
  1358. X`009`009orgexitnam := bite(s);
  1359. X`009`009firsttime := true;
  1360. X`009end;
  1361. X
  1362. X`009repeat
  1363. X`009`009if not(firsttime) then
  1364. X`009`009`009grab_line('Direction of exit to relink? ',orgexitnam,
  1365. X`009`009`009    eof_handler := leave)
  1366. X`009`009else
  1367. X`009`009`009firsttime := false;
  1368. X
  1369. X`009`009ok :=lookup_dir(origdir,orgexitnam,true);
  1370. X`009`009if ok then
  1371. X`009`009`009ok := can_alter(origdir);
  1372. X`009until (orgexitnam = '') or ok;
  1373. X
  1374. X`009if ok then begin
  1375. X`009`009if s = '' then
  1376. X`009`009`009firsttime := false
  1377. X`009`009else begin
  1378. X`009`009`009targnam := s;
  1379. X`009`009`009firsttime := true;
  1380. X`009`009end;
  1381. X
  1382. X`009`009repeat
  1383. X`009`009`009if not(firsttime) then
  1384. X`009`009`009`009grab_line('Room to relink exit into? ',targnam,
  1385. X`009`009`009`009    eof_handler := leave)
  1386. X`009`009`009else
  1387. X`009`009`009`009firsttime := false;
  1388. X
  1389. X`009`009`009ok := lookup_room(targroom,targnam,true);
  1390. X`009`009until (targnam = '') or ok;
  1391. X`009end;
  1392. X
  1393. X`009if ok then begin
  1394. X`009`009repeat
  1395. X`009`009`009writeln('New exit comes out in target room');
  1396. X`009`009`009grab_line('from what direction? ',trgexitnam,
  1397. X`009`009`009    eof_handler := leave);
  1398. X`009`009`009ok := lookup_dir(targdir,trgexitnam,true);
  1399. X`009`009`009if ok then
  1400. X`009`009`009`009ok := can_make(targdir,targroom);
  1401. X`009`009until (trgexitnam='') or ok;
  1402. X`009end;
  1403. X
  1404. X`009if ok then begin `123 actually create the exit `125
  1405. X`009`009relink_room(origdir,targdir,targroom);
  1406. X`009end;
  1407. X`009end;
  1408. X    exit_label:
  1409. Xend;
  1410. X
  1411. X
  1412. X`123 print the room default no-go message if there is one;
  1413. X  otherwise supply the generic "you can't do that." `125
  1414. X
  1415. Xprocedure default_fail;
  1416. X
  1417. Xbegin
  1418. X`009if (here.exitfail <> 0) and (here.exitfail <> DEFAULT_LINE) then
  1419. X`009`009print_desc(here.exitfail)
  1420. X`009else
  1421. X`009`009writeln('You can''t do that.');
  1422. Xend;
  1423. X
  1424. Xprocedure  exit_fail(dir: integer);
  1425. Xvar
  1426. X`009tmp: string;
  1427. X
  1428. Xbegin
  1429. X`009if (dir < 1) or (dir > maxexit) then
  1430. X`009`009default_fail
  1431. X`009else if (here.exits`091dir`093.fail = DEFAULT_LINE) then begin
  1432. X`009`009case here.exits`091dir`093.kind of
  1433. X`009`009`0095: writeln('There isn''t an exit there yet.');
  1434. X`009`009`0096: writeln('You don''t have the power to go there.');
  1435. X`009`009`009otherwise default_fail;
  1436. X`009`009end;
  1437. X`009end else if here.exits`091dir`093.fail <> 0 then
  1438. X`009`009block_subs(here.exits`091dir`093.fail,myname);
  1439. X
  1440. X
  1441. X`123 now print the exit failure message for everyone else in the room:
  1442. X`009if they tried to go through a valid exit,
  1443. X`009  and the exit has an other-person failure desc, then
  1444. +-+-+-+-+-+-+-+-  END  OF PART 20 +-+-+-+-+-+-+-+-
  1445.