Jump to content

AI Party Script Crashes To Desktop


plainab

Recommended Posts

Okay, here's the deal. I created a party script for EasyTutu/BG2.

It's pretty basic:

pass potions - poison curing

use potions - poison curing

use spells - poison curing

use scorlls - poison curing

pass potions - healing

use potions - healing

use spells -healing

use scrolls - healing

attack spells (which increase hp)

runaway from attacking party members

runaway at low hitpoints

attack and defend

non-combat spells (which create items like goodberries)

hotkey ability to find traps

hotkey ability to pick up ammo (may be included as an option in the Projectile Retrieval Mod).

 

Here's the problem. I want to have a variable global or local that will keep the spell casters from healing when I have potions available and the same thing with scrolls when potions and spells are available. So at the top of my script I have something like this:(I used a setup similar to this all throughout IWD1. I even ported that script to BG1 where it worked there. This script is based on it, but not it.)

IF
PartyRested()
THEN
RESPONSE #100
SetGlobal("ab_heal","LOCALS",0)
SetGlobal("ab_poison","LOCALS",0)
Continue()
END
IF
Or(6)
StateCheck(Player1,STATE_POISONED)
StateCheck(Player2,STATE_POISONED)
StateCheck(Player3,STATE_POISONED)
StateCheck(Player4,STATE_POISONED)
StateCheck(Player5,STATE_POISONED)
StateCheck(Player6,STATE_POISONED)
THEN
RESPONSE #100
SetGlobal("ab_poison","LOCALS",1)
Continue()
END
IF
Global("ab_poison","LOCALS",1)
List of poison curing potions each using !PartyHasItem("RESREF")
THEN
RESPONSE #100
SetGlobal("ab_poison","LOCALS",2)
Continue()
END
IF
Global("ab_poison","LOCALS",2)
List of poison curing spells each using !HaveSpellParty(SPELL_NAME_HERE)
THEN
RESPONSE #100
SetGlobal("ab_poison","LOCALS",3)
Continue()
END
IF
!StateCheck(Player1,STATE_POISONED)
!StateCheck(Player2,STATE_POISONED)
!StateCheck(Player3,STATE_POISONED)
!StateCheck(Player4,STATE_POISONED)
!StateCheck(Player5,STATE_POISONED)
!StateCheck(Player6,STATE_POISONED)
THEN
RESPONSE #100
SetGlobal("ab_poison","LOCALS",0)
Continue()
END
IF
HPPercentLT(MostDamagedOf(GroupOf(Myself)),75)
THEN
RESPONSE #100
SetGlobal("ab_heal","LOCALS",1)
Continue()
END
IF
Global("ab_heal","LOCALS",1)
List of healing potions each using !PartyHasItem("RESREF")
THEN
RESPONSE #100
SetGlobal("ab_heal","LOCALS",2)
Continue()
END
IF
Global("ab_heal","LOCALS",2)
List of healing spells each using !HaveSpellParty(SPELL_NAME_HERE)
THEN
RESPONSE #100
SetGlobal("ab_heal","LOCALS",3)
Continue()
END
IF
HPPercentGT(MostDamagedOf(GroupOf(Myself)),74)
THEN
RESPONSE #100
SetGlobal("ab_heal","LOCALS",0)
Continue()
END

And then later on when the stuff is to be used, I check to make sure that the appropriate variable is set to 1 for potions, 2 for spells and 3 for scrolls. I've had each of those blocks reset it's variable to 0 as well, but there is not really a point to it unless the party gets more potions before they rest. Resting would restore the spells and reset the variables anyway.

 

But the script crashes to desktop whenever any one of the blocks with the global variable check and/or set tries to fire. I've had it crash when I've tried to rest, pass potions, or use potions. It even crashed when I equipped a potion in the quick item slot and it wasn't even on my list. I create my script on the fly so to speak during install. Could I be doing something wrong there? Could I some how be introducing bug into my game? The script can be installed and the game won't crash. The game only crashes after the script has be activated. The game will still crash if the script has been turned off or even changed all together.

 

Any ideas or thoughts?

Don't tell me to use the e-series or something like that. I've got it and it stutters too much for me. I want a simple script that uses what I use.

Link to comment
Okay, here's the deal. I created a party script for EasyTutu/BG2.

It's pretty basic:

pass potions - poison curing

use potions - poison curing

use spells - poison curing

use scorlls - poison curing

pass potions - healing

use potions - healing

use spells -healing

use scrolls - healing

attack spells (which increase hp)

runaway from attacking party members

runaway at low hitpoints

attack and defend

non-combat spells (which create items like goodberries)

hotkey ability to find traps

hotkey ability to pick up ammo (may be included as an option in the Projectile Retrieval Mod).

 

Here's the problem. I want to have a variable global or local that will keep the spell casters from healing when I have potions available and the same thing with scrolls when potions and spells are available. So at the top of my script I have something like this:(I used a setup similar to this all throughout IWD1. I even ported that script to BG1 where it worked there. This script is based on it, but not it.)

IF
PartyRested()
THEN
RESPONSE #100
SetGlobal("ab_heal","LOCALS",0)
SetGlobal("ab_poison","LOCALS",0)
Continue()
END
IF
Or(6)
StateCheck(Player1,STATE_POISONED)
StateCheck(Player2,STATE_POISONED)
StateCheck(Player3,STATE_POISONED)
StateCheck(Player4,STATE_POISONED)
StateCheck(Player5,STATE_POISONED)
StateCheck(Player6,STATE_POISONED)
THEN
RESPONSE #100
SetGlobal("ab_poison","LOCALS",1)
Continue()
END
IF
Global("ab_poison","LOCALS",1)
List of poison curing potions each using !PartyHasItem("RESREF")
THEN
RESPONSE #100
SetGlobal("ab_poison","LOCALS",2)
Continue()
END
IF
Global("ab_poison","LOCALS",2)
List of poison curing spells each using !HaveSpellParty(SPELL_NAME_HERE)
THEN
RESPONSE #100
SetGlobal("ab_poison","LOCALS",3)
Continue()
END
IF
!StateCheck(Player1,STATE_POISONED)
!StateCheck(Player2,STATE_POISONED)
!StateCheck(Player3,STATE_POISONED)
!StateCheck(Player4,STATE_POISONED)
!StateCheck(Player5,STATE_POISONED)
!StateCheck(Player6,STATE_POISONED)
THEN
RESPONSE #100
SetGlobal("ab_poison","LOCALS",0)
Continue()
END
IF
HPPercentLT(MostDamagedOf(GroupOf(Myself)),75)
THEN
RESPONSE #100
SetGlobal("ab_heal","LOCALS",1)
Continue()
END
IF
Global("ab_heal","LOCALS",1)
List of healing potions each using !PartyHasItem("RESREF")
THEN
RESPONSE #100
SetGlobal("ab_heal","LOCALS",2)
Continue()
END
IF
Global("ab_heal","LOCALS",2)
List of healing spells each using !HaveSpellParty(SPELL_NAME_HERE)
THEN
RESPONSE #100
SetGlobal("ab_heal","LOCALS",3)
Continue()
END
IF
HPPercentGT(MostDamagedOf(GroupOf(Myself)),74)
THEN
RESPONSE #100
SetGlobal("ab_heal","LOCALS",0)
Continue()
END

And then later on when the stuff is to be used, I check to make sure that the appropriate variable is set to 1 for potions, 2 for spells and 3 for scrolls. I've had each of those blocks reset it's variable to 0 as well, but there is not really a point to it unless the party gets more potions before they rest. Resting would restore the spells and reset the variables anyway.

 

But the script crashes to desktop whenever any one of the blocks with the global variable check and/or set tries to fire. I've had it crash when I've tried to rest, pass potions, or use potions. It even crashed when I equipped a potion in the quick item slot and it wasn't even on my list. I create my script on the fly so to speak during install. Could I be doing something wrong there? Could I some how be introducing bug into my game? The script can be installed and the game won't crash. The game only crashes after the script has be activated. The game will still crash if the script has been turned off or even changed all together.

 

Any ideas or thoughts?

Don't tell me to use the e-series or something like that. I've got it and it stutters too much for me. I want a simple script that uses what I use.

 

plainab,

 

In a quick glance through, I'm not seeing anything obviously wrong.

 

Uhmm, if you have some the innate spells scripted (like innate_cure_poison) and their spell level is not set to 0 (or was it 1?), it will crash the game if you try to check for them using HaveSpell(). Although, I think most of these should be taken care of in the various fixpacks.

 

If you are looking for simple, you might want to check out the tSeries. Nevermind, since your are using TuTu/BG2, tSeries would be too simple for your needs.

Link to comment
Uhmm, if you have some the innate spells scripted (like innate_cure_poison) and their spell level is not set to 0 (or was it 1?), it will crash the game if you try to check for them using HaveSpell(). Although, I think most of these should be taken care of in the various fixpacks.
Actually, yes I do. So to check this, I need to examine the .spl file and ensure that the level is set to 1 or 0, but not sure which at this point? I'll examine the bg2fixpack and see if it's got a component that adjusts the bg2 version of them in someway. Then I'll make sure that my script mod ensures those files are correct when it installs.

 

I'll let ya know what I find out.

I think you might be right, because I dropped the global variables and it still crashed.

 

What's the best way to have party members automatically attack when they see enemy? Is there something better than See([ENEMY]). My fighters don't seem to see the enemy when ActionListEmpty() is present. Would Exist([ENEMY]) or Detect([ENEMY]) be better options? I would go without ActionListEmpty() but that means player assigned tasks get stoped. Which is fine for walking, but not for wands or spell casting. It wouldn't hurt to have all three would it? Would using NearestEnemyOf(Myself) be better than [ENEMY]?

Link to comment

As long as you have that Continue() in there, your variables won't be set, and cannot be called in your next script block.

 

Continue() sends the engine off to look at the next block without setting globals or locals. It is only once you reach the end, when you have no more Continue()'s that you do all that. If you wanted to have your globals get set and your script function as you intend, set a trigger early in the script block that will keep it from running if a previous one has been set. And then let it skip script blocks until it hits one that returns true.

 

Give it a shot without them, and let me know how it works out.

Link to comment

The spin and spcl were all at 1 or higher, since I didn't know what would happen in game if I lowered them all to level 1, I just switched to HaveSpellRES and SpellRES and that solved the crashes.

 

Now as to the use of Continue(), I've read that it means "do this, but keep looking for something else to do." Instead, from what you describe, it should mean "don't do this yet, wait until I've found all that I can do. If two actions conflict, just stop everything and be stubborn about it."

 

If I've read the above posts correctly, I should remove Continue() from the initial blocks where the globals are set and see how that works. I can do that.

Link to comment

Okay, I dropped the Continue()'s from the script. The only place that has it is in the optional hotkey ability to remove traps.

 

So, here's the annoying part: Someone got injured in battle, everyone stoped fighting and started resetting their local variables. Before they got that done, the injured character was killed and at that point it didn't matter what the variable value was.

 

I don't like it one bit. Since I was only using the variables to say that certain items were available, I moved the lists of negative items into the individual blocks where I was going to have the associated variable. I know it means a larger file, but it is a whole lot smoother than before.

 

I guess, I'll leave the variables to easier things like

-- 0 I have not picked the lock

-- 1 I have picked or tried to pick the lock

 

NEW QUESTION:

I can use PickLock() or UnLock() to remove the locked status of a container, but they don't set the status as unlocked. It's either that or the trigger !Unlocked() does not work. The thief will keep going back to the same container (if in view). I've worked around it by setting a local variable (which is set even if the picklock fails and will keep the same thief from trying to pick the lock again via script), but I wanted to know if there was a better trigger to check the status of the container. If I can drop the variables, then the player can use the same thief (after increasing abilities) to try picking the lock again.

 

Do hotkeys work within area scripts?

I've thought about doing a remove traps/pick locks version for BG1, but there is no AreaCheck() trigger for BG1 as there is in the BG2 engine. If the hotkeys work inside the area scripts, then that actually opens a whole new realm of possibilities, plus it trims down the size of the player script quite dramatically.

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...