| 09-26-2006, 09:16 PM | #1 |
K I thought id start of very simple. Final Spell should be Lightning Blast - Deals X damage divided amongst all enemy units surrounding target unit. An improved Chain Lightning/Forked Lightning pretty much. Im stuck at the stage of damaging the group, no damage is dealt???? JASS:function Trig_Lightning_Blast_Conditions takes nothing returns boolean return GetSpellAbilityId() == 'AOcl' endfunction function Trig_Lightning_Blast_Actions takes nothing returns nothing local unit u = GetTriggerUnit() local unit t = GetSpellTargetUnit() local location newx = GetLocationX(t) local location newy = GetLocationY(t) local unit d local group g = CreateGroup() call GroupEnumUnitsInRange(g, newx, newy, 500, null) loop set picked=FirstOfGroup(g) exitwhen (picked==null) call UnitDamageTargetBJ( u, picked, 500, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL ) call GroupRemoveUnit(g,picked) endloop endfunction //=========================================================================== function InitTrig_Lightning_Blast takes nothing returns nothing set gg_trg_Lightning_Blast = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_Lightning_Blast, EVENT_PLAYER_UNIT_SPELL_EFFECT ) call TriggerAddAction( gg_trg_Lightning_Blast, function Trig_Lightning_Blast_Actions ) call TriggerAddCondition( gg_trg_Lightning_Blast, Condition( function Trig_Lightning_Blast_Conditions ) ) endfunction Originally I was going to set d = FirstOfGroup in the loop, but I looked at a thread where Vex was demonstrating loop/get first unit. thx for any help |
| 09-26-2006, 09:23 PM | #2 |
I'd be surprised if that compiled. You should be using GetUnitX/Y, not GetLocationX/Y. And they should be of type real, not location. You also have not declared a variable named picked. |
| 09-26-2006, 09:23 PM | #3 |
That won't compile. Picked is undefined. Also, it should be 500., rather than 500, as it then doesn't convert from int to real (making it faster). |
| 09-26-2006, 09:45 PM | #4 |
kk thx guys, got it now. I added a Lightning Effect JASS:function Trig_Lightning_Blast_Conditions takes nothing returns boolean return GetSpellAbilityId() == 'AOcl' endfunction function Trig_Lightning_Blast_Actions takes nothing returns nothing local unit u = GetTriggerUnit() local unit t = GetSpellTargetUnit() local real newx = GetUnitX(t) local real newy = GetUnitY(t) local unit d local group g = CreateGroup() call GroupEnumUnitsInRange(g, newx, newy, 500, null) loop set d = FirstOfGroup(g) exitwhen (d==null) call UnitDamageTargetBJ( u, d, 500, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL ) call AddLightningLoc( "CLPB", GetUnitLoc(t), GetUnitLoc(d)) call GroupRemoveUnit(g,d) endloop endfunction //=========================================================================== function InitTrig_Lightning_Blast takes nothing returns nothing set gg_trg_Lightning_Blast = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_Lightning_Blast, EVENT_PLAYER_UNIT_SPELL_EFFECT ) call TriggerAddAction( gg_trg_Lightning_Blast, function Trig_Lightning_Blast_Actions ) call TriggerAddCondition( gg_trg_Lightning_Blast, Condition( function Trig_Lightning_Blast_Conditions ) ) endfunction Now 2 things im uncertain how to do. - Adding an expiration timer or destroying the Lightning Effects after X seconds. - Counting number of units in group, and setting X = (level of spell) / Number of Units in group To split damage of spell equally |
| 09-26-2006, 11:24 PM | #5 |
You can use the function CountUnitsInGroup to get the amount of units in a group (non native function). Then take the total damage and then divide those numbers. As for added the lightning effect for a certain time, I would try making another function that would take in a lightning effect, set the lightning in a handle variable, start the timer for X seconds, and then destroy the lightning effect in the function the timer called, like this: JASS:function DestroyLightning2_Fx takes nothing returns nothing local timer t = GetExpiredTimer() call DestroyLightning(GetHandleLightning(t, "lightning")) call FlushHandleLocals(t) call DestroyTimer(t) set t = null endunction function DestroyLightning2 takes lightning l, real time, returns nothin local timer t = CreateTimer() call SetHandleHandle(t, "lightning", l) call TimerStart(t, time, false, function DestroyLightning2_Fx) set t = null endfunction |
| 09-27-2006, 08:32 AM | #6 |
EDIT>>> Ok Ive got ti all working now except for the Lightning. How can I convert the above to use tables instead of handles?? thx |
