Jump to content

Use script to check PC's level is greater or less than a specific level


Recommended Posts

Posted

There's the following function to check the level of the character:

CheckStatGT(Myself,10,LEVEL)

Is there something similar or a way to check if a PC's level is greater or less than a specific number (e.g. >=5 or <=15)?

Or better yet, check if it's in a range:

5 <= LEVEL <= 15

 

Posted

I guess I could use something like:

IF
	OR(11)
	CheckStatGT(Myself,5,LEVEL)
	CheckStatGT(Myself,6,LEVEL)
	CheckStatGT(Myself,7,LEVEL)
	CheckStatGT(Myself,8,LEVEL)
	CheckStatGT(Myself,9,LEVEL)
	CheckStatGT(Myself,10,LEVEL)
	CheckStatGT(Myself,11,LEVEL)
	CheckStatGT(Myself,12,LEVEL)
	CheckStatGT(Myself,13,LEVEL)
	CheckStatGT(Myself,14,LEVEL)
	CheckStatGT(Myself,15,LEVEL)
THEN
	RESPONSE #100
		//Do something
END

But it's pretty damn ugly...

Posted (edited)

Two boundaries? Two conditions.

CheckStatGT(Myself,4,LEVEL)
CheckStatLT(Myself,16,LEVEL)

(Your proposed code is using the wrong triggers, checking for inequality instead of equality)

There's also a specific trigger to check levels (Level, LevelGT, LevelLT); the number it uses is the average of all relevant levels for multi-class and dual-class characters. [Ignore what I previously wrote in this paragraph; it was based on an error]

With the CheckStat method applied to a multi-class or dual-class character, note that you're checking the creature's first level - order determined by the naming order of the multiclass. Apply this to Anomen (fighter/cleric), and you'll always get his fighter level of 7. Apply this to Nalia (mage/thief), and you'll always get her mage level (varies). Properly accounting for multiclass and dual-class characters would require more complicated logic that also looks at the LEVEL2 and LEVEL3 stats. Or the Level/LevelGT/LevelLT trigger group.

Edited by jmerry
Correcting a mistake
Posted (edited)

isn't that just

CheckStatGT(Myself,5,LEVEL)
CheckStatLT(Myself,15,LEVEL)

I never found any reference for the BAF syntax so I'm a bit unsure. But that would make sense if it were like this (except the way the AND and OR are handled seems really stange but... the entirety of weidu syntax is kind of baroque anyway)

(also needsto check if GT and LT include the limit value or not, which https://gibberlings3.github.io/iesdp/scripting/triggers/bgeetriggers.htm doesn't seem to tell)

 

EDIT: ignore me, way better (and more informed) anwser above mine.

Edited by mickabouille
Posted

GT in triggers is always >, LT in triggers is always <. If you want the boundary value, you either shift by one or use the negation. This code:

!CheckStatLT(Myself,5,LEVEL)
!CheckStatGT(Myself,15,LEVEL)

is equivalent to what I wrote in my previous post.

Posted (edited)

Thanks!

I feel this could be explicit in the description linked above.

I forbid myself from ever saying (even orally) "greater than". I always say "strictly greater than" or "greater than or equal".

Of course, CheckStatLT/CheckStatGT are consistent with other languages/apis that use a LT/LTE or GT/GTE distinction, but as the LTE/GTE variants do not exist (or do they?) I couldn't be sure.

Edited by mickabouille
Posted

They don't exist; I checked by searching the IESDP triggers page. Not one hit for "gte" or "lte". Trying "ge" or "le" returns only cases of those letters embedded in other words like "general" or "less" (but not "morale"; the browser's text search only checks capital letters and beginnings of words for the start of the search string).

If you want any sort of "greater than or equal to" check in the BAF/BCS scripting language, you need to either shift the endpoint, negate a "less than" check, or cobble it together with an OR combination. Always, no exceptions.

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

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...