| 06-24-2006, 06:31 AM | #1 |
This trigger is supposed to create a walking unit from a corpse. If an enemy unit is killed by any type of unit matching the id of the walking unit, it needs to wait 5 seconds and then create another walking unit. Example: A unit is created from a corpse. If an enemy unit is killed by the unit created, after 5 seconds the same type of unit that got created will raise from the corpse. The problem is that it acts weird, instead of doing that, it just creates units from allied killed units, without having anything to do with the conditions. The conditions are if the unit type of the killing unit equals to XXXX, however, when allied units are killed, they are killed by the enemy, and are not equal to the XXXX, and still the actions go on. Here is the script: JASS:function Mutagenic_Spores_Conditions takes nothing returns boolean return GetSpellAbilityId() == 'AUcb' endfunction function Mutagenic_SpawnCorpse takes nothing returns nothing local string s = TableData(GetTriggeringTrigger()) local unit u = GetTableUnit(s, "u") local player p = GetOwningPlayer(u) local integer lvl = GetUnitAbilityLevel(u, 'AUcb') local unit t = GetDyingUnit() local unit k=GetKillingUnit() local real x = GetUnitX(t) local real y = GetUnitY(t) if GetUnitTypeId(k) == 'ndmu' and IsUnitEnemy(t, p) and not IsUnitType(t, ConvertUnitType(15)) and not IsUnitType(t, UNIT_TYPE_HERO) then call DestroyEffect(AddSpecialEffect("MDX\\MutagenicSporesBuff.mdx", x, y)) call PolledWait(5) call RemoveUnit(t) set t = CreateUnit(p, 'ndmu', x, y, GetRandomReal(0, 360)) call SetUnitAnimation(t, "birth") call QueueUnitAnimation(t, "stand") call DestroyEffect(AddSpecialEffect("MDX\\MutagenicSporesBuff.mdx", x, y)) if lvl > 1 then call UnitAddAbility(t, 'AItj') call SetUnitAbilityLevel(t, 'AItj', lvl-1) endif call UnitApplyTimedLife(t, 'BTLF', 10+(5*I2R(lvl))) endif set u = null set p = null set k=null set t = null endfunction function Mutagenic_Spores_Actions takes nothing returns nothing local unit u = GetSpellAbilityUnit() local player p = GetOwningPlayer(u) local integer lvl = GetUnitAbilityLevel(u, 'AUcb') local unit t = GetSpellTargetUnit() local real x = GetUnitX(t) local real y = GetUnitY(t) local trigger trg = CreateTrigger() local triggeraction ta local string s = TableData(trg) call SetTable(s, "u", u) call RemoveUnit(t) set t = CreateUnit(p, 'ndmu', x, y, GetRandomReal(0, 360)) call SetUnitAnimation(t, "birth") call QueueUnitAnimation(t, "stand") call DestroyEffect(AddSpecialEffect("MDX\\MutagenicSporesBuff.mdx", x, y)) if lvl >= 2 then call UnitAddAbility(t, 'AItj') if lvl > 2 then call SetUnitAbilityLevel(t, 'AItj', lvl-1) endif endif call TriggerRegisterAnyUnitEventBJ(trg, EVENT_PLAYER_UNIT_DEATH) set ta = TriggerAddAction(trg, function Mutagenic_SpawnCorpse) call UnitApplyTimedLife(t, 'BTLF', 10+(5*I2R(lvl))) call PolledWait(10+(5*I2R(lvl))) call TriggerRemoveAction(trg, ta) call ClearTable(s) call DestroyTrigger(trg) set u = null set p = null set t = null endfunction function InitTrig_Mutagenic_Spores takes nothing returns nothing set gg_trg_Mutagenic_Spores = CreateTrigger() call TriggerRegisterAnyUnitEventBJ(gg_trg_Mutagenic_Spores, EVENT_PLAYER_UNIT_SPELL_EFFECT) call TriggerAddCondition(gg_trg_Mutagenic_Spores, Condition( function Mutagenic_Spores_Conditions)) call TriggerAddAction(gg_trg_Mutagenic_Spores, function Mutagenic_Spores_Actions) endfunction Any point outs would be appreciated, I must be doing something wrong. |
| 06-24-2006, 09:03 AM | #2 |
Your spell has a general problem: When you have multiple units that use the spell in the duration range of the first, every death trigger will be executed on death of of ONE unit for EACH player ONE summoned unit. About alley/enemy thing, atm I do not see why it should not work. |
| 06-24-2006, 10:40 AM | #3 |
Yea but it still shouldnt work when allied units die.. |
| 06-24-2006, 11:28 AM | #4 |
JASS:if GetUnitTypeId(k) == 'ndmu' and IsUnitEnemy(t, p) and not IsUnitType(t, ConvertUnitType(15)) and not IsUnitType(t, UNIT_TYPE_HERO) then You might consider instead of making the trigger register on every unit that dies on the map just using a triggercondition and then clearing it like a boolean expression. To be fair, just by doing that you may clear its erratic behavior. Also, didn't we establish ConvertXXX()s should be replaced by their UNIT_TYPE_XXX? :P |
| 06-24-2006, 12:08 PM | #5 |
It already WAS on a boolexpr using a triggercondition, for my own personal reasons I am avoiding boolean expressions. As for the convert unit type, its just UNIT_TYPE_MECHANICAL, it doesnt really matter in this case. This also proves that a boolexpr and a regular condition doesnt affect any behavior. |
| 06-24-2006, 12:50 PM | #6 |
Well obviously a bunch of conditional statements will do the same thing... I was just suggesting it for convenience and possibility of alluding to the problem. And I was speaking in jest over the Convert. Meh, anyways. The conditions appear fine to me. But if you want to try different things to fix it, experiment with adding things like "== true" at the end of some of the conditions. I've noticed myself some things don't return the proper boolean at weird instances (Like an IsUnitEnemy() not working somewhere, but working elsewhere). |
| 06-24-2006, 02:54 PM | #7 |
The only explanation I can think about is that TableData() is returning different values. Use debug messages to know what is TableData when creating the trigger and what it is when a unit dies. Could also be that the gamecache is flushed. I dislike the fact you are using some of the names of the tables functions but for other ones another names. It is a different set if you release this spell there will be conflicts, not that it really matters. |
| 06-24-2006, 04:59 PM | #8 |
I'm not releasing the spell, it's used on my map, that's why the names are for my convenience. The game cache isn't flushed at any time. Whenever I released a spell (See the resources section), I always include the right names. I'll try some debug messages. edit: debug messages showed just fine the killer, the dying unit and the raising unit. weird. Edit 2: nm, found the reason. |
| 06-25-2006, 12:44 AM | #9 | |
Quote:
|
| 06-25-2006, 06:08 AM | #10 |
The trigger was acting weird, sometimes spawning multiple times and sometimes not spawning at all. Lets say you cast the spell and a unit is created from the corpse. A trigger is registered, then if you spawn it again, another trigger is registered. The condition was if the killing unit's type id == 'ndmu', so, you got now two triggers firing everytime it kills a unit. The fix was to attach the spawned unit to the trigger, and if the killing unit == spawning unit, order it to spawn. I have no idea why it didnt fire at all in the first place, thats why I was surprised. The fix: JASS:function Mutagenic_Spores_Conditions takes nothing returns boolean return GetSpellAbilityId() == 'AUcb' endfunction function Mutagenic_SpawnCorpse takes nothing returns nothing local string s = TableData(GetTriggeringTrigger()) local unit u = GetTableUnit(s, "u") local player p = GetOwningPlayer(u) local integer lvl = GetUnitAbilityLevel(u, 'AUcb') local unit t = GetDyingUnit() local unit k=GetKillingUnit() local real x = GetUnitX(t) local real y = GetUnitY(t) local unit corpse=GetTableUnit(s, "corpse") if k==corpse and IsUnitEnemy(t, p) and not IsUnitType(t, UNIT_TYPE_MECHANICAL) and not IsUnitType(t, UNIT_TYPE_HERO) and not IsUnitType(t, UNIT_TYPE_GIANT) then call DestroyEffect(AddSpecialEffect("MDX\\MutagenicSporesBuff.mdx", x, y)) call PolledWait(5) call RemoveUnit(t) set t = CreateUnit(p, 'ndmu', x, y, GetRandomReal(0, 360)) call SetUnitAnimation(t, "birth") call QueueUnitAnimation(t, "stand") call DestroyEffect(AddSpecialEffect("MDX\\MutagenicSporesBuff.mdx", x, y)) if lvl > 1 then call UnitAddAbility(t, 'AItj') call SetUnitAbilityLevel(t, 'AItj', lvl-1) endif call UnitApplyTimedLife(t, 'BTLF', 10+(5*I2R(lvl))) endif set u = null set corpse=null set p = null set k=null set t = null endfunction function Mutagenic_Spores_Actions takes nothing returns nothing local unit u = GetSpellAbilityUnit() local player p = GetOwningPlayer(u) local integer lvl = GetUnitAbilityLevel(u, 'AUcb') local unit t = GetSpellTargetUnit() local real x = GetUnitX(t) local real y = GetUnitY(t) local trigger trg=CreateTrigger() local triggeraction ta local string s=TableData(trg) call SetTable(s, "u", u) call RemoveUnit(t) set t = CreateUnit(p, 'ndmu', x, y, GetRandomReal(0, 360)) call SetTable(s, "corpse", t) call SetUnitAnimation(t, "birth") call QueueUnitAnimation(t, "stand") call DestroyEffect(AddSpecialEffect("MDX\\MutagenicSporesBuff.mdx", x, y)) if lvl >= 2 then call UnitAddAbility(t, 'AItj') if lvl > 2 then call SetUnitAbilityLevel(t, 'AItj', lvl-1) endif endif call TriggerRegisterAnyUnitEventBJ(trg, EVENT_PLAYER_UNIT_DEATH) set ta = TriggerAddAction(trg, function Mutagenic_SpawnCorpse) call UnitApplyTimedLife(t, 'BTLF', 10+(5*I2R(lvl))) call PolledWait(10+(5*I2R(lvl))) call TriggerRemoveAction(trg, ta) call ClearTable(s) call DestroyTrigger(trg) set u = null set p = null set t = null endfunction function InitTrig_Mutagenic_Spores takes nothing returns nothing set gg_trg_Mutagenic_Spores = CreateTrigger() call TriggerRegisterAnyUnitEventBJ(gg_trg_Mutagenic_Spores, EVENT_PLAYER_UNIT_SPELL_EFFECT) call TriggerAddCondition(gg_trg_Mutagenic_Spores, Condition( function Mutagenic_Spores_Conditions)) call TriggerAddAction(gg_trg_Mutagenic_Spores, function Mutagenic_Spores_Actions) endfunction |
