falldamage and invslotype

This commit is contained in:
Evil Factory
2021-08-17 17:04:25 -03:00
parent a2cb256aa6
commit 98fd600696
2 changed files with 16 additions and 0 deletions

View File

@@ -149,6 +149,9 @@ namespace Barotrauma
UserData.RegisterType<CharacterInventory>();
UserData.RegisterType<Hull>();
UserData.RegisterType<Gap>();
UserData.RegisterType<PhysicsBody>();
UserData.RegisterType<SubmarineBody>();
UserData.RegisterType<InvSlotType>();
lua = new Script(CoreModules.Preset_SoftSandbox | CoreModules.LoadMethods);
@@ -187,6 +190,8 @@ namespace Barotrauma
lua.Globals["CreateVector3"] = (Func<float, float, float, Vector3>)CreateVector3;
lua.Globals["CreateVector4"] = (Func<float, float, float, float, Vector4>)CreateVector4;
lua.Globals["ChatMessage"] = UserData.CreateStatic<ChatMessage>();
lua.Globals["Hull"] = UserData.CreateStatic<Hull>();
lua.Globals["InvSlotType"] = UserData.CreateStatic<InvSlotType>();
foreach (string d in Directory.GetDirectories("Mods"))
{

View File

@@ -11,6 +11,7 @@ using System.Xml.Linq;
using Barotrauma.Extensions;
using LimbParams = Barotrauma.RagdollParams.LimbParams;
using JointParams = Barotrauma.RagdollParams.JointParams;
using MoonSharp.Interpreter;
namespace Barotrauma
{
@@ -711,6 +712,16 @@ namespace Barotrauma
float impactDamage = Math.Min((impact - ImpactTolerance) * ImpactDamageMultiplayer, character.MaxVitality * MaxImpactDamage);
#if SERVER
var should = GameMain.Lua.hook.Call("changeFallDamage", new DynValue[] { DynValue.NewNumber(impactDamage), LuaSetup.CreateUserDataSafe(character), LuaSetup.CreateUserDataSafe(impactPos), LuaSetup.CreateUserDataSafe(velocity) });
if (should != null)
{
impactDamage = (float)should.CastToNumber();
}
#endif
character.LastDamageSource = null;
character.AddDamage(impactPos, AfflictionPrefab.ImpactDamage.Instantiate(impactDamage).ToEnumerable(), 0.0f, true);
strongestImpact = Math.Max(strongestImpact, impact - ImpactTolerance);