mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
59 lines
1.7 KiB
Plaintext
59 lines
1.7 KiB
Plaintext
/*
|
|||
|
|
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
|