Supported In: | ||
---|---|---|
C | D/S/W | W-CD |
? | ? | ? |
The scripting command If has the opcode (0x08/0x09/0x0A).
Arguments
- byte - comparison type
- Additional arguments by type
- Line Number (byte) - destination line number if comparison is true
Description
Performs a comparison depending on type and additional bytes. Jumps to the given line number if comparison is true, else continues to the next line. Most comparisons are performed on the currently selected character, as by WhoWill or SelRndChar for example.
- 0x08 - true if actual value <= comparison value
- 0x09 - true if actual value == comparison value
- 0x0A - true if actual value > comparison value
Notes
The "If" structure is very complex, with many, many comparison types. It always takes at least 3 arguments: the comparison type; at least one argument (though may be more, depending on type); and a destination number. This will need a lot of further investigation.
08 09 00 is often used as always true: every character will have at least 0 spell points. (if sp >= 0, do...)
Type | Arguments | Description |
---|---|---|
0x00 | --- | UNUSED: This does nothing. Do Not use! |
0x01 | --- | UNUSED: This does nothing. Do Not use! |
0x02 | --- | UNUSED: This does nothing. Do Not use! |
0x03 | Sex | TODO: Confirm 0=male, 1=female |
0x04 | Race | 0=Human, 1=Elf, 2=Dwarf, 3=Gnome, 4=H-Orc |
0x05 | Class | 0=Knight, 1=Paladin, 2=Archer, 3=Cleric, 4=Sorcerer, 5=Robber, 6=Ninja, 7=Barbarian, 8=Druid, 9=Ranger |
0x06 | --- | UNUSED: This does nothing. Do Not use! |
0x07 | --- | UNUSED: This does nothing. Do Not use! |
0x08 | HP (1) | Current Health Points. TODO: Why is this only 1 byte comparison? It can go higher than 256. |
0x09 | SP (1) | Current Spell Points. |
0x0A | AC (1) | Current Armor Class, including bonuses. TODO: Why is this only 1 byte comparison? It can go higher than 256. |
0x0B | LevelTmp (1) | Level bonus (extra beyond base) |
0x0C | Age (1) | Current Age, including unnatural aging. Capped at 254. |
0x0D | Skill (1) | Has the skill. 0=Theivary, 1=ArmsMaster, 2=Astrologer, 3=BodyBuilder, 4=Cartographer, 5=Crusader, 6=DirectionSense, 7=Linguist, 8=Merchant, 9=Mountaineer, 10=Navigator, 11=PathFinder, 12=PrayerMaster, 13=Prestidigitator, 14=Swimmer, 15=Tracker, 16=SpotSecretDoors, 17=DangerSense |
0x0E | --- | UNUSED: This does nothing. Do Not use! |
0x0F | Award | Checks if you have the given award number. TODO: Seems a little more complex than just a straight lookup. |
0x10 | Exp (4) | Current Experience (max 4,294,967,296) |
0x11 | PartyPoison (1) | Checks party magical resistance to poison, as set by Prot. from Elements spell. |
0x12 | Condition (1) | Is under the given condition. 0=Cursed, 1=HeartBroken, 2=Weak, 3=Poisoned, 4=Diseased, 5=Insane, 6=InLove, 7=Drunk |
0x13 | CanCast (1) | Checks if the character class is capable of casting the given spell number, and then if the character has actually purchased that spell. See AllSpells for a list of spells, who can cast them, and their corresponding numbers |
0x14 | GameFlag (1) | Checks if the given game flag is set. See Game_bit. |
0x15 | Item (1) | Searches inventories for given item number. Returns true if found. |
0x16 | --- | UNUSED: This does nothing. Do Not use! |
0x17 | --- | UNUSED: This does nothing. Do Not use! |
0x18 | --- | UNUSED: This does nothing. Do Not use! |
0x19 | Minutes (2) | Minutes since midnight. There is no "hour" variable (max 1,440) |
0x1A | --- | UNUSED: This does nothing. Do Not use! |
0x1B | --- | UNUSED: This does nothing. Do Not use! |
0x1C | --- | UNUSED: This does nothing. Do Not use! |
0x1D | --- | UNUSED: This does nothing. Do Not use! |
0x1E | --- | UNUSED: This does nothing. Do Not use! |
0x1F | --- | UNUSED: This does nothing. Do Not use! |
0x20 | --- | UNUSED: This does nothing. Do Not use! |
0x21 | --- | UNUSED: This does nothing. Do Not use! |
0x22 | Gold (4) | Current party gold (max 4,294,967,296) |
0x23 | Gems (2) | Current party gems (max 65,536) |
0x24 | --- | UNUSED: This does nothing. Do Not use! |
0x25 | MightTmp | Might Bonus (extra beyond base) |
0x26 | IntTmp | Intelligence Bonus (extra beyond base) |
0x27 | PersTmp | Personality Bonus (extra beyond base) |
0x28 | EndTmp | Endurance Bonus (extra beyond base) |
0x29 | SpdTmp | Speed Bonus (extra beyond base) |
0x2A | AccTmp | Accuracy Bonus (extra beyond base) |
0x2B | LuckTmp | Luck Bonus (extra beyond base) |
0x2C | YesNo (1) | If YesNo flag is 0, then it displays a Yes/No prompt. Clicking Yes makes the comparison true. If flag is 1, no prompt is displayed, but execution is paused until a key is pressed and comparison is automatically true. |
0x2D | MightBase | Might Base (before bonus) |
0x2E | IntBase | Intelligence Base (before bonus) |
0x2F | PersBase | Personality Base (before bonus) |
0x30 | EndBase | Endurance Base (before bonus) |
0x31 | SpdBase | Speed Bonus Base (before bonus) |
0x32 | AccBase | Accuracy Base (before bonus) |
0x33 | LuckBase | Luck Base (before bonus) |
0x34 | FireBase | Fire Resistance Base (before bonus) |
0x35 | ElecBase | Electricity Resistance Base (before bonus) |
0x36 | ColdBase | Cold Resistance Base (before bonus) |
0x37 | PsnBase | Poison Resistance Base (before bonus) |
0x38 | NrgBase | Energy Resistance Base (before bonus) |
0x39 | MgcBase | Magic Resistance Base (before bonus) |
0x3A | FireTmp | Fire Resistance Bonus (extra beyond base) |
0x3B | ElecTmp | Electricity Resistance Bonus (extra beyond base) |
0x3C | ColdTmp | Cold Resistance Bonus (extra beyond base) |
0x3D | PsnTmp | Poison Resistance Bonus (extra beyond base) |
0x3E | NrgTmp | Energy Resistance Bonus (extra beyond base) |
0x3F | MgcTmp | Magic Resistance Bonus (extra beyond base) |
0x40 | LevelBase | Base level (before bonuses) |
0x41 | Food | Party Food Amount |
0x42 | --- | UNUSED: This does nothing. Do Not use! |
0x43 | --- | UNUSED: This does nothing. Do Not use! |
0x44 | --- | UNUSED: This does nothing. Do Not use! |
0x45 | Levitate | Comparison against whether levitate spell is active or not. |
0x46 | Light | Comparison against the amount of light. |
0x47 | PartyFire (1) | Checks party magical resistance to fire, as set by Prot. from Elements spell. |
0x48 | PartyElec (1) | Checks party magical resistance to electricity, as set by Prot. from Elements spell. |
0x49 | PartyCold (1) | Checks party magical resistance to cold, as set by Prot. from Elements spell. |
0x4A | --- | UNUSED: This does nothing. Do Not use! |
0x4B | --- | UNUSED: This does nothing. Do Not use! |
0x4C | Day | Day of the current year (100 days per year) |
0x4D | ACTmp | Armor Class Bonuses (extra beyond base) |
0x4E | HPFull | Boolean compare: 1 if current HP is greater than or equal to max HP, 0 if below |
0x4F | WizardEye | Comparison against whether WizardEye spell is active or not. |
0x50 | --- | UNUSED: This does nothing. Do Not use! |
0x51 | SPFull | Boolean compare: 1 if current SP is greater than or equal to max SP, 0 if below |
0x52 | --- | UNUSED: This does nothing. Do Not use! |
0x53 | --- | UNUSED: This does nothing. Do Not use! |
0x54 | UNK | Comparison against a currently unknown byte |
0x55 | Year | Current game year since start. |
0x56 | Might | Total Might (base plus bonus) |
0x57 | Int | Total Intelligence (base plus bonus) |
0x58 | Pers | Total Personality (base plus bonus) |
0x59 | End | Total Endurance (base plus bonus) |
0x5A | Spd | Total Speed Bonus (base plus bonus) |
0x5B | Acc | Total Accuracy (base plus bonus) |
0x5C | Luck | Total Luck (base plus bonus) |
0x5D | Week | Current week of current year (day of year / 10) |
0x5E | WalkOnWater | Comparison against whether Walk On Water spell is active or not. |
0x5F | --- | UNUSED: This does nothing. Do Not use! |
0x60 | --- | UNUSED: This does nothing. Do Not use! |
0x61 | --- | UNUSED: This does nothing. Do Not use! |
0x62 | --- | UNUSED: This does nothing. Do Not use! |
0x63 | PartySkill | Boolean compare: 5=All Members have Crusader, 9=At least 2 have Mountaineer, 11=At least 2 have PathFinder, 14=All members have Swimmer. All others return true if at least one member of the party has the selected skill. |
0x64 | --- | UNUSED: This does nothing. Do Not use! |
0x65 | --- | UNUSED: This does nothing. Do Not use! |
0x66 | Thievery | Compares to the characters thievery skill |
0x67 | WorldFlag (1) | Checks if the given world flag is set. See World_bit. |
0x68 | QuestFlag (1) | Checks if the given quest flag is set. See Quest_bit. |
0x69 | MGCredit | Test number of Megacredits in the party. Only used by King's Engineer in Castle Burlock |
0x6A | --- | UNUSED: This does nothing. Do Not use! |
0x6B | InParty | Unknown use. Appears to be incomplete. Uses the currently selected character, but does no sanity checks against it. Also references code blocks as data blocks. Probably not safe to use. DO NOT USE! |
Additional notes: In theory the UNUSED codes can be implemented in future ports. Discussion may be required.
TODO: 0x54 reference two bytes of currently unknown use.
Event Opcodes
| ||||||||||
|