Jump to content

Recommended Posts

Hi everyone, I am new to modding. I noticed there is a game mechanism change from DS to DST. Your followers used to attack your target when you give the order to attack. However, in DST, they seem only to attack after you actually attacked. I am trying to mod DST to restore the behaviour of DS. 

I checked the following files but can't seem to find the logic that deals with this behaviour. Can someone point me to the right direction?

leader.lua, follower.lua, commander.lua, combat.lua, actions.lua, team_leader.lua, player_common.lua,braincommon.lua, chaseandattack.lua, follow.lua, spiderbrain.lua, 

 

1 hour ago, pspencil said:

Hi everyone, I am new to modding. I noticed there is a game mechanism change from DS to DST. Your followers used to attack your target when you give the order to attack. However, in DST, they seem only to attack after you actually attacked. I am trying to mod DST to restore the behaviour of DS. 

I checked the following files but can't seem to find the logic that deals with this behaviour. Can someone point me to the right direction?


leader.lua, follower.lua, commander.lua, combat.lua, actions.lua, team_leader.lua, player_common.lua,braincommon.lua, chaseandattack.lua, follow.lua, spiderbrain.lua, 

 

@rezecib did this in his rebalance mod: http://steamcommunity.com/sharedfiles/filedetails/?id=741879530

"Followers will get the same target at you as soon as you target, not at the start of the attack animation"

If you just want this and nothing else, then you can poke around his files to see what he has done to do it.

 

As an aside the method on forcing followers to attack in DST currently is to fake hit- go up and begin attacking but then issue a movement command to cancel the swing from connecting.

Most/all of the code for that should be in patches/attackfixes. There's some other code in there, though, but it's commented:

--[[
Dependencies:
none
]]

local require = GLOBAL.require
local TheNet = GLOBAL.TheNet

--Protects player followers from attacks by other players outside of PvP
local Combat = require("components/combat_replica")
local _IsValidTarget = Combat.IsValidTarget
function Combat:IsValidTarget(target, ...)
	local isvalid = _IsValidTarget(self, target, ...)
	if target ~= nil and not TheNet:GetPVPEnabled() and self.inst:HasTag("player")
	and target.replica.follower and target.replica.follower:GetLeader()
	and target.replica.follower:GetLeader():HasTag("player") then
		return isvalid and self.inst == target.replica.follower:GetLeader()
	else
		return isvalid
	end
end

-- Fixes attack commands for clients with movement prediction on
AddModRPCHandler(modname, "SetTarget", function(player, target)
	if player then
		player.components.combat:SetTarget(target)
	end
end)

local LocoMotor = require("components/locomotor")
local _PreviewAction = LocoMotor.PreviewAction
function LocoMotor:PreviewAction(bufferedaction, ...)
	_PreviewAction(self, bufferedaction, ...)
	if bufferedaction and bufferedaction.action == GLOBAL.ACTIONS.ATTACK then
		SendModRPCToServer(MOD_RPC[modname].SetTarget, bufferedaction.target)
	end
end

--Add an action for toggling Abigail
local TOGGLEAGGRO = AddAction("TOGGLEAGGRO", "Disengage", function(act)
	if act.target and act.doer and act.target._playerlink == act.doer then --it's our own minion
		act.target.components.aggrotoggleable:Toggle()
		return true
	end
end)
GLOBAL.STRINGS.ACTIONS.TOGGLEAGGRO = { STOPAGGRO = "Disengage", STARTAGGRO = "Engage" }
TOGGLEAGGRO.strfn = function(act)
	return act.target and (act.target:HasTag("aggro_active") and "STOPAGGRO" or "STARTAGGRO")
end
TOGGLEAGGRO.distance = 15
TOGGLEAGGRO.mount_valid = true

AddComponentAction("SCENE", "aggrotoggleable", function(inst, doer, actions, right)
	if right and inst.replica.follower:GetLeader() and inst.replica.follower:GetLeader() == doer then
		table.insert(actions, TOGGLEAGGRO)
	end
end)

AddStategraphActionHandler("wilson", GLOBAL.ActionHandler(TOGGLEAGGRO, "give"))
AddStategraphActionHandler("wilson_client", GLOBAL.ActionHandler(TOGGLEAGGRO, "give"))

if not GLOBAL.TheNet:GetIsServer() then return end

AddPrefabPostInit("abigail", function(inst)
	inst:AddComponent("aggrotoggleable")
end)

-- Fixes attack commands for everyone else
local _PushAction = LocoMotor.PushAction
function LocoMotor:PushAction(bufferedaction, ...)
	_PushAction(self, bufferedaction, ...)
	if bufferedaction and bufferedaction.action == GLOBAL.ACTIONS.ATTACK then
		bufferedaction.doer.components.combat:SetTarget(bufferedaction.target)
	end
end	

 

On 03/02/2017 at 9:10 PM, CarlZalph said:

@rezecib did this in his rebalance mod: http://steamcommunity.com/sharedfiles/filedetails/?id=741879530

"Followers will get the same target at you as soon as you target, not at the start of the attack animation"

If you just want this and nothing else, then you can poke around his files to see what he has done to do it.

 

As an aside the method on forcing followers to attack in DST currently is to fake hit- go up and begin attacking but then issue a movement command to cancel the swing from connecting.

Thank you sooo much! I will look at the files of that mod!

4 minutes ago, CarlZalph said:

No problem, but definitely look at the post right above.

That's the dev of the mod I linked with the relevant code bits.

Yea I am looking through the code, but I didn't find anything related.. Maybe the pushAction? 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...