Skip to content

Commit

Permalink
Release v3.3
Browse files Browse the repository at this point in the history
Changelog:
- Fix Hood with Mouth Piece not spawning on Brigand Marksmen as intended
- Change internal hook structure to create less noise in logs on initial
  startup
  • Loading branch information
jcsato committed Dec 5, 2023
1 parent 774a0ba commit 3486e8f
Show file tree
Hide file tree
Showing 24 changed files with 254 additions and 257 deletions.
15 changes: 10 additions & 5 deletions build.bat
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
@echo off

set modname=sato_additional_equipment
set modkitdir=YOUR_MODKIT_BIN_PATH
set version=3.2
set version=3.3

echo.
echo Creating temporary directory...
echo.

@REM /i means create tmp\scripts if it's not there, /e means copy subdirectories even if empty, /f outputs full src/dst paths (if you want), /y means overwrite, /c ignores errors
xcopy "%~dp0\scripts\" "%~dp0\tmp_scripts\" /i /e /y
xcopy "%~dp0\script_hooks\" "%~dp0\tmp_script_hooks\" /i /e /y

cd "%modkitdir%"
CALL "%modkitdir%\masscompile.bat" "%~dp0\tmp_scripts"
CALL "%modkitdir%\masscompile.bat" "%~dp0\tmp_script_hooks"

REM %~dp0 refers to the drive letter + path of where THIS batch file lives

echo.
echo Copying files to dist\scripts
echo.

REM after build, copy folders to dist\ folder.
REM after build, copy scripts folder to dist\scripts folder. /i means create dist\scripts if it's not there, /e means copy subdirectories even if empty, /f outputs full src/dst paths (if you want), /y means overwrite, /c ignores errors
xcopy "%~dp0\tmp_scripts" "%~dp0\dist\scripts" /i /e /y /c
xcopy "%~dp0\tmp_script_hooks" "%~dp0\dist\script_hooks" /i /e /y /c
xcopy "%~dp0\brushes" "%~dp0\dist\brushes" /i /e /y /c
xcopy "%~dp0\gfx" "%~dp0\dist\gfx" /i /e /y /c

Expand All @@ -33,30 +35,33 @@ echo.

REM Remove tmp_scripts directory
rmdir "%~dp0\tmp_scripts" /s /q
rmdir "%~dp0\tmp_script_hooks" /s /q

echo.
echo Removing uncompiled source from dist...
echo.

REM Remove uncompiled source from dist\scripts directory
for /r "%~dp0\dist\scripts" %%f in (*.nut) do del /f /q "%%f"
for /r "%~dp0\dist\script_hooks" %%f in (*.nut) do del /f /q "%%f"

echo.
echo Packaging mod into .zip...
echo.

REM Requires Powershell 5.0 / .NET Framework 4.x (some claim 4, some claim 4.5, some claim 4.8)
powershell.exe -nologo -noprofile -command "& { Compress-Archive -Force -Path '%~dp0\dist\brushes', '%~dp0\dist\gfx', '%~dp0\dist\scripts' -DestinationPath '%~dp0\dist\%modname%_%version%.zip' }"
powershell.exe -nologo -noprofile -command "& { Compress-Archive -Force -Path '%~dp0\dist\brushes', '%~dp0\dist\gfx', '%~dp0\dist\script_hooks', '%~dp0\dist\scripts' -DestinationPath '%~dp0\dist\%modname%_%version%.zip' }"

echo.
echo Cleaning up dist\scripts
echo.

REM Remove dist\scripts directory
rmdir "%~dp0\dist\scripts" /s /q
rmdir "%~dp0\dist\script_hooks" /s /q
rmdir "%~dp0\dist\brushes" /s /q
rmdir "%~dp0\dist\gfx" /s /q

echo Done.

pause
pause
34 changes: 34 additions & 0 deletions script_hooks/mod_sae_closed_conic_helmet.nut
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
::mods_hookExactClass("entity/world/attached_location/blast_furnace_location", function(bfl) {
local onUpdateShopList = ::mods_getMember(bfl, "onUpdateShopList");

bfl.onUpdateShopList = function( _id, _list ) {
if (_id == "building.armorsmith")
_list.push({ R = 30, P = 1.0, S = "helmets/closed_conic_helmet" });

onUpdateShopList( _id, _list );
}
});

::mods_hookExactClass("entity/world/attached_location/leather_tanner_location", function(ltl) {
local onUpdateShopList = ::mods_getMember(ltl, "onUpdateShopList");

ltl.onUpdateShopList = function( _id, _list ) {
if (_id == "building.armorsmith")
_list.push({ R = 45, P = 1.0, S = "helmets/closed_conic_helmet" });

onUpdateShopList( _id, _list );
}
});

::mods_hookExactClass("entity/tactical/humans/mercenary", function(merc) {
local assignRandomEquipment = ::mods_getMember(merc, "assignRandomEquipment");

merc.assignRandomEquipment = function() {
assignRandomEquipment();

if (Math.rand(1, 100) <= 6) {
m.Items.unequip(m.Items.getItemAtSlot(Const.ItemSlot.Head));
m.Items.equip(new("scripts/items/helmets/closed_conic_helmet"));
}
}
});
10 changes: 10 additions & 0 deletions script_hooks/mod_sae_closed_conic_helmet_with_mail.nut
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
::mods_hookExactClass("entity/world/attached_location/blast_furnace_location", function(bfl) {
local onUpdateShopList = ::mods_getMember(bfl, "onUpdateShopList");

bfl.onUpdateShopList = function( _id, _list ) {
if (_id == "building.armorsmith")
_list.push({ R = 30, P = 1.0, S = "helmets/closed_conic_helmet_with_mail" });

onUpdateShopList( _id, _list );
}
});
10 changes: 10 additions & 0 deletions script_hooks/mod_sae_closed_conic_helmet_with_neckguard.nut
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
::mods_hookExactClass("entity/world/attached_location/blast_furnace_location", function(bfl) {
local onUpdateShopList = ::mods_getMember(bfl, "onUpdateShopList");

bfl.onUpdateShopList = function( _id, _list ) {
if (_id == "building.armorsmith")
_list.push({ R = 35, P = 1.0, S = "helmets/closed_conic_helmet_with_neckguard" });

onUpdateShopList( _id, _list );
}
});
38 changes: 38 additions & 0 deletions script_hooks/mod_sae_hood_with_mouth_piece.nut
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
::mods_hookExactClass("entity/tactical/enemies/bandit_marksman", function(bm) {
local assignRandomEquipment = ::mods_getMember(bm, "assignRandomEquipment");

bm.assignRandomEquipment = function() {
assignRandomEquipment();

if (Math.rand(1, 100) <= 16) {
m.Items.unequip(m.Items.getItemAtSlot(Const.ItemSlot.Head));
m.Items.equip(new("scripts/items/helmets/hood_with_mouth_piece"));
}
}
});

::mods_hookExactClass("entity/tactical/enemies/bandit_marksman_low", function(bml) {
local assignRandomEquipment = ::mods_getMember(bml, "assignRandomEquipment");

bml.assignRandomEquipment = function() {
assignRandomEquipment();

if (Math.rand(1, 100) <= 33) {
m.Items.unequip(m.Items.getItemAtSlot(Const.ItemSlot.Head));
m.Items.equip(new("scripts/items/helmets/hood_with_mouth_piece"));
}
}
});

::mods_hookExactClass("skills/backgrounds/killer_on_the_run_background", function(kotrb) {
local onAddEquipment = ::mods_getMember(kotrb, "onAddEquipment");

kotrb.onAddEquipment = function() {
onAddEquipment();

if (Math.rand(1, 100) <= 50) {
getContainer().getActor().getItems().unequip(getContainer().getActor().getItems().getItemAtSlot(Const.ItemSlot.Head));
getContainer().getActor().getItems().equip(new("scripts/items/helmets/hood_with_mouth_piece"));
}
}
});
10 changes: 10 additions & 0 deletions script_hooks/mod_sae_iron_pot_helm.nut
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
::mods_hookExactClass("entity/world/attached_location/blast_furnace_location", function(bfl) {
local onUpdateShopList = ::mods_getMember(bfl, "onUpdateShopList");

bfl.onUpdateShopList = function( _id, _list ) {
if (_id == "building.armorsmith")
_list.push({ R = 85, P = 1.0, S = "helmets/iron_pot_helm" });

onUpdateShopList( _id, _list );
}
});
38 changes: 38 additions & 0 deletions script_hooks/mod_sae_masked_nomad_light_helmet.nut
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
::mods_hookExactClass("entity/tactical/humans/nomad_outlaw", function(no) {
local assignRandomEquipment = ::mods_getMember(no, "assignRandomEquipment");

no.assignRandomEquipment = function() {
assignRandomEquipment();

if (Math.rand(1, 100) <= 20) {
m.Items.unequip(m.Items.getItemAtSlot(Const.ItemSlot.Head));
m.Items.equip(new("scripts/items/helmets/oriental/masked_nomad_light_helmet"));
}
}
});

::mods_hookExactClass("skills/backgrounds/nomad_background", function(nb) {
local onAddEquipment = ::mods_getMember(nb, "onAddEquipment");

nb.onAddEquipment = function() {
onAddEquipment();

if (Math.rand(1, 100) <= 25) {
getContainer().getActor().getItems().unequip(getContainer().getActor().getItems().getItemAtSlot(Const.ItemSlot.Head));
getContainer().getActor().getItems().equip(new("scripts/items/helmets/oriental/masked_nomad_light_helmet"));
}
}
});

::mods_hookExactClass("skills/backgrounds/nomad_ranged_background", function(nrb) {
local onAddEquipment = ::mods_getMember(nrb, "onAddEquipment");

nrb.onAddEquipment = function() {
onAddEquipment();

if (Math.rand(1, 100) <= 25) {
getContainer().getActor().getItems().unequip(getContainer().getActor().getItems().getItemAtSlot(Const.ItemSlot.Head));
getContainer().getActor().getItems().equip(new("scripts/items/helmets/oriental/masked_nomad_light_helmet"));
}
}
});
2 changes: 2 additions & 0 deletions script_hooks/mod_sae_named_nomad_light_helmet.nut
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
getroottable().Const.Items.NamedSouthernHelmets.push("helmets/named/named_nomad_light_helmet")
getroottable().Const.Items.NamedHelmets.push("helmets/named/named_nomad_light_helmet")
12 changes: 12 additions & 0 deletions script_hooks/mod_sae_reinforced_padded_armor.nut
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
::mods_hookExactClass("skills/backgrounds/assassin_southern_background", function(ab) {
local onAddEquipment = ::mods_getMember(ab, "onAddEquipment");

ab.onAddEquipment = function() {
onAddEquipment();

if (Math.rand(1, 100) <= 33) {
getContainer().getActor().getItems().unequip(getContainer().getActor().getItems().getItemAtSlot(Const.ItemSlot.Body));
getContainer().getActor().getItems().equip(new("scripts/items/armor/oriental/reinforced_padded_armor"));
}
}
});
27 changes: 27 additions & 0 deletions script_hooks/mod_sae_southern_conic_helmet_with_closed_mail.nut
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
::mods_hookExactClass("entity/tactical/humans/officer", function(o) {
local assignRandomEquipment = ::mods_getMember(o, "assignRandomEquipment");

o.assignRandomEquipment = function() {
local hasFamedHelmet = m.Items.getItemAtSlot(Const.ItemSlot.Head) != null;

assignRandomEquipment();

if (!hasFamedHelmet && Math.rand(1, 100) <= 25) {
m.Items.unequip(m.Items.getItemAtSlot(Const.ItemSlot.Head));
m.Items.equip(new("scripts/items/helmets/oriental/southern_conic_helmet_with_closed_mail"));
}
}
});

::mods_hookBaseClass("entity/world/settlement", function(s) {
while(!("onUpdateShopList" in s)) s = s[s.SuperName];

local onUpdateShopList = s.onUpdateShopList;

s.onUpdateShopList = function( _id, _list ) {
if (Const.DLC.Desert && _id == "building.armorsmith_oriental")
_list.push({ R = 35, P = 1.0, S = "helmets/oriental/southern_conic_helmet_with_closed_mail" });

onUpdateShopList( _id, _list );
}
});
23 changes: 23 additions & 0 deletions script_hooks/mod_sae_visored_barbute_helmet.nut
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
::mods_hookExactClass("entity/world/attached_location/blast_furnace_location", function(bfl) {
local onUpdateShopList = ::mods_getMember(bfl, "onUpdateShopList");

bfl.onUpdateShopList = function( _id, _list ) {
if (_id == "building.armorsmith")
_list.push({ R = 65, P = 1.0, S = "helmets/visored_barbute_helmet" });

onUpdateShopList( _id, _list );
}
});

::mods_hookBaseClass("entity/world/settlement", function(s) {
while(!("onUpdateShopList" in s)) s = s[s.SuperName];

local onUpdateShopList = s.onUpdateShopList;

s.onUpdateShopList = function( _id, _list ) {
if (Const.DLC.Unhold && _id == "building.armorsmith")
_list.push({ R = 85, P = 1.0, S = "helmets/visored_barbute_helmet" });

onUpdateShopList( _id, _list );
}
});
25 changes: 25 additions & 0 deletions script_hooks/mod_sae_visored_plumed_bascinet_helmet.nut
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
::mods_hookExactClass("entity/tactical/humans/hedge_knight", function(hk) {
local assignRandomEquipment = ::mods_getMember(hk, "assignRandomEquipment");

hk.assignRandomEquipment = function() {
local hasFamedHelmet = m.Items.getItemAtSlot(Const.ItemSlot.Head) != null;

assignRandomEquipment();

if (!hasFamedHelmet && Math.rand(1, 100) <= 33) {
m.Items.unequip(m.Items.getItemAtSlot(Const.ItemSlot.Head));
m.Items.equip(new("scripts/items/helmets/visored_plumed_bascinet_helmet"));
}
}
});

::mods_hookExactClass("entity/world/attached_location/blast_furnace_location", function(bfl) {
local onUpdateShopList = ::mods_getMember(bfl, "onUpdateShopList");

bfl.onUpdateShopList = function( _id, _list ) {
if (_id == "building.armorsmith")
_list.push({ R = 45, P = 1.0, S = "helmets/visored_plumed_bascinet_helmet" });

onUpdateShopList( _id, _list );
}
});
16 changes: 15 additions & 1 deletion scripts/!mods_preload/!mod_additional_equipment.nut
Original file line number Diff line number Diff line change
@@ -1 +1,15 @@
::mods_registerMod("sato_additional_equipment", 3.2, "Sato's Additional Equipment");
::mods_registerMod("sato_additional_equipment", 3.3, "Sato's Additional Equipment");

::mods_queue("sato_additional_equipment", null, function() {
::include("script_hooks/mod_sae_closed_conic_helmet_with_mail");
::include("script_hooks/mod_sae_closed_conic_helmet_with_neckguard");
::include("script_hooks/mod_sae_closed_conic_helmet");
::include("script_hooks/mod_sae_hood_with_mouth_piece");
::include("script_hooks/mod_sae_iron_pot_helm");
::include("script_hooks/mod_sae_masked_nomad_light_helmet");
::include("script_hooks/mod_sae_named_nomad_light_helmet");
::include("script_hooks/mod_sae_reinforced_padded_armor");
::include("script_hooks/mod_sae_southern_conic_helmet_with_closed_mail");
::include("script_hooks/mod_sae_visored_barbute_helmet");
::include("script_hooks/mod_sae_visored_plumed_bascinet_helmet");
});
36 changes: 0 additions & 36 deletions scripts/!mods_preload/mod_sae_closed_conic_helmet.nut

This file was deleted.

12 changes: 0 additions & 12 deletions scripts/!mods_preload/mod_sae_closed_conic_helmet_with_mail.nut

This file was deleted.

This file was deleted.

0 comments on commit 3486e8f

Please sign in to comment.