tCop configuration stuff updated; PolicePresence now used for dropping drugs - vaccinewars - be a doctor and try to vaccinate the world
(HTM) git clone git://src.adamsgaard.dk/vaccinewars
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit b947413073f021dad64d7f2b19dbaa4873fe8bb4
(DIR) parent 275f3dd7e8490d3e45d805a7ce1736d5d17f5d7d
(HTM) Author: Ben Webb <ben@salilab.org>
Date: Sun, 12 Nov 2000 19:41:09 +0000
Cop configuration stuff updated; PolicePresence now used for dropping drugs
Diffstat:
M src/dopewars.c | 88 ++++++++++++++++++++-----------
M src/dopewars.h | 26 ++++++++++++--------------
M src/message.c | 8 ++++----
M src/serverside.c | 52 ++++++++++++++++++++-----------
4 files changed, 106 insertions(+), 68 deletions(-)
---
(DIR) diff --git a/src/dopewars.c b/src/dopewars.c
t@@ -103,8 +103,7 @@ GScannerConfig ScannerConfig = {
struct LOCATION StaticLocation,*Location=NULL;
struct DRUG StaticDrug,*Drug=NULL;
struct GUN StaticGun,*Gun=NULL;
-struct COP *Cop=NULL;
-struct COPS Cops = { 70,2,65,2,5,2,30 };
+struct COP StaticCop,*Cop=NULL;
struct NAMES Names = { NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
NULL,NULL,NULL,NULL };
struct NAMES DefaultNames = {
t@@ -164,7 +163,7 @@ struct GLOBALS Globals[NUMGLOB] = {
{ &Sanitized,NULL,NULL,NULL,"Sanitized",N_("Random events are sanitized"),
NULL,NULL,0,"",NULL,NULL },
{ &DrugValue,NULL,NULL,NULL,"DrugValue",
- N_("Non-zero if the total value of bought drugs should be stored"),
+ N_("Non-zero if the value of bought drugs should be saved"),
NULL,NULL,0,"",NULL,NULL },
{ &ConfigVerbose,NULL,NULL,NULL,"ConfigVerbose",
N_("Be verbose in processing config file"),NULL,NULL,0,"",NULL,NULL },
t@@ -172,6 +171,9 @@ struct GLOBALS Globals[NUMGLOB] = {
N_("Number of locations in the game"),
(void **)(&Location),NULL,sizeof(struct LOCATION),"",NULL,
ResizeLocations },
+ { &NumCop,NULL,NULL,NULL,"NumCop",
+ N_("Number of types of cop in the game"),
+ (void **)(&Cop),NULL,sizeof(struct COP),"",NULL,ResizeCops },
{ &NumGun,NULL,NULL,NULL,"NumGun",N_("Number of guns in the game"),
(void **)(&Gun),NULL,sizeof(struct GUN),"",NULL,ResizeGuns },
{ &NumDrug,NULL,NULL,NULL,"NumDrug",N_("Number of drugs in the game"),
t@@ -231,6 +233,36 @@ struct GLOBALS Globals[NUMGLOB] = {
N_("Maximum number of drugs at each location"),
(void **)(&Location),&StaticLocation,
sizeof(struct LOCATION),"Location",&NumLocation,NULL },
+ { NULL,NULL,&StaticCop.Name,NULL,"Name",
+ N_("Name of each cop"),
+ (void **)(&Cop),&StaticCop,sizeof(struct COP),"Cop",&NumCop,NULL },
+ { NULL,NULL,&StaticCop.DeputyName,NULL,"DeputyName",
+ N_("Name of each cop's deputy"),
+ (void **)(&Cop),&StaticCop,sizeof(struct COP),"Cop",&NumCop,NULL },
+ { NULL,NULL,&StaticCop.DeputiesName,NULL,"DeputiesName",
+ N_("Name of each cop's deputies"),
+ (void **)(&Cop),&StaticCop,sizeof(struct COP),"Cop",&NumCop,NULL },
+ { &StaticCop.Health,NULL,NULL,NULL,"Health",
+ N_("Health of each cop"),
+ (void **)(&Cop),&StaticCop,sizeof(struct COP),"Cop",&NumCop,NULL },
+ { &StaticCop.DeputyHealth,NULL,NULL,NULL,"DeputyHealth",
+ N_("Health of each cop's deputy"),
+ (void **)(&Cop),&StaticCop,sizeof(struct COP),"Cop",&NumCop,NULL },
+ { &StaticCop.AttackPenalty,NULL,NULL,NULL,"AttackPenalty",
+ N_("Attack penalty relative to a player"),
+ (void **)(&Cop),&StaticCop,sizeof(struct COP),"Cop",&NumCop,NULL },
+ { &StaticCop.DefendPenalty,NULL,NULL,NULL,"DefendPenalty",
+ N_("Defend penalty relative to a player"),
+ (void **)(&Cop),&StaticCop,sizeof(struct COP),"Cop",&NumCop,NULL },
+ { &StaticCop.MinDeputies,NULL,NULL,NULL,"MinDeputies",
+ N_("Minimum number of accompanying deputies"),
+ (void **)(&Cop),&StaticCop,sizeof(struct COP),"Cop",&NumCop,NULL },
+ { &StaticCop.MaxDeputies,NULL,NULL,NULL,"MaxDeputies",
+ N_("Maximum number of accompanying deputies"),
+ (void **)(&Cop),&StaticCop,sizeof(struct COP),"Cop",&NumCop,NULL },
+ { &StaticCop.GunIndex,NULL,NULL,NULL,"GunIndex",
+ N_("Zero-based index of the gun that cops are armed with"),
+ (void **)(&Cop),&StaticCop,sizeof(struct COP),"Cop",&NumCop,NULL },
{ NULL,NULL,&StaticDrug.Name,NULL,"Name",
N_("Name of each drug"),
(void **)(&Drug),&StaticDrug,
t@@ -283,27 +315,6 @@ struct GLOBALS Globals[NUMGLOB] = {
N_("Damage done by each gun"),
(void **)(&Gun),&StaticGun,
sizeof(struct GUN),"Gun",&NumGun,NULL },
- { &(Cops.EscapeProb),NULL,NULL,NULL,"Cops.EscapeProb",
- N_("% probability of escaping from Officer Hardass"),
- NULL,NULL,0,"",NULL,NULL },
- { &(Cops.DeputyEscape),NULL,NULL,NULL,"Cops.DeputyEscape",
- N_("Modifier to EscapeProb for each extra deputy"),
- NULL,NULL,0,"",NULL,NULL },
- { &(Cops.HitProb),NULL,NULL,NULL,"Cops.HitProb",
- N_("% probability that Officer Hardass hits you"),
- NULL,NULL,0,"",NULL,NULL },
- { &(Cops.DeputyHit),NULL,NULL,NULL,"Cops.DeputyHit",
- N_("Modifier to HitProb for each extra deputy"),
- NULL,NULL,0,"",NULL,NULL },
- { &(Cops.Damage),NULL,NULL,NULL,"Cops.Damage",
- N_("Maximum damage done to you by each cop"),
- NULL,NULL,0,"",NULL,NULL },
- { &(Cops.Toughness),NULL,NULL,NULL,"Cops.Toughness",
- N_("Toughness of (difficulty of hitting) each cop"),
- NULL,NULL,0,"",NULL,NULL },
- { &(Cops.DropProb),NULL,NULL,NULL,"Cops.DropProb",
- N_("% probability that the cops catch you dropping drugs"),
- NULL,NULL,0,"",NULL,NULL },
{ NULL,NULL,&Names.Bitch,NULL,"Names.Bitch",
N_("Word used to denote a single \"bitch\""),NULL,NULL,0,"",NULL,NULL },
{ NULL,NULL,&Names.Bitches,NULL,"Names.Bitches",
t@@ -396,8 +407,9 @@ char *DefaultStoppedTo[NUMSTOPPEDTO] = {
};
struct COP DefaultCop[NUMCOP] = {
- { N_("Officer Hardass"),N_("deputy"),N_("deputies") },
- { N_("Officer Bob"),N_("deputy"),N_("deputies") }
+ { N_("Officer Hardass"),N_("deputy"),N_("deputies"),2,2,30,30,2,8,0 },
+ { N_("Officer Bob"),N_("deputy"),N_("deputies"),6,4,30,20,4,10,0 },
+ { N_("Agent Smith"),N_("cop"),N_("cops"),20,6,20,20,6,18,1 }
};
struct GUN DefaultGun[NUMGUN] = {
t@@ -491,7 +503,7 @@ int CountPlayers(GSList *First) {
int count=0;
for (list=First;list;list=g_slist_next(list)) {
Play=(Player *)list->data;
- if (strlen(GetPlayerName(Play))>0 && !Play->IsCop) count++;
+ if (strlen(GetPlayerName(Play))>0 && !IsCop(Play)) count++;
}
return count;
}
t@@ -532,7 +544,7 @@ GSList *AddPlayer(int fd,Player *NewPlayer,GSList *First) {
NewPlayer->Debt=StartDebt;
NewPlayer->Bank=0;
NewPlayer->Bitches.Carried=8;
- NewPlayer->IsCop=FALSE;
+ NewPlayer->CopIndex=0;
NewPlayer->Health=MaxHealth(NewPlayer,NewPlayer->Bitches.Carried);
NewPlayer->CoatSize=100;
NewPlayer->Flags=0;
t@@ -559,7 +571,7 @@ GSList *RemovePlayer(Player *Play,GSList *First) {
g_assert(First);
First=g_slist_remove(First,(gpointer)Play);
- if (Server && !Play->IsCop && Play->fd>=0) {
+ if (Server && !IsCop(Play) && Play->fd>=0) {
CloseSocket(Play->fd);
}
ClearList(&(Play->SpyList));
t@@ -591,12 +603,17 @@ void CopyPlayer(Player *Dest,Player *Src) {
}
int MaxHealth(Player *Play,int NumBitches) {
- if (Play->IsCop)
- return (5+NumBitches*2);
+ if (IsCop(Play))
+ return (Cop[Play->CopIndex-1].Health+
+ NumBitches*Cop[Play->CopIndex-1].DeputyHealth);
else
return (80+NumBitches*20);
}
+gboolean IsCop(Player *Play) {
+ return (Play->CopIndex>0);
+}
+
char *GetPlayerName(Player *Play) {
if (Play->Name) return Play->Name;
else return "";
t@@ -630,7 +647,7 @@ Player *GetPlayerByName(char *Name,GSList *First) {
if (Name==NULL || Name[0]==0) return &Noone;
for (list=First;list;list=g_slist_next(list)) {
Play=(Player *)list->data;
- if (!Play->IsCop && strcmp(GetPlayerName(Play),Name)==0) return Play;
+ if (!IsCop(Play) && strcmp(GetPlayerName(Play),Name)==0) return Play;
}
return NULL;
}
t@@ -1121,6 +1138,13 @@ void CopyCop(struct COP *dest,struct COP *src) {
AssignName(&dest->Name,_(src->Name));
AssignName(&dest->DeputyName,_(src->DeputyName));
AssignName(&dest->DeputiesName,_(src->DeputiesName));
+ dest->Health=src->Health;
+ dest->DeputyHealth=src->DeputyHealth;
+ dest->AttackPenalty=src->AttackPenalty;
+ dest->DefendPenalty=src->DefendPenalty;
+ dest->MinDeputies=src->MinDeputies;
+ dest->MaxDeputies=src->MaxDeputies;
+ dest->GunIndex=src->GunIndex;
}
void CopyGun(struct GUN *dest,struct GUN *src) {
(DIR) diff --git a/src/dopewars.h b/src/dopewars.h
t@@ -80,11 +80,6 @@ typedef struct ABILITIES {
gboolean Shared[A_NUM];
} Abilities;
-struct COPS {
- int EscapeProb,DeputyEscape,HitProb,DeputyHit,Damage,
- Toughness,DropProb;
-};
-
struct NAMES {
gchar *Bitch,*Bitches,*Gun,*Guns,*Drug,*Drugs,*Month,*Year,
*Officer,*ReserveOfficer,*LoanSharkName,*BankName,
t@@ -122,7 +117,6 @@ extern int MaxClients,AITurnPause;
extern struct PRICES Prices;
extern struct BITCH Bitch;
extern price_t StartCash,StartDebt;
-extern struct COPS Cops;
extern struct NAMES Names;
extern struct METASERVER MetaServer;
extern int NumTurns;
t@@ -146,7 +140,7 @@ extern int NumTurns;
#define NUMDRUG 12
#define NUMGUN 4
-#define NUMCOP 2
+#define NUMCOP 3
#define NUMLOCATION 8
#define ESCAPE 0
t@@ -185,11 +179,6 @@ extern int NumTurns;
#define CANSHOOT 64
#define TRADING 128
-#define LISTONLY 0
-#define PAGETO 1
-#define SELECTTIP 2
-#define SELECTSPY 3
-
#define E_NONE 0
#define E_SUBWAY 1
#define E_OFFOBJECT 2
t@@ -213,6 +202,10 @@ extern int NumTurns;
struct COP {
gchar *Name,*DeputyName,*DeputiesName;
+ gint Health,DeputyHealth;
+ gint AttackPenalty,DefendPenalty;
+ gint MinDeputies,MaxDeputies;
+ gint GunIndex;
};
extern struct COP DefaultCop[NUMCOP],*Cop;
t@@ -298,7 +291,11 @@ struct PLAYER_T {
ConnBuf ReadBuf,WriteBuf;
Abilities Abil;
GPtrArray *FightArray;
- gint IsCop;
+ gint CopIndex; /* if >0, then this player is a cop, described
+ by Cop[CopIndex-1]
+ if ==0, this is a normal player that has killed no cops
+ if <0, then this is a normal player, who has killed
+ cops up to Cop[-1-CopIndex] */
};
#define CM_SERVER 0
t@@ -312,7 +309,7 @@ typedef struct tag_serverdata {
char *Comment,*Version,*Update,*UpSince;
} ServerData;
-#define NUMGLOB 80
+#define NUMGLOB 84
struct GLOBALS {
int *IntVal;
price_t *PriceVal;
t@@ -397,4 +394,5 @@ void PrintConfigValue(int GlobalIndex,int StructIndex,gboolean IndexGiven,
GScanner *scanner);
void SetConfigValue(int GlobalIndex,int StructIndex,gboolean IndexGiven,
GScanner *scanner);
+gboolean IsCop(Player *Play);
#endif
(DIR) diff --git a/src/message.c b/src/message.c
t@@ -175,7 +175,7 @@ void SendServerMessage(Player *From,char AICode,char Code,
/* code "AICode", human-readable code "Code" and data "Data", claiming */
/* to be from player "From" */
GString *text;
- if (To->IsCop) return;
+ if (IsCop(To)) return;
text=g_string_new(NULL);
if (HaveAbility(To,A_PLAYERID)) {
if (From) g_string_sprintfa(text,"%d",From->ID);
t@@ -1093,9 +1093,9 @@ void FormatFightMessage(Player *To,GString *text,Player *Attacker,
int Health,Bitches;
gchar *BitchName,*BitchesName;
- if (Defender && Defender->IsCop) {
- BitchName=Cop[Defender->IsCop-1].DeputyName;
- BitchesName=Cop[Defender->IsCop-1].DeputiesName;
+ if (Defender && IsCop(Defender)) {
+ BitchName=Cop[Defender->CopIndex-1].DeputyName;
+ BitchesName=Cop[Defender->CopIndex-1].DeputiesName;
} else {
BitchName=Names.Bitch;
BitchesName=Names.Bitches;
(DIR) diff --git a/src/serverside.c b/src/serverside.c
t@@ -249,7 +249,7 @@ void HandleServerMessage(gchar *buf,Player *Play) {
SetPlayerName(Play,Data);
for (list=FirstServer;list;list=g_slist_next(list)) {
pt=(Player *)list->data;
- if (pt!=Play && !pt->IsCop) SendPlayerDetails(pt,Play,C_LIST);
+ if (pt!=Play && !IsCop(pt)) SendPlayerDetails(pt,Play,C_LIST);
}
SendServerMessage(NULL,C_NONE,C_ENDLIST,Play,NULL);
RegisterWithMetaServer(TRUE,FALSE);
t@@ -664,7 +664,7 @@ gboolean HandleServerCommand(char *string) {
g_print(_("Users currently logged on:-\n"));
for (list=FirstServer;list;list=g_slist_next(list)) {
tmp=(Player *)list->data;
- if (!tmp->IsCop) g_print("%s\n",GetPlayerName(tmp));
+ if (!IsCop(tmp)) g_print("%s\n",GetPlayerName(tmp));
}
} else g_message(_("No users currently logged on!"));
} else if (strncasecmp(string,"push ",5)==0) {
t@@ -754,7 +754,7 @@ void ServerLoop() {
topsock=ListenSock+1;
for (list=FirstServer;list;list=g_slist_next(list)) {
tmp=(Player *)list->data;
- if (!tmp->IsCop && tmp->fd>0) {
+ if (!IsCop(tmp) && tmp->fd>0) {
FD_SET(tmp->fd,&readfs);
if (tmp->WriteBuf.DataPresent) FD_SET(tmp->fd,&writefs);
FD_SET(tmp->fd,&errorfs);
t@@ -1184,18 +1184,23 @@ int SendCopOffer(Player *To,char Force) {
void CopsAttackPlayer(Player *Play) {
/* Has the cops attack player "Play" */
Player *Cops;
- gint CopIndex;
+ gint CopIndex,NumDeputy,GunIndex;
- CopIndex=brandom(1,NumCop+1);
+ CopIndex=1-Play->CopIndex;
+ if (CopIndex > NumCop) CopIndex=NumCop;
Cops=g_new(Player,1);
FirstServer=AddPlayer(0,Cops,FirstServer);
SetPlayerName(Cops,Cop[CopIndex-1].Name);
- Cops->IsCop=CopIndex;
+ Cops->CopIndex=CopIndex;
Cops->Cash=Cops->Debt=0;
- Cops->Bitches.Carried=10;
- Cops->Guns[0].Carried=5;
- Cops->Health=MaxHealth(Cops,Cops->Bitches.Carried);
+ NumDeputy=brandom(Cop[CopIndex-1].MinDeputies,
+ Cop[CopIndex-1].MaxDeputies);
+ Cops->Bitches.Carried=NumDeputy;
+ GunIndex=Cop[CopIndex-1].GunIndex;
+ if (GunIndex>=NumGun) GunIndex=NumGun-1;
+ Cops->Guns[GunIndex].Carried=NumDeputy+1;
+ Cops->Health=MaxHealth(Cops,NumDeputy);
Play->EventNum++;
AttackPlayer(Cops,Play);
t@@ -1302,10 +1307,10 @@ void GetFightRatings(Player *Attack,Player *Defend,
for (i=0;i<NumGun;i++) {
*AttackRating+=Gun[i].Damage*Attack->Guns[i].Carried;
}
- if (Attack->IsCop) *AttackRating-=30;
+ if (IsCop(Attack)) *AttackRating-=Cop[Attack->CopIndex-1].AttackPenalty;
*DefendRating-=5*Defend->Bitches.Carried;
- if (Defend->IsCop) *DefendRating-=30;
+ if (IsCop(Defend)) *DefendRating-=Cop[Defend->CopIndex-1].DefendPenalty;
*DefendRating=MAX(*DefendRating,10);
*AttackRating=MAX(*AttackRating,10);
t@@ -1327,11 +1332,11 @@ void DoReturnFire(Player *Play) {
if (!Play || !Play->FightArray) return;
- if (FightTimeout!=0 || !Play->IsCop) {
+ if (FightTimeout!=0 || !IsCop(Play)) {
for (ArrayInd=0;Play->FightArray && ArrayInd<Play->FightArray->len;
ArrayInd++) {
Defend=(Player *)g_ptr_array_index(Play->FightArray,ArrayInd);
- if (Defend->IsCop && CanPlayerFire(Defend)) Fire(Defend);
+ if (IsCop(Defend) && CanPlayerFire(Defend)) Fire(Defend);
}
}
}
t@@ -1340,6 +1345,9 @@ void RunFromCombat(Player *Play) {
/* Withdraws player "Play" from combat, and levies any penalties on */
/* the player for this cowardly act, if applicable */
int EscapeProb,RandNum;
+ int ArrayInd;
+ gboolean FightingCop=FALSE;
+ Player *Defend;
if (!Play || !Play->FightArray) return;
t@@ -1347,6 +1355,13 @@ void RunFromCombat(Player *Play) {
RandNum=brandom(0,100);
if (RandNum<EscapeProb) {
+ if (!IsCop(Play) && brandom(0,100)<30) {
+ for (ArrayInd=0;ArrayInd<Play->FightArray->len;ArrayInd++) {
+ Defend=(Player *)g_ptr_array_index(Play->FightArray,ArrayInd);
+ if (IsCop(Defend)) { FightingCop=TRUE; break; }
+ }
+ if (FightingCop) Play->CopIndex--;
+ }
WithdrawFromCombat(Play);
Play->EventNum=Play->ResyncNum; SendEvent(Play);
} else {
t@@ -1373,7 +1388,8 @@ void CheckForKilledPlayers(Player *Play) {
for (ArrayInd=0;ArrayInd<KilledPlayers->len;ArrayInd++) {
Defend=(Player *)g_ptr_array_index(KilledPlayers,ArrayInd);
WithdrawFromCombat(Defend);
- if (Defend->IsCop) {
+ if (IsCop(Defend)) {
+ if (!IsCop(Play)) Play->CopIndex=-Defend->CopIndex;
FirstServer=RemovePlayer(Defend,FirstServer);
} else {
FinishGame(Defend,_("You're dead! Game over."));
t@@ -1454,7 +1470,7 @@ Player *GetNextShooter(Player *Play) {
void ResolveTipoff(Player *Play) {
GString *text;
- if (Play->IsCop || !CanRunHere(Play)) return;
+ if (IsCop(Play) || !CanRunHere(Play)) return;
if (g_slist_find(FirstServer,(gpointer)Play->OnBehalfOf)) {
g_message(_("%s: tipoff by %s finished OK."),GetPlayerName(Play),
t@@ -1507,7 +1523,7 @@ void WithdrawFromCombat(Player *Play) {
Defend=(Player *)g_ptr_array_index(Play->FightArray,i);
Defend->FightArray=NULL;
ResolveTipoff(Defend);
- if (Defend->IsCop) {
+ if (IsCop(Defend)) {
FirstServer=RemovePlayer(Defend,FirstServer);
} else if (Defend->Health==0) {
FinishGame(Defend,_("You're dead! Game over."));
t@@ -1884,7 +1900,7 @@ void BuyObject(Player *From,char *data) {
SendPlayerData(From);
if (!Sanitized && (From->Drugs[index].Price==0 &&
- brandom(0,100)<Cops.DropProb)) {
+ brandom(0,100)<Location[(int)From->IsAt].PolicePresence)) {
lone=g_strdup_printf(_("YN^Officer %%s spots you dropping %s, and "
"chases you!"),Names.Drugs);
deputy=g_strdup_printf(_("YN^Officer %%s and %%d of his deputies "
t@@ -2060,7 +2076,7 @@ GSList *HandleTimeouts(GSList *First) {
First=RemovePlayer(Play,First);
} else if (Play->FightTimeout!=0 && Play->FightTimeout<=timenow) {
ClearFightTimeout(Play);
- if (Play->IsCop) Fire(Play);
+ if (IsCop(Play)) Fire(Play);
else SendFightReload(Play);
}
list=nextlist;