| 01-15-2007, 07:48 PM | #1 |
I have a hero who's supposed to cast an ability on an enemy hero. Then, when the enemy hero dies, he's supposed to get revived so that he can be killed again for the evil enjoyment of the first. Previously (when the ability was working) I used custom unit values on the casting hero, but this had issues and later conflicted with another ability I had in mind which, to the best of my limitted JASS knowledge, needed them. I realized the easy way out was to use local variables to free up the custom unit values of things to the benefit of everything. Everything went along like a dream until I ran up against a problem: The unit would just not revive. The game remembers the enemy unit's location and identity (the various string displays were my tests) but doesn't revive. Thinking I must have been trying to revive the unit while it was still unreviveable, I stuck in those huge polled waits to test the idea. No luck. Anyways, here's the code. As you might be able to tell, I started by making a framework in the GUI, converting it to JASS, then adding stuff in as I needed to, because I don't have the vocabulary to just write things. JASS:function Trig_New_Pupirupiru_Conditions takes nothing returns boolean if ( not ( GetSpellAbilityId() == 'A031' ) ) then return false endif if ( not ( GetUnitTypeId(GetTriggerUnit()) == 'N009' ) ) then return false endif return true endfunction function StrPoint takes location apoint returns string return "(" + R2S(GetLocationX(apoint)) + "," + R2S(GetLocationY(apoint)) + ")" endfunction function Trig_New_Pupirupiru_Actions takes nothing returns nothing local unit pupiunit local location punitloc set pupiunit = GetSpellTargetUnit() set punitloc = GetUnitLoc(pupiunit) loop exitwhen ( IsUnitDeadBJ(pupiunit) == true ) // call DisplayTextToForce( GetPlayersAll(), StrPoint(punitloc) ) set punitloc = GetUnitLoc(pupiunit) call TriggerSleepAction(RMaxBJ(bj_WAIT_FOR_COND_MIN_INTERVAL, 1.00)) endloop call DisplayTextToForce( GetPlayersAll(), "time" ) call PolledWait( 10 ) call DisplayTextToForce( GetPlayersAll(), "time2" ) call PolledWait( 10 ) call DisplayTextToForce( GetPlayersAll(), "revive" ) // call DisplayTextToForce( GetPlayersAll(), GetHeroProperName(pupiunit) + "Pupirupirupirupipirupiiiiii" ) // call DisplayTextToForce( GetPlayersAll(), StrPoint(punitloc) ) call ReviveHeroLoc( pupiunit, punitloc, true ) call SetUnitLifePercentBJ( pupiunit, 25.00 ) set pupiunit = null set punitloc = null endfunction //=========================================================================== function InitTrig_New_Pupirupiru takes nothing returns nothing set gg_trg_New_Pupirupiru = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_New_Pupirupiru, EVENT_PLAYER_UNIT_SPELL_CAST ) call TriggerAddCondition( gg_trg_New_Pupirupiru, Condition( function Trig_New_Pupirupiru_Conditions ) ) call TriggerAddAction( gg_trg_New_Pupirupiru, function Trig_New_Pupirupiru_Actions ) endfunction My pessimistic guess is that my code is perfect and I'm butting my head up against some game constraint. Hopefully there's an error in there somwhere which I can't see... |
| 01-15-2007, 08:32 PM | #2 |
Which part stops to work? |
| 01-15-2007, 08:37 PM | #3 | |
Quote:
Are you sure that that line is executed? |
| 01-15-2007, 10:06 PM | #4 |
I'm pretty sure it is. Both pupiunit and punitloc have valid values at the time, and the trigger does eventually get past the wait-for-condition part to get to the rest of it, and it displays any text message I put in there at some point regardless, though I haven't tried putting one in after the revive call. Therefore I'm pretty sure it calls the revive function. |
| 01-16-2007, 03:41 AM | #5 |
Sorry for the double post, but I hope enough time has transpired that I can be forgiven of the offense on the grounds of new information! (I've been reading too much Cicero) I can only conclude that it's some incredibly odd bug. This is because, as it turns on, the only situation so far where I've found it to NOT WORK is on the paladin and a mountain king I was testing on, EXCEPT when my spawn trigger (I was spawning units everyplace to get a fight going) was turned off. I could have it cast on me, cast it myself on another of my heros, whatever, and it works. So long as I use my custom heros I seem to be ok. I had no idea things could get this weird... [edit] Ok, I finally found out what the problem is. You can't revive a hero unless you have the resources (food, maybe gold and lumber too) to do so. Otherwise it won't work. Thanks for trying to help guys! |
