</code></pre></div></div><p>Gets the next argument from sfall. Each time it’s called it returns the next argument, or otherwise it returns 0 if there are no more arguments left. You can arbitrarily get the value of any argument using the <codeclass="language-plaintext highlighter-rouge">sfall_func1("get_sfall_arg_at", argNum)</code> function.</p><hr/><h3class="d-inline-block"id="get_sfall_arg_at"><ahref="#get_sfall_arg_at"class="anchor-heading"aria-labelledby="get_sfall_arg_at"><svgviewBox="0 0 16 16"aria-hidden="true"><usexlink:href="#svg-link"></use></svg></a><strong>get_sfall_arg_at</strong></h3><pclass="label label-green">sfall.h</p><divclass="language-c++ highlighter-rouge"><divclass="highlight"><preclass="highlight"><code><spanclass="n">mixed</span><spanclass="n">get_sfall_arg_at</span><spanclass="p">(</span><spanclass="kt">int</span><spanclass="n">argNum</span><spanclass="p">)</span>
</code></pre></div></div><p>Gets the value of hook argument with the specified argument number (first argument of hook starts from 0)</p><hr/><h3id="get_sfall_args"><ahref="#get_sfall_args"class="anchor-heading"aria-labelledby="get_sfall_args"><svgviewBox="0 0 16 16"aria-hidden="true"><usexlink:href="#svg-link"></use></svg></a><strong>get_sfall_args</strong></h3><divclass="language-c++ highlighter-rouge"><divclass="highlight"><preclass="highlight"><code><spanclass="kt">int</span><spanclass="n">get_sfall_args</span><spanclass="p">()</span>
</code></pre></div></div><p>Returns all hook arguments as a new temp array.</p><hr/><h3id="init_hook"><ahref="#init_hook"class="anchor-heading"aria-labelledby="init_hook"><svgviewBox="0 0 16 16"aria-hidden="true"><usexlink:href="#svg-link"></use></svg></a><strong>init_hook</strong></h3><divclass="language-c++ highlighter-rouge"><divclass="highlight"><preclass="highlight"><code><spanclass="kt">int</span><spanclass="n">init_hook</span><spanclass="p">()</span>
</code></pre></div></div><p>The hook script equivalent of <codeclass="language-plaintext highlighter-rouge">game_loaded</code>; it returns 1 when the script is loaded for the first time or when the player reloads the game, and 0 otherwise.</p><hr/><h3id="register_hook"><ahref="#register_hook"class="anchor-heading"aria-labelledby="register_hook"><svgviewBox="0 0 16 16"aria-hidden="true"><usexlink:href="#svg-link"></use></svg></a><strong>register_hook</strong></h3><divclass="language-c++ highlighter-rouge"><divclass="highlight"><preclass="highlight"><code><spanclass="kt">void</span><spanclass="n">register_hook</span><spanclass="p">(</span><spanclass="kt">int</span><spanclass="n">hookID</span><spanclass="p">)</span>
</code></pre></div></div><p>Used from a normal global script if you want to run it at the same point a full hook script would normally run. In case of this function, <codeclass="language-plaintext highlighter-rouge">start</code> procedure will be executed in current global script. You can use all above functions like normal.</p><hr/><h3id="register_hook_proc"><ahref="#register_hook_proc"class="anchor-heading"aria-labelledby="register_hook_proc"><svgviewBox="0 0 16 16"aria-hidden="true"><usexlink:href="#svg-link"></use></svg></a><strong>register_hook_proc</strong></h3><divclass="language-c++ highlighter-rouge"><divclass="highlight"><preclass="highlight"><code><spanclass="kt">void</span><spanclass="n">register_hook_proc</span><spanclass="p">(</span><spanclass="kt">int</span><spanclass="n">hookID</span><spanclass="p">,</span><spanclass="n">proc</span><spanclass="n">procedure</span><spanclass="p">)</span>
</code></pre></div></div><p>The same as <codeclass="language-plaintext highlighter-rouge">register_hook</code>, except that you specifically define which procedure in the current script should be called as a hook (instead of “start” by default). Pass procedure the same as how you use dialog option functions. This IS the recommended way to use hook scripts, as it gives both modularity (each mod logic in a separate global script with no conflicts) and flexibility. You can place all related hook scripts for a specific mod in one global script!</p><p>Use zero (0) as second argument to unregister hook script from current global script.</p><p><strong>NOTE:</strong> you can hook several scripts to a single hook point, for example if it’s different mods from different authors or just some different aspects of one larger mod. When one of the scripts in a chain returns value with <codeclass="language-plaintext highlighter-rouge">set_sfall_return</code>, the next script may override this value if calls <codeclass="language-plaintext highlighter-rouge">set_sfall_return</code> again.</p><p><strong>Example:</strong> Sometimes you need to multiply certain value in a chain of hook scripts. Let’s say we have a <strong>Mod A</strong> which reduces all “to hit” chances by 50%. The code might look like this:</p><divclass="language-js highlighter-rouge"><divclass="highlight"><preclass="highlight"><code><spanclass="nx">original_chance</span><spanclass="o">=</span><spanclass="nx">get_sfall_arg</span><spanclass="p">;</span>
</code></pre></div></div><p><strong>Mod B</strong> also want to affect hit chances globally, by increasing them by 50%. Now in order for both mods to work well together, we need to add this line to <strong>Mod A</strong> hook script:</p><divclass="language-js highlighter-rouge"><divclass="highlight"><preclass="highlight"><code><spanclass="nx">set_sfall_arg</span><spanclass="p">(</span><spanclass="mi">0</span><spanclass="p">,</span><spanclass="p">(</span><spanclass="nx">original_chance</span><spanclass="o">/</span><spanclass="mi">2</span><spanclass="p">));</span>
</code></pre></div></div><p>This basically changes hook argument for the next script. <strong>Mod B</strong> code:</p><divclass="language-js highlighter-rouge"><divclass="highlight"><preclass="highlight"><code><spanclass="nx">original_chance</span><spanclass="o">=</span><spanclass="nx">get_sfall_arg</span><spanclass="p">;</span>
</code></pre></div></div><p>So if you combine both mods together, they will run in chain and the end result will be a 75% from original hit chance (hook register order doesn’t matter in this case, if you use <codeclass="language-plaintext highlighter-rouge">set_sfall_arg</code> in both hooks).</p><p>The defines to use for the <codeclass="language-plaintext highlighter-rouge">hookID</code> are in <strong>sfall.h</strong>.</p><hr/><h3id="register_hook_proc_spec"><ahref="#register_hook_proc_spec"class="anchor-heading"aria-labelledby="register_hook_proc_spec"><svgviewBox="0 0 16 16"aria-hidden="true"><usexlink:href="#svg-link"></use></svg></a><strong>register_hook_proc_spec</strong></h3><divclass="language-c++ highlighter-rouge"><divclass="highlight"><preclass="highlight"><code><spanclass="kt">void</span><spanclass="n">register_hook_proc_spec</span><spanclass="p">(</span><spanclass="kt">int</span><spanclass="n">hookID</span><spanclass="p">,</span><spanclass="n">procedure</span><spanclass="n">proc</span><spanclass="p">)</span>
</code></pre></div></div><p>Works the same as <codeclass="language-plaintext highlighter-rouge">register_hook_proc</code>, except that it registers the current script at the end of the hook script execution chain (i.e. the script will be executed after all previously registered scripts for the same hook, including the <codeclass="language-plaintext highlighter-rouge">hs_<name>.int</code> script). In addition, all scripts hooked to a single hook point with this function are executed in the exact order of how they were registered. In the case of using <codeclass="language-plaintext highlighter-rouge">register_hook</code> and <codeclass="language-plaintext highlighter-rouge">register_hook_proc</code> functions, scripts are executed in reverse order of how they were registered. <strong>The execution chain of script procedures for a hook is as follows:</strong> 1. Procedures registered with <codeclass="language-plaintext highlighter-rouge">register_hook</code> and <codeclass="language-plaintext highlighter-rouge">register_hook_proc</code> functions (executed in reverse order of registration). 2. The <codeclass="language-plaintext highlighter-rouge">hs_<name>.int</code> script. 3. Procedures registered with the <codeclass="language-plaintext highlighter-rouge">register_hook_proc_spec</code> function (executed in the exact order of registration).</p><hr/><h3id="set_sfall_arg"><ahref="#set_sfall_arg"class="anchor-heading"aria-labelledby="set_sfall_arg"><svgviewBox="0 0 16 16"aria-hidden="true"><usexlink:href="#svg-link"></use></svg></a><strong>set_sfall_arg</strong></h3><divclass="language-c++ highlighter-rouge"><divclass="highlight"><preclass="highlight"><code><spanclass="kt">void</span><spanclass="n">set_sfall_arg</span><spanclass="p">(</span><spanclass="kt">int</span><spanclass="n">argNum</span><spanclass="p">,</span><spanclass="kt">int</span><spanclass="n">value</span><spanclass="p">)</span>
</code></pre></div></div><p>Changes argument value. The argument number (<codeclass="language-plaintext highlighter-rouge">argNum</code>) is 0-indexed. This is useful if you have several hook scripts attached to one hook point (see <codeclass="language-plaintext highlighter-rouge">register_hook_proc</code>).</p><hr/><h3id="set_sfall_return"><ahref="#set_sfall_return"class="anchor-heading"aria-labelledby="set_sfall_return"><svgviewBox="0 0 16 16"aria-hidden="true"><usexlink:href="#svg-link"></use></svg></a><strong>set_sfall_return</strong></h3><divclass="language-c++ highlighter-rouge"><divclass="highlight"><preclass="highlight"><code><spanclass="kt">void</span><spanclass="n">set_sfall_return</span><spanclass="p">(</span><spanclass="n">any</span><spanclass="n">value</span><spanclass="p">)</span>
</code></pre></div></div><p>Used to return the new values from the script. Each time it’s called it sets the next value, or if you’ve already set all return values it does nothing.</p></main></div></div><divclass="search-overlay"></div></div></body></html>