[10.3i] fixed shooting in the Wild West

This commit is contained in:
Zeno Rogue 2018-06-29 13:14:49 +02:00
parent 0faccacaf6
commit 0f4de1fa9a
3 changed files with 38 additions and 25 deletions

View File

@ -1140,19 +1140,18 @@ bool flashWouldKill(cell *c, flagtype extra) {
return false;
}
// this is not completely correct, but it works in the Wild West
bool outlawNearby(cell *c, int dist) {
if(dist == 0) return false;
for(int i=0; i<c->type; i++) {
cell *c2 = c->mov[i];
if(!c2) continue;
if(c2->monst == moOutlaw && !stalemate::isKilled(c2))
return true;
if((passable(c2, NULL, 0) || (c2->monst && stalemate::isKilled(c2))) &&
outlawNearby(c2, dist-1))
return true;
vector<cell*> gun_targets(cell *c) {
manual_celllister cl;
vector<int> dists;
cl.add(c); dists.push_back(0);
for(int i=0; i<isize(dists); i++) {
cell *c1 = cl.lst[i];
if(dists[i] <= 2)
forCellEx(c2, c1)
if(passable(c2, c1, P_BULLET | P_FLYING | P_MONSTER))
if(cl.add(c2)) dists.push_back(dists[i] + 1);
}
return false;
return cl.lst;
}
namespace stalemate {
@ -1218,11 +1217,13 @@ bool monstersnear(stalemate1& sm) {
fast = (items[itOrbSpeed] && (items[itOrbSpeed] & 1));
}
if(havewhat&HF_OUTLAW)
if(outlawNearby(c, 3)) {
res++; who_kills_me = moOutlaw;
}
if(havewhat&HF_OUTLAW) {
for(cell *c1: gun_targets(c))
if(c1->monst == moOutlaw && !c1->stuntime && !stalemate::isKilled(c1)) {
res++; who_kills_me = moOutlaw;
}
}
for(int t=0; t<c->type; t++) {
cell *c2 = c->mov[t];
@ -5398,9 +5399,13 @@ void specialMoves() {
}
}
else if(m == moOutlaw && c->pathdist <= GUNRANGE) {
killThePlayer(m, nearestPathPlayer(c), 0);
c->stuntime = 1;
else if(m == moOutlaw) {
for(cell *c1: gun_targets(c))
if(canAttack(c, moOutlaw, c1, c1->monst, AF_GETPLAYER | AF_ONLY_FBUG | AF_GUN)) {
attackMonster(c1, AF_GETPLAYER | AF_ONLY_FBUG | AF_GUN, moOutlaw);
c->stuntime = 1;
break;
}
}
else if(m == moWitchFlash && flashWouldKill(c, AF_GETPLAYER | AF_ONLY_FBUG) && !flashWouldKill(c, false)) {

View File

@ -3047,9 +3047,16 @@ void setcolors(cell *c, int& wcol, int &fcol) {
wcol = gradient(0x804060, wcol, 0,2,3),
fcol = gradient(0x804060, fcol, 0,2,3);
if(items[itRevolver] && c->pathdist > GUNRANGE && !shmup::on)
fcol = gradient(fcol, 0, 0, 25, 100),
wcol = gradient(wcol, 0, 0, 25, 100);
if(items[itRevolver] && !shmup::on) {
bool inrange = c->mpdist <= GUNRANGE;
if(inrange) {
inrange = false;
for(int i=0; i<numplayers(); i++) for(cell *c1: gun_targets(playerpos(i))) if(c1 == c) inrange = true;
}
if(!inrange)
fcol = gradient(fcol, 0, 0, 25, 100),
wcol = gradient(wcol, 0, 0, 25, 100);
}
if(highwall(c) && !wmspatial)
fcol = wcol;

View File

@ -1172,8 +1172,9 @@ eItem targetRangedOrb(cell *c, orbAction a) {
// (4a) colt
if(!shmup::on && items[itRevolver] && c->monst && canAttack(cwt.c, moPlayer, c, c->monst, AF_GUN)) {
pathdata pd(moEagle);
if(c->pathdist <= GUNRANGE && !monstersnearO(a, cwt.c, c, moPlayer, NULL, cwt.c)) {
bool inrange = false;
for(cell *c1: gun_targets(cwt.c)) if(c1 == c) inrange = true;
if(inrange && !monstersnearO(a, cwt.c, c, moPlayer, NULL, cwt.c)) {
if(!isCheck(a)) gun_attack(c);
return itRevolver;
}