PDA

View Full Version : (5e) Issue with CombatManager.setCustomTurnEnd ?



Stv
May 31st, 2020, 20:15
I have the following code as a test in an extension :

in the onit I have :

CombatManager.setCustomTurnEnd(turnEnd)

followed by :

function turnEnd()
Debug.console("newturnendfunction")
end

All is working fine until it is a turn end AND a round end, then it seems that the turnend function is called twice. Once before and once after the round end function.

Am I being stupid, or is this happening for others also?

Cheers, Steve.

jackkerouac
June 1st, 2020, 03:15
I have the following code as a test in an extension :

in the onit I have :

CombatManager.setCustomTurnEnd(turnEnd)

followed by :

function turnEnd()
Debug.console("newturnendfunction")
end

All is working fine until it is a turn end AND a round end, then it seems that the turnend function is called twice. Once before and once after the round end function.

Am I being stupid, or is this happening for others also?

Cheers, Steve.


I just ran your code and I can confirm. It is firing every time a character in the CT turn's is over AS WELL as when the round is over. If I have two characters in the CT and an NPC, it fires after each one and again when the round is over. So if I just click the Next Round button instead of the Next Actor button, it fires FOUR times (one for each actor in the CT and once for when the round is over).

I tried also using CombatManager.setCustomTurnStart(), but that fires the same amount of times. I'm not sure what you are looking to do, but if you want something to fire each ROUND, you should look at CombatManager.setCustomRoundStart() or even setCustomCombatReset().

Hope that helps.

Stv
June 1st, 2020, 09:20
Thanks for checking for me Jack, although not what I wanted to hear :P
I need something to fire on the end of an actors turn, but also something different to fire on a turn end.
Guess I'll have to find some part of the base functions to override instead of using the 'setCustom' funtions.
I thought the way I had attacked it was the correct way, maybe it is and that part of the code is buggy.

Thanks again for confiming.

Cheer, Steve.

Trenloe
June 1st, 2020, 09:27
The turn end gets ran whenever there’s a change in the current unit slot - which happens at the end of the round too. There’s another custom function in the CoreRPG effects package, I can't remember what it’s called as I’m not in front of my computer, it’s something like customActorEndTurn - it has "actor" in the name.

Trenloe
June 1st, 2020, 10:54
I was getting a bit confused. The custom event I was thinking of was fCustomOnEffectActorEndTurn in CoreRPG scripts\manager_effects.lua. But this only gets called if there are effects on the actor.

In the custom turnEnd script you have in post #1, add nodeCT as an event variable. You can check this and if it's the first node in the CT you can assume it's the beginning of the round? I don't know, just thinking out loud...

Stv
June 1st, 2020, 10:57
I had a play with a workaround earlier Trenloe, if I use a temporary flag, I can set/reset it depending on if the round end has been triggered, if it does, then don't trigger the turn end (as it will already have been processed before the round end).
It's a bit messy, but it works :)


Thanks for you help :)



Although there is something else you could also maybe help with..... :P

What event is triggered if you manually change the current actor in the CT by using the left hand buttons ?


Cheers, Steve.

Trenloe
June 1st, 2020, 11:35
What event is triggered if you manually change the current actor in the CT by using the left hand buttons ?
There's no central handler than I can see. In 5e it fires the onActiveChanged handler in ct\scripts\ct_entry.lua.

Stv
June 1st, 2020, 14:02
There's no central handler than I can see. In 5e it fires the onActiveChanged handler in ct\scripts\ct_entry.lua.
Thanks for the heads up.
I'll take a look at that and see if it can do what I need.

Cheers, Steve.