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 upAutomatic aim ai rework #10601
Conversation
Coolthulhu
added some commits
Dec 22, 2014
This comment has been minimized.
This comment has been minimized.
|
Nice! |
KA101
reviewed
Dec 22, 2014
| const std::string ammo_type("120mm_HEAT"); | ||
| // Make sure our ammo isn't weird. | ||
| if (z->ammo[ammo_type] > 40) { | ||
| debugmsg("Generated too much ammo (%d) for %s in mattack::tank_tur", z->ammo[ammo_type], z->name().c_str()); | ||
| debugmsg("Generated too much ammo (%d) for %s in mattack::tank_gun", z->ammo[ammo_type], z->name().c_str()); |
This comment has been minimized.
This comment has been minimized.
KA101
assigned
KA101
and unassigned
KA101
Dec 22, 2014
BevapDin
reviewed
Dec 22, 2014
| if( z->friendly != 0 ) { | ||
| // Let friendly bots taze too | ||
| for( size_t i = 0; i < g->num_zombies(); i++ ) { | ||
| monster *tmp = &( g->zombie( i ) ); |
This comment has been minimized.
This comment has been minimized.
BevapDin
Dec 22, 2014
Contributor
Why a pointer and not a reference? Also, below, the this-> is redundant.
BevapDin
reviewed
Dec 22, 2014
| g->u.worn_with_flag("ELECTRIC_IMMUNE")) { //Resistances applied. | ||
| add_msg(m_info, _("The %s unsuccessfully attempts to shock you."), z->name().c_str()); | ||
| return; | ||
| if( target == &g->u ) { |
This comment has been minimized.
This comment has been minimized.
BevapDin
Dec 22, 2014
Contributor
Player character and npcs can use the same branch, a npc is "kind of a player", npcs have the very same functions that a player has. Also, below the add_msg will be shown when the npcs or the monster is not visible to the player. add_msg_player_or_npc will handle that case.
And why is the npc hurt differently than the player? hurtall(rng(5,20)) vs apply_damag(rng(1,3)*rng(1,5))
This comment has been minimized.
This comment has been minimized.
BevapDin
reviewed
Dec 23, 2014
| @@ -13440,27 +13436,43 @@ Creature *player::auto_find_hostile_target(int range, int &boo_hoo, int &fire_t) | |||
| targets.push_back( p ); | |||
| } | |||
| for( auto &m : targets ) { | |||
| if (!sees(m, t)) { | |||
| // inline player::sees because we're static now | |||
This comment has been minimized.
This comment has been minimized.
BevapDin
Dec 23, 2014
Contributor
This code "nicely" ignores the (non) visibility of digging or submerged monsters. That thing was handled in player::sees.
Edit: and it considers hallucinations, but I assume that most code in monattack does this.
This comment has been minimized.
This comment has been minimized.
kevingranade
Dec 23, 2014
Member
If by "inline" you mean "copy the contents of player::sees(), please don't, it's just asking for it to go out of sync at some point in the future.
It's much preferable to extract it to some third location and have it included in both player and monster. Possibly reasonable to go in creature, but then again what would be really nice is a new class that has an instance included in both.
For now just avoid duplicating the code by extracting it somewhere as a helper function or something.
BevapDin
reviewed
Dec 23, 2014
| @@ -13401,27 +13401,23 @@ Creature::Attitude player::attitude_to( const Creature &other ) const | |||
| return A_NEUTRAL; | |||
| } | |||
|
|
|||
| Creature *player::auto_find_hostile_target(int range, int &boo_hoo, int &fire_t) | |||
| Creature *player::auto_find_hostile_target(point pos, int range, int &boo_hoo, int area) | |||
This comment has been minimized.
This comment has been minimized.
BevapDin
reviewed
Dec 23, 2014
| z->moves -= 500; // It takes a while | ||
| std::vector<point> traj = line_to(z->posx(), z->posy(), target->xpos(), target->ypos(), fire_t); | ||
| std::vector<point> traj = line_to(z->posx(), z->posy(), target->xpos(), target->ypos(), 0); |
This comment has been minimized.
This comment has been minimized.
BevapDin
Dec 23, 2014
Contributor
line_to will generate different lines depending on that t parameter, map::sees uses the same code. It's quite likely that one of those lines allows seeing the target , while another line goes through opaque terrain and does not allow the point to be seen. The sees function stores the number that will create a line through transparent terrain in the t parameter. Passing the same value to line_to ensure that the generate line is the same as the line used by sees.
This comment has been minimized.
This comment has been minimized.
|
OK, I get most of those, except the fire_t one. I removed fire_t, because the only function that used it was flamethrower. All others would simply declare it, then forget about it as soon as auto_find_hostile_target returned. What is it used for? Does it ensure the fire trail follows the correct path or something? EDIT: Tazing has different damage for player and NPC, because player taze code is from monster function, while NPC one is from iuse::tazer. Should I nerf NPC taze back to player taze level? |
BevapDin
reviewed
Dec 23, 2014
| // code copied form mattack::smg, mattack::flamethrower | ||
| int range = ammo.type == fuel_type_gasoline ? 5 : 12; | ||
| int range = part_info( p ).range; | ||
| if( range < 1 ) { |
This comment has been minimized.
This comment has been minimized.
BevapDin
Dec 23, 2014
Contributor
Instead of setting this here, why not as the default value when it's loaded from json: jo.get_int("range", 12)
This comment has been minimized.
This comment has been minimized.
|
You can try this out: go into ranged.cpp, there are several places that have
Change them to always use 0 as t parameter and no
Than try to aim along a wall:
|
This comment has been minimized.
This comment has been minimized.
|
Is it OK if I retrace the lines for the bresenham value? It (the bresenham parameter) is only used in flamethrower code and map::sees is checked for every monster loaded, so it shouldn't be expensive to check it once more for one monster 5 tiles from us. Flamethrowers are back to being perfectly accurate. |
This comment has been minimized.
This comment has been minimized.
That is either a bug, or the functions call
Sure. I'm only aware of this bresenham line thing as I once tried to remove that parameter from all |
Coolthulhu
added some commits
Dec 23, 2014
This comment has been minimized.
This comment has been minimized.
|
OK, rebase this and I'll see about fast-tracking it. |
Coolthulhu
added some commits
Dec 25, 2014
This comment has been minimized.
This comment has been minimized.
|
Seems to work after merge. At least I couldn't get it to not-work. |
KA101
self-assigned this
Dec 25, 2014
KA101
reviewed
Dec 25, 2014
| } else if( target->is_npc() ) { | ||
| npc *foe = dynamic_cast< npc* >( target ); | ||
| int shock = rng(5, 20); | ||
| foe->moves -= shock * 100; |
This comment has been minimized.
This comment has been minimized.
KA101
Dec 25, 2014
Contributor
Differential stun-amounts are suboptimal. Knocking 'em all to 1-20 damage and 50x move-loss multiplier. Net effect, taser's less effective at stunlocking critters/NPCs and more effective at stunlocking you. Nerf.
This comment has been minimized.
This comment has been minimized.
|
Changed the message but in testing the skitterbot refused to target the nearby NPC, instead tazing me whenever I got within 2-3 tiles. Bug: tazers don't have that much reach and the NPC was the active threat. Sorry, sending it back. |
KA101
removed their assignment
Dec 25, 2014
Coolthulhu
added some commits
Dec 25, 2014
This comment has been minimized.
This comment has been minimized.
|
OK, I added tazing NPCs, either hostile or non-hostile (depending on mon's attitude). I didn't include your balancing change, because it kinda goes out of scope. Also because skitterbots are quite scary to new survivors already. I nerfed NPC tazing to player tazing level. NPCs who somehow managed to acquired immunity to electricity should now be immune to tazing (I couldn't think of a good way of testing if it works, though). I discovered a problem with friendly monster AI vs. hostile NPCs, but it also is out of scope of this PR. Friendly mons can stumble into tiles occupied by hostile NPCs. |
This comment has been minimized.
This comment has been minimized.
BevapDin
commented on src/monattack.cpp in a0f7386
Dec 25, 2014
|
You can use Same below, calling |
This comment has been minimized.
This comment has been minimized.
|
Fair enough on the change, that was to reconcile the three different standards (which you now have) and we can revisit it later if need be. Might want to implement BevapDin's there though. |
This comment has been minimized.
This comment has been minimized.
|
That failed check is bot losing connection, not a compilation failure. |
This comment has been minimized.
This comment has been minimized.
|
Nice to see someone clicking the details link. ;-) |
KA101
self-assigned this
Dec 25, 2014
This comment has been minimized.
This comment has been minimized.
|
Next is gonna be tweaking it to not use explosive rounds on squirrels, cats, etc but for now I think it's workable. |
Coolthulhu commentedDec 22, 2014
Changes quite significantly the behavior of some hacked bots (tested on tanks, chickens and skitterbots) and turrets with area of effect attacks.
Hacked bots will no longer depend on distance from player to pick an attack and will not skip turns if they can't see the player. Before, they'd attack zombies with the same attack they'd use to attack the player.
Bots (skitters, tanks and chickens) can now zap enemies when hacked. Currently this is always successful when attempted (because player can only dodge tazing with uncanny_dodge). Stun times and damage copied from iuse::tazer.
Made mutant-ignoring turrets attack mutants driving vehicles, because weird animals don't drive vehicles.
Moved range setting of turrets from hardcoded to a json member.
Made turrets consider area of effect of their projectiles. They will ignore any target too close to attack without risking including self in the area of effect.
During my testing it worked nicely, so it's probably fully or at least mostly functional.
I changed the structure of monattack.cpp quite significantly. I moved aiming from functions like frag_tur up to the functions that use them, like multi_robot and chickenbot (otherwise hacked chickens and tanks would aim twice per attack).
I sent a conflicting PR yesterday (manual turrets - conflicting on incredibly minor things, but still), so this is more for a review right now.