The resref field in Opcode #403 defines a Lua function that is called whenever an effect is being added to the target creature. The Lua function's signature can be seen in the following example:
function B3BLOCKD(effectData, creatureData)
local effectID = EEex_ReadDword(effectData + 0xC)
if effectID == 12 then
Infinity_DisplayString("B3BLOCKD blocking effectID 12")
return true
end
end
A return value of true blocks the effect from applying. Note: the immunity function "sees" effects after they have passed their probability roll, but before any saving throws have been made against said effect / other immunity mechanisms have taken place.
I've updated my Near Infinity fork to include the new opcode definition: here.
Mmm, well I would have said "absolutely" before I looked at it, but the way I've implemented it abstracts away the actual opcode...
Would require a major rework of the mechanism to store the originating effect instead of just the Lua function. Does what you are trying to do require access to the originating opcode?
Mmm, well I would have said "absolutely" before I looked at it, but the way I've implemented it abstracts away the actual opcode...
Would require a major rework of the mechanism to store the originating effect instead of just the Lua function. Does what you are trying to do require access to the originating opcode?
If it's that hard to do it, then don't worry about it right now. I just asked in case it was easy.
EEex has been able to alter the actionbar for a while now via a combination of EEex_AddActionbarListener() and EEex_SetActionbarButton(), but, admittedly, it is difficult to persistently target specific creatures using these mechanisms.
Would an Opcode #404 be desired, which changes a specified button on the target creature?
EEex has been able to alter the actionbar for a while now via a combination of EEex_AddActionbarListener() and EEex_SetActionbarButton(), but, admittedly, it is difficult to persistently target specific creatures using these mechanisms.
Would an Opcode #404 be desired, which changes a specified button on the target creature?
2) It has to do with how the engine recommends you equip certain items when you are moving them around the inventory. The VALUE column is multiplied with the stat's real value, and the resulting number is added to a total "rating" count. The higher the rating, the better the item in the eyes of the engine.
Any stat not listed in this file will be treated as a "0" towards the total rating. ARMORCLASS has a VALUE of -1 because lower is better, and so it needs to be flipped. It appears this file can be appended with any stat in STATS.IDS along with a multiplier to make the engine consider that stat when recommending equipment.
I noticed that when an area script (or BALDUR.BCS) casts a spell, the effects of that spell have a source ID that's not 0. When I put something like EEex_GetActorStat(sourceID, 645) in my code, the game crashes if the source is an area script or BALDUR.BCS. How would I check whether or not an actor ID is pointing to an actual creature?
Another question: how can I store a global variable at instant speed (i.e. as fast as a normal Lua function like EEex_GetGlobal)? Setting a global variable via a script action or an opcode is too slow. Using a Lua global won't work because those aren't specific to a save game.
I just need a place somewhere in the save game data that's not being used where I can store a number.
@OlvynChuru: That would require a new function. I was looking at this a week ago and actually made some progress towards it; I'll have it uploaded either tonight or tomorrow.
It take it you need a game variable that's stored in the GAM file? Is it possible to create one beforehand (I'm not versed on the exact details on how that's done so maybe its not something that can be done easily) and get the address of that game variable in memory (probably via some EEex function) and then use one of the fields that not been used? Not sure what version of the GAM format EE games use. Read/write directly to the address via other EEex functions (EEex_ReadDword, EEexWriteDword) - which wrap the VirtualProtect api and read/write to the memory address of the game variable field.
By the way, what options are there for changing a creature's height? I remember you said trying to change a creature's height causes them to bounce. But is there any way we could control or change the bouncing? Maybe make the height only change in one direction rather than going up and down? Or could we pause the bouncing in the middle, to keep the creature at a new height? What things could EEex do here?
By the way, the context for this is I'm creating a flying mechanic, allowing certain creatures to fly over normally impassable areas.
@OlvynChuru: Bounce mechanics are not meant to be used on the living :
Besides, the posz value isn't persisted in save games. In order to change posz it would require a new opcode that sets a minimum possible value, and disables the bounce mechanism. Would also have to make sure it plays nice with the height map, or possibly ignore it.
Does the height need to be changed dynamically, (I.E. from Lua?), or will a static opcode do?
@Bubb Oh wow! I had no idea it was even possible to do that much! Looks good so far!
The problem with posz not being saved could be fixed by having an effect that sets the height automatically trigger when the creature is spawned or the game is loaded. I've figured out ways of doing that without any additional help. One way is to have a permanent Invoke Lua opcode that does something if the source ID of the opcode is -1 (which it is set to when the game is loaded) and then sets the opcode's source ID the actor's ID.
Disabling the bounce mechanism sounds good, though if that is too hard then setting a minimum possible value would be fine as well.
Since you were able to set the Z Position value, is it also possible to set the Delta Z value? I remember there being something like that.
The simplest way of dealing with the height map is to have an opcode that makes a sprite always be rendered on top of everything else, like flying creatures are. (This was actually something else I was going to ask you for.)
It would be better for the height to be changed via Lua, since if that is possible then an opcode could also do it (with opcode 402).
By the way, that B3SetPosZ function could also be used to represent a creature falling from a great height.
From what I can tell, the states in STATE.IDS that aren't a power of 2 are combinations of other states. STATE_ILLUSIONS, for example, is a combination of STATE_INVISIBLE, STATE_IMPROVEDINVISIBILITY, STATE_BLUR, and STATE_MIRRORIMAGE (the IDS value for STATE_ILLUSIONS is gotten by adding the IDS values of those four states).
I think that StateCheck(NearestEnemyOf(Myself),STATE_ILLUSIONS) might check if the enemy has at least one of those four states, but I haven't tested it.
Once again, I'd like to know if a certain feature is functional or not....
@Bubb What can you tell me of SPLPROT.2da and '0x106 - areatype (like outdoors, forest, etc)'? Is it functional? I'm asking because opcode #318 (AREATYPE != specified value, where 'value' is OUTDOOR) returns true in OUTDOOR areas (e.g., AR2600.are......)
EDIT: sorry, it works now - I set 'relation' to 5 (not equal) in SPLPROT.2da, whereas the correct value is 9 (binary not match)...
Param1 is the button type to replace, (ids match what is defined by EEex_ACTIONBAR_TYPE in M__EEex.lua).
Param2 is the button type to replace with, (ids same as above).
Note that I implemented this opcode almost entirely in Lua, so let me know if the game is laggier than normal.
My NI fork has been updated with the new opcode: download it here.
I've been doing some research testing the bounce mechanic. I cast a spell on Dynaheir that causes her corpse to jump out of her skin.
Her corpse then walks up to Charname for the "do you want me back in the party" dialogue. But a few seconds later she freezes in place for a couple of seconds. This is the same issue you had shown when you used that function to change a creature's height.
Fortunately, I've found a way to fix that freezing thing. Applying any effect to the immobile character ends that freezing thing and lets them move as normal. I think I could probably deal with the freezing problem on my own if you could give us ways to change a creature's height and change or possibly disable the bounce effect.
Once again, I'd like to know if a certain feature is functional or not....
@Bubb What can you tell me of SPLPROT.2da and '0x106 - areatype (like outdoors, forest, etc)'? Is it functional? I'm asking because opcode #318 (AREATYPE != specified value, where 'value' is OUTDOOR) returns true in OUTDOOR areas (e.g., AR2600.are......)
EDIT: sorry, it works now - I set 'relation' to 5 (not equal) in SPLPROT.2da, whereas the correct value is 9 (binary not match)...
Wait - do you have this working in the unmodded game, or only with EEex?
B3_CuBar.lua and Opcode #405 (OverrideButtonIndex) are now in master!
B3_CuBar.lua =>
Enables customization of a character's actionbar ingame through a graphical interface. Simply hold shift with the character you want to alter selected, and change the buttons as you wish, like so:
Note that for the sake of fair play only buttons that are already available to the character / don't provide new powers are able to be swapped in. Release the shift key when done editing the actionbar.
To enable, flip
["B3_CuBar"] = false,
to true in EEex_INI.lua
Opcode #405 (OverrideButtonIndex) =>
Overrides a button based on index and actionbar configuration:
Param1 = Button index to override
Param2 = Button type to override with
Special = Actionbar config to match (-1 to match any class home)
@OlvynChuru: Your bounce mechanic override will be the next thing I do.
B3_CuBar.lua and Opcode #405 (OverrideButtonIndex) are now in master!
B3_CuBar.lua =>
Enables customization of a character's actionbar ingame through a graphical interface. Simply hold shift with the character you want to alter selected, and change the buttons as you wish, like so:
Note that for the sake of fair play only buttons that are already available to the character / don't provide new powers are able to be swapped in. Release the shift key when done editing the actionbar.
To enable, flip
["B3_CuBar"] = false,
to true in EEex_INI.lua
Opcode #405 (OverrideButtonIndex) =>
Overrides a button based on index and actionbar configuration:
Param1 = Button index to override
Param2 = Button type to override with
Special = Actionbar config to match (-1 to match any class home)
@OlvynChuru: Your bounce mechanic override will be the next thing I do.
Cool!
Regarding B3_CuBar.lua.
I vaguely remember that there was a spontaneous casting mechanism that also used the shift key(i.e. hold the shift key to cast cure light wounds instead of any first level priest spell, for instance). I still have to go through the thread, so maybe I'm wrong, but is there a conflict?
Comments
The resref field in Opcode #403 defines a Lua function that is called whenever an effect is being added to the target creature. The Lua function's signature can be seen in the following example:
A return value of true blocks the effect from applying. Note: the immunity function "sees" effects after they have passed their probability roll, but before any saving throws have been made against said effect / other immunity mechanisms have taken place.
I've updated my Near Infinity fork to include the new opcode definition: here.
Could you let it pass the parameters of the opcode 403 effect to the function, as can be done with opcode 402?
Would require a major rework of the mechanism to store the originating effect instead of just the Lua function. Does what you are trying to do require access to the originating opcode?
If it's that hard to do it, then don't worry about it right now. I just asked in case it was easy.
Would an Opcode #404 be desired, which changes a specified button on the target creature?
That would be nice!
1) No. It appears only the resref field is used.
2) It has to do with how the engine recommends you equip certain items when you are moving them around the inventory. The VALUE column is multiplied with the stat's real value, and the resulting number is added to a total "rating" count. The higher the rating, the better the item in the eyes of the engine.
Any stat not listed in this file will be treated as a "0" towards the total rating. ARMORCLASS has a VALUE of -1 because lower is better, and so it needs to be flipped. It appears this file can be appended with any stat in STATS.IDS along with a multiplier to make the engine consider that stat when recommending equipment.
Well, I noticed it's set to 1 for Shamans - both player created and enemies (e.g., BDTROLSH.cre)....
Edit: Btw, here's all of the types if you are curious:
0x1 = CGameObject::TYPE_AIBASE
0x10 = CGameObject::TYPE_SOUND
0x11 = CGameObject::TYPE_CONTAINER
0x20 = CGameObject::TYPE_SPAWNING
0x21 = CGameObject::TYPE_DOOR
0x30 = CGameObject::TYPE_STATIC
0x31 = CGameObject::TYPE_SPRITE
0x40 = CGameObject::TYPE_OBJECT_MARKER
0x41 = CGameObject::TYPE_TRIGGER
0x51 = CGameObject::TYPE_TILED_OBJECT
0x60 = CGameObject::TYPE_TEMPORAL
0x61 = CGameObject::TYPE_AREA_AI
0x70 = CGameObject::TYPE_FIREBALL
0x71 = CGameObject::TYPE_GAME_AI
Another question: how can I store a global variable at instant speed (i.e. as fast as a normal Lua function like EEex_GetGlobal)? Setting a global variable via a script action or an opcode is too slow. Using a Lua global won't work because those aren't specific to a save game.
I just need a place somewhere in the save game data that's not being used where I can store a number.
EEex_SetGlobal(globalName, value) - Sets variable in GAM
EEex_SetAreaGlobal(areaResref, globalName, value) - Sets variable in ARE
EEex_SetActorLocal(actorID, localName, value) - Sets variable in CRE
( @OlvynChuru )
By the way, what options are there for changing a creature's height? I remember you said trying to change a creature's height causes them to bounce. But is there any way we could control or change the bouncing? Maybe make the height only change in one direction rather than going up and down? Or could we pause the bouncing in the middle, to keep the creature at a new height? What things could EEex do here?
By the way, the context for this is I'm creating a flying mechanic, allowing certain creatures to fly over normally impassable areas.
Besides, the posz value isn't persisted in save games. In order to change posz it would require a new opcode that sets a minimum possible value, and disables the bounce mechanism. Would also have to make sure it plays nice with the height map, or possibly ignore it.
Does the height need to be changed dynamically, (I.E. from Lua?), or will a static opcode do?
The problem with posz not being saved could be fixed by having an effect that sets the height automatically trigger when the creature is spawned or the game is loaded. I've figured out ways of doing that without any additional help. One way is to have a permanent Invoke Lua opcode that does something if the source ID of the opcode is -1 (which it is set to when the game is loaded) and then sets the opcode's source ID the actor's ID.
Disabling the bounce mechanism sounds good, though if that is too hard then setting a minimum possible value would be fine as well.
Since you were able to set the Z Position value, is it also possible to set the Delta Z value? I remember there being something like that.
The simplest way of dealing with the height map is to have an opcode that makes a sprite always be rendered on top of everything else, like flying creatures are. (This was actually something else I was going to ask you for.)
It would be better for the height to be changed via Lua, since if that is possible then an opcode could also do it (with opcode 402).
By the way, that B3SetPosZ function could also be used to represent a creature falling from a great height.
Edit: it seems to be BLUR bor IMPROVEDINVISIBILITY bor MIRRORIMAGE bor INVISIBLE. Can you confirm?
2) What about STATE_HARMLESS?
From what I can tell, the states in STATE.IDS that aren't a power of 2 are combinations of other states. STATE_ILLUSIONS, for example, is a combination of STATE_INVISIBLE, STATE_IMPROVEDINVISIBILITY, STATE_BLUR, and STATE_MIRRORIMAGE (the IDS value for STATE_ILLUSIONS is gotten by adding the IDS values of those four states).
I think that StateCheck(NearestEnemyOf(Myself),STATE_ILLUSIONS) might check if the enemy has at least one of those four states, but I haven't tested it.
Yes, you're right. In particular, you can BOR the base STATEs (i.e., all those listed at offset 0x0020 of a CRE file) to form all the others.....
So, STATE_HARMLESS is FEEBLEMINDED | CHARMED | IMMOBILE..... and IMMOBILE is HELPLESS | STUNNED | SLEEPING
@Bubb What can you tell me of SPLPROT.2da and '0x106 - areatype (like outdoors, forest, etc)'? Is it functional? I'm asking because opcode #318 (AREATYPE != specified value, where 'value' is OUTDOOR) returns true in OUTDOOR areas (e.g., AR2600.are......)
EDIT: sorry, it works now - I set 'relation' to 5 (not equal) in SPLPROT.2da, whereas the correct value is 9 (binary not match)...
Param1 is the button type to replace, (ids match what is defined by EEex_ACTIONBAR_TYPE in M__EEex.lua).
Param2 is the button type to replace with, (ids same as above).
Note that I implemented this opcode almost entirely in Lua, so let me know if the game is laggier than normal.
My NI fork has been updated with the new opcode: download it here.
I've been doing some research testing the bounce mechanic. I cast a spell on Dynaheir that causes her corpse to jump out of her skin.
Her corpse then walks up to Charname for the "do you want me back in the party" dialogue. But a few seconds later she freezes in place for a couple of seconds. This is the same issue you had shown when you used that function to change a creature's height.
Fortunately, I've found a way to fix that freezing thing. Applying any effect to the immobile character ends that freezing thing and lets them move as normal. I think I could probably deal with the freezing problem on my own if you could give us ways to change a creature's height and change or possibly disable the bounce effect.
Unmodded, EEex is not required...
Hahahahahahah.....I can't wait to see v3.0 of HP BG.
B3_CuBar.lua =>
Enables customization of a character's actionbar ingame through a graphical interface. Simply hold shift with the character you want to alter selected, and change the buttons as you wish, like so:
Note that for the sake of fair play only buttons that are already available to the character / don't provide new powers are able to be swapped in. Release the shift key when done editing the actionbar.
To enable, flip
to true in EEex_INI.lua
Opcode #405 (OverrideButtonIndex) =>
Overrides a button based on index and actionbar configuration:
Param1 = Button index to override
Param2 = Button type to override with
Special = Actionbar config to match (-1 to match any class home)
@OlvynChuru: Your bounce mechanic override will be the next thing I do.
Cool!
Regarding B3_CuBar.lua.
I vaguely remember that there was a spontaneous casting mechanism that also used the shift key(i.e. hold the shift key to cast cure light wounds instead of any first level priest spell, for instance). I still have to go through the thread, so maybe I'm wrong, but is there a conflict?