|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T o
Length: 12950 (0x3296)
Types: TextFile
Names: »objsys.c«
└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987
└─⟦this⟧ »EUUGD18/General/Abermud/objsys.c«
#include "kernel.h"
#ifdef RCSID
static char RCS[] =
"$Header: objsys.c,v 1.1 89/03/13 09:37:18 rsalz Exp $";
#endif /* RCSID */
static LEVEL u;
static char *classnam[] =
{
"light", "unlight", "open", "shut", "closed", "locked", "unlocked",
"weapon", "container", "food", "all", NULL
};
static short class_data[] = {
1 << 13, 0,
-999, 0,
1 << 2, 0,
-999, 2,
-999, 2,
1 << 3, 2,
-999, 5,
1 << 15, -1,
1 << 14, -1,
1 << 6, -1,
0, -1
};
inventory()
{
bprintf("You are carrying\n");
lobjsat(mynum);
}
lobjsat(loc)
{
aobjsat(loc, 1, 0);
}
mlobjsat(x, m)
{
aobjsat(x, 1, m);
}
aobjsat(loc, mode, marg) /* Carried Loc ! */
int loc, mode;
{
int ostack[16];
int ostackp;
int a, c, e, f, g;
char x[6], y[6];
ostackp = 0;
for (f = 0; f < marg; f++)
bprintf(" ");
for (e = 0, c = 0; c < numobs; c++) {
g = 0;
if ((iscarrby(c, loc) && mode == 1)
|| (iscontin(c, loc) && mode == 3)) {
e = 1;
g = 1;
f += 1 + strlen(oname(c));
if (debug_mode) {
f += 5;
sprintf(x, "%d", c);
sprintf(y, "{%-3s}", x);
}
if (otstbit(c, 0))
f += 2;
if (iswornby(c, loc))
f += strlen("<worn> ");
if (f > 79) {
bprintf("\n");
for (f = 0; f < marg; f++)
bprintf(" ");
}
if (otstbit(c, 0))
bprintf("(");
bprintf("%s", oname(c));
if (debug_mode)
bprintf(y);
if (iswornby(c, loc))
bprintf(" <worn>");
if (otstbit(c, 0))
bprintf(")");
bprintf(" ");
if (otstbit(c, 14) && g && (!otstbit(c, 2) || state(c) == 0)) {
ostack[ostackp++] = c;
f++;
}
}
}
if (!e)
bprintf("Nothing");
bprintf("\n");
for (f = 0; f < ostackp; f++) {
for (a = 0; a < marg; a++)
bprintf(" ");
bprintf(" The %s contains\n", oname(ostack[f]));
pbfr();
aobjsat(ostack[f], 3, marg + 8);
}
}
iscontin(o1, o2)
int o1, o2;
{
if (ocarrf(o1) != 3 || oloc(o1) != o2)
return 0;
if (plev(mynum) < 10 && otstbit(o1, 0))
return 0;
return 1;
}
brkwordw(x)
char *x;
{
strcpy(x, brkword() == -1 ? "<nothing>" : wordbuf);
}
fobnsys(nam, ctrl, ct_inf)
char *nam;
int ctrl, ct_inf;
{
int a;
int v = 0;
char l1[128], l2[128];
lowercase(strcpy(l1, nam));
skicand = 0;
if (EQ(l1, "first")) {
v = 1;
brkwordw(l1);
}
if (EQ(l1, "second")) {
v = 2;
brkwordw(l1);
}
if (EQ(l1, "third")) {
v = 3;
brkwordw(l1);
}
if (EQ(l1, "fourth")) {
v = 4;
brkwordw(l1);
}
if (EQ(l1, "fifth")) {
v = 5;
brkwordw(l1);
}
if (EQ(l1, "sixth")) {
v = 6;
brkwordw(l1);
}
if (EQ(l1, "green"))
skicand = 1;
if (EQ(l1, "red"))
skicand = 1;
if (EQ(l1, "blue"))
skicand = 1;
for (a = 0; a < numobs; a++) {
strcpy(l2, oname(a));
if (EQ(l1, lowercase(l2)) || EQ(l1, oaltname(a)) && --v < 1) {
strcpy(wd_it, nam);
switch (ctrl) {
case 0:
return a;
case 1: /* Patch for shields */
if (a == 112 && iscarrby(113, mynum))
return 113;
if (a == 112 && iscarrby(114, mynum))
return 114;
if (isavl(a))
return a;
break;
case 2:
if (iscarrby(a, mynum))
return a;
break;
case 3:
if (iscarrby(a, ct_inf))
return a;
break;
case 4:
if (ishere(a))
return a;
break;
case 5:
if (iscontin(a, ct_inf))
return a;
break;
default:
return a;
}
}
}
return -1;
}
fobn(word)
char *word;
{
int x;
if ((x = fobna(word)) != -1)
return x;
return fobnsys(word, 0, 0);
}
fobna(word)
char *word;
{
return fobnsys(word, 1, 0);
}
fobnin(word, ct)
char *word;
int ct;
{
return fobnsys(word, 5, ct);
}
fobnc(word)
char *word;
{
return fobnsys(word, 2, 0);
}
fobncb(word, by)
char *word;
{
return fobnsys(word, 3, by);
}
fobnh(word)
char *word;
{
return fobnsys(word, 4, 0);
}
getobj()
{
int a;
int i;
int des_inf = -1;
char bf[256];
if (brkword() == -1) {
bprintf("Get what ?\n");
return -1;
}
if (findclass(wordbuf) != -1) {
getall();
return 0;
}
a = fobnh(wordbuf);
/* Hold */
i = stp;
strcpy(bf, wordbuf);
if (brkword() != -1 && (EQ(wordbuf, "from") || EQ(wordbuf, "out"))) {
if (brkword() == -1) {
bprintf("From what ?\n");
return -1;
}
if ((des_inf = fobna(wordbuf)) == -1) {
bprintf("You can't take things from that - it's not here\n");
return -1;
}
a = fobnin(bf, des_inf);
}
stp = i;
if (a == -1) {
bprintf("That is not here.\n");
return -1;
}
if (a == 112 && ishere(113))
a = 113;
if (a == 112 && ishere(114))
a = 114;
if (a == 112 && des_inf == -1) {
if (otstbit(113, 0))
a = 113;
else if (otstbit(114, 0))
a = 114;
if (a == 113 || a == 114)
oclrbit(a, 0);
else {
bprintf("The shields are all to firmly secured to the walls\n");
return 0;
}
}
if (oflannel(a) == 1) {
bprintf("You can't take that!\n");
return -1;
}
if (des_inf == -1 || !iscarrby(des_inf, mynum))
if (dragget())
return -1;
if (!cancarry(mynum)) {
bprintf("You can't carry any more\n");
return -1;
}
if (a == 32 && state(a) == 1 && ptothlp(mynum) == -1) {
bprintf("Its too well embedded to shift alone.\n");
return 0;
}
setoloc(a, mynum, 1);
sprintf(bf, "\001D%s\001\001c takes the %s\n\001", pname(mynum), oname(a));
if (des_inf != -1)
sprintf(bf, "\001D%s\001\001c takes the %s from the %s\n\001",
pname(mynum), oname(a), oname(des_inf));
bprintf("Ok...\n");
sendsys(pname(mynum), pname(mynum), -10000, ploc(mynum), bf);
if (otstbit(a, 12))
setobjstate(a, 0);
if ((ploc(mynum) == -1081) && (state(20) == 0)) {
setobjstate(20, 1);
bprintf("The door clicks shut....\n");
}
return 0;
}
getall()
{
int x;
int cl;
cl = findclass(wordbuf);
if (isdark()) {
bprintf("Its dark!\n");
return;
}
if (brkword() != -1) {
getallfr();
return;
}
for (x = 0; x < numobs; x++) {
if (ishere(x) && !oflannel(x) && classmatch(x, cl)) {
sprintf(strbuf, "%s", oname(x));
stp = 0;
bprintf("%s:\n", oname(x));
if (getobj() == -1)
break;
}
}
}
getallfr()
{
int a, x;
int cl;
cl = findclass(wordbuf);
if (brkword() == -1) {
bprintf("From what ?\n");
return;
}
if ((a = fobna(wordbuf)) == -1) {
bprintf("That isn't here.\n");
return;
}
/* Do items */
for (x = 0; x < numobs; x++) {
if (iscontin(x, a) && !oflannel(x) && classmatch(x, cl)) {
sprintf(strbuf, "%s from %s", oname(x), oname(a));
stp = 0;
bprintf("%s:\n", oname(x));
if (getobj() == -1)
break;
}
}
}
dropall()
{
int x;
int cl;
for (cl = findclass(wordbuf), x = 0; x < numobs; x++) {
if (iscarrby(x, mynum) && classmatch(x, cl)) {
sprintf(strbuf, "%s", oname(x));
stp = 0;
bprintf("%s:\n", oname(x));
if (dropitem() == -1)
return;
}
}
}
ishere(item)
int item;
{
if (plev(mynum) < 10 && otstbit(item, 0))
return 0;
if (ocarrf(item) == 1 || oloc(item) != ploc(mynum))
return 0;
return 1;
}
iscarrby(item, user)
int item, user;
{
if (plev(mynum) < 10 && otstbit(item, 0))
return 0;
if (ocarrf(item) != 1 && ocarrf(item) != 2)
return 0;
if (oloc(item) != user)
return 0;
return 1;
}
dropitem()
{
int a;
char bf[80];
if (brkword() == -1) {
bprintf("Drop what ?\n");
return -1;
}
if (findclass(wordbuf) != -1) {
dropall();
return 0;
}
if ((a = fobnc(wordbuf)) == -1) {
bprintf("You are not carrying that.\n");
return -1;
}
if (plev(mynum) < 10 && a == 32) {
bprintf("You can't let go of it!\n");
return 0;
}
setoloc(a, ploc(mynum), 0);
bprintf("OK..\n");
sprintf(bf, "\001D%s\001\001c drops the %s.\n\n\001",
pname(mynum), oname(a));
sendsys(pname(mynum), pname(mynum), -10000, ploc(mynum), bf);
if (ploc(mynum) != -183 && ploc(mynum) != -5)
return 0;
sprintf(bf, "The %s disappears into the bottomless pit.\n", oname(a));
bprintf("It disappears down into the bottomless pit.....\n");
sendsys(pname(mynum), pname(mynum), -10000, ploc(mynum), bf);
setpscore(mynum, pscore(mynum) + (tscale() * obaseval(a)) / 9);
calibme();
setoloc(a, -6, 0);
return 0;
}
lisobs()
{
lojal2(1);
showwthr();
lojal2(0);
}
lojal2(n)
int n;
{
int a;
for (a = 0; a < numobs; a++) {
if (ishere(a) && oflannel(a) == n) {
if (state(a) > 3)
continue;
if (!EMPTY(olongt(a, state(a)))) { /* OLONGT NOTE TO BE ADDED */
if (otstbit(a, 0))
bprintf("--");
oplong(a);
strcpy(wd_it, oname(a));
}
else if (my_lev > 9999)
bprintf("<marker>%s\n", oname(a));
}
}
}
dumpitems()
{
dumpstuff(mynum, ploc(mynum));
}
dumpstuff(n, loc)
int n, loc;
{
int b;
for (b = 0; b < numobs; b++)
if (iscarrby(b, n))
setoloc(b, loc, 0);
}
whocom()
{
whop2(0, 0, 47);
}
whop2(mode, st, end)
int mode, st, end;
{
int a;
int bas;
bas = 16;
if (plev(mynum) > 9 && !mode) {
bprintf("Players\n");
bas = 64;
}
a = 0;
if (mode) {
bas = end;
a = st;
}
for (; a < bas; a++) {
if (!mode && a == 16)
bprintf("----------\nMobiles\n");
if (EMPTY(pname(a)))
continue;
if (seeplayer(a) && mode) {
bprintf("%-14s", pname(a));
if (mode)
bprintf(ptstflg(a, 14) ? "*" : " ");
}
else
dispuser(a);
if (mode && seeplayer(a)) {
if (plev(mynum) > 9)
desrm(ploc(a), 0);
else
bprintf("\n");
}
}
bprintf("\n");
}
dispuser(ubase)
int ubase;
{
if (pstr(ubase) < 0 || pvis(ubase) > plev(mynum))
return;
if (pvis(ubase))
bprintf("(");
bprintf("%s ", pname(ubase));
disl4(plev(ubase), psex(ubase));
if (pvis(ubase))
bprintf(")");
if (ppos(ubase) == -2)
bprintf(" [Absent From Reality]");
bprintf("\n");
}
disle3(n, s)
int n, s;
{
disl4(n, s);
bprintf("\n");
}
disl4(n, s)
int n, s; /* n is level, s is sex */
{
FILE *fp;
char line[150];
int flag;
if ((fp = fopen(LEVEL_FILE, "r")) == NULL)
crapup("Wot! No levels...");
for (flag = 0; fgets(line, sizeof line, fp); ) {
unpack(line);
if (n == u.level) {
flag = 1;
break;
}
}
fclose(fp);
if (!flag) {
if (n >= 0)
bprintf("The Cardboard Box");
return;
}
if (!*u.m_name)
bprintf(u.f_name);
else if (s)
bprintf(u.f_name);
else
bprintf(u.m_name);
}
unpack(line)
char *line;
{
char c, *ptr2, *ptr = line;
while (*ptr++ != ':');
*(ptr - 1) = '\0';
u.level = atoi(line);
ptr2 = u.f_name;
while ((c = *ptr++) != ':') {
if (c == '\n') {
*u.m_name = '\0';
*ptr2 = '\0';
return;
}
*ptr2++ = c;
}
*ptr2 = '\0';
ptr2 = u.m_name;
while ((*ptr2++ = *ptr++) != '\n');
*--ptr2 = '\0';
}
fpbn(name)
char *name;
{
int s;
if ((s = fpbns(name)) == -1)
return s;
return seeplayer(s) ? s : -1;
}
fpbns(name)
char *name;
{
char n1[40], n2[40];
register int a;
for (a = 0; a < 64; a++) {
lowercase(strcpy(n1, name));
lowercase(strcpy(n2, pname(a)));
lowercase(n2);
if (!EMPTY(n2) && EQ(n1, n2))
return a;
if (strncmp(n2, "the ", 4) == 0)
if (!EMPTY(n2) && EQ(n1, n2 + 4))
return a;
}
return -1;
}
lispeople()
{
int a;
for (a = 0; a < 64; a++) {
if (a == mynum)
continue;
if (!EMPTY(pname(a)) && ploc(a) == ploc(mynum) && seeplayer(a)) {
if (a > 15) {
bprintf("%s", pftxt[a - 16]);
if (debug_mode)
bprintf("{%d}", a);
if (gotanything(a))
bprintf("\n%s is", pname(a));
else
bprintf("\n");
}
else {
bprintf("%s ", pname(a));
if (debug_mode)
bprintf("{%d}", a);
disl4(plev(a), psex(a));
if (psex(a))
strcpy(wd_her, pname(a));
else
strcpy(wd_him, pname(a));
bprintf(" is here");
if (!gotanything(a))
bprintf(".\n");
}
if (gotanything(a)) {
bprintf(" carrying\n");
mlobjsat(a, 8);
}
}
}
}
usercom()
{
whop2(1, 0, 15);
}
oplong(x)
int x;
{
if (debug_mode) {
bprintf("{%d} %s\n", x, olongt(x, state(x)));
return;
}
if (!EMPTY(olongt(x, state(x))))
bprintf("%s\n", olongt(x, state(x)));
}
gotanything(x)
int x;
{
int ct;
for (ct = 0; ct < numobs; ct++)
if (iscarrby(ct, x))
return 1;
return 0;
}
findclass(n)
char *n;
{
int a;
for (a = 0; classnam[a]; a++)
if (EQ(classnam[a], n))
return a;
return -1;
}
classmatch(ob, cl)
int ob, cl;
{
int neg;
if (cl == -1)
return 1;
neg = 0;
if (class_data[cl * 2] == -999) {
neg = 1;
cl = class_data[cl * 2 + 1];
}
if (class_data[cl * 2 + 1] >= 0 && class_data[cl * 2 + 1] != state(ob))
return neg;
if (otstmask(ob, class_data[cl * 2]) == 0)
return neg;
return 1 - neg;
}