Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.
Sign upNon-player creature fighting overhaul #10693
Conversation
Coolthulhu
added some commits
Dec 31, 2014
BevapDin
reviewed
Dec 31, 2014
| !g->m.clear_path(z->posx(), z->posy(), g->u.posx, g->u.posy, 10, 1, 100, junk)) { | ||
| return; // Can't see/reach you, no attack | ||
| int range = z->vision_range( target->xpos(), target->ypos() ); | ||
| bool mon_sees = g->m.sees( z->xpos(), z->ypos(), target->xpos(), target->ypos(), range, t ) && |
This comment has been minimized.
This comment has been minimized.
BevapDin
Dec 31, 2014
Contributor
This should simply be z->sees(*target) and let that function decide how to check the visibility of the target (different code for monster vs player), like it works for player::sees.
BevapDin
reviewed
Dec 31, 2014
| // Costs lots of moves to give you a little bit of a chance to get away. | ||
| z->moves -= 400; | ||
|
|
||
| if (g->u.uncanny_dodge()) { | ||
| if( foe == &g->u && g->u.uncanny_dodge() ) { |
This comment has been minimized.
This comment has been minimized.
BevapDin
Dec 31, 2014
Contributor
Why not just foe != nullptr && fow->uncanny_dodge(), npcs have that function and the ability to uncanny dodge. In short: avoid introducing special cases on this side of the code. Even better would be to add a pure virtual function uncanny_dodge to Creature and implement it as empty, only returning false in monster. Then you would need no special case here at all.
This comment has been minimized.
This comment has been minimized.
Coolthulhu
Dec 31, 2014
Author
Contributor
This is because uncanny_dodge wouldn't output proper message if neither target nor the attacker was the player. Since it never happens in game, I decided to add that line instead of rewriting uncanny_dodge (and including player.cpp in the already big PR).
Coolthulhu
added some commits
Dec 31, 2014
KA101
self-assigned this
Jan 1, 2015
KA101
merged commit db4340f
into
CleverRaven:master
Jan 1, 2015
1 check passed
BevapDin
reviewed
Jan 1, 2015
| @@ -378,6 +378,16 @@ int monster::vision_range(const int x, const int y) const | |||
| return range; | |||
| } | |||
|
|
|||
| bool monster::sees(int &bresenham_slope, Creature *target) const | |||
This comment has been minimized.
This comment has been minimized.
BevapDin
Jan 1, 2015
Contributor
This might be a bit confusing: all the other sees function have the parameter in reverse order: player::sees(Creature, t), Creature:sees etc.
Coolthulhu commentedDec 31, 2014
Biggest change is probably how the monmove function handles non-player things. Friendly creatures can now be hostile to NPCs and do not ignore their sight range when fighting non-player targets (before, friendlies would ignore their VIS_x flags when looking for non-player targets).
NPCs will no longer check creature friendliness (which is friendliness to player), but its actual attitude to given NPC. As a minor positive side effect, this should make them prioritize stuff that wants them dead over neutral animals.
Zombies who are friendly to the player will still be hostile to NPCs (pheromones make the player, not NPCs, smell like a zombie). This is currently a special hardcoded case, other species of tame monsters will not attack non-hostile NPCs.
Example of above behaviors: friendly drone, friendly zombie and friendly NPC. Zombie and NPC will fight, drone will ignore both. Currently there's no friendly creature infighting or non-friendly creature infighting.
I also updates some of the special attacks and zapback defense.
Zapback defense will now zap back non-player stuff. Not just NPCs, but also zombies. I also fixed the bug where NPC striking a zapback monster adjacent to the player would cause the player to get zapped.
Special attacks do not respect zapback yet, so a zombie can bite a shocker and not get hurt and then get zapped when bashing it.
Shockstorm, spit and knockback can target stuff that isn't the player now.
I can split the changes into two or even three PRs (AI update in the first, attacks to show it in one after it, zapback in third) if so desired, but the updated AI is best seen with the special attacks, which are also relatively simple changes (basically the same thing I did to bite function).
Happy new year everyone