| 03-15-2007, 09:38 PM | #1 |
JASS:function Trig_Throws_Dodgeball_Conditions takes nothing returns boolean return GetSpellAbilityId() == 'A000' endfunction function Trig_Throws_Dodgeball_Callback_Conditions takes nothing returns boolean return IsUnitType( GetFilterUnit(), UNIT_TYPE_HERO ) == true and IsUnitEnemy( GetFilterUnit(), GetOwningPlayer( GetEnumUnit() ) ) == true endfunction function Trig_Throws_Dodgeball_Callback takes nothing returns nothing local unit a = GetEnumUnit() local real ax = GetUnitX(a) local real ay = GetUnitY(a) local real pf = GetUnitFacing(a) local group g = CreateGroup() local boolexpr b = Condition( function Trig_Throws_Dodgeball_Callback_Conditions ) local unit f call GroupEnumUnitsInRange( g, ax, ay, 65, b ) set f = FirstOfGroup(g) if f == null then call SetUnitPosition( a, 15 * Cos(pf * bj_DEGTORAD), 15 * Sin(pf * bj_DEGTORAD) ) else call KillUnit(f) call CreateItem( 'I000', ax, ay ) endif call DestroyGroup(g) call DestroyBoolExpr(b) set g = null set f = null set b = null set a = null endfunction function Trig_Throws_Dodgeball_Effect_Core takes timer t returns nothing local unit c = GetHandleUnit( t, "cast" ) local unit d = GetHandleUnit( t, "ball" ) local real x = GetHandleReal( t, "x" ) local real y = GetHandleReal( t, "y" ) local integer i = GetHeroStr(c, false) * 2 local group g = CreateGroup() call SetHandleInt( t, "int", GetHandleInt( t, "int" ) + 1 ) if GetHandleInt( t, "int" ) < i then call GroupAddUnit( g, d ) call ForGroup( g, function Trig_Throws_Dodgeball_Callback ) else call PauseTimer(t) call DestroyTimer(t) call FlushHandleLocals(t) endif call DestroyGroup(g) set c = null set d = null set g = null endfunction function Trig_Throws_Dodgeball_Effect takes nothing returns nothing call Trig_Throws_Dodgeball_Effect_Core( GetExpiredTimer() ) endfunction function Trig_Throws_Dodgeball_Actions_Core takes unit a, timer t, location l returns nothing local real lx = GetLocationX( l ) local real ly = GetLocationY( l ) call SetHandleHandle( t, "cast", a ) call SetHandleHandle( t, "ball", CreateUnit( GetOwningPlayer(a), 'n000', GetUnitX(a), GetUnitY(a), GetUnitFacing(a) ) ) call SetHandleReal( t, "x", lx ) call SetHandleInt( t, "int", 0 ) call SetHandleReal( t, "y", ly ) call TimerStart( t, 0.02, true, function Trig_Throws_Dodgeball_Effect ) set l = null set a = null endfunction function Trig_Throws_Dodgeball_Actions takes nothing returns nothing local unit a = GetTriggerUnit() local integer i = GetPlayerId(GetOwningPlayer(a)) local item it = null if udg_NumberD[i] == 1 then set it = UnitRemoveItemFromSlot( a, 0 ) call RemoveItem(it) call UnitRemoveAbility( a, 'A003' ) call UnitRemoveAbility( a, 'A000' ) elseif udg_NumberD[i] == 2 then set it = UnitRemoveItemFromSlot( a, 1 ) call RemoveItem(it) call UnitRemoveAbility( a, 'A002' ) endif call Trig_Throws_Dodgeball_Actions_Core( a, CreateTimer(), GetSpellTargetLoc() ) set it = null set a = null endfunction //=========================================================================== function InitTrig_Throws_Dodgeball takes nothing returns nothing set gg_trg_Throws_Dodgeball = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_Throws_Dodgeball, EVENT_PLAYER_UNIT_SPELL_EFFECT ) call TriggerAddCondition( gg_trg_Throws_Dodgeball, Condition( function Trig_Throws_Dodgeball_Conditions ) ) call TriggerAddAction( gg_trg_Throws_Dodgeball, function Trig_Throws_Dodgeball_Actions ) endfunction |
| 03-16-2007, 12:49 AM | #2 |
I don't know about your problem, but that trigger leaks like crap. You might want to fix that. There's a ton of tutorials around on fixing memory leaks. |
| 03-16-2007, 01:40 AM | #3 | |
Quote:
Do you mean variables or something else? From a glance I don't think he leaks any variables. |
| 03-16-2007, 01:47 AM | #4 |
Eh...never mind. I guess I was hallucinating. XD |
| 03-16-2007, 03:17 AM | #5 |
Does GetSpellTargetLoc() return correctly for EVENT_PLAYER_UNIT_SPELL_EFFECT? Try it with SPELL_CAST instead and see if that works. You really should try structs. You can get rid of most of those get/set handle calls and simplify your code a lot. |
| 03-16-2007, 05:29 PM | #6 |
What ability are you using (that the unit casts)? |
| 03-16-2007, 05:48 PM | #7 | |
Quote:
Yes, it returns correctly..so that's not the issue. |
| 03-17-2007, 02:58 AM | #8 | |
Quote:
|
| 03-17-2007, 03:22 AM | #9 |
Are you using the channel that targets a point? If you look through your code you will see you never actually use the location. You get its x and y values and attach them to the timer but you never do anything with them. I don't know why the unit is being created in the middle of the map, but you do some pretty odd stuff. Why do you create a group add a single unit to that group and then call ForGroup? JASS:local group g = CreateGroup() // // call GroupAddUnit( g, d ) call ForGroup( g, function Trig_Throws_Dodgeball_Callback ) // // call DestroyGroup(g) JASS:call Trig_Throws_Dodgeball_Callback(d) |
