Aller au contenu

Photo

What is the best way to customize a Creature's Combat AI?


  • Veuillez vous connecter pour répondre
30 réponses à ce sujet

#26
ColorsFade

ColorsFade
  • Members
  • 1 267 messages
I am in a clean area now and the script runs every time, but doesn't work. It doesn't do what it's supposed to do, so I am going to check my conditional statements to figure out why.

I also noticed on my script that changes the factions, I had it using DetermineCombatRound instead of HenchDetermineCombat round. So that explains part of the problem with the first around issues.

#27
kevL

kevL
  • Members
  • 4 056 messages
don't forget that in *your* script you have to turn off the rest of the AI (when it returns from ExecuteScript)

Search around for 'x2_ai_demo.nss' -- that's the template to start working from

#28
ColorsFade

ColorsFade
  • Members
  • 1 267 messages

kevL wrote...

don't forget that in *your* script you have to turn off the rest of the AI (when it returns from ExecuteScript)

Search around for 'x2_ai_demo.nss' -- that's the template to start working from



That was the most crucial part of the script and I just figured it out before I saw your post. 

You have to have this line in there to cause the rest of the script to stop: 

SetLocalInt(OBJECT_SELF, "X2_SPECIAL_COMBAT_AI_SCRIPT_OK",TRUE);


I decided to look at the hench_o0_ai script where it calls the X2 script to see if maybe my script was supposed to return a TRUE/FALSE or something. Then I noticed that line and understood what it was doing. The HenchDetermineCombatRound will return if you set that "OK" variable to true. And that's what has to happen. 

The second I changed it, the script worked (in the empty area). 

So, now to change it over to the real area and see if that does it. 

Wow.... if this works, this is gonna make my day. 

#29
ColorsFade

ColorsFade
  • Members
  • 1 267 messages
It works correctly now!

One thing I noticed in the real Area is that my SendMessageToPC messages are not happening and so at first I thought it was still not working. But watching the spells cast, they are being cast EXACTLY how I want them. I ran through it twice. Perfect both times.

Only the first batch of Messages get through and then they stop. Now, there are 3 PC's, the NPC and 10 skeletons all attacking simultaneously, so I figured that's the issue. And as I read the notes from NW Lexicon:

If you attempt to send too many SendMessageToPC() commands at the same time the messages will begin to be dropped, causing some of the messages to not appear at all



So clearly that's the issue. But I'm happy - it works. I can script my hostile attackers now... I'm elated.

#30
kevL

kevL
  • Members
  • 4 056 messages
well Good luck

( i'm trying to get my PC to stop auto-attacking (but am thinking more and more that it's hardcoded.) )


cheers CF.

#31
ColorsFade

ColorsFade
  • Members
  • 1 267 messages

kevL wrote...

well Good luck

( i'm trying to get my PC to stop auto-attacking (but am thinking more and more that it's hardcoded.) )


cheers CF.


Thanks kevL. For all your help - you've been great. 

I'm thrilled that this works. So much of what I wanted to do in this campaign is based around the idea of scripting enounters... Now that I know how, I'm jacked.