diff --git a/artifacts/scripting/hookscripts.txt b/artifacts/scripting/hookscripts.txt index 2f49e023..b14fc3c9 100644 --- a/artifacts/scripting/hookscripts.txt +++ b/artifacts/scripting/hookscripts.txt @@ -77,7 +77,7 @@ The defines to use for the hooktype are in sfall.h. HOOK_TOHIT (hs_tohit.int) -Runs when fallout is calculating the chances of an attack striking a target +Runs when Fallout is calculating the chances of an attack striking a target Runs after the hit chance is fully calculated normally, including applying the 95% cap int arg1 - The unmodified hit chance @@ -94,7 +94,7 @@ int ret1 - the new hit chance HOOK_AFTERHITROLL (hs_afterhitroll.int) -Runs after fallout has decided if an attack will hit or miss +Runs after Fallout has decided if an attack will hit or miss int arg1 - If the attack will hit. (0 - critical miss, 1 - miss, 2 - hit, 3 - critical hit) critter arg2 - The attacker @@ -110,22 +110,22 @@ critter ret3 - Override the target of the attack HOOK_CALCAPCOST (hs_calcapcost.int) -Runs whenever fallout is calculating the ap cost of using the weapon (or unarmed attack). Doesn't run for using other item types or moving. -Note that the first time a game is loaded, this script doesn't run before the initial interface is drawn, so if the script effects the ap cost of whatever is in the players hands at the time the wrong ap cost will be shown. It will be fixed the next time the interface is redrawn. +Runs whenever Fallout is calculating the AP cost of using the weapon (or unarmed attack). Doesn't run for using other item types or moving. +Note that the first time a game is loaded, this script doesn't run before the initial interface is drawn, so if the script effects the AP cost of whatever is in the players hands at the time the wrong AP cost will be shown. It will be fixed the next time the interface is redrawn. You can get the weapon object by checking item slot based on attack type (ATKTYPE_LWEP1, ATKTYPE_LWEP2, etc) and then calling critter_inven_obj(). critter arg1 - The critter performing the action int arg2 - Attack Type (see ATKTYPE_* constants) int arg3 - Is aimed attack (1 or 0) -int arg4 - The normal ap cost +int arg4 - The normal AP cost -int ret1 - The new ap cost +int ret1 - The new AP cost ------------------------------------------- HOOK_DEATHANIM1 (hs_deathanim1.int) -Runs before fallout tries to calculate the death animation. Lets you switch out which weapon fallout sees +Runs before Fallout tries to calculate the death animation. Lets you switch out which weapon Fallout sees int arg1 - The pid of the weapon performing the attack. (May be -1 if the attack is unarmed) critter arg2 - The attacker @@ -138,14 +138,14 @@ int ret1 - The pid of an object to override the attacking weapon with HOOK_DEATHANIM2 (hs_deathanim2.int) -Runs after fallout has calculated the death animation. Lets you set your own custom frame id, so more powerful than hs_deathanim1, but performs no validation. +Runs after Fallout has calculated the death animation. Lets you set your own custom frame id, so more powerful than hs_deathanim1, but performs no validation. When using critter_dmg function, this script will also run. In that case weapon pid will be -1 and target will point to an object with obj_art_fid == 0x20001F5. item arg1 - The pid of the weapon performing the attack. (May be -1 if the attack is unarmed) critter arg2 - The attacker critter arg3 - The target int arg4 - The amount of damage -int arg5 - The death anim id calculated by fallout +int arg5 - The death anim id calculated by Fallout int ret1 - The death anim id to override with @@ -271,13 +271,13 @@ int ret1 - the modified value of all of the goods HOOK_MOVECOST (hs_movecost.int) -Runs when calculating the ap cost of movement +Runs when calculating the AP cost of movement Critter arg1 - the critter doing the moving int arg2 - the number of hexes being moved -int arg3 - the original ap cost +int arg3 - the original AP cost -int ret1 - the new ap cost +int ret1 - the new AP cost ------------------------------------------- diff --git a/artifacts/scripting/sfall function notes.txt b/artifacts/scripting/sfall function notes.txt index ce0419e1..38af1774 100644 --- a/artifacts/scripting/sfall function notes.txt +++ b/artifacts/scripting/sfall function notes.txt @@ -157,7 +157,7 @@ array - array ID to be used with array-related functions (actually an integer) - if you add 0x80000000 to the sid when calling set_script, map_enter_p_proc will be SKIPPED. The start proc will always be run. > int get_script(object) -- accepts a pointer to an object and returns it's scriptID (line number in scripts.lst), or -1 if the object is unscripted. +- accepts a pointer to an object and returns its scriptID (line number in scripts.lst), or -1 if the object is unscripted. > void set_self(int obj) - overrides the scripts self_obj for the next function call. @@ -214,7 +214,7 @@ Some additional reg_anim_* functions were introduced. They all work in the same - plays "take out weapon" animation for given holdFrameID. It is not required to have such weapon in critter's inventory. > void reg_anim_turn_towards(object, tile/target, delay) -- makes object change it's direction to face given tile num or target object. +- makes object change its direction to face given tile num or target object. > int metarule2_explosions(int arg1, int arg2) was made as a dirty easy hack to allow dynamically change some explosion parameters (ranged attack). All changed parameters are reset to vanilla state automatically after each attack action. Following macros are available in sfall.h: diff --git a/sfall/FalloutEngine.cpp b/sfall/FalloutEngine.cpp index 99c00040..a57aa866 100644 --- a/sfall/FalloutEngine.cpp +++ b/sfall/FalloutEngine.cpp @@ -369,6 +369,7 @@ const DWORD intface_use_item_ = 0x45F5EC; const DWORD intface_show_ = 0x45EA10; const DWORD intface_hide_ = 0x45E9E0; const DWORD intface_is_hidden_ = 0x45EA5C; +const DWORD intface_get_attack_ = 0x45EF6C; const DWORD invenUnwieldFunc_ = 0x472A64; const DWORD invenWieldFunc_ = 0x472768; const DWORD inven_display_msg_ = 0x472D24; diff --git a/sfall/FalloutEngine.h b/sfall/FalloutEngine.h index e62ebddd..f64b4f88 100644 --- a/sfall/FalloutEngine.h +++ b/sfall/FalloutEngine.h @@ -543,6 +543,7 @@ extern const DWORD intface_use_item_; extern const DWORD intface_show_; extern const DWORD intface_hide_; extern const DWORD intface_is_hidden_; +extern const DWORD intface_get_attack_; extern const DWORD invenUnwieldFunc_; // (int critter@, int slot@, int a3@) - int result (-1 on error, 0 on success) extern const DWORD invenWieldFunc_; // (int who@, int item@, int a3@, int slot@) - int result (-1 on error, 0 on success) extern const DWORD inven_display_msg_; diff --git a/sfall/ScriptOps/MiscOps.hpp b/sfall/ScriptOps/MiscOps.hpp index c3ab7fb8..6475f04b 100644 --- a/sfall/ScriptOps/MiscOps.hpp +++ b/sfall/ScriptOps/MiscOps.hpp @@ -550,17 +550,12 @@ static void _stdcall IncNPCLevel4(char* npc) { SafeWrite16(0x495C50, 0x840F); //Want to keep this check intact. SafeWrite32(0x495C52, 0x000001FB); - //SafeWrite16(0x495C50, 0x9090); - //SafeWrite32(0x495C52, 0x90909090); - SafeWrite16(0x495C77, 0x9090); //Check that the player is high enough for the npc to consider this level - SafeWrite32(0x495C79, 0x90909090); - //SafeWrite16(0x495C8C, 0x9090); //Check that the npc isn't already at its maximum level - //SafeWrite32(0x495C8E, 0x90909090); - SafeWrite16(0x495CEC, 0x9090); //Check that the npc hasn't already levelled up recently - SafeWrite32(0x495CEE, 0x90909090); + //SafeMemSet(0x495C50, 0x90, 6); + SafeMemSet(0x495C77, 0x90, 6); //Check that the player is high enough for the npc to consider this level + //SafeMemSet(0x495C8C, 0x90, 6); //Check that the npc isn't already at its maximum level + SafeMemSet(0x495CEC, 0x90, 6); //Check that the npc hasn't already levelled up recently if (!npcautolevel) { - SafeWrite16(0x495D22, 0x9090);//Random element - SafeWrite32(0x495D24, 0x90909090); + SafeMemSet(0x495D22, 0x90, 6); //Random element } } } @@ -1353,12 +1348,29 @@ static void __declspec(naked) get_attack_type() { __asm { push edx; push ecx; - mov ecx, eax; - mov edx, ds:[_main_ctd + 0x4]; - call interpretPushLong_; - mov eax, ecx; - mov edx, VAR_TYPE_INT; - call interpretPushShort_; + push eax; + sub esp, 8; + lea edx, [esp]; + lea eax, [esp+4]; + call intface_get_attack_; + add esp, 4; // is_secondary + test eax, eax; + jz skip; + add esp, 4; + // get reload + cmp ds:[_interfaceWindow], eax; + jz end; + mov ecx, ds:[_itemCurrentItem]; // 0 - left, 1 - right + imul edx, ecx, 0x18; + cmp ds:[_itemButtonItems+5+edx], 1; // .itsWeapon + jnz end; + lea eax, [ecx+6]; + jmp end; +skip: + pop eax; // hit_mode +end: + pop ecx; + _RET_VAL_INT(ecx); pop ecx; pop edx; retn; diff --git a/sfall/main.cpp b/sfall/main.cpp index a8faaae8..9b67fa37 100644 --- a/sfall/main.cpp +++ b/sfall/main.cpp @@ -1051,17 +1051,11 @@ static void DllMain2() { HookCall(0x4A34F9, &TimerReset); HookCall(0x4A3551, &TimerReset); - SafeWrite32(0x4A34EF, 0x90909090); - SafeWrite32(0x4A34F3, 0x90909090); - SafeWrite16(0x4A34F7, 0x9090); - SafeWrite32(0x4A34FE, 0x90909090); - SafeWrite16(0x4A3502, 0x9090); + SafeMemSet(0x4A34EF, 0x90, 10); + SafeMemSet(0x4A34FE, 0x90, 6); - SafeWrite32(0x4A3547, 0x90909090); - SafeWrite32(0x4A354B, 0x90909090); - SafeWrite16(0x4A354F, 0x9090); - SafeWrite32(0x4A3556, 0x90909090); - SafeWrite16(0x4A355A, 0x9090); + SafeMemSet(0x4A3547, 0x90, 10); + SafeMemSet(0x4A3556, 0x90, 6); } else { SafeWrite8(0x4A34EC, limit); SafeWrite8(0x4A3544, limit);