Skip to content
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

Non-player creature fighting overhaul #10693

Merged
merged 7 commits into from Jan 1, 2015

Conversation

Projects
None yet
3 participants
@Coolthulhu
Copy link
Contributor

commented Dec 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

!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.

Copy link
@BevapDin

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.

// 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.

Copy link
@BevapDin

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.

Copy link
@Coolthulhu

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 KA101 self-assigned this Jan 1, 2015

@KA101 KA101 merged commit db4340f into CleverRaven:master Jan 1, 2015

1 check passed

default
Details
@@ -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.

Copy link
@BevapDin

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 Coolthulhu deleted the cataclysmbnteam:smash-everything branch Jan 16, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.