Jump to content

Detect(O:Object*), Objects and Invisibility


Recommended Posts

A lot of scripts use Detect() with combination of objects eg. NearestEnemyOf(Myself), but Detect won't detect  if enemy is fully invisible somehow. It works with with EA eg. ANYONE, GOODCUTOFF, EVILCUTOFF

Priest18.BCS

IF
    Detect(NearestEnemyOf(Myself))
    !See(NearestEnemyOf(Myself))
    HaveSpell(CLERIC_TRUE_SIGHT)  // SPPR505.SPL (True Seeing)
THEN
    RESPONSE #100
        Spell(NearestEnemyOf(Myself),CLERIC_TRUE_SIGHT)  // SPPR505.SPL (True Seeing)
END

 

Second script works (for nearest GOODCUTOFF invisible/improved invisibility target only)


IF
	ActionListEmpty()
	Allegiance(Myself,ENEMY)
	Detect([GOODCUTOFF])
	OR(3)
		!See(LastSeenBy(Myself))
		StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
		StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
	HaveSpell(CLERIC_TRUE_SIGHT)  // SPPR505.SPL (True Seeing)
THEN
	RESPONSE #100
		Spell(Myself,CLERIC_TRUE_SIGHT)  // SPPR505.SPL (True Seeing)
END

 

Edited by Gamemacik
Link to comment

So what did you try? You have non-trivial code there, so it's not clear that the problem is where you say it is. Eg. does this block also result in a cast when in your special invisibility state?

IF
    Detect(NearestEnemyOf(Myself))
    HaveSpell(CLERIC_TRUE_SIGHT)  // SPPR505.SPL (True Seeing)
THEN
    RESPONSE #100
        Spell(NearestEnemyOf(Myself),CLERIC_TRUE_SIGHT)  // SPPR505.SPL (True Seeing)
END

And are you sure NearestEnemyOf(Myself) is matching and matching who you expect?

Link to comment
Posted (edited)
16 hours ago, lynx said:


IF
    Detect(NearestEnemyOf(Myself))
    HaveSpell(CLERIC_TRUE_SIGHT)  // SPPR505.SPL (True Seeing)
THEN
    RESPONSE #100
        Spell(NearestEnemyOf(Myself),CLERIC_TRUE_SIGHT)  // SPPR505.SPL (True Seeing)
END

 

I would not post untested code, i tested also this code (above) of course, i tested it today again, I spawned enemy orc shaman with this code attached to class script, tested with override script also, shaman just stand and does nothing. I tried also code without HaveSpell and with ForceSpell, result is same also. Shaman had only one script attached to avoid possible script conflicts, from my testing result is same as posted in my first post above. 

IF
	Detect(NearestEnemyOf(Myself))
THEN
	RESPONSE #100
		ForceSpell(NearestEnemyOf(Myself),CLERIC_TRUE_SIGHT)  // SPPR505.SPL (True Seeing)
END

 

Edited by Gamemacik
Link to comment

For a more bulletproof test you'd have to use a message or ReallyForceSpell, but I doubt you'd get much different results. I still think your corner case is a problem in matching, not Detect though. And with the last two tests that could be in the action body as well.

Link to comment

To be clear, Detect() has no problem detecting invisible creatures, as evidenced by it working "correctly" when using object selectors, (eg. [ANYONE]).

NearestEnemyOf(), however, will not match an invisible creature unless the caller is under op193 (Invisible Detection by Script). I suspect this is true for all/most of the Nearest objects.

Edited by Bubb
Link to comment

@Bubb  I may be remembering wrong, but:

Isn't it only the 0x0### triggers that allow object selectors to include invisible objects (as well as a few other normally undetectable conditions).

While the 0x4### triggers as well as all actions do not allow object selectors to include invisible objects without op193.

Then their's ActionOverride(), which allows it's object specifier to include the active creature.

Link to comment
Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...