C ROBADV-- STEAL WINNER'S VALUABLES
C
C COPYRIGHT 1980, INFOCOM COMPUTERS AND COMMUNICATIONS, CAMBRIDGE MA. 02142
C ALL RIGHTS RESERVED, COMMERCIAL USAGE STRICTLY PROHIBITED
C WRITTEN BY R. M. SUPNIK
C
C DECLARATIONS
C
	INTEGER FUNCTION ROBADV(ADV,NR,NC,NA)
	IMPLICIT INTEGER (A-Z)
#include "objects.h"
#include "oflags.h"
C
	ROBADV=0
C						!COUNT OBJECTS
	DO 100 I=1,OLNT
	  IF((OADV(I).NE.ADV).OR.(OTVAL(I).LE.0).OR.
&		(and(OFLAG2(I),SCRDBT).NE.0)) GO TO 100
	  CALL NEWSTA(I,0,NR,NC,NA)
C						!STEAL OBJECT
	  ROBADV=ROBADV+1
100	CONTINUE
	RETURN
	END
C ROBRM-- STEAL ROOM VALUABLES
C
C DECLARATIONS
C
	INTEGER FUNCTION ROBRM(RM,PR,NR,NC,NA)
	IMPLICIT INTEGER (A-Z)
	LOGICAL PROB,QHERE
#include "objects.h"
#include "oflags.h"
C
	ROBRM=0
C						!COUNT OBJECTS
	DO 100 I=1,OLNT
C						!LOOP ON OBJECTS.
	  IF(.NOT. QHERE(I,RM)) GO TO 100
	  IF((OTVAL(I).LE.0).OR.(and(OFLAG2(I),SCRDBT).NE.0).OR.
&		(and(OFLAG1(I),VISIBT).EQ.0).OR.(.NOT.PROB(PR,PR)))
&		GO TO 50
	  CALL NEWSTA(I,0,NR,NC,NA)
	  ROBRM=ROBRM+1
	  OFLAG2(I)=or(OFLAG2(I),TCHBT)
	  GO TO 100
50	  IF(and(OFLAG2(I),ACTRBT).NE.0)
&		ROBRM=ROBRM+ROBADV(OACTOR(I),NR,NC,NA)
100	CONTINUE
	RETURN
	END
C WINNIN-- SEE IF VILLAIN IS WINNING
C
C DECLARATIONS
C
	LOGICAL FUNCTION WINNIN(VL,HR)
	IMPLICIT INTEGER (A-Z)
	LOGICAL PROB
#include "objects.h"
C
	VS=OCAPAC(VL)
C						!VILLAIN STRENGTH
	PS=VS-FIGHTS(HR,.TRUE.)
C						!HIS MARGIN OVER HERO
	WINNIN=PROB(90,100)
	IF(PS.GT.3) RETURN
C						!+3... 90% WINNING
	WINNIN=PROB(75,85)
	IF(PS.GT.0) RETURN
C						!>0... 75% WINNING
	WINNIN=PROB(50,30)
	IF(PS.EQ.0) RETURN
C						!=0... 50% WINNING
	WINNIN=PROB(25,25)
	IF(VS.GT.1) RETURN
C						!ANY VILLAIN STRENGTH.
	WINNIN=PROB(10,0)
	RETURN
	END
C FIGHTS-- COMPUTE FIGHT STRENGTH
C
C DECLARATIONS
C
	INTEGER FUNCTION FIGHTS(H,FLG)
	IMPLICIT INTEGER (A-Z)
	LOGICAL FLG
C
C GAME STATE
C
#include "state.h"
#include "advers.h"
C
C FUNCTIONS AND DATA
C
	DATA SMAX/7/,SMIN/2/
C
	FIGHTS=SMIN+((((SMAX-SMIN)*ASCORE(H))+(MXSCOR/2))/MXSCOR)
	IF(FLG) FIGHTS=FIGHTS+ASTREN(H)
	RETURN
	END
C VILSTR-	COMPUTE VILLAIN STRENGTH
C
C DECLARATIONS
C
	INTEGER FUNCTION VILSTR(V)
	IMPLICIT INTEGER (A-Z)
#include "parser.h"
#include "objects.h"
#include "oflags.h"
#include "oindex.h"
#include "villians.h"
#include "flags.h"
C VILSTR, PAGE 2
C
	VILSTR=OCAPAC(V)
	IF(VILSTR.LE.0) RETURN
	IF((V.NE.THIEF).OR..NOT.THFENF) GO TO 100
	THFENF=.FALSE.
C						!THIEF UNENGROSSED.
	VILSTR=MIN0(VILSTR,2)
C						!NO BETTER THAN 2.
C
100	DO 200 I=1,VLNT
C						!SEE IF  BEST WEAPON.
	  IF((VILLNS(I).EQ.V).AND.(PRSI.EQ.VBEST(I)))
&		VILSTR=MAX0(1,VILSTR-1)
200	CONTINUE
	RETURN
	END
