Closed tnevolin closed 3 years ago
Give your examples or Goal.
I am trying to create a QoL improvement where player does not need to use lockpicks on a lock to benefit from their lockpicking bonus. Instead I will intercept the lockpick operation, check whether dude has lockpicks in inventory and modify success ratio corresponding to the best and matching lockpicks type in the inventory.
I have tried to use HOOK_USESKILLON but it is not executed for lockpicking as it is overridden by scripts for each and every lock in the game. Now I am trying to do the same with HOOK_STDPROCEDURE that is called when lockpick script use_skill_on_p_proc procedure is called. It works fine. Unfortunately, it does not pass skill as a parameter and I don't know how else to retrieve it. The action_being_used fails with an error as it is called from hook function not from within the script.
Unfortunately, it does not pass skill as a parameter and I don't know how else to retrieve it.
Why not just check source_obj's skill level on your own?
I don't need skill level. I need the skill id/name. The use_skill_on_p_proc procedure could be called for any skill: science, repair, lockpick, etc. I need to make sure it is called for lockpick specifically and ignore other cases.
See example in DOORL100.ssl
procedure use_skill_on_p_proc begin
variable Skill_Used;
Skill_Used:=action_being_used;
if (Skill_Used == SKILL_LOCKPICK) then begin
…
When using a lockpick item, various events may occur for the game, which with your "QoL" will not be able to occur.
You probably need to unlock the lock yourself, and not pass the modified skill values. Another way is to temporarily increase the skill, and then lower it.
I don't need skill level. I need the skill id/name.
OK.
The action_being_used fails with an error as it is called from hook function not from within the script.
This should work from HOOK as well. Show your script.
procedure start begin
register_hook_proc(HOOK_STDPROCEDURE, handleStandardProcedure);
end
procedure handleStandardProcedure begin
// fails at this point
variable skill = action_being_used;
end
https://fakelshub.github.io/sfall-wiki/objects/#set_self Used it?
set_self(source);
action_being_used
https://fakelshub.github.io/sfall-wiki/objects/#set_self Used it?
Nope. Let me try.
I'll see later why action_being_used
doesn't work if set_self doesn't act for it.
https://fakelshub.github.io/sfall-wiki/objects/#set_self Used it?
Nope. Let me try.
That worked. Thank you!
I have another question if you can answer it from the top of your head. If not, I'll create an issue.
All locks are scripted and the type of the lock (standard/electric) is defined in the the script.
#define LOCK_STATUS STATE_STANDARD_LOCK
or
#define LOCK_STATUS STATE_ELECTRIC_LOCK
Is there a way to retrieve this information from the object (door)? The only thing I could find is https://sfall.bgforge.net/objects-and-scripts/#get_script that return script # for object but what to do with it? Can I extract script text to parse it manually?
Can I extract script text to parse it manually?
no (there is no text, there are operation codes)
Is there a way to retrieve this information from the object (door)?
no, this information is only in the script (in a local variable).
I did this ugly way. Thank you for help with hooks!
https://sfall.bgforge.net/hook-types/#stdprocedure
This would be a tremendous hook if it can also capture action_being_used thing. Unfortunately, the direct call to this function results in error probably because it is not called from the object script. Any other ways to capture skill being used when use_skill_on_p_proc is invoked ?