| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
#include <ctype.h> |
| 10 |
#include "agility.h" |
| 11 |
#include "interp.h" |
| 12 |
#include "exec.h" |
| 13 |
|
| 14 |
static void d_moveobj(int obj,int dest) |
| 15 |
|
| 16 |
{ |
| 17 |
if (obj==-1) { |
| 18 |
writestr("Which object? "); |
| 19 |
obj=read_number(); |
| 20 |
if (obj!=1 && !tnoun(obj) && !tcreat(obj)) { |
| 21 |
writeln("Invalid object"); |
| 22 |
return; |
| 23 |
} |
| 24 |
} |
| 25 |
if (dest==-1) { |
| 26 |
writestr("To where? "); |
| 27 |
dest=read_number(); |
| 28 |
if (dest!=1 && dest!=0 && !tnoun(dest) && !tcreat(dest) && !troom(dest)) { |
| 29 |
writeln("Invalid object"); |
| 30 |
return; |
| 31 |
} |
| 32 |
} |
| 33 |
if (obj!=1) |
| 34 |
it_move(obj,dest); |
| 35 |
else { |
| 36 |
if (!troom(dest)) { |
| 37 |
writeln("Player can only be moved to a room"); |
| 38 |
return; |
| 39 |
} |
| 40 |
goto_room(dest-first_room); |
| 41 |
} |
| 42 |
} |
| 43 |
|
| 44 |
|
| 45 |
static int print_objid(int obj) |
| 46 |
{ |
| 47 |
char buff[10]; |
| 48 |
char *s; |
| 49 |
int n; |
| 50 |
|
| 51 |
sprintf(buff,"%4d: ",obj); |
| 52 |
writestr(buff); |
| 53 |
s=objname(obj); |
| 54 |
for(n=0;s[n]!=0;n++) |
| 55 |
if (s[n]<=8 || (uchar)s[n]==0xFF) s[n]=' '; |
| 56 |
writestr(s); |
| 57 |
n=strlen(s); |
| 58 |
rfree(s); |
| 59 |
return n; |
| 60 |
} |
| 61 |
|
| 62 |
|
| 63 |
static void d_listroom(void) |
| 64 |
{ |
| 65 |
int i; |
| 66 |
|
| 67 |
writeln(" ROOM"); |
| 68 |
writeln(" ------"); |
| 69 |
writeln(""); |
| 70 |
for(i=0;i<=maxroom-first_room;i++) { |
| 71 |
print_objid(i+first_room); |
| 72 |
writeln(""); |
| 73 |
} |
| 74 |
} |
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
#define SEPLENG 27 |
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
static void d_listnoun(void) |
| 83 |
{ |
| 84 |
int i; |
| 85 |
int len; |
| 86 |
|
| 87 |
writestr(" NOUN ");padout(SEPLENG-6);writeln(" LOCATION "); |
| 88 |
writestr(" ------");padout(SEPLENG-6);writeln(" ----------"); |
| 89 |
writeln(""); |
| 90 |
len=SEPLENG-print_objid(1); |
| 91 |
padout(len); |
| 92 |
writestr("["); |
| 93 |
print_objid(loc); |
| 94 |
writeln("]"); |
| 95 |
|
| 96 |
nounloop(i) { |
| 97 |
len=print_objid(i+first_noun); |
| 98 |
len=SEPLENG-len; |
| 99 |
if (len>0) padout(len); |
| 100 |
writestr("["); |
| 101 |
print_objid(noun[i].location); |
| 102 |
writeln("]"); |
| 103 |
} |
| 104 |
} |
| 105 |
|
| 106 |
static void d_listcreat(void) |
| 107 |
{ |
| 108 |
int i; |
| 109 |
int len; |
| 110 |
|
| 111 |
writestr(" CREATURE ");padout(SEPLENG-11);writeln(" LOCATION "); |
| 112 |
writestr(" ----------");padout(SEPLENG-11);writeln(" ----------"); |
| 113 |
writeln(""); |
| 114 |
|
| 115 |
creatloop(i) { |
| 116 |
len=print_objid(i+first_creat); |
| 117 |
len=SEPLENG-len; |
| 118 |
if (len>0) padout(len); |
| 119 |
writestr(" ["); |
| 120 |
print_objid(creature[i].location); |
| 121 |
writeln("]"); |
| 122 |
} |
| 123 |
} |
| 124 |
|
| 125 |
|
| 126 |
static void writetbl(const char *s,int width) |
| 127 |
|
| 128 |
|
| 129 |
{ |
| 130 |
writestr(s); |
| 131 |
width=width-strlen(s); |
| 132 |
if (width>0) padout(width); |
| 133 |
} |
| 134 |
|
| 135 |
|
| 136 |
static void var_edit(int vtype) |
| 137 |
|
| 138 |
{ |
| 139 |
long n; |
| 140 |
int i; |
| 141 |
int imax; |
| 142 |
char sbuff[30]; |
| 143 |
|
| 144 |
switch (vtype) |
| 145 |
{ |
| 146 |
case 0: imax=VAR_NUM;break; |
| 147 |
case 1: imax=CNT_NUM;break; |
| 148 |
case 2: imax=FLAG_NUM;break; |
| 149 |
default: writeln("INTERNAL ERROR: Invalid vtype."); |
| 150 |
return; |
| 151 |
} |
| 152 |
|
| 153 |
for(;;) { |
| 154 |
agt_clrscr(); |
| 155 |
writeln(""); |
| 156 |
switch (vtype) { |
| 157 |
case 0:writeln("Variables");break; |
| 158 |
case 1:writeln("Counters (-1 means the counter is off)");break; |
| 159 |
case 2:writeln("Flags ( f=false [OFF] and t=true [ON] )");break; |
| 160 |
} |
| 161 |
writeln(""); |
| 162 |
for(i=0;i<=imax;i++) { |
| 163 |
switch (vtype) { |
| 164 |
case 0:sprintf(sbuff,"[Var%3d]=%4ld",i,(long)agt_var[i]);break; |
| 165 |
case 1:sprintf(sbuff,"[Cnt%3d]=%4ld",i,(long)agt_counter[i]);break; |
| 166 |
case 2:sprintf(sbuff,"%3d%c",i,flag[i]?'t':'f');break; |
| 167 |
} |
| 168 |
writetbl(sbuff,(vtype==2)? 5 : 20); |
| 169 |
} |
| 170 |
writeln("");writeln(""); |
| 171 |
for(;;) { |
| 172 |
switch (vtype) { |
| 173 |
case 0:writestr("Variable to change");break; |
| 174 |
case 1:writestr("Counter to change");break; |
| 175 |
case 2:writestr("Flag to toggle");break; |
| 176 |
} |
| 177 |
writestr(" (-1 to quit): "); |
| 178 |
i=read_number(); |
| 179 |
if (i<0) return; |
| 180 |
if (i<=imax) { |
| 181 |
if (vtype!=2) { |
| 182 |
if (vtype==0) |
| 183 |
sprintf(sbuff,"[Var%d]=%ld",i,(long)agt_var[i]); |
| 184 |
else sprintf(sbuff,"[Cnt%d]=%ld (-1 means it's off)", |
| 185 |
i,(long)agt_counter[i]); |
| 186 |
writestr(sbuff); |
| 187 |
writestr("; new value = "); |
| 188 |
n=read_number(); |
| 189 |
if (vtype==0) |
| 190 |
agt_var[i]=n; |
| 191 |
else |
| 192 |
if (n<-1 || n>(((long)1)<<15)-1 ) |
| 193 |
writeln("Invalid value for a counter."); |
| 194 |
else agt_counter[i]=n; |
| 195 |
} else flag[i]=!flag[i]; |
| 196 |
break; |
| 197 |
} else |
| 198 |
writeln("Invalid index."); |
| 199 |
} |
| 200 |
} |
| 201 |
} |
| 202 |
|
| 203 |
|
| 204 |
static void edit_str(void) |
| 205 |
{ |
| 206 |
int i,j; |
| 207 |
char buff[10]; |
| 208 |
char *tmpstr; |
| 209 |
|
| 210 |
if (MAX_USTR==0 || userstr==NULL) { |
| 211 |
writeln("This game doesn't contain any user strings"); |
| 212 |
return; |
| 213 |
} |
| 214 |
for(;;) { |
| 215 |
agt_clrscr(); |
| 216 |
writeln("User Definable Strings"); |
| 217 |
writeln(""); |
| 218 |
for(i=0;i<MAX_USTR;i++) { |
| 219 |
sprintf(buff,"%2d:",i+1); |
| 220 |
writestr(buff); |
| 221 |
writeln(userstr[i]); |
| 222 |
} |
| 223 |
writestr(" (0 to quit): "); |
| 224 |
i=read_number(); |
| 225 |
if (i==0) return; |
| 226 |
if (i>0 && i<=MAX_USTR) { |
| 227 |
writeln("Enter new string:"); |
| 228 |
tmpstr=agt_readline(3); |
| 229 |
j=strlen(tmpstr)-1; |
| 230 |
if (j>0 && tmpstr[j]=='\n') tmpstr[j]=0; |
| 231 |
strncpy(userstr[i-1],tmpstr,80); |
| 232 |
} else writeln("Invalid string number"); |
| 233 |
} |
| 234 |
} |
| 235 |
|
| 236 |
static uchar attrcol; |
| 237 |
static uchar attrwidth; |
| 238 |
|
| 239 |
static void next_col(void) |
| 240 |
{ |
| 241 |
if (++attrcol==attrwidth) { |
| 242 |
writeln(""); |
| 243 |
attrcol=0; |
| 244 |
} |
| 245 |
else |
| 246 |
padout(10); |
| 247 |
} |
| 248 |
|
| 249 |
static void writeattr(char *attrname,rbool attrval) |
| 250 |
{ |
| 251 |
writestr(attrname); |
| 252 |
padout(15-strlen(attrname)); |
| 253 |
if (attrval) writestr("yes"); else writestr("no "); |
| 254 |
next_col(); |
| 255 |
} |
| 256 |
|
| 257 |
static void writegender(char *gendername, uchar genderval) |
| 258 |
{ |
| 259 |
writestr(gendername); |
| 260 |
padout(15-strlen(gendername)-3); |
| 261 |
switch(genderval) |
| 262 |
{ |
| 263 |
case 2: writestr("Male ");break; |
| 264 |
case 1: writestr("Female");break; |
| 265 |
case 0: writestr("Thing");break; |
| 266 |
} |
| 267 |
next_col(); |
| 268 |
} |
| 269 |
|
| 270 |
static void writeprop(char *propname,int obj) |
| 271 |
{ |
| 272 |
writestr(propname); |
| 273 |
writestr(" ["); |
| 274 |
print_objid(obj); |
| 275 |
writeln("]"); |
| 276 |
} |
| 277 |
|
| 278 |
static int writedir(int index,int dir,int obj) |
| 279 |
{ |
| 280 |
char sbuff[40]; |
| 281 |
|
| 282 |
sprintf(sbuff,"%2d.%-2s %d",index,exitname[dir],obj); |
| 283 |
writestr(sbuff); |
| 284 |
return strlen(sbuff); |
| 285 |
} |
| 286 |
|
| 287 |
void writenum(char *propname,int n) |
| 288 |
{ |
| 289 |
char sbuff[20]; |
| 290 |
|
| 291 |
writestr(propname); |
| 292 |
sprintf(sbuff,"%4d",n); |
| 293 |
writeln(sbuff); |
| 294 |
} |
| 295 |
|
| 296 |
static void writeflags(char *flagname, int32 flags) |
| 297 |
{ |
| 298 |
int i; |
| 299 |
char sbuff[5]; |
| 300 |
|
| 301 |
writestr(flagname); |
| 302 |
for(i=0;i<32;i++) { |
| 303 |
if (flags & 1) { |
| 304 |
sprintf(sbuff,"%2d ",i); |
| 305 |
writestr(sbuff); |
| 306 |
} else |
| 307 |
writestr(" "); |
| 308 |
flags>>=1; |
| 309 |
if (i%12==11) { |
| 310 |
writeln(""); |
| 311 |
padout(strlen(flagname)); |
| 312 |
} |
| 313 |
} |
| 314 |
writeln(""); |
| 315 |
} |
| 316 |
|
| 317 |
|
| 318 |
static void readflags(int32 *flags) |
| 319 |
{ |
| 320 |
long n; |
| 321 |
|
| 322 |
writestr("Room flag to toggle (0-31)? "); |
| 323 |
n=read_number(); |
| 324 |
if (n<=31 && n>=0) |
| 325 |
*flags^=( ((long)1) << n ); |
| 326 |
} |
| 327 |
|
| 328 |
static long readval(const char *prompt,int type) |
| 329 |
{ |
| 330 |
long val; |
| 331 |
|
| 332 |
for(;;) { |
| 333 |
writestr(prompt); |
| 334 |
writestr(" "); |
| 335 |
val=read_number(); |
| 336 |
if (argvalid(type,val)) return val; |
| 337 |
writeln("Invalid value."); |
| 338 |
} |
| 339 |
} |
| 340 |
|
| 341 |
|
| 342 |
static uchar readgender(void) |
| 343 |
{ |
| 344 |
char c; |
| 345 |
|
| 346 |
writestr("Gender (M/F/N): "); |
| 347 |
for(;;) { |
| 348 |
c=tolower(agt_getchar()); |
| 349 |
switch(c) |
| 350 |
{ |
| 351 |
case 'm': return 2; |
| 352 |
case 'w': |
| 353 |
case 'f': return 1; |
| 354 |
case 'n': |
| 355 |
case 't': return 0; |
| 356 |
default: ; |
| 357 |
} |
| 358 |
} |
| 359 |
} |
| 360 |
|
| 361 |
|
| 362 |
static void edit_objattr(int obj) |
| 363 |
{ |
| 364 |
int i,k, kprop, n; |
| 365 |
long v; |
| 366 |
|
| 367 |
for(;;) { |
| 368 |
k=1; |
| 369 |
agt_clrscr(); |
| 370 |
print_objid(obj); |
| 371 |
writeln(""); |
| 372 |
if (oflag_cnt>0) { |
| 373 |
writeln("ObjFlags:"); |
| 374 |
for(i=0;i<oflag_cnt;i++) |
| 375 |
if (have_objattr(0,obj,i)) { |
| 376 |
v=op_objflag(2,obj,i); |
| 377 |
rprintf("%2d. ObjProp%2d:%c %-40s\n", k++, i, (v ? '+' : '-'), |
| 378 |
get_objattr_str(AGT_OBJFLAG,i,v)); |
| 379 |
} |
| 380 |
writeln(""); |
| 381 |
} |
| 382 |
kprop=k; |
| 383 |
if (oprop_cnt>0) { |
| 384 |
writeln("ObjProps:"); |
| 385 |
for(i=0;i<oprop_cnt;i++) |
| 386 |
if (have_objattr(1,obj,i)) { |
| 387 |
v=op_objprop(2,obj,i,0); |
| 388 |
rprintf("%2d. ObjFlag%2d: [%3ld] %-40s\n", k++, i, v, |
| 389 |
get_objattr_str(AGT_OBJPROP,i,v)); |
| 390 |
} |
| 391 |
writeln(""); |
| 392 |
} |
| 393 |
writestr("Field to change (0 to return to main view)? "); |
| 394 |
n=read_number(); |
| 395 |
if (n==0) return; |
| 396 |
if (n<1 || n>=k) continue; |
| 397 |
k=0; |
| 398 |
if (n<kprop) { |
| 399 |
for(i=0;i<oflag_cnt;i++) |
| 400 |
if (have_objattr(0,obj,i)) |
| 401 |
if (n==++k) break; |
| 402 |
if (n==k && have_objattr(0,obj,i)) |
| 403 |
op_objflag(3,obj,i); |
| 404 |
} else { |
| 405 |
for(i=0;i<oprop_cnt;i++) |
| 406 |
if (have_objattr(1,obj,i)) |
| 407 |
if (n==++k) break; |
| 408 |
if (n==k && have_objattr(1,obj,i)) |
| 409 |
op_objprop(1,obj,i,readval("New value:",AGT_NUM)); |
| 410 |
} |
| 411 |
} |
| 412 |
} |
| 413 |
|
| 414 |
|
| 415 |
static void room_edit(int i) |
| 416 |
{ |
| 417 |
int n, j; |
| 418 |
|
| 419 |
for(;;) { |
| 420 |
agt_clrscr(); |
| 421 |
writestr("ROOM "); |
| 422 |
print_objid(i+first_room); |
| 423 |
writeln(""); |
| 424 |
writeln(""); |
| 425 |
attrcol=0;attrwidth=2; |
| 426 |
writeattr("1.*WinGame:",room[i].win); |
| 427 |
writeattr("4. Seen:",room[i].seen); |
| 428 |
writeattr("2.*EndGame:",room[i].end); |
| 429 |
writeattr("5. LockedDoor:",room[i].locked_door); |
| 430 |
writeattr("3.*Die:",room[i].killplayer); |
| 431 |
writeln("");writeln(""); |
| 432 |
writeprop("6.*Key =",room[i].key); |
| 433 |
writeprop("7. Light =",room[i].light); |
| 434 |
writenum("8. Points =",room[i].points); |
| 435 |
writeprop("9. Class = ",room[i].oclass); |
| 436 |
writeln(""); |
| 437 |
writeln("EXITS:"); |
| 438 |
for(j=0;j<12;j++) { |
| 439 |
n=writedir(j+10,j,room[i].path[j]); |
| 440 |
if (j%4==3) writeln(""); else padout(15-n); |
| 441 |
} |
| 442 |
writeprop("22. SPECIAL:",room[i].path[12]); |
| 443 |
writeflags("23. Room Flags:",room[i].flag_noun_bits); |
| 444 |
writeln("24. Object properties and attributes."); |
| 445 |
writeln(""); |
| 446 |
writeln("(Fields marked with an * are not saved or restored.)"); |
| 447 |
|
| 448 |
writestr("Field to change (0 to exit)? "); |
| 449 |
n=read_number(); |
| 450 |
if (n==0) return; |
| 451 |
switch (n) |
| 452 |
{ |
| 453 |
case 1:room[i].win=!room[i].win;break; |
| 454 |
case 2:room[i].end=!room[i].end;break; |
| 455 |
case 3:room[i].killplayer=!room[i].killplayer;break; |
| 456 |
case 4:room[i].seen=!room[i].seen;break; |
| 457 |
case 5:room[i].locked_door=!room[i].locked_door;break; |
| 458 |
case 6:room[i].key=readval("Key = ",AGT_ITEM|AGT_NONE);break; |
| 459 |
case 7:room[i].light=readval("Light = ",AGT_ITEM|AGT_NONE|AGT_SELF); |
| 460 |
break; |
| 461 |
case 8:room[i].points=readval("Points = ",AGT_NUM);break; |
| 462 |
case 9:room[i].oclass=readval("Class = ",AGT_ROOM|AGT_NONE);break; |
| 463 |
case 22:room[i].path[12]=readval("SPECIAL: ",AGT_NUM);break; |
| 464 |
case 23:readflags(&room[i].flag_noun_bits);break; |
| 465 |
case 24:edit_objattr(i+first_room);break; |
| 466 |
default: |
| 467 |
if (n>=10 && n<22) { |
| 468 |
room[i].path[n-10]=readval(exitname[n-10],AGT_NUM); |
| 469 |
} |
| 470 |
else writeln("Invalid field"); |
| 471 |
} |
| 472 |
} |
| 473 |
} |
| 474 |
|
| 475 |
|
| 476 |
#define tog(x) {x=!x;break;} |
| 477 |
|
| 478 |
static void noun_edit(int i) |
| 479 |
{ |
| 480 |
int n; |
| 481 |
|
| 482 |
for(;;) { |
| 483 |
agt_clrscr(); |
| 484 |
|
| 485 |
writestr("NOUN "); |
| 486 |
print_objid(i+first_noun); |
| 487 |
|
| 488 |
|
| 489 |
writeprop(" Location=",noun[i].location); |
| 490 |
writeln(""); |
| 491 |
attrcol=0;attrwidth=3; |
| 492 |
writeattr(" 1.*Pushable:",noun[i].pushable); |
| 493 |
writeattr(" 8.*Lockable:",noun[i].lockable); |
| 494 |
writeattr("15.*Drinkable:",noun[i].drinkable); |
| 495 |
writeattr(" 2.*Pullable:",noun[i].pullable); |
| 496 |
writeattr(" 9.*Light:",noun[i].light); |
| 497 |
writeattr("16.*Poisonous:",noun[i].poisonous); |
| 498 |
writeattr(" 3.*Turnable:",noun[i].turnable); |
| 499 |
writeattr("10.*Plural:",noun[i].plural); |
| 500 |
writeattr("17. Open:",noun[i].open); |
| 501 |
writeattr(" 4.*Playable:",noun[i].playable); |
| 502 |
writeattr("11. Movable:",noun[i].movable); |
| 503 |
writeattr("18. Locked:",noun[i].locked); |
| 504 |
writeattr(" 5.*Readable:",noun[i].readable); |
| 505 |
writeattr("12.*Shootable:",noun[i].shootable); |
| 506 |
writeattr("19.*Win Game:",noun[i].win); |
| 507 |
writeattr(" 6.*Wearable:",noun[i].wearable); |
| 508 |
writeattr("13. On:",noun[i].on); |
| 509 |
writeattr("20.*Global:",noun[i].isglobal); |
| 510 |
writeattr(" 7.*Closable:",noun[i].closable); |
| 511 |
writeattr("14.*Edible:",noun[i].edible); |
| 512 |
writeattr("21.*Proper:",noun[i].proper); |
| 513 |
|
| 514 |
writeln(""); |
| 515 |
writenum("22. Shots =",noun[i].num_shots); |
| 516 |
writenum("23. Points =",noun[i].points); |
| 517 |
writenum("24. Weight =",noun[i].weight); |
| 518 |
writenum("25. Size =",noun[i].size); |
| 519 |
writeprop("26.*Key =",noun[i].key); |
| 520 |
writeprop("27. Class =",noun[i].oclass); |
| 521 |
writenum("28. Flag =",noun[i].flagnum); |
| 522 |
writeln(""); |
| 523 |
|
| 524 |
writeln("29. Object properties and attributes."); |
| 525 |
writeln(""); |
| 526 |
writeln("(Fields marked with an * are not saved or restored.)"); |
| 527 |
writestr("Field to change (0 to exit)? "); |
| 528 |
n=read_number(); |
| 529 |
if (n==0) return; |
| 530 |
switch (n) |
| 531 |
{ |
| 532 |
case 1:tog(noun[i].pushable); |
| 533 |
case 2:tog(noun[i].pullable); |
| 534 |
case 3:tog(noun[i].turnable); |
| 535 |
case 4:tog(noun[i].playable); |
| 536 |
case 5:tog(noun[i].readable); |
| 537 |
case 6:tog(noun[i].wearable); |
| 538 |
case 7:tog(noun[i].closable); |
| 539 |
case 8:tog(noun[i].lockable); |
| 540 |
case 9:tog(noun[i].light); |
| 541 |
case 10:tog(noun[i].plural); |
| 542 |
case 11:tog(noun[i].movable); |
| 543 |
case 12:tog(noun[i].shootable); |
| 544 |
case 13:tog(noun[i].on); |
| 545 |
case 14:tog(noun[i].edible); |
| 546 |
case 15:tog(noun[i].drinkable); |
| 547 |
case 16:tog(noun[i].poisonous); |
| 548 |
case 17:tog(noun[i].open); |
| 549 |
case 18:tog(noun[i].locked); |
| 550 |
case 19:tog(noun[i].win); |
| 551 |
case 20:tog(noun[i].isglobal); |
| 552 |
case 21:tog(noun[i].proper); |
| 553 |
|
| 554 |
case 22:noun[i].num_shots=readval("Shots =",AGT_NUM);break; |
| 555 |
case 23:noun[i].points=readval("Points =",AGT_NUM);break; |
| 556 |
case 24:noun[i].weight=readval("Weight =",AGT_NUM);break; |
| 557 |
case 25:noun[i].size=readval("Size =",AGT_NUM);break; |
| 558 |
case 26:noun[i].key=readval("Key =",AGT_ITEM|AGT_NONE);break; |
| 559 |
case 27:noun[i].oclass=readval("Class =",AGT_ITEM|AGT_NONE);break; |
| 560 |
case 28:noun[i].flagnum=readval("Flag Number=",AGT_ROOMFLAG);break; |
| 561 |
case 29:edit_objattr(i+first_noun);break; |
| 562 |
default:writeln("Invalid field"); |
| 563 |
} |
| 564 |
} |
| 565 |
} |
| 566 |
|
| 567 |
|
| 568 |
static void creat_edit(int i) |
| 569 |
{ |
| 570 |
int n; |
| 571 |
|
| 572 |
for(;;) { |
| 573 |
agt_clrscr(); |
| 574 |
writestr("CREATURE "); |
| 575 |
print_objid(i+first_creat); |
| 576 |
writeln(""); |
| 577 |
writeln(""); |
| 578 |
writeprop("Location =",creature[i].location); |
| 579 |
writeln(""); |
| 580 |
attrcol=0;attrwidth=2; |
| 581 |
writeattr(" 1. Hostile:",creature[i].hostile); |
| 582 |
writeattr(" 4. Global:",creature[i].isglobal); |
| 583 |
writeattr(" 2. Grp member:",creature[i].groupmemb); |
| 584 |
writeattr(" 5.*Proper:",creature[i].proper); |
| 585 |
writegender(" 3.*Gender:",creature[i].gender); |
| 586 |
writeln("");writeln(""); |
| 587 |
writeprop(" 6.*Weapon = ",creature[i].weapon); |
| 588 |
writenum(" 7. Points = ",creature[i].points); |
| 589 |
writenum(" 8.*Attack Threshold = ",creature[i].threshold); |
| 590 |
writenum(" 9. Attack counter = ",creature[i].counter); |
| 591 |
writenum("10.*Attack Time Limit = ",creature[i].timethresh); |
| 592 |
writenum("11. Attack timer = ",creature[i].timecounter); |
| 593 |
writeprop("12. Class = ",creature[i].oclass); |
| 594 |
writenum("13. Flag = ",creature[i].flagnum); |
| 595 |
writeln(""); |
| 596 |
writeln("14. Object properties and attributes."); |
| 597 |
writeln(""); |
| 598 |
writeln("(Fields marked with an * are not saved or restored.)"); |
| 599 |
writeln(""); |
| 600 |
writestr("Field to change (0 to exit)? "); |
| 601 |
n=read_number(); |
| 602 |
if (n==0) return; |
| 603 |
switch (n) |
| 604 |
{ |
| 605 |
case 1:tog(creature[i].hostile); |
| 606 |
case 2:tog(creature[i].groupmemb); |
| 607 |
case 3:tog(creature[i].isglobal); |
| 608 |
case 4:tog(creature[i].proper); |
| 609 |
|
| 610 |
case 5:creature[i].gender=readgender();break; |
| 611 |
case 6:creature[i].weapon=readval("Weapon =",AGT_ITEM|AGT_NONE);break; |
| 612 |
case 7:creature[i].points=readval("Points =",AGT_NUM);break; |
| 613 |
case 8:creature[i].threshold=readval("Threshold =",AGT_NUM);break; |
| 614 |
case 9:creature[i].counter=readval("Attack counter =",AGT_NUM);break; |
| 615 |
case 10:creature[i].timethresh=readval("Time limit =",AGT_NUM);break; |
| 616 |
case 11:creature[i].timecounter=readval("Timer =",AGT_NUM);break; |
| 617 |
case 12:creature[i].oclass=readval("Class =",AGT_ITEM|AGT_NONE);break; |
| 618 |
case 13:noun[i].flagnum=readval("Flag Number=",AGT_ROOMFLAG);break; |
| 619 |
case 14:edit_objattr(i+first_creat);break; |
| 620 |
default:writeln("Invalid field"); |
| 621 |
} |
| 622 |
} |
| 623 |
} |
| 624 |
|
| 625 |
#undef tog |
| 626 |
|
| 627 |
|
| 628 |
|
| 629 |
|
| 630 |
|
| 631 |
static void obj_edit(void) |
| 632 |
{ |
| 633 |
int n; |
| 634 |
|
| 635 |
for(;;) { |
| 636 |
writeln(""); |
| 637 |
do { |
| 638 |
writestr("Enter object number (0 to exit)? "); |
| 639 |
n=read_number(); |
| 640 |
if (n<=0) return; |
| 641 |
} while (!troom(n) && !tnoun(n) && !tcreat(n)); |
| 642 |
|
| 643 |
if (troom(n)) room_edit(n-first_room); |
| 644 |
else if (tnoun(n)) noun_edit(n-first_noun); |
| 645 |
else if (tcreat(n)) creat_edit(n-first_creat); |
| 646 |
else writeln("[Not yet implemented]"); |
| 647 |
|
| 648 |
} |
| 649 |
} |
| 650 |
|
| 651 |
static char *yesnostr[]={"No","Yes"}; |
| 652 |
|
| 653 |
static void set_debug_options(void) |
| 654 |
{ |
| 655 |
char buff[80]; |
| 656 |
int n; |
| 657 |
|
| 658 |
for(;;) { |
| 659 |
agt_clrscr(); |
| 660 |
writeln("DEBUGGING OPTIONS:"); |
| 661 |
writeln(""); |
| 662 |
sprintf(buff," 1. Trace metacommands: %s",yesnostr[DEBUG_AGT_CMD]); |
| 663 |
writeln(buff); |
| 664 |
sprintf(buff," 2. Trace ANY metacommands: %s",yesnostr[debug_any]); |
| 665 |
writeln(buff); |
| 666 |
sprintf(buff," 3. Trace during disambiguation: %s", |
| 667 |
yesnostr[debug_disambig]); |
| 668 |
writeln(buff); |
| 669 |
writeln(""); |
| 670 |
writeln("(<2> and <3> are ignored if <1> is not set; option <1> can" |
| 671 |
" also be changed from the main debugging menu)"); |
| 672 |
writeln(""); |
| 673 |
writestr("Option to toggle (0 to exit): "); |
| 674 |
n=read_number(); |
| 675 |
switch(n) |
| 676 |
{ |
| 677 |
case 0:return; |
| 678 |
case 1:DEBUG_AGT_CMD=!DEBUG_AGT_CMD;break; |
| 679 |
case 2:debug_any=!debug_any;break; |
| 680 |
case 3:debug_disambig=!debug_disambig;break; |
| 681 |
default:writeln("Not a valid option"); |
| 682 |
} |
| 683 |
} |
| 684 |
} |
| 685 |
|
| 686 |
|
| 687 |
void get_debugcmd(void) |
| 688 |
{ |
| 689 |
int n; |
| 690 |
|
| 691 |
for(;;) { |
| 692 |
writeln("DEBUGGING COMMANDS"); |
| 693 |
writeln(""); |
| 694 |
writeln("1. Move player 8. List Rooms"); |
| 695 |
writeln("2. Get Noun 9. List Nouns"); |
| 696 |
writeln("3. Move object 10. List Creatures"); |
| 697 |
writeln("4. View/Edit object 11. List/Set Flags"); |
| 698 |
writeln("5. Toggle Trace 12. List/Set Variables"); |
| 699 |
writeln("6. Set Debug Options 13. List/Set Counters"); |
| 700 |
writeln("7. Edit User Strings"); |
| 701 |
writeln(""); |
| 702 |
writestr("Enter choice (0 to exit): "); |
| 703 |
n=read_number(); |
| 704 |
switch(n) |
| 705 |
{ |
| 706 |
case -1: |
| 707 |
case 0:return; |
| 708 |
case 1:d_moveobj(1,-1);break; |
| 709 |
case 2:d_moveobj(-1,1);break; |
| 710 |
case 3:d_moveobj(-1,-1);break; |
| 711 |
case 4:obj_edit();break; |
| 712 |
case 5:DEBUG_AGT_CMD=!DEBUG_AGT_CMD;break; |
| 713 |
case 6:set_debug_options();break; |
| 714 |
case 7:edit_str();break; |
| 715 |
case 8:d_listroom();break; |
| 716 |
case 9:d_listnoun();break; |
| 717 |
case 10:d_listcreat();break; |
| 718 |
case 11:var_edit(2);break; |
| 719 |
case 12:var_edit(0);break; |
| 720 |
case 13:var_edit(1);break; |
| 721 |
default:writeln("Not a valid option"); |
| 722 |
} |
| 723 |
writeln(""); |
| 724 |
}; |
| 725 |
} |