| 04-06-2007, 04:59 PM | #1 |
I dont know whats wrong with this spell, its my first 100% jass spell i tryed to do (ye i know im nooby at this, dont go hard on me :P ) JASS:function Trig_CtD_Conditions takes nothing returns boolean return GetSpellAbilityId() == 'A00N' endfunction function Trig_CtD_Func1 takes nothing returns boolean local unit a = GetTriggerUnit() return GetBooleanAnd((UnitHasBuffBJ(GetFilterUnit(), 'B002') == true), (IsUnitAliveBJ(a) == true)) endfunction function Trig_CtD_Func2 takes nothing returns nothing local unit a = GetTriggerUnit() local group temp local lightning light call AddLightningLoc( "AFOD", GetUnitLoc(a), GetUnitLoc(temp) ) set light = GetLastCreatedLightningBJ() call UnitDamageTargetBJ( a, b, 350.00, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_DEATH ) endfunction function Trig_CtD_Actions takes nothing returns nothing local unit a = GetTriggerUnit() local integer loopv = 0 local group temp if ( GetUnitAbilityLevel( a, 'A00N') == 1 ) then set loopv = 1 loop exitwhen loopv > 10 if ( IsUnitAliveBJ(a) == false ) then set loopv = 10 else set temp = GetRandomSubGroup(1, GetUnitsInRangeOfLocMatching(800.00, GetUnitLoc(a), Condition(function Trig_CtD_Func1) ) ) call ForGroup( temp, function Trig_CtD_Func2 ) endif endloop else if ( GetUnitAbilityLevel( a, 'A00N') == 1 ) then set loopv = 1 loop exitwhen loopv > 20 if ( IsUnitAliveBJ(a) == false ) then set loopv = 10 else set temp = GetRandomSubGroup(1, GetUnitsInRangeOfLocMatching(800.00, GetUnitLoc(a), Condition(function Trig_CtD_Func1) ) ) call ForGroup( temp, function Trig_CtD_Func2 ) endif endloop else if ( GetUnitAbilityLevel( a, 'A00N') == 1 ) then set loopv = 1 loop exitwhen loopv > 30 if ( IsUnitAliveBJ(a) == false ) then set loopv = 10 else set temp = GetRandomSubGroup(1, GetUnitsInRangeOfLocMatching(800.00, GetUnitLoc(a), Condition(function Trig_CtD_Func1) ) ) call ForGroup( temp, function Trig_CtD_Func2 ) endif endloop endif endif endif endfunction //=========================================================================== function InitTrig_CtD takes nothing returns nothing set gg_trg_CtD = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_CtD, EVENT_PLAYER_UNIT_SPELL_EFFECT ) call TriggerAddCondition( gg_trg_CtD, Condition( function Trig_CtD_Conditions ) ) call TriggerAddAction( gg_trg_CtD, function Trig_CtD_Actions ) endfunction |
| 04-06-2007, 05:14 PM | #2 |
We really don't know what's wrong with it, you don't tell us what it is supposed to do nor how does it fail |
| 04-06-2007, 06:05 PM | #3 |
its suposed to create lightning beetwen random unit from units under effect of ability and unit which casts this ability, the lightning isnt created and unit isnt damaged, better now? :P |
| 04-06-2007, 09:03 PM | #4 |
You have three infinite loops in your CtD Actions function. You can't use GetTriggerUnit() in a ForGroup callback function. JASS:function Trig_CtD_Func2 takes nothing returns nothing local unit a = GetTriggerUnit() //you cant do this. You need to pass this unit to the function through globals or gamecache. local group temp//this is wrong local unit temp = GetEnumUnit()//use this to get the temp unit. local lightning light call AddLightningLoc( "AFOD", GetUnitLoc(a), GetUnitLoc(temp) )//you are leaking locations here. set light = GetLastCreatedLightningBJ() call UnitDamageTargetBJ( a, b, 350.00, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_DEATH )//you don't have a unit b in this function. endfunction |
| 04-06-2007, 09:06 PM | #5 | |
JASS:
set loopv = 1
loop
exitwhen loopv > 10
if ( IsUnitAliveBJ(a) == false) then
set loopv = 10
else
set temp = GetRandomSubGroup(1,GetUnitsInRangeOfLocMatching(800.00,GetUnitLoc(a),Condition(function Trig_CtD_Func1)))
call ForGroup( temp, function Trig_CtD_Func2 )
endif
endloopYou dont end the other loops 2 for the others ...i edited the formating of the trigger so that you can easier read it ..
|
| 04-07-2007, 08:16 AM | #6 |
The error, I believe, lies in these two lines: JASS:local group temp //... call AddLightningLoc( "AFOD", GetUnitLoc(a), GetUnitLoc(temp) ) |
| 04-07-2007, 01:21 PM | #7 | |
well, the spell is working now, but it isnt mui! (i guess its because i used udg, any other way for it? handle var or something?) heres the code
|
| 04-07-2007, 01:33 PM | #8 |
I suggest using grimoire's war3err when testing Jass scripts, it would report all these mistakes automatically to you while playing the map. |
| 04-07-2007, 01:38 PM | #9 |
well ive somewhat fixed the spell, but can anyone help make it MUI? :/ also i have to null every local i use, right? abd u an ysubg grimoire's war3err |
| 04-07-2007, 02:57 PM | #10 |
There are still things that could be improved, but give this function a shot. You don't need the ForGroup callback function anymore. This should be fully MUI. JASS:function Trig_CtD_Actions takes nothing returns nothing local unit a = GetTriggerUnit() local integer loopv = 1 local unit u local location loc = GetUnitLoc(a) local group g = GetUnitsInRangeOfLocMatching(800.00, loc, Condition(function Trig_CtD_Func1) ) if ( GetUnitAbilityLevel( a, 'A00N') == 1 ) then loop exitwhen loopv > 10 if ( IsUnitAliveBJ(a) == false ) then set loopv = 11 else set u = GroupPickRandomUnit(g) exitwhen u == null call DestroyLightning(AddLightning("AFOD", TRUE, GetUnitX(a), GetUnitY(a), GetUnitX(u), GetUnitY(u))//I'm not sure if this actually works for lightning. I know you can do this for many special effects. call UnitDamageTarget(a, u, 350., TRUE, FALSE, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_DEATH, WEAPON_TYPE_WHOKNOWS) set loopv = loopv + 1 endif endloop elseif ( GetUnitAbilityLevel( a, 'A00N') == 2 ) then loop exitwhen loopv > 20 if ( IsUnitAliveBJ(a) == false ) then set loopv = 21 else set u = GroupPickRandomUnit(g) exitwhen u == null call DestroyLightning(AddLightning("AFOD", TRUE, GetUnitX(a), GetUnitY(a), GetUnitX(u), GetUnitY(u)) call UnitDamageTarget(a, u, 350., TRUE, FALSE, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_DEATH, WEAPON_TYPE_WHOKNOWS) set loopv = loopv + 1 endif endloop elseif ( GetUnitAbilityLevel( a, 'A00N') == 3 ) then loop exitwhen loopv > 30 if ( IsUnitAliveBJ(a) == false ) then set loopv = 31 else set u = GroupPickRandomUnit(g) exitwhen u == null call DestroyLightning(AddLightning("AFOD", TRUE, GetUnitX(a), GetUnitY(a), GetUnitX(u), GetUnitY(u)) call UnitDamageTarget(a, u, 350., TRUE, FALSE, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_DEATH, WEAPON_TYPE_WHOKNOWS) set loopv = loopv + 1 endif endloop endif set u = null set a = null call RemoveLocation(loc) call DestroyGroup(g) set loc = null set g = null endfunction |
| 04-07-2007, 05:31 PM | #11 |
well theres still something wrong with spell, one the spell is casted before the first finishes it just stops working, everything jumps on second hero (there are two untis damaged near him etc.) would setting variables just before the loop (after IF) or somewhere else? (Except the 'a' variable) fix that problem? |
| 04-07-2007, 05:55 PM | #12 |
Post the code you are using now. We can't fix it if we can't see it. |
| 04-07-2007, 06:04 PM | #13 | ||
Quote:
using the one given by you :P
|
| 04-07-2007, 06:28 PM | #14 |
Ok try this one. I think this will work properly now. edit: actually it may not. I am investigating further edit2: I did some testing and it seemed to work fine. There is a problem with the lightning not showing up. You'd probably be best served by making a dummy caster and having it cast chain lightning on all the targetted units. JASS:function Trig_CtD_Conditions takes nothing returns boolean return GetSpellAbilityId() == 'A00N' endfunction function Trig_CtD_Func1 takes nothing returns boolean return (UnitHasBuffBJ(GetFilterUnit(), 'B002') == true) endfunction function Trig_CtD_Actions takes nothing returns nothing local unit a = GetSpellAbilityUnit() local integer loopv = 1 local unit u local group g = CreateGroup() local real x = GetUnitX(a) local real y = GetUnitY(a) call GroupEnumUnitsInRange(g, x, y, 800.00, Condition(function Trig_CtD_Func1) ) if ( GetUnitAbilityLevel( a, 'A00N') == 1 ) then loop exitwhen loopv > 10 if ( IsUnitAliveBJ(a) == false ) then set loopv = 11 else set u = GroupPickRandomUnit(g) exitwhen u == null call DestroyLightning(AddLightning("AFOD", TRUE, x, y, GetUnitX(u), GetUnitY(u))) call UnitDamageTarget(a, u, 350., TRUE, FALSE, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_DEATH, WEAPON_TYPE_WHOKNOWS) set loopv = loopv + 1 endif endloop elseif ( GetUnitAbilityLevel( a, 'A00N') == 2 ) then loop exitwhen loopv > 20 if ( IsUnitAliveBJ(a) == false ) then set loopv = 21 else set u = GroupPickRandomUnit(g) exitwhen u == null call DestroyLightning(AddLightning("AFOD", TRUE, x, y, GetUnitX(u), GetUnitY(u))) call UnitDamageTarget(a, u, 350., TRUE, FALSE, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_DEATH, WEAPON_TYPE_WHOKNOWS) set loopv = loopv + 1 endif endloop elseif ( GetUnitAbilityLevel( a, 'A00N') == 3 ) then loop exitwhen loopv > 30 if ( IsUnitAliveBJ(a) == false ) then set loopv = 31 else set u = GroupPickRandomUnit(g) exitwhen u == null call DestroyLightning(AddLightning("AFOD", TRUE, x, y, GetUnitX(u), GetUnitY(u))) call UnitDamageTarget(a, u, 350., TRUE, FALSE, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_DEATH, WEAPON_TYPE_WHOKNOWS) set loopv = loopv + 1 endif endloop endif set u = null set a = null call RemoveLocation(loc) call DestroyGroup(g) set loc = null set g = null endfunction //=========================================================================== function InitTrig_CtD takes nothing returns nothing set gg_trg_CtD = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_CtD, EVENT_PLAYER_UNIT_SPELL_EFFECT ) call TriggerAddCondition( gg_trg_CtD, Condition( function Trig_CtD_Conditions ) ) call TriggerAddAction( gg_trg_CtD, function Trig_CtD_Actions ) endfunction |
| 04-07-2007, 08:10 PM | #15 |
just one question, wouldnt making unit cast finger of death be easier etc.? well, you got icq/msn? Because i cant explain how ability works, and if you dont know it, you cant really fix it, and i already appriciate what you made for me |
