Terrabull
Veteran Member (Done that)
- Reaction score
- 38
I have a trigger that creates a unit group, then assigns all the units in that group an ability. This works fine when I test it in single player, but when people are beta testing it they are getting fatal errors. I have heard a lot that it happens with this trigger (or triggers nearly identical to this, just the ability ID is changed.)
My questions:
Would this trigger cause a crash?
Is it possible for a unit to die between being assigned to the group, and given the ability?
If the answer to both of those questions (or at least, the answer to the first question) is "No." Then does anyone know what could be causing the crash? I am not sure what to even look for.
A related trigger, not sure if it is necessary to post this.
My questions:
Would this trigger cause a crash?
Is it possible for a unit to die between being assigned to the group, and given the ability?
If the answer to both of those questions (or at least, the answer to the first question) is "No." Then does anyone know what could be causing the crash? I am not sure what to even look for.
JASS:
function Cond_Morale_Vampiric takes nothing returns boolean
return GetSpellAbilityId() == 039;A01K039;
endfunction
function Add_Vampiric takes nothing returns nothing
call UnitAddAbility(GetEnumUnit(),039;A01G039;)
call UnitAddAbility(GetEnumUnit(),039;A020039;)
endfunction
function Act_Morale_Vampiric takes nothing returns nothing
local group TG = CreateGroup()
local integer P = 0
if GetTriggerUnit() == gg_unit_n010_0181 then
set P = 10
else
set P = 11
endif
call GroupEnumUnitsOfPlayer(TG,Player(P),Condition(function Not_Structure))
call ForGroup(TG,function Add_Vampiric)
call DestroyGroup(TG)
set TG = null
call SetUnitOwner(GetTriggerUnit(),Player(P),true)
endfunction
//===========================================================================
function InitTrig_Morale_Vampiric takes nothing returns nothing
set gg_trg_Morale_Vampiric = CreateTrigger()
call TriggerRegisterUnitEvent(gg_trg_Morale_Vampiric,gg_unit_n010_0181,EVENT_UNIT_SPELL_FINISH)
call TriggerRegisterUnitEvent(gg_trg_Morale_Vampiric,gg_unit_n010_0182,EVENT_UNIT_SPELL_FINISH)
call TriggerAddCondition(gg_trg_Morale_Vampiric,Condition(function Cond_Morale_Vampiric))
call TriggerAddAction(gg_trg_Morale_Vampiric,function Act_Morale_Vampiric)
endfunction
A related trigger, not sure if it is necessary to post this.
JASS:
library LeftMorale initializer Init_Left_Morale requires Morale
function Cond_Left_Morale takes nothing returns boolean
return GetTriggerUnit() == gg_unit_n010_0181
endfunction
function Act_Left_Morale takes nothing returns nothing
if GetOwningPlayer(GetTriggerUnit()) == Player(10) and GetTriggerUnit() == gg_unit_n010_0181 then
call SetUnitOwner(gg_unit_n010_0181,GetTriggerPlayer(),true)
call DisplayTimedTextToPlayer(GetTriggerPlayer(),0,0,5,"|CFFFF0000You |CFFFF5500have |CFFFFBF0030 |CFFEAFF00seconds |CFF40FF00to |CFF00EA15use |CFF00956Athe |CFF0040BFMorale |CFF552AFFCenter.")
call TriggerSleepAction(30.00)
if GetOwningPlayer(GetTriggerUnit()) == GetTriggerPlayer() then
call SetUnitOwner(gg_unit_n010_0181,Player(10),true)
endif
else
if GetOwningPlayer(GetTriggerUnit()) != GetTriggerPlayer() and GetTriggerUnit() == gg_unit_n010_0181 then
call DisplayTimedTextToPlayer(GetTriggerPlayer(),0,0,7,"|CFF59DED2C|CFF65DCCAu|CFF71DAC2r|CFF7ED8B9r|CFF8AD6B1e|CFF96D4A8n|CFFA3D1A0t|CFFAFCF97l|CFFBBCD8Fy |CFFE1C675i|CFFDEC77Bn |CFFD7C988u|CFFD4CA8Fs|CFFD1CB95e|CFFCDCC9C, |CFFC7CEA9p|CFFC3CFAFl|CFFBCD2BDe|CFFBBC7B3a|CFFBABBA9s|CFFB9AF9Ee |CFFB79789w|CFFB68C7Fa|CFFB58074i|CFFB4746At |CFFB25C553|CFFB1504A0 |CFFA85062s|CFFA4516Ee|CFF9F517Ac|CFF9A5186o|CFF965292n|CFF91529Ed|CFF8C52AAs|CFF8853B6.|R")
endif
endif
endfunction
//===========================================================================
function Init_Left_Morale takes nothing returns nothing
local integer i = 0
set gg_trg_Left_Morale = CreateTrigger()
loop
exitwhen i>3
call TriggerRegisterPlayerUnitEvent(gg_trg_Left_Morale,Player(i),EVENT_PLAYER_UNIT_SELECTED,Condition(function Morale_Center))
set i=i+1
endloop
// call TriggerAddCondition(gg_trg_Left_Morale,Condition(function Cond_Left_Morale))
call TriggerAddAction(gg_trg_Left_Morale,function Act_Left_Morale)
endfunction
endlibrary