OpenXcom Forum

Modding => OpenXcom Extended => OXCE Suggestions DONE => Topic started by: Meridian on August 02, 2017, 05:19:25 pm

Title: [Documentation] Mindless charging AI (Leeroy Jenkins mode)
Post by: Meridian on August 02, 2017, 05:19:25 pm
Based on Stoddard's code with small changes: https://openxcom.org/forum/index.php/topic,5345.msg83664.html#msg83664

Code: [Select]
units:
  - type: STR_CHRYSSALID_TERRORIST
    isLeeroyJenkins: true

Unit marked as leeroy must have a melee weapon (and be able to use it).
It will completely ignore vanilla AI "decision making" and run around (using vanilla patrol routine) until it spots someone and then charge at the nearest target (if multiple spotted).
Charge is mostly vanilla/OXCE, with the following differences:
 - ignore remaining TUs (charge even if not enough TUs to attack now)
 - ignore dangerous tiles (grenades? pfff!)
 - ignore OXCE melee dodge (leeroy is not intelligent enough to attack from behind)

Units which are not marked behave normally... vanilla/OXCE behaviour is untouched.

@Stoddard:
1. cherrypicked commit c6b65f7dfbd2c66a5bdad69d612e7eee9627f19e
2. cherrypicked commit c8f23ec183f07c76b9f9e69112a7ff44868c3f6c
3. fixed compilation error (and vs. &&)
4. reverted all vanilla AI changes from first commit that you (probably?) forgot to revert in the second commit
5. iffed the AI trace logs
6. a few cosmetic changes in code formatting and log output
7. change: charge blindly #1 (don't care even if you end up in grenade blast radius)
8. change: charge blindly #2 (you're not intelligent enough to consider OXCE melee dodge and attack from behind)

Code: [Select]
[02-08-2017_14-56-31] [INFO] LEEROY: Unit 1000014 of type STR_CHRYSSALID_TERRORIST is Leeroy...
[02-08-2017_14-56-31] [INFO] LEEROY: visibleEnemiesToAttack: 0 _melee: 1
[02-08-2017_14-56-31] [INFO] LEEROY: No one to LEEROY!, patrolling...

[02-08-2017_14-56-33] [INFO] LEEROY: Unit 1000014 of type STR_CHRYSSALID_TERRORIST is Leeroy...
[02-08-2017_14-56-33] [INFO] LEEROY: visibleEnemiesToAttack: 2 _melee: 1
[02-08-2017_14-56-33] [INFO] LEEROY: LEEROYIN' at someone!

This code is highly experimental (doesn't mean it's buggy)... test it if you want and give feedback if it's usable in its current form.
Title: Re: Mindless charging AI (Leeroy Jenkins mode)
Post by: Solarius Scorch on August 02, 2017, 08:12:50 pm
That definitely makes me want to buy you a beer or two. :)
Title: Re: Mindless charging AI (Leeroy Jenkins mode)
Post by: yrizoud on August 03, 2017, 03:10:56 am
Hmm what about a leeroychance instead of a boolean ? (percent chance 0 - 100, or floating point number 0.0 - 1.0) Applied every turn it would let modders use the features also for more subtle situations, like a Black Lotus agent going berserk 5% times, or a Spider normally rushing, but sometimes staying evasive and employing a ranged attack.
Title: Re: Mindless charging AI (Leeroy Jenkins mode)
Post by: Meridian on August 03, 2017, 08:59:57 am
Hmm what about a leeroychance instead of a boolean ? (percent chance 0 - 100, or floating point number 0.0 - 1.0) Applied every turn it would let modders use the features also for more subtle situations, like a Black Lotus agent going berserk 5% times, or a Spider normally rushing, but sometimes staying evasive and employing a ranged attack.

That's what vanilla AI does at the moment.

The complaint was that it's not enough and the unit should always charge, not just sometimes.

But yeah, can be done if someone would be interested... 4 lines of code.
Title: Re: Mindless charging AI (Leeroy Jenkins mode)
Post by: Stoddard on August 05, 2017, 04:12:01 pm
Nice to see this merged. Thanks, Meridian.
Title: Re: Mindless charging AI (Leeroy Jenkins mode)
Post by: bulletdesigner on August 05, 2017, 06:41:37 pm
Will defnitly use this for beserker units with bloddlust hehe
Title: Re: Mindless charging AI (Leeroy Jenkins mode)
Post by: Meridian on September 07, 2017, 06:10:45 pm
Nice to see this merged. Thanks, Meridian.

Btw. there was a serious flaw in the original code... leeroys were deciding what to do using new AI, but actually acting using old AI.
This led to:
- in usual case, enemies (with low or average TUs) freezing in place (unless you came closer to them)
- in worse cases, a crash

Fix here: https://github.com/MeridianOXC/OpenXcom/commit/d3cfa270ad7a69cc80e6f074f24414262704962b
Title: Re: Mindless charging AI (Leeroy Jenkins mode)
Post by: Stoddard on September 08, 2017, 08:35:56 pm
Btw. there was a serious flaw in the original code... leeroys were deciding what to do using new AI, but actually acting using old AI.
This led to:
- in usual case, enemies (with low or average TUs) freezing in place (unless you came closer to them)
- in worse cases, a crash

Fix here: https://github.com/MeridianOXC/OpenXcom/commit/d3cfa270ad7a69cc80e6f074f24414262704962b

Yeah, I saw it back in August. Was a bad idea, no objection.
Title: Re: [Documentation] Mindless charging AI (Leeroy Jenkins mode)
Post by: Meridian on January 09, 2021, 02:15:53 pm
Since OXCE v6.9.1 Leeroys can perform charging also over multiple turns.
Title: Re: [Documentation] Mindless charging AI (Leeroy Jenkins mode)
Post by: Solarius Scorch on January 09, 2021, 06:41:53 pm
Since OXCE v6.9.1 Leeroys can perform charging also over multiple turns.

This is very good news. Thanks!