/* adv02.c: Cloak_of_Darkness - copyright Mike Arnautov 2022. Licensed under
 * GPL (version 3 or later) or the Modified BSD Licence, whichever
 * is asserted by the supplied LICENCE file.*/

#include "adv0.h"
#include "adv3.h"
int p5(void)
{
   int lval [1];
   short lbts [1];
   lval[0] = 0;
   lbts [0] = 0;
value[0]=(bitest(evar(34),3));
if(value[0]){
say(2,34,0);
lbts[0*VARSIZE]= -1; lval[0]=FOBJ-1; while (++lval[0]<=LOBJ) {
value[0]=(ishere(lval[0],-1,-1));
if(value[0]){
say(0,lval[0],0);
}}
}else{
say(0,46,0);
}
return 0;
}
int p3(void)
{
move(6,0,11,19,-6); if (loop) return(0);
value[0]=(value[5]>0);
if(value[0]){
value[5] -= 1;
}
value[0]=(bitest(evar(34),3));
if(value[0]){
value[0]=(KEY(21));
if(value[0]){
if (anyof(27,-1))say(72,57,1);
 if (loop) return(0);value[0]=(KEY(5));
if(value[0]){
(*procs[22])();
if (loop) return (0);
}}
return 0;
}
value[0]=(KEY(26));
if(value[0]){
(*procs[26])();
if (loop) return (0);
}
value[0]=(value[5]>0);
if(value[0]){
value[5] -= 1;
}
say(64,45,0);
 if (loop) return(0);return 0;
}
int p4(void)
{
move(6,0,13,19,-6); if (loop) return(0);
value[0]=(keyword(25,4,-1));
if(value[0]){
value[0]=(value[4]==1);
if(value[0]){
say(64,44,0);
 if (loop) return(0);}
set('E',4,'c',1,NULL,NULL);
set('E',3,'c',1,NULL,NULL);
apport(4,HERE);
bitmod('s',8,3);
say(64,41,0);
 if (loop) return(0);}
return 0;
}
int p8(void)
{
move(7,0,-17); if (loop) return(0);
move(8,0,-15); if (loop) return(0);
if (anyof(11,19,-1))say(64,40,0);
 if (loop) return(0);return 0;
}
int p9(void)
{
if (!KEY(4)) return 0;
value[0]=(isnear(4,-1,-1));
if(value[0]){
say(64,43,0);
 if (loop) return(0);}
return 0;
}
int p6(void)
{
say(64,48,0);
 if (loop) return(0);return 0;
}
int p11(void)
{
   int lval [2];
   short lbts [2];
   lval[0] = 0;
   lbts [0] = 0;
   lval[1] = 0;
   lbts [1] = 0;
set('L',0,'c',0,lval, lbts);
lbts[1*VARSIZE]= -1; lval[1]=FOBJ-1; while (++lval[1]<=LOBJ) {
value[0]=(have(lval[1],-1,-1));
if(value[0]){
value[0]=(lval[0]==0);
if(value[0]){
say(0,50,0);
}
say(0,lval[1],0);
lval[0] += 1;
}}
value[0]=(lval[0]==0);
if(value[0]){
say(0,49,0);
}
loop=1; return(0);
return 0;
}
int p12(void)
{
value[0]=(bitest(evar(34),3));
if(!value[0]){
say(64,46,0);
 if (loop) return(0);}
value[0]=(value[32]==1);
if(value[0]){
p5();
if (loop) return (0);
loop=1; return(0);
}
if (anyof(27,-1))say(72,57,0);
 if (loop) return(0);value[0]=(isnear(value[37],-1,-1));
if(value[0]){
say(34,37,0);
}else{
say(12,53,37);
}
loop=1; return(0);
return 0;
}
int p14(void)
{
value[0]=(bitest(evar(34),3));
if(!value[0]){
say(64,46,0);
 if (loop) return(0);}
value[0]=(KEY(5));
value[0]|=(value[32]==1);
value[0]&=(isnear(5,-1,-1));
if(value[0]){
say(12,42,5);
finita();
loop=1; return(0);
}
value[0]=(value[32]==1);
if(value[0]){
say(64,47,0);
 if (loop) return(0);}
return 0;
}
int p7(void)
{
value[0]=(value[32]==1);
if(value[0]){
say(76,55,36);
 if (loop) return(0);}
return 0;
}
int p10(void)
{
say(64,60,0);
 if (loop) return(0);return 0;
}
int p13(void)
{
say(0,54,0);
finita();
loop=1; return(0);
return 0;
}
int p1(void)
{
bitmod('s',6,3);
bitmod('s',7,3);
apport(5,8);
apport(3,7);
apport(4,INHAND);
set('E',5,'c',4,NULL,NULL);
set('V',33,'c',0,NULL,NULL);
move(6,-1);
say(0,39,0);
return 0;
}
int p2(void)
{
value[0]=(bitest(evar(32),0));
if(value[0]){
p5();
if (loop) return (0);
}
set('V',32,'c',99,NULL,NULL);
input(0);
if (loop) return(0);
value[0]=(value[36]==-2);
value[0]|=(value[36]==-3);
if(value[0]){
say(76,51,36);
 if (loop) return(0);}
value[0]=(value[37]==-2);
value[0]|=(value[37]==-3);
if(value[0]){
say(76,51,37);
 if (loop) return(0);}
value[0]=(anyof(12,14,16,18,-1));
if(value[0]){
value[0]=(value[32]==1);
if(value[0]){
say(76,56,36);
 if (loop) return(0);}else{
say(76,56,37);
 if (loop) return(0);}}
if (value[34]<LPROC && value[34]>= 0) (*procs[value[34]])(); else pcall(value[34]);
if (loop) return (0);
if (value[36]<LPROC && value[36]>= 0) (*procs[value[36]])(); else pcall(value[36]);
if (loop) return (0);
value[0]=(value[32]>1);
value[0]&=!(isnear(value[37],-1,-1));
if(value[0]){
say(76,53,37);
 if (loop) return(0);}
value[0]=(value[32]==1);
value[0]&=(11<=value[36] && value[36]<=18);
if(value[0]){
say(76,56,36);
 if (loop) return(0);}
say(64,52,0);
 if (loop) return(0);return 0;
}
