mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Changed the two example hook scripts to global scripts.
This commit is contained in:
+3
-1
@@ -14,7 +14,9 @@
|
|||||||
procedure start;
|
procedure start;
|
||||||
|
|
||||||
procedure start begin
|
procedure start begin
|
||||||
if (init_hook == 0) then begin
|
if game_loaded then begin
|
||||||
|
register_hook(HOOK_EXPLOSIVETIMER);
|
||||||
|
end else begin
|
||||||
variable
|
variable
|
||||||
time := get_sfall_arg,
|
time := get_sfall_arg,
|
||||||
result := ROLL_CRITICAL_FAILURE;
|
result := ROLL_CRITICAL_FAILURE;
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
Example implementation of the algorithm of how the game engine checks if one critter sees another critter.
|
||||||
|
|
||||||
|
NOTE: the AllowUnsafeScripting option must be enabled.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "..\headers\define.h"
|
||||||
|
#include "..\headers\command.h"
|
||||||
|
#include "..\headers\sfall\sfall.h"
|
||||||
|
#include "..\headers\sfall\define_extra.h"
|
||||||
|
|
||||||
|
#define can_see_(source, target) call_offset_r2(0x412BEC, source, target)
|
||||||
|
#define obj_dist_(target, source) call_offset_r2(0x48BBD4, target, source)
|
||||||
|
|
||||||
|
procedure start;
|
||||||
|
|
||||||
|
procedure start begin
|
||||||
|
if game_loaded then begin
|
||||||
|
register_hook(HOOK_WITHINPERCEPTION);
|
||||||
|
end else begin
|
||||||
|
variable
|
||||||
|
source := get_sfall_arg,
|
||||||
|
target := get_sfall_arg,
|
||||||
|
original := get_sfall_arg,
|
||||||
|
hookType := get_sfall_arg, /* new arg */
|
||||||
|
result := 0,
|
||||||
|
distance;
|
||||||
|
|
||||||
|
if target then begin
|
||||||
|
distance := get_critter_stat(source, STAT_pe);
|
||||||
|
|
||||||
|
if can_see_(source, target) then begin
|
||||||
|
distance *= 5;
|
||||||
|
if (get_flags(target) bwand FLAG_TRANSGLASS) then distance /= 2;
|
||||||
|
end else if combat_is_initialized then begin
|
||||||
|
distance *= 2;
|
||||||
|
end
|
||||||
|
|
||||||
|
if (target == dude_obj) then begin
|
||||||
|
if sneak_success then begin
|
||||||
|
distance /= 4;
|
||||||
|
if has_skill(target, SKILL_SNEAK) > 120 then distance -= 1;
|
||||||
|
end else if dude_is_sneaking then begin
|
||||||
|
distance := distance * 2 / 3;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if obj_dist_(target, source) <= distance then result := 1;
|
||||||
|
|
||||||
|
// example
|
||||||
|
if (result) then begin
|
||||||
|
display_msg("hs_withinperception: " + obj_name(source) + " sees " + obj_name(target) + " [original: " + original + " script: " + result + "]");
|
||||||
|
end else begin
|
||||||
|
display_msg("hs_withinperception: " + obj_name(source) + " does not see " + obj_name(target) + " [original: " + original + " script: " + result + "]");
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
//set_sfall_return(result);
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
/*
|
|
||||||
Example engine algorithm.
|
|
||||||
|
|
||||||
* The AllowUnsafeScripting option must be enabled.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "define_lite.h"
|
|
||||||
#include "command.h"
|
|
||||||
|
|
||||||
#include "sfall.h"
|
|
||||||
#include "define_extra.h"
|
|
||||||
|
|
||||||
|
|
||||||
#define can_see_(source, target) call_offset_r2(0x412BEC, source, target)
|
|
||||||
#define obj_dist_(target, source) call_offset_r2(0x48BBD4, target, source)
|
|
||||||
|
|
||||||
procedure start;
|
|
||||||
|
|
||||||
procedure start begin
|
|
||||||
if not(init_hook) then begin
|
|
||||||
|
|
||||||
variable source := get_sfall_arg,
|
|
||||||
target := get_sfall_arg,
|
|
||||||
original := get_sfall_arg,
|
|
||||||
type := get_sfall_arg, /* new arg */
|
|
||||||
result := 0,
|
|
||||||
distance;
|
|
||||||
|
|
||||||
if target then begin
|
|
||||||
distance := get_critter_stat(source, STAT_pe);
|
|
||||||
|
|
||||||
if can_see_(source, target) then begin
|
|
||||||
distance *= 5;
|
|
||||||
if (get_flags(target) bwand FLAG_TRANSGLASS) then distance /= 2;
|
|
||||||
end
|
|
||||||
else if combat_is_initialized then distance *= 2;
|
|
||||||
|
|
||||||
if target == dude_obj then begin
|
|
||||||
if sneak_success then begin
|
|
||||||
distance /= 4;
|
|
||||||
if has_skill(target, SKILL_SNEAK) > 120 then distance -= 1;
|
|
||||||
end
|
|
||||||
else if dude_is_sneaking then distance := distance * 2 / 3;
|
|
||||||
end
|
|
||||||
|
|
||||||
if obj_dist_(target, source) <= distance then result := 1;
|
|
||||||
|
|
||||||
// example
|
|
||||||
if (result) then begin
|
|
||||||
display_msg("hs_withinperception: " + obj_name(source) + " does he see > " + obj_name(target) + " [original: " + original + " script: " + result + "]");
|
|
||||||
end else begin
|
|
||||||
display_msg("hs_withinperception: " + obj_name(source) + " he does not see > " + obj_name(target) + " [original: " + original + " script: " + result + "]");
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
//set_sfall_return(result);
|
|
||||||
end
|
|
||||||
end
|
|
||||||
Reference in New Issue
Block a user