00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #include <config.h>
00035
00036 #include "commands.h"
00037 #include "item.h"
00038 #include "land.h"
00039 #include "news.h"
00040 #include "path.h"
00041
00042 int
00043 shoo(void)
00044 {
00045 struct sctstr sect;
00046 struct nstr_sect nstr;
00047 struct nstr_item ni;
00048 int nshot;
00049 double m;
00050 i_type item;
00051 struct ichrstr *ip;
00052 struct lndstr land;
00053 int targets;
00054 char *p;
00055 int mil, nsec;
00056 char prompt[128];
00057 char buf[1024];
00058
00059 ip = whatitem(player->argp[1], "Shoot what <civ or uw> ");
00060 if (ip == 0 || (ip->i_uid != I_CIVIL && ip->i_uid != I_UW))
00061 return RET_SYN;
00062 item = ip->i_uid;
00063 if (!snxtsct(&nstr, player->argp[2]))
00064 return RET_SYN;
00065 sprintf(prompt, "number of %s to shoot? ", ip->i_name);
00066 p = getstarg(player->argp[3], prompt, buf);
00067 if (p == 0 || (targets = atoi(p)) <= 0)
00068 return RET_SYN;
00069 while (nxtsct(&nstr, §)) {
00070 if (!player->owner)
00071 continue;
00072 mil = sect.sct_item[I_MILIT];
00073 nsec = 0;
00074 snxtitem_xy(&ni, EF_LAND, sect.sct_x, sect.sct_y);
00075 while (nxtitem(&ni, &land)) {
00076 mil += land.lnd_item[I_MILIT];
00077
00078 if (lchr[(int)land.lnd_type].l_flags & L_SECURITY) {
00079 mil += land.lnd_item[I_MILIT];
00080 nsec++;
00081 }
00082 }
00083
00084 if (sect.sct_item[item] == 0 || sect.sct_item[I_CIVIL] > mil * 10)
00085 continue;
00086 nshot = sect.sct_item[item] > targets ? targets : sect.sct_item[item];
00087 if (nshot > sect.sct_mobil * 5)
00088 nshot = sect.sct_mobil * 5;
00089 m = nshot / 5.0;
00090
00091
00092
00093
00094
00095 if (nsec > 5)
00096 nsec = 5;
00097 m *= 1.0 - nsec * 0.1;
00098 if (nshot <= 0)
00099 continue;
00100 if (m < 0)
00101 m = 0;
00102 if (m > sect.sct_mobil)
00103 m = sect.sct_mobil;
00104 sect.sct_mobil -= roundavg(m);
00105 sect.sct_item[item] -= nshot;
00106 pr("BANG!! (thump) %d %s shot in %s!\n",
00107 nshot, ip->i_name, xyas(sect.sct_x, sect.sct_y, player->cnum));
00108 if (chance(nshot / 100.0))
00109 nreport(player->cnum, N_SHOOT_CIV, sect.sct_oldown, 1);
00110 if (sect.sct_item[item] <= 0 && item == I_CIVIL
00111 && (sect.sct_own != sect.sct_oldown)) {
00112 sect.sct_oldown = sect.sct_own;
00113 pr(" %s is now completely yours\n",
00114 xyas(sect.sct_x, sect.sct_y, player->cnum));
00115 }
00116 putsect(§);
00117 }
00118 return RET_OK;
00119 }