renamed hooks (with compatibility), added new hook: character.giveJobItems (because of how often its used) and updated hook docs
This commit is contained in:
@@ -25,7 +25,7 @@ namespace Barotrauma
|
|||||||
GameServer.Log(GameServer.CharacterLogName(this) + " has died (Cause of death: " + causeOfDeath + ")", ServerLog.MessageType.Attack);
|
GameServer.Log(GameServer.CharacterLogName(this) + " has died (Cause of death: " + causeOfDeath + ")", ServerLog.MessageType.Attack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GameMain.LuaCs.Hook.Call("characterDeath", this,causeOfDeathAffliction);
|
GameMain.LuaCs.Hook.Call("character.death", this,causeOfDeathAffliction);
|
||||||
|
|
||||||
if (HasAbilityFlag(AbilityFlags.RetainExperienceForNewCharacter))
|
if (HasAbilityFlag(AbilityFlags.RetainExperienceForNewCharacter))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -293,7 +293,7 @@ namespace Barotrauma.Networking
|
|||||||
SendConsoleMessage("Granted all permissions to " + newClient.Name + ".", newClient);
|
SendConsoleMessage("Granted all permissions to " + newClient.Name + ".", newClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
GameMain.LuaCs.Hook.Call("clientConnected", newClient);
|
GameMain.LuaCs.Hook.Call("client.connected", newClient);
|
||||||
|
|
||||||
|
|
||||||
SendChatMessage($"ServerMessage.JoinedServer~[client]={clName}", ChatMessageType.Server, null, changeType: PlayerConnectionChangeType.Joined);
|
SendChatMessage($"ServerMessage.JoinedServer~[client]={clName}", ChatMessageType.Server, null, changeType: PlayerConnectionChangeType.Joined);
|
||||||
@@ -2899,7 +2899,7 @@ namespace Barotrauma.Networking
|
|||||||
{
|
{
|
||||||
if (client == null) return;
|
if (client == null) return;
|
||||||
|
|
||||||
GameMain.LuaCs.Hook.Call("clientDisconnected", client);
|
GameMain.LuaCs.Hook.Call("client.disconnected", client);
|
||||||
|
|
||||||
if (gameStarted && client.Character != null)
|
if (gameStarted && client.Character != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -76,4 +76,20 @@ end
|
|||||||
|
|
||||||
compatibilityLib["Player"] = luaPlayer
|
compatibilityLib["Player"] = luaPlayer
|
||||||
|
|
||||||
|
Hook.Add("character.created", "compatibility.character.created", function (character)
|
||||||
|
Hook.Call("characterCreated", character)
|
||||||
|
end)
|
||||||
|
|
||||||
|
Hook.Add("character.death", "compatibility.character.death", function (character, causeOfDeathAffliction)
|
||||||
|
Hook.Call("characterDeath", character, causeOfDeathAffliction)
|
||||||
|
end)
|
||||||
|
|
||||||
|
Hook.Add("client.connected", "compatibility.client.connected", function (client)
|
||||||
|
Hook.Call("clientConnected", client)
|
||||||
|
end)
|
||||||
|
|
||||||
|
Hook.Add("client.disconnected", "compatibility.client.disconnected", function (client)
|
||||||
|
Hook.Call("clientDisconnected", client)
|
||||||
|
end)
|
||||||
|
|
||||||
return compatibilityLib
|
return compatibilityLib
|
||||||
+1
-1
@@ -80,7 +80,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public void AddObjective<T>(T objective) where T : AIObjective
|
public void AddObjective<T>(T objective) where T : AIObjective
|
||||||
{
|
{
|
||||||
var result = GameMain.LuaCs.Hook.Call<bool?>("AI.AddObjective", this, objective);
|
var result = GameMain.LuaCs.Hook.Call<bool?>("AI.addObjective", this, objective);
|
||||||
|
|
||||||
if (result != null && result.Value) return;
|
if (result != null && result.Value) return;
|
||||||
|
|
||||||
|
|||||||
@@ -1043,7 +1043,7 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
GameMain.LuaCs.Hook.Call("characterCreated", new object[] { newCharacter });
|
GameMain.LuaCs.Hook.Call("character.created", new object[] { newCharacter });
|
||||||
|
|
||||||
return newCharacter;
|
return newCharacter;
|
||||||
}
|
}
|
||||||
@@ -1441,6 +1441,8 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
if (info?.Job == null) { return; }
|
if (info?.Job == null) { return; }
|
||||||
info.Job.GiveJobItems(this, spawnPoint);
|
info.Job.GiveJobItems(this, spawnPoint);
|
||||||
|
|
||||||
|
GameMain.LuaCs.Hook.Call("character.giveJobItems", this, spawnPoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GiveIdCardTags(WayPoint spawnPoint, bool createNetworkEvent = false)
|
public void GiveIdCardTags(WayPoint spawnPoint, bool createNetworkEvent = false)
|
||||||
|
|||||||
+28
-11
@@ -25,7 +25,7 @@ function Hook.Add(eventName, hookName, func) end
|
|||||||
-- @tparam string hookname hook name
|
-- @tparam string hookname hook name
|
||||||
-- @realm shared
|
-- @realm shared
|
||||||
-- @usage
|
-- @usage
|
||||||
-- Hook.Remove("characterDeath", "characterDeathExample")
|
-- Hook.Remove("character.death", "characterDeathExample")
|
||||||
function Hook.Remove(eventName, hookName) end
|
function Hook.Remove(eventName, hookName) end
|
||||||
|
|
||||||
--- Calls a hook.
|
--- Calls a hook.
|
||||||
@@ -34,7 +34,7 @@ function Hook.Remove(eventName, hookName) end
|
|||||||
-- @realm shared
|
-- @realm shared
|
||||||
-- @usage
|
-- @usage
|
||||||
-- Hook.Add("think", "happyDebuggingSuckers", function()
|
-- Hook.Add("think", "happyDebuggingSuckers", function()
|
||||||
-- Hook.Call("characterDead", {}) -- ruin someone's day
|
-- Hook.Call("character.death", {}) -- ruin someone's day
|
||||||
-- end)
|
-- end)
|
||||||
function Hook.Call(eventName, parameters) end
|
function Hook.Call(eventName, parameters) end
|
||||||
|
|
||||||
@@ -62,12 +62,13 @@ function chatMessage(message, sender) end
|
|||||||
--- Called when a client connects
|
--- Called when a client connects
|
||||||
-- @tparam client connectedClient
|
-- @tparam client connectedClient
|
||||||
-- @realm shared
|
-- @realm shared
|
||||||
function clientConnected(connectedClient) end
|
function client.connected(connectedClient) end
|
||||||
|
|
||||||
--- Called when a client disconnects
|
--- Called when a client disconnects
|
||||||
-- @tparam client disconnectedClient
|
-- @tparam client disconnectedClient
|
||||||
-- @realm shared
|
-- @realm shared
|
||||||
function clientDisconnected(disconnectedClient) end
|
function client.disconnected(disconnectedClient) end
|
||||||
|
|
||||||
|
|
||||||
--- Called on round start
|
--- Called on round start
|
||||||
-- @realm shared
|
-- @realm shared
|
||||||
@@ -77,23 +78,35 @@ function roundStart() end
|
|||||||
-- @realm shared
|
-- @realm shared
|
||||||
function roundEnd() end
|
function roundEnd() end
|
||||||
|
|
||||||
--- Gets callled everytime a character is created.
|
--- Gets called everytime a character is created.
|
||||||
-- @tparam character createdCharacter
|
-- @tparam character createdCharacter
|
||||||
-- @realm shared
|
-- @realm shared
|
||||||
function characterCreated(createdCharacter) end
|
function character.created(createdCharacter) end
|
||||||
|
|
||||||
|
--- Gets called after the character is given the job items, useful if your script only wants to check for newly created characters in campaign gamemode.
|
||||||
|
-- @tparam character character
|
||||||
|
-- @tparam WayPoint waypoint
|
||||||
|
-- @realm shared
|
||||||
|
function character.giveJobItems(character, waypoint) end
|
||||||
|
|
||||||
--- Gets called everytime a Character dies.
|
--- Gets called everytime a Character dies.
|
||||||
-- @tparam Character character A dead Character.
|
-- @tparam Character character A dead Character.
|
||||||
-- @realm shared
|
-- @realm shared
|
||||||
-- @usage
|
-- @usage
|
||||||
-- Hook.Add("characterDeath", "characterDeathExample", function(character)
|
-- Hook.Add("character.death", "characterDeathExample", function(character)
|
||||||
-- print(character)
|
-- print(character)
|
||||||
-- end)
|
-- end)
|
||||||
function characterDeath(character) end
|
function character.death(character) end
|
||||||
|
|
||||||
--- Gets called every time an affliction is applied.
|
--- Gets called every time an affliction is applied to a character.
|
||||||
-- @realm shared
|
-- @realm shared
|
||||||
function afflictionApplied(affliction, characterHealth, limb) end
|
function character.applyAffliction(character, limbHealth, newAffliction, allowStacking) end
|
||||||
|
|
||||||
|
--- Gets gets called every time an attack damage.
|
||||||
|
-- @realm shared
|
||||||
|
function character.applyDamage(character, attackResult, hitLimb, allowStacking) end
|
||||||
|
|
||||||
|
|
||||||
--- Gets called every time an affliction updates.
|
--- Gets called every time an affliction updates.
|
||||||
-- @realm shared
|
-- @realm shared
|
||||||
function afflictionUpdate(affliction, characterHealth, limb) end
|
function afflictionUpdate(affliction, characterHealth, limb) end
|
||||||
@@ -125,7 +138,11 @@ function item.interact(item, characterPicker, ignoreRequiredItemsBool, forceSele
|
|||||||
|
|
||||||
--- Gets called every time two items are combined, eg: drag an half empty magazine to another half empty magazine to combine
|
--- Gets called every time two items are combined, eg: drag an half empty magazine to another half empty magazine to combine
|
||||||
-- @realm shared
|
-- @realm shared
|
||||||
function item.combine(item, otherItem, userCharacter) end
|
function item.combine(item, deconstructor, characterUser, allowRemove) end
|
||||||
|
|
||||||
|
--- Gets called every time an item is deconstructed. Return true to prevent item from being removed.
|
||||||
|
-- @realm shared
|
||||||
|
function item.deconstructed(item, otherItem, userCharacter) end
|
||||||
|
|
||||||
--- Gets called every time an item is moved from one inventory slot to another, return true to cancel
|
--- Gets called every time an item is moved from one inventory slot to another, return true to cancel
|
||||||
-- @realm shared
|
-- @realm shared
|
||||||
|
|||||||
Reference in New Issue
Block a user