| 05-26-2006, 06:58 AM | #1 |
EDIT: After hours of searching in my own codes I finally found out what caused the function OnAbilityLearn to stop working. Try a trigger like this: JASS:function Trig_GetAbility_Actions takes nothing returns nothing call BJDebugMsg("GetAbility") endfunction function Trig_LearnAbility1_Actions takes nothing returns nothing call BJDebugMsg("Learnt Blizzard") endfunction function Trig_LearnAbility2_Actions takes nothing returns nothing call BJDebugMsg("Learnt Water Elemental") endfunction //===================================================== function InitTrig_Test takes nothing returns nothing call OnAbilityLearn('AHbz', "Trig_LearnAbility1_Actions") call OnAbilityGet('ACbh', "Trig_GetAbility_Actions") call OnAbilityLearn('AHwe', "Trig_LearnAbility2_Actions") endfunction The function won't be called when hero learn Blizzard or Water Elemental(I using the default skill here). It getting even weird if the Spell Event is splitted to 3 Triggers, each having only 1 OnAbilityXXXX function won't cause any problems at all. So I decided to find out what causes this problem inside Caster System source code and I found out a weird problem: JASS:function InitPassiveEvent takes gamecache g returns nothing local trigger t call TimerStart(CreateTimer(),0,false,function Event_OnPassive_InitEnum) call StoreInteger(g,"eventhandlers","passives",1) if (not HaveStoredInteger(g,"eventhandlers","learn")) then call InitLearnEvent(g,2) else set t=GetTableTrigger("Events_ProbablyTemp","learntrig") call TriggerRemoveAction(t,GetTableTriggerAction("Events_ProbablyTemp","learntriga") ) call FlushStoredMission(g,"Events_ProbablyTemp") set t=CreateTrigger() call TriggerAddAction(t, function Event_OnLearn2) call StoreInteger(g,"eventhandlers","learn",2) set t=null endif endfunction The new trigger created seems to missing an AddEvent function. And after I added this line JASS:
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_DEATH )
Thanks |
| 05-29-2006, 12:53 AM | #2 |
Er my problem is fixed but could is there a better solution to fix this problem? I don't want to edit the CS code as I'll need to modify it again when I updated the lastest CS? Now I'm using 13.3 and wish to update it to 13.4 without modifying the code again. |
| 05-29-2006, 02:55 AM | #3 |
I don't think the cause is the one you stated, that wouldn't explain that it works if you split the events. I think it has something to do with the fact you are using Get and Learn events at the same time. JASS:function InitLearnEvent takes gamecache g, integer i returns nothing local trigger t=CreateTrigger() local integer j=0 loop call TriggerRegisterPlayerUnitEvent(t, Player(j),EVENT_PLAYER_HERO_SKILL, null) set j=j+1 exitwhen j==bj_MAX_PLAYER_SLOTS endloop if (i==1) then call StoreInteger(g,"Events_ProbablyTemp","learntrig",CS_H2I(t)) call StoreInteger(g,"Events_ProbablyTemp","learntriga",CS_H2I(TriggerAddAction(t, function Event_OnLearn1))) else call TriggerAddAction(t, function Event_OnLearn2) endif call StoreInteger(g,"eventhandlers","learn",i) set t=null endfunction function OnAbilityLearn takes integer abilid, string funcname returns nothing local gamecache g=CSCache() if (not HaveStoredInteger(g,"eventhandlers","learn")) then call InitLearnEvent(g,1) endif call StoreString( g,"events_onlearn", I2S(abilid), funcname) set g=null endfunction Note that it does have the event registering function. Not that I take a look into the code I think that there is a problem if you call OnAbilityLearn after calling OnAbilityGet , Try making it so the Get call is bellow the learn ones. If that works a way to fix it would be to use only Get Events, just check if GetHeroSkillId() equals 0 to recognize getting from learning, I am gonna check better later (currently I used wine to open world editor on linux it is able to read triggers but is quite bugged otherwise) and fix the issue. |
| 05-29-2006, 04:14 AM | #4 |
What I feel weird is that you create new trigger at the InitPassiveEvent function without adding a new event. I though it suppose to be either adding the new action directly to the old trigger or create a brand new trigger with new event? Btw, this is some info I get when working on a test map: - Putting Get at top of all the Learn functions fix the problem. - Only 1 Get is needed to be on topmost of the Init_TrigXXX to fix the problem. (Get-Learn-Get-Learn or Get-Learn-Learn-Get works with no problem) - If Learn is at the topmost of the Init_TrigXXXX it cause problem again. - Putting Get below all the Learn functions doesn't help. . - Removing the Get function fix the problem. - Replacing all the Learn with Get fix the problem. And the weirdest thing is that as long as i split all the OnAbilityXXXX function into multiple triggers(as I stated before), it never cause any problem no matter how the sequence I put. I tried nearly all the possible sequence with 2 Get and 2 Learn(total 4 trigger) and none of them cause problem. This is what makes me getting confused that what actually cause the problem. But at least that explains to me that why I never get this problem before until recently. This is because I combined the spells into one single trigger for each hero(to tidy up my massive triggers list in WE) and suddently half of my spells couldn't work anymore. |
