rename item hooks to use the new name scheme, register body, new meleeWeapon.handleImpact hook and statusEffect.apply.ItemIdentifier hook

This commit is contained in:
Evil Factory
2022-02-02 11:52:08 -03:00
parent efc62387ff
commit 15294a4a61
4 changed files with 15 additions and 6 deletions

View File

@@ -8,7 +8,7 @@ Hook.HookMethod(
"System.Boolean"
},
function (instance, p)
if Hook.Call("itemInteract", instance, p.picker, p.ignoreRequiredItems, p.forceSelectKey, p.forceActionKey) == true then
if Hook.Call("item.interact", instance, p.picker, p.ignoreRequiredItems, p.forceSelectKey, p.forceActionKey) == true then
return false
end
end,
@@ -23,7 +23,7 @@ Hook.HookMethod(
"Barotrauma.Limb"
},
function (instance, p)
if Hook.Call("itemApplyTreatment", instance, p.user, p.character, p.targetLimb) then
if Hook.Call("item.applyTreatment", instance, p.user, p.character, p.targetLimb) then
return false
end
end,
@@ -37,7 +37,7 @@ Hook.HookMethod(
"Barotrauma.Character"
},
function (instance, p)
if Hook.Call("itemCombine", instance, p.item, p.user) == true then
if Hook.Call("item.combine", instance, p.item, p.user) == true then
return false
end
end,
@@ -51,7 +51,7 @@ Hook.HookMethod(
"System.Boolean"
},
function (instance, p)
if Hook.Call("itemDrop", instance, p.dropper) == true then
if Hook.Call("item.drop", instance, p.dropper) == true then
return false
end
end,
@@ -64,7 +64,7 @@ Hook.HookMethod(
"Barotrauma.Character"
},
function (instance, p)
if Hook.Call("itemEquip", instance, p.character) == true then
if Hook.Call("item.equip", instance, p.character) == true then
return false
end
end,
@@ -77,7 +77,7 @@ Hook.HookMethod(
"Barotrauma.Character"
},
function (instance, p)
if Hook.Call("itemUnequip", instance, p.character) == true then
if Hook.Call("item.unequip", instance, p.character) == true then
return false
end
end,

View File

@@ -196,6 +196,7 @@ RegisterBarotrauma("SkillPrefab")
RegisterBarotrauma("TraitorMissionPrefab")
RegisterBarotrauma("TraitorMissionResult")
LuaUserData.RegisterType("FarseerPhysics.Dynamics.Body")
LuaUserData.RegisterType("FarseerPhysics.Dynamics.World")
LuaUserData.RegisterType("FarseerPhysics.Dynamics.Fixture")
RegisterBarotrauma("Physics")

View File

@@ -383,6 +383,7 @@ namespace Barotrauma.Items.Components
Limb targetLimb = target.UserData as Limb;
Character targetCharacter = targetLimb?.character ?? target.UserData as Character;
GameMain.Lua.hook.Call("meleeWeapon.handleImpact", this, target);
if (Attack != null)
{
Attack.SetUser(User);

View File

@@ -1135,6 +1135,13 @@ namespace Barotrauma
if (lifeTimer <= 0) { return; }
}
{
if (entity is Item item)
{
GameMain.Lua.hook.Call("statusEffect.apply." + item.Prefab.Identifier, this, deltaTime, entity, targets, worldPosition);
}
}
Hull hull = GetHull(entity);
Vector2 position = GetPosition(entity, targets, worldPosition);
foreach (ISerializableEntity serializableEntity in targets)