Jump to content


AI scripting problem


  • Please log in to reply
5 replies to this topic

#1 -Krevett-

-Krevett-
  • Guest

Posted 10 November 2015 - 08:12 AM

Hello, I'm very new to scripting in IE engine and I'm currently playing with the IWD in BG2 modification (no enhanced edition for me!)

I'm used to playing BGT with SCS install and I want to increase the AI difficulty in the IWD in BG2 mod (just for personal entertainment, nothing else)

My current problem is with a mage script, the monster seems to rest whenever I go out of his sight (so he starts his sequence from the beginning, doing the buff things again and regaining all his spells whenever he's out of sight), but I can't find where the problem is!

 

The script:

 

Spoiler

 

For now many varables are not put to any use as I want to start simple and go with increasing difficulty (better targeting, etc...)

I've taken some inspiration from stratagems scripting (for now it's very basic but I'm satisfied with the call for help :) ) for the "rest" part but it does not seems to work properly. If anyone is willing to help, I'll greatly appreciate it!



#2 The Imp

The Imp

    Not good, see EVIL is better. You'll LIVE.

  • Member
  • 5150 posts

Posted 10 November 2015 - 08:58 AM

The forseeable source of the problem should be this:

 

IF
    Global("rest","LOCALS",1)
    !GlobalTimerNotExpired("rtime","LOCALS")
    !See(NearestEnemyOf(Myself))
THEN
    RESPONSE #100
        SetGlobal("rest","LOCALS",0)
        SetGlobal("inafight","LOCALS",0)
        SetGlobal("prebuff","LOCALS",0)
        SetGlobal("trigger","LOCALS",0)
        SetGlobal("contingency","LOCALS",0)
        SetGlobal("redefend","LOCALS",0)
        ApplySpell(Myself,RESTORE_FULL_HEALTH) // SPIN746.SPL (No such index)
        Rest()
END

 

Just remove the third and second last lines from that block, recompile the script and save it.

*Then begin the game a new, or from a spot you have not visite the map the enemy is currently in... or use the BG2 Console and enabling the cheat keys, and Ctrl + Y the enemy after which you can re-spawn the creature again, and have the actual fight. :devil:

Yeah, I forgot if the above* is strictly nessasary. By the by, the IWD-in-BG2 Fix&Tweakpack has the DavidW(the maker of both the IWD-in-BG2 and (SCSI, SCSII and thus) SCS) improved scripts for the enemy, so the SCS is not needed at all.


Edited by The Imp, 10 November 2015 - 09:00 AM.

Yep, Jarno Mikkola. my Mega Mod FAQ. Use of the BWS, and how to use it(scroll down that post a bit). 
OK, desert dweller, welcome to the sanity, you are free to search for the limit, it's out there, we drew it in the sand. Ouh, actually it was still snow then.. but anyways.


#3 -Krevett-

-Krevett-
  • Guest

Posted 10 November 2015 - 09:10 AM

You mean the Rest() and ApplySpell() lines? What I want to do is make the creature regain his spell if noone is around and enough time has passed (like in SCS if you rest after fleeing, the creature will regains it's powers)

And the IWD in BG2 tweakpack does not include such scripts, only weapons proficiency mods, NPC, map notes and other small tweaks but no improved scripts at all, if it was the case I would nether bother myself with improving scripts that are billions times better than what I'm able to do :)



#4 The Imp

The Imp

    Not good, see EVIL is better. You'll LIVE.

  • Member
  • 5150 posts

Posted 10 November 2015 - 09:47 AM

Yep, those lines. Now you could set up a timer for the resting action all on it's own, and remove also the "SetGlobal("rest","LOCALS",0)" -line... So it ends up something like:

IF
    Global("rest","LOCALS",1)
    !GlobalTimerNotExpired("rtime","LOCALS")
    !See(NearestEnemyOf(Myself))
THEN
    RESPONSE #100
        SetGlobal("inafight","LOCALS",0)
        SetGlobal("prebuff","LOCALS",0)
        SetGlobal("trigger","LOCALS",0)
        SetGlobal("contingency","LOCALS",0)
        SetGlobal("redefend","LOCALS",0)
        SetGlobal("norealrest","LOCALS",1)
        SetGlobal("rest","LOCALS",0)
END

IF
    Global("norealrest","LOCALS",1)
    !See(NearestEnemyOf(Myself))
THEN
    RESPONSE #100
        SetGlobal("norealrest","LOCALS",2)
        StartTimer("RESTTIMER",600)
END

IF
    TimerExpired("RESTTIMER")
    Global("norealrest","LOCALS",2)
    !See(NearestEnemyOf(Myself))
THEN
    RESPONSE #100
        ApplySpell(Myself,RESTORE_FULL_HEALTH) // SPIN746.SPL (No such index)
        SetGlobal("norealrest","LOCALS",0)
        Rest()
END

At least in theory... The 600 is ten minutes in real time, but if you have started a fight and then disappeared for 10 minutes, you are not coming back. :devil:

Also the "RESTTIMER" with the quotes can be a simple number, it doesn't matter, as long as the TimerExpired has the same thing in the brackets.

 

Yeah, well there's at least the better calls for help, which is really the thing that makes the game about 6 times as hard sometimes... as in the IWD, you could pick the monsters one at a time, mostly, but not so in IWD-in-BG2.


Edited by The Imp, 10 November 2015 - 10:00 AM.

Yep, Jarno Mikkola. my Mega Mod FAQ. Use of the BWS, and how to use it(scroll down that post a bit). 
OK, desert dweller, welcome to the sanity, you are free to search for the limit, it's out there, we drew it in the sand. Ouh, actually it was still snow then.. but anyways.


#5 Krevett

Krevett
  • Member
  • 4 posts

Posted 11 November 2015 - 12:43 PM

Sorry to disturb again but I really don't understand why it doen't work as it is written:

 

IF
    See(NearestEnemyOf(Myself))
    Global("rest","LOCALS",0)
THEN
    RESPONSE #100
        Shout(ALERT)
        SetGlobalTimer("rtime","LOCALS",SIX_HOURS)
        SetGlobal("rest","LOCALS",1)
        SetGlobal("inafight","LOCALS",1)
        Continue()
END

IF
    Global("rest","LOCALS",1)
    !GlobalTimerNotExpired("rtime","LOCALS")
    !See(NearestEnemyOf(Myself))
THEN
    RESPONSE #100
        SetGlobal("rest","LOCALS",0)
        SetGlobal("inafight","LOCALS",0)
        SetGlobal("prebuff","LOCALS",0)
        SetGlobal("trigger","LOCALS",0)
        SetGlobal("contingency","LOCALS",0)
        SetGlobal("redefend","LOCALS",0)
        ApplySpell(Myself,RESTORE_FULL_HEALTH) // SPIN746.SPL (No such index)
        Rest()
END

 

The creature sees an enemy, rest is set to 1 and the timer is set to 6 hours in game time, so the next block should not execute until the timer is up, but it is executed whenever I go out of the creature sight...

Also looking at stratagems scripting, creature rest is handled the same way, that's why I don't understand my error!



#6 -Gimble-

-Gimble-
  • Guest

Posted 11 August 2016 - 04:30 AM

it's a dead thread, so I doubt you care, but here is a guess. Flip the order of the two blocks you quote above (move sleep block above enemy detect block). If that works, I have a good guess as to why. If not, I am no more insane than I was yesterday.