Jump to content

Issues with creating an equippable item having the new spellbook component


Recommended Posts

So I have a small mod that I privately use and also try to program with my very limited programming knowledge. The mod basicly modifies the walking cane into a swiss-knife-type item adding many features to it, also the ability to cast certain aoe and non-aoe spells. Before the Maxwell refresh, I used very primitive ways to make the item work in regards to its spells, but after the update it seemed like a perfect idea to use the new spellbook/aoetargeting/aoespell components to rewrite my mod and make it more elegant. So I reprogrammed all the existing aoe spells into the invidual spells of the new spellbook component to detach them from the non-aoe ones. It worked perfectly with the exception of one thing. One of the components doesnt seem to interact very well with the fact that the item having it can be equipped in the hand. So while equipped they somehow allow the action CASTAOE to be 'active' without using (reading) the item (which has the spellbook component) or casting one of its spells. So whenever the item is equipped the action CASTAOE can be activated with a right mouse click and then executed with a left mouse click. This is very annoying, because it gets conflicted with other actions that the item has. I intend to fix this issue to make sure that the action CASTAOE can only be used after one of the spells from the spellbook has been cast and only once, but I have no idea how. I suspect that the action CASTAOE and/or the aoespell component should be modified somehow, because these seem to cause the issue. I hope my problem is somehow fixabIe. I would very much appreciate all the help.

GLOBAL.ACTIONS.CASTAOE.stroverridefn = function(act)
	return act.invobject ~= nil and act.invobject.components.spellbook ~= nil and act.invobject.components.spellbook:GetSpellName() or nil
end

GLOBAL.ACTIONS.CASTAOE.strfn = function(act)
    return act.invobject ~= nil and string.upper(act.invobject.prefab) or nil
end

GLOBAL.ACTIONS.CASTAOE.fn = function(act)
	local act_pos = act:GetActionPoint()
    if act.invobject ~= nil and act.invobject.components.aoespell ~= nil and act.invobject.components.aoespell:CanCast(act.doer, act_pos) then
		return act.invobject.components.aoespell:CastSpell(act.doer, act_pos)
    end
end

I added the codes that might have to be modified.

Link to comment
Share on other sites

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
 Share

×
  • Create New...