Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions msu/hooks/entity/tactical/actor.nut
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,29 @@
this.m.Skills.update();
}

q.onSkillsUpdated = @(__original) function()
{
__original();
if (this.isPlacedOnMap() && !this.m.MSU_IsAssigningRandomEquipment && this.m.MSU_IsInstanceAdded && !::Tactical.Entities.m.MSU_IsResurrecting)
this.onSpawn();
}

q.onSpawn <- function()
{
if (this.m.MSU_HasOnSpawnBeenCalled)
return;

::logInfo(format("onSpawn %s (%i) of faction %i with %i items at tile %i with %i skills and %i skillsToAdd", this.getName(), this.getID(), this.getFaction(), this.getItems().getAllItems().len(), this.getTile().ID, this.getSkills().m.Skills.len(), this.getSkills().m.SkillsToAdd.len()));
this.m.MSU_HasOnSpawnBeenCalled = true;
foreach (faction in ::Tactical.Entities.getAllInstances())
{
foreach (actor in faction)
{
actor.getSkills().onSpawnEntity(this);
}
}
}

q.getMainhandItem <- function()
{
return this.getItems().getItemAtSlot(::Const.ItemSlot.Mainhand);
Expand Down Expand Up @@ -139,5 +162,19 @@
}
}
}

q.assignRandomEquipment = @(__original) function()
{
this.m.MSU_IsAssigningRandomEquipment = true;
__original();
this.m.MSU_IsAssigningRandomEquipment = false;
this.onSpawn();
}

q.onAfterInit = @(__original) function()
{
__original();
this.m.MSU_HasOnSpawnBeenCalled = false;
}
});
});
22 changes: 22 additions & 0 deletions msu/hooks/entity/tactical/tactical_entity_manager.nut
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
::MSU.MH.hook("scripts/entity/tactical/tactical_entity_manager", function(q) {
q.m.MSU_IsResurrecting <- false;

q.addInstance = @(__original) function( _actor )
{
__original(_actor);
if (_actor.getFaction() != 0)
{
::logInfo(format("addInstance %s (%i) with faction %i and %i items at tile %i and %i skills and %i skillsToAdd", _actor.getName(), _actor.getID(), _actor.getFaction(), _actor.getItems().getAllItems().len(), _actor.getTile().ID, _actor.getSkills().m.Skills.len(), _actor.getSkills().m.SkillsToAdd.len()));
_actor.m.MSU_IsInstanceAdded = true;
}
}

q.onResurrect = @(__original) function( _info, _force = false )
{
this.m.MSU_IsResurrecting = true;
local ret = __original(_info, _force);
if (ret != null)
ret.onSpawn();
this.m.MSU_IsResurrecting = false;
return ret;
}

// VANILLAFIX: http://battlebrothersgame.com/forums/topic/oncombatstarted-is-not-called-for-ai-characters/
// This fix is spread out over 4 files: tactical_entity_manager, actor, player, standard_bearer
q.spawn = @(__original) function( _properties )
Expand Down
4 changes: 4 additions & 0 deletions msu/hooks/skills/skill.nut
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,10 @@
return __original(_f);
}

q.onSpawnEntity <- function( _entity )
{
}

q.onMovementStarted <- function( _tile, _numTiles )
{
}
Expand Down
8 changes: 8 additions & 0 deletions msu/hooks/skills/skill_container.nut
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@
return _argsArray[_argsArray.len() - 1];
}

q.onSpawnEntity <- function( _entity, _isResurrection )
{
this.callSkillsFunction("onSpawnEntity", [
_entity,
]);
}

q.onMovementStarted <- function( _tile, _numTiles )
{
this.callSkillsFunction("onMovementStarted", [
Expand Down Expand Up @@ -487,6 +494,7 @@
q.onCombatFinished = @() function()
{
this.m.IsPreviewing = false;
this.getActor().m.MSU_HasOnSpawnBeenCalled = false;
this.callSkillsFunction("onCombatFinished");
}

Expand Down