-
Notifications
You must be signed in to change notification settings - Fork 135
Fix for whip/pike attack invisible but revealed enemies #540
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a803c14
b52efd6
6b5e9e4
b17dfe1
100f0bc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| - | ||
| The whip, spear, and rapier now work against invisible enemies when you are telepathic. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -639,7 +639,7 @@ void populateItems(pos upstairs) { | |
| } else if (rogue.depthLevel > gameConst->amuletLevel) { | ||
| theCategory = GEM; | ||
| } else { | ||
|
|
||
| for (int j = 0; j < gameConst->numberMeteredItems; j++) { | ||
| // Create any metered items that reach generation thresholds | ||
| if (meteredItemsGenerationTable[j].levelScaling != 0 && | ||
|
|
@@ -3491,13 +3491,13 @@ void getImpactLoc(pos *returnLoc, const pos originLoc, const pos targetLoc, | |
| pos coords[DCOLS + 1]; | ||
| short i, n; | ||
| creature *monst; | ||
| creature *orig = monsterAtLoc(originLoc); | ||
|
|
||
| n = getLineCoordinates(coords, originLoc, targetLoc, theBolt); | ||
| n = min(n, maxDistance); | ||
| for (i=0; i<n; i++) { | ||
| monst = monsterAtLoc(coords[i]); | ||
| if (monst | ||
| && !monsterIsHidden(monst, monsterAtLoc(originLoc)) | ||
| if (canAttack(orig, monst) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is wrong from the POV of getImpactLoc. Bolts do not pass through creatures if the caster is unable to attack them. |
||
| && !(monst->bookkeepingFlags & MB_SUBMERGED)) { | ||
| // Imaginary bolt hit the player or a monster. | ||
| break; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -231,6 +231,30 @@ boolean canDirectlySeeMonster(creature *monst) { | |
| return false; | ||
| } | ||
|
|
||
| // Centralize the logic of whether an attacker can/will attack the defender | ||
| boolean canAttack( creature *attacker, creature *defender ) { | ||
|
Comment on lines
+234
to
+235
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should decide what this means precisely. For example, this check includes that the defender's location is known, but it's obviously possible to attack completely invisible enemies. It probably means something more like "does the attack know it will attack defender if it moves into its cell?" |
||
| if (attacker == NULL || defender == NULL) return false; | ||
|
|
||
| // Must be enemies | ||
| boolean areEnemies = monsterWillAttackTarget(attacker, defender); | ||
|
|
||
| // Must be able to attack the cell where the defender is located | ||
| boolean canAttackCell = !cellHasTerrainFlag(defender->loc.x, defender->loc.y, T_OBSTRUCTS_PASSABILITY) | ||
| || (defender->info.flags & MONST_ATTACKABLE_THRU_WALLS); | ||
|
|
||
| // Must be able to detect the defender | ||
| boolean locationKnown; | ||
| if (attacker == &player) { | ||
| locationKnown = canSeeMonster(defender) || monsterRevealed(defender); | ||
| } else { | ||
| // Monsters don't understand revealing. | ||
| locationKnown = !monsterIsHidden(defender, attacker); | ||
| } | ||
|
|
||
| // All three requirements must be met | ||
| return (areEnemies && canAttackCell && locationKnown); | ||
| } | ||
|
|
||
| void monsterName(char *buf, creature *monst, boolean includeArticle) { | ||
| short oldRNG; | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe also mention that whips no longer work against submerged enemies?