Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Dark Dreams of Furiae - a new module for NWN:EE! Buy now
Attention, new and old users! Please read the new rules of conduct for the forums, and we hope you enjoy your stay!

Nearest[ENEMY]

MathsorcererMathsorcerer Member Posts: 3,003
Is it just me or is Nearest([ENEMY]) not working when I try to use it in a script? I can get NearestEnemyOf(Myself) or LastSeenBy(Myself) to work just fine but the one referencing the EA IDS doesn't appear to work. Other things do seem to work, such as See([ENEMY.0.0.MAGE]).

Similarly, I was introducing our 10-year-old son to scripting--bright kid--and we couldn't gett See([0.0.0.FAIRY_SIRINE]) to work but if I removed that line the rest of his script worked perfectly.

Or...is this a known issue and I missed that main thread? Anyway....if any of you have any insights or inside knowledge I would appreciate it.

Comments

  • CoM_SolaufeinCoM_Solaufein Member Posts: 2,603
    You should post a snippet of the code. Here is an example from the WTASIGHT script in BG2.
    IF
    Heard([ANYONE],111)
    THEN
    RESPONSE #100
    MoveToObject(NearestEnemyOf(Myself))
    END

    IF
    AttackedBy([GOODCUTOFF],DEFAULT)
    !Allegiance(Myself,ENEMY)
    THEN
    RESPONSE #100
    Enemy()
    END

    IF
    See(NearestEnemyOf(Myself))
    THEN
    RESPONSE #100
    AttackReevaluate(NearestEnemyOf(Myself),30)
    END

    IF
    AttackedBy([ANYONE],DEFAULT)
    THEN
    RESPONSE #100
    Attack(LastAttackerOf(Myself))
    END

  • MathsorcererMathsorcerer Member Posts: 3,003
    I am reworking the scripts the NPCs are using and this simple section is the one in question:

    IF
    See([ENEMY])
    THEN
    RESPONSE #100
    Attack(NearestEnemyOf(Myself))
    END

    This works but if I replace it with

    IF
    See([ENEMY])
    THEN
    RESPONSE #100
    Attack(Nearest([ENEMY])
    END

    it doesn't work.

  • horredtheplaguehorredtheplague Member, Developer Posts: 183
    @Mathsorcerer I documented this bug and several other Object.IDS bugs in the ToB engine many years back, on TeamBg site. The scripting guide available on SHS has my notes on it intact (sorry, forget the guide's name offhand). But the gist of it, was that Nearest(), especially w/ IDS targetting (like Nearest([ENEMY])) didn't work. Something like:
    NearestEnemyOfType([ENEMY.0.0.CLERIC_ALL]) does. NearestMyGroupOfType also works fine. It's possible that BGEE addressed the top-block usage of Nearest, but overlooked its bottom extensions.

    In the script you have above, try using:

    Attack(LastSeenBy(Myself)) instead of Attack(Nearest([ENEMY])) and you'll be golden.

  • MathsorcererMathsorcerer Member Posts: 3,003
    I may have read the information from that site at some point in the past but too much time has passed. I have simply adjusted my scripting to avoid the particular things which do not work. Things like See([ALLY]) work, but for this I'll just go with NearestEnemyOfType([ids]) from now on.

    My wife thinks I am making certain parts too difficult, but I have been upgrading certain encounters so that the characters have a better balance of spells and use them correctly. Davaeorn will now use Stoneskin and Improved Invisibilty but if you don't defeat him quickly enough he will go up to the first level of the mine and flood it with you inside. I had Mulahey opening up with Unholy Blight if the party's alignment is good but the first time I tried it he killed 4 out of 6 people, so I had to take that out, going back to Rigid Thinking, Hold Person, and Silence 15' Radius. There were also some loops in Mulahey's dialog that I fixed. Nimbul will Haste himself, use Horror and Web on you, then starts throwing poisoned daggers. I haven't gotten to other specific encounters yet but this is a work in progress.

    Since I don't download and use other people's mods I have to do something to fix little things in the game I think should be improved.

Sign In or Register to comment.