Reaching higher levels in my campaign, I feel the need to make some fights more interesting than just a tough enemy. My question is, how do I make enemies smarter? Like a duo of wizards that will try to aid one another - cast fireballs on a pool of oil if a PC actually goes over it causing more fire damage , or a spellcaster that will always open fight with dispel magic. Or a boss that keeps resurrecting until we destroy his minions... stuff like that. Are these the AI scripts that I hear about? Or heartbeats? Or what
?
Boss fight scripts/more interesting fights. (AI?)
#1
Posté 29 juillet 2014 - 05:14
#2
Posté 29 juillet 2014 - 01:00
Pretty much. What you will want to do is be looking at the AI scripts you see attached to monsters. Make copies of those and change their names to something meaningful for you and attach to the monsters (wizards in this case) you want.
Then its a case of scripting in conditionals for what you want to happen.
For example, you may want to change the on perception script if you want then to do something specific when they first spot the PC, for example, shout a challenge to them or start off by casting a specific spell.
Or change the on death event to force the other wizard to shout something like "My brother is slain! You shall be punished for that!"
- andysks aime ceci
#3
Posté 29 juillet 2014 - 01:28
It's interesting that you brought this subject up because boss fights were something I enjoyed in early Nintendo games and so I decided to add that aspect to my module as well.
So, when I look for inspiration on this, I just look to the old games.
That and old comic books.
#4
Posté 29 juillet 2014 - 02:04
Pretty much. What you will want to do is be looking at the AI scripts you see attached to monsters. Make copies of those and change their names to something meaningful for you and attach to the monsters (wizards in this case) you want.
Then its a case of scripting in conditionals for what you want to happen.
For example, you may want to change the on perception script if you want then to do something specific when they first spot the PC, for example, shout a challenge to them or start off by casting a specific spell.
Or change the on death event to force the other wizard to shout something like "My brother is slain! You shall be punished for that!"
Which creatures have AI scripts attached to them, and on which event
?
I just know the switches like X2_L_BEH_MAGIC. But these don't do anything really specific.
#5
Posté 29 juillet 2014 - 02:18
there's a hook in the stock NPC-AI scripts that's useful for tweaking combat behavior. It's accessed by putting a local_string on the NPC:
"X2_SPECIAL_COMBAT_AI_SCRIPT"
and define your custom AI-script as a string, eg:
"wombat_ai" [.nss]
Whenever the stock AI is determining what the wombat, in this case, should do, it checks for this defined string and if found executes it before continuing ...
The thing is, on a less technical level, once you start tinkering with AI ... uh, there's no end to it.
----
if you want to start messing with the stock AI scripts, first look for hooks that might be in them already. If you want one but that's not there, I suggest putting one in rather than rewriting. ( stock AI makes a good fallback )
you'd be looking for things like "Spawnscript="
those define custom scripts that various events can execute.
- Loki_999 aime ceci
#6
Posté 29 juillet 2014 - 02:23
Which creatures have AI scripts attached to them, and on which event
?
I just know the switches like X2_L_BEH_MAGIC. But these don't do anything really specific.
the event scripts *are* the AI
( ps. i wouldna trust those X2_L_BEH* vars -- they might work they might not, depending on which 'edition' of the AI is running )
#7
Posté 29 juillet 2014 - 02:25
Hi KevL. Not really, I don't think I can, or want to start rewriting the AI
. I just got pissed today because I had two wizards in a room who cast summon monster, stoneskin, enlarge person and after that start hitting me with their fists like there's no end to it
. But they both have fireballs, magic missiles... they are level 8 for crying out loud.
Anyway. So I should open the OC and search for creatures with the hook on them huh? Will do that. I guess I'll find something
. Thanks.
#8
Posté 29 juillet 2014 - 02:38
yeh i know what you're saying & the next time that happens to me, as a player, I'm gonna break out my rewrite-Axe and go Norman Bates.
I suggest what yer looking for is info on the "X2_SPECIAL_COMBAT_AI_SCRIPT" for starters. a Google search will probably turn up more info than you'll want to deal with. It's pretty simple in its implementation, though.
The tough part, for example to ensure that casters don't go mano-a-mano when they have a half dozen spells left, is the tricky/ tedious part.
i would suggest taking a peek at Dragons in the OC from my .sig, but don't think that'll help too much unless you figure out exactly what you should be looking at. The 'custom Ai' script is labelled 'roundend' or something, and most of the rest are just to make it work in the OC. I set the string variable for the custom script in the spawnscript ....
[edit] ah, here's some relevant docs i wrote for Dragons:
A string variable on Tholapsyx herself is "SpawnScript = ai_reddragon_spawnscript". This script gets called by the default OnSpawnInScript (nw_c2_default9). It sets up her Breath, Buffet, and Tailsweep attack counters and specifies her AI script, ai_reddragon_roundend. Tholapsyx' special spawnscript also prepares the userdefined event, EVENT_HEARTBEAT, to fire ...
ai_reddragon_roundend is where everything happens .... basically it attempts to find a valid target and then attack it with everything - no sorry. Tholapsyx' first round is an instant buffing routine. She will then pick out a target (generally the closest enemy) and depending on her health and some random chance may attack with one of her special combat abilities, choose to buff more or heal herself, attack with a spell, or simply do tooth & claw attack possibly w/ Knockdown or Power Attack.
Modifié par kevL, 29 juillet 2014 - 02:56 .
#9
Posté 29 juillet 2014 - 02:53
For my boss fights, I experimented with a number of different methods, but for the latter ones I just employed a parasite that would take over the boss' actions when I wanted to ensure that something happened, and didn't do much with the AI that was actually attached to the creatures except for the perception and death scripts.
#10
Posté 29 juillet 2014 - 03:59
I guess casters have the problem. Otherwise, my enemies seem to change between weapons and stuff. Potions they won't use, this is why I installed today the Tony's Ai in case it fixes that. Will check now your scripts KevL and tell you if i understand
.
#11
Posté 29 juillet 2014 - 10:46
it's not so much understanding it, as just scratching yer beard for a while and saying "yes, yes i see.."
As you browse the roundend scripts from top to bottom you should get some gist of (a way) to do decisions. What isn't as obvious as it should be, is that i told the stock AI to use that AI w/ AIAssignDCR() in the spawnscript. And all that does is assign this string to the NPC:
X2_SPECIAL_COMBAT_AI_SCRIPT="ai_reddragon_roundend"
forget why i did it that way (onSpawn instead of just putting it straight on the creature) but that might be backward compatibility, or perhaps the way it was officially done in the OC and i din't want to change, shrug unimportant; what's important is that the variable gets set. (and then another variable turns the stock AI on/off depending on whether a custom-AI makes a decision or decides to 'fallthrough' back to stock *each round*
DCR stands for DetermineCombatRound() and is the core function of combat AI. That's where the hook for Special_Combat_Script is, iirc
#12
Posté 29 juillet 2014 - 11:59
forget why i did it that way (onSpawn instead of just putting it straight on the creature)
There's a custom AI template in the toolset that does all of its work (including damage conditions) in the On Spawn script. Maybe that's why.
#13
Posté 30 juillet 2014 - 12:16
if so, that was a decision by the developers of OC. All i vaguely remember is 'scratching my beard' and wondering if I should do it this way or that ..
#14
Posté 30 juillet 2014 - 09:17
I got the grip. Scratched my beard quite a lot though
. Now the wizards did some nuking. Thanks a lot for the info.
#15
Posté 30 juillet 2014 - 10:46
np
#16
Posté 31 juillet 2014 - 06:10
I can't believe I didn't see this thread earlier.
Andy - if you need any help with this let me know. I've written a ton of custom AI for my campaign. All my custom AI uses the X2_SPECIAL_COMBAT_AI_SCRIPT to give enemies custom behavior. I'm happy to help you, or guide you, in any of this.
Custom AI for enemies has been a big part of my mod and a major reason I wanted to write my own adventure. It really does make the game better.
Have fun!
#17
Posté 01 août 2014 - 02:24
Hi Cristopher. I know AI is a major thing in you work but I didn't want to bother you personally... again
! What with companions, loot, world map... does the list stop
?
I will admit though that together with KevL's scripts I also took a small look at yours. The d_target_ai, d_combat_ai and data_structures I believe. This is some great work. In no way do I want or am willing to take this effort as you do to build AI, but as I said above... maybe some mages would be better if they were more intelligent. I will send you after work to see if we can make my scripts better, or more stable.
Thanks
.
#18
Posté 01 août 2014 - 02:16
No problem Andy. I just wanted you to know - I can and will answer questions. Anytime.
Having better spellcasters is a lot of fun.
- andysks aime ceci
#19
Posté 01 août 2014 - 06:13
I'm really interested in this CF and would like to contact you over the coming weeks. My next mod is going to be typically human centric and I want to make the combat more challenging.
PJ
#20
Posté 02 août 2014 - 05:56
Sure thing PJ. Just give me a PM or email me.
The AI is something that I am always growing as I progress into my campaign. It's pretty robust right now, but I know there are things I will want to do later, and I'll have to add to the library to do those things. If you want to use it, I'd send you upgrades to the scripts as I go.
The AI, by the way, at least right now, is really only beneficial for spell casters or any creature that you want to give special abilities to. I have not done any work on making melee fighters more effective, although I have done some limited work to make enemy archers better (they don't all shoot at the same target when you enter a room now, so no more instant death for the lead party member at lower levels). Melee improvements are something I intend to do in time, however.
But as an example of things you can do with this: I created a mockup of a battle I was thinking about for later in my campaign. I created a very powerful undead Doomknight-type creature, and gave him around 400 HP at level 19 (I think). Now, with a full party against him, even 400 HP goes pretty quick. But what I did is grant him special ability to Harm and he has 4 uses of it. With the AI, he monitors his own health, and when he drops below 50% (or maybe I did it at 25%), he Harms himself and goes back to full health. I thought it was a really, really neat test, as it stretched out the battle for much longer. And the longer the battle, the more stuff I can do in the real setting, like have him Gate in devil, and call minions to his aid, etc... There's just a lot of possibilities for better encounters.
Without the AI, my first necromancer encounter, the guy started blasting away with level 0 spells. With the AI, he self-buffs all his spells immediately (simulating sequencer), and then starts off looking to cast his nastiest spells first - like finding the lowest WILL save party member to Charm, or casting Magic Missile at the party member with the lowest hit points, etc.
There's a bunch of options in the AI for targeting, so your enemies can make smarter choices about their spells. If a certain spell has a Fortitude save, then obviously it makes sense for the creature to cast it against the party member with the lowest Fortitude save, so the spell has a chance of succeeding. You can target a number of ways: by class type (Fighter, Divine Caster, Arcane Caster, or "Hybrid"), you can target by Save (high or low), Hit points (high or low), ability score (high or low) or just target the nearest enemy. With that... you can make some pretty evil enemies if you want (you could have them go after the Cleric first... etc.).
In experimenting with it, and using it some in my campaign, I've been pretty happy with the results. It gets way more fun at higher levels when the enemies have more spells to work with.
#21
Posté 04 août 2014 - 05:11
There are some variables (defined in X2_inc_switches) that can be set on creatures that the default OnSpawn script checks for to set certain behaviour flags. I don't know how many still work in NWN2 - I've only ever used X2_L_NOTREASURE. Some of the interesting sounding ones are:
X2_L_BEH_COMPASSION (INT - the higher the value, the more likely a creature is to aid its allies in combat)
X2_L_BEH_MAGIC (INT, 0 to 100 - the percentage chance that a creature will use magic in combat)
X2_L_BEH_OFFENSE (INT - the higher the value, the more likely to use offensive abilities in combat)
X1_L_IMMUNE_TO_DISPEL (INT, 1 or 0 - a value of 1 makes the creature immune to dispel magic)
X2_L_NUMBER_OF_ATTACKS (INT, 1 to 6 - overrides the number of attacks per round a creature has)
X2_SPELL_RANDOM (INT, 1 or 0 - a value of 1 slightly randomises spell selection, so no more mass Magic Missile casting!)
X2_L_SPAWN_USE_SEARCH (INT, 1 or 0 - a value of 1 makes the creature activate detect mode when it spawns)
X2_L_SPAWN_USE_STEALTH (INT, 1 or 0 - a value of 1 makes the creature activate stealth mode when it spawns)
X2_L_NOTREASURE (INT, 1 or 0 - a value of 1 stops random loot generation for the creature)
#22
Posté 04 août 2014 - 10:34
The search and stealth are working as well. I used them often. The rest I have no idea, KevL might know if and why not etc. With the BEH_MAGIC is hard to tell, because you will give it to spell casters anyway... and they will cast spells anyway. I tried it but couldn't tell if it worked or not.
The Behloder hak, if I remember correctly that is, says that we should use the BEH_MAGIC in order for the creature to use most or all of its eye attacks... Maybe they tested it and it worked?
#23
Posté 04 août 2014 - 12:40
i traced the BEH vars once pon a time. ( beh .. beholder )
iirc, those ones -should- work for default NPC ai, DetermineCombatRound()
but not for HenchDetermineCombatRound()
or something like that ... it's confusing partly because there seem to be a bunch of NwN1 ai scriptsets (nw_ch_* etc) still hanging around.
#24
Posté 04 août 2014 - 10:55
I gave a few of those variables a try on my overland map encounters.
X2_L_BEH_MAGIC works a treat. My hobgoblin warcasters no longer charge straight into combat, or just cast a couple of spells and do so. I set the chance of using magic to 75 (percent), so they use up most of their spells now before trying to knock your head off with a staff.
A few of my bandit rogues now enter stealth mode as soon as the encounter begins, so while their fighter or barbarian comrades try to beat you to a pulp, they're sneaking in for a more surgical strike.
I didn't notice much of a difference using X2_L_BEH_COMPASSION. Bards still seem to want to cast offensive spells or summon creatures rather than try to heal their injured comrades. Clerics have always tried to heal nearby comrades even without the variable being set.
I need to do some more tests with X2_SPELL_RANDOM. It certainly seems to stop casters spamming Magic Missile over and over, but the usual AI seems pretty random to me anyway. I'd need to have multiple identical spellcasters (preferably sorcerors) fighting at the same time, which isn't something my current encounters are likely to do.
#25
Posté 05 août 2014 - 12:44
There is a standard boss spawn script nw_c2_bossspawn that can be used that will cause the boss to be auto-buffed. It sets the spawn in condition NW_FLAG_FAST_BUFF_ENEMY. I use a slightly modified version of this script since the original doesn't check for the Local Variable SpawnScript the way that the standard creature spawn script does.
Regards





Retour en haut






