| 08-17-2007, 05:32 AM | #1 |
JASS:function Trig_Ranged_Attack_Filter takes nothing returns boolean return IsPlayerEnemy(GetOwningPlayer(GetTriggerUnit()), GetOwningPlayer(GetFilterUnit())) and GetWidgetLife(GetFilterUnit()) > 0.405 endfunction function Trig_Ranged_Attack_Condition2 takes nothing returns boolean return GetSpellAbilityId() == 'A002' endfunction function Trig_Ranged_Attack_Loop takes nothing returns nothing local timer t = GetExpiredTimer() local integer i = GetHandleInt(t, "i") local unit a = GetHandleUnit(t, "a") local unit r = GetHandleUnit(t, "r") local boolexpr d = Condition(function Trig_Ranged_Attack_Filter) local unit f local group g = CreateGroup() call GetUnitsInRangeOfLocMatching(100, GetUnitLoc(r), d) set g = GetLastCreatedGroup() if CountUnitsInGroup(g) >= 1 then loop set f = FirstOfGroup(g) exitwhen f == null call UnitDamageTargetBJ(a, f, (100+(I2R(GetHeroStatBJ(bj_HEROSTAT_STR, a, true)))*2.50), ATTACK_TYPE_PIERCE, DAMAGE_TYPE_NORMAL) call AddSpecialEffectTargetUnitBJ("head", GetEnumUnit(), "Objects\\Spawnmodels\\Critters\\Albatrosse\\CritterBloodAlbatross.mdl") call GroupRemoveUnit(g, f) endloop set f = null set g = null set d = null else call SetUnitPositionLoc(r, PolarProjectionBJ(GetUnitLoc(r), 15.00, GetUnitFacing(r))) endif call SetHandleInt(t, "i", i+1) if i >= 40 then call FlushHandleLocals(t) call DestroyTimer(t) set t = null endif endfunction function Trig_Ranged_Attack_Actions takes nothing returns nothing local timer t local location p = PolarProjectionBJ(GetUnitLoc(GetSpellAbilityUnit()), 600.00, GetUnitFacing(GetSpellAbilityUnit())) local real i = 1.00 if GetSpellAbilityId() == 'A002' then set t = CreateTimer() call CreateNUnitsAtLocFacingLocBJ( 1, 'e000', GetOwningPlayer(GetSpellAbilityUnit()), GetUnitLoc(GetSpellAbilityUnit()), p ) call SetHandleHandle(t, "r", GetLastCreatedUnit()) call SetHandleHandle(t, "a", GetSpellAbilityUnit()) call SetHandleInt(t, "i", R2I(i)) call TimerStart(t, i, true, function Trig_Ranged_Attack_Loop) endif endfunction //=========================================================================== function InitTrig_Ranged_Attack takes nothing returns nothing set gg_trg_Ranged_Attack = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_Ranged_Attack, EVENT_PLAYER_UNIT_SPELL_CAST ) call TriggerAddCondition( gg_trg_Ranged_Attack, Condition(function Trig_Ranged_Attack_Condition2)) call TriggerAddAction( gg_trg_Ranged_Attack, function Trig_Ranged_Attack_Actions ) endfunction Well... there it is. What its supposed to do is when its cast it makes a dummy projectile and shoots it 600 range in from of the caster, and if it comes close to an enemy unit it deals damage to it and then dissapears without going further... Unfortunately, it makes a dummy and then it doesn't move, and I don't know that if it did move it would do damage. Also, with my poor coding skills I don't know whats wrong. This is the second or third time I've recoded it from scratch, so I think I keep making the same mistake because they all come out the same with the same problems. ![]() |
| 08-17-2007, 09:16 AM | #2 |
How about you forget about this trigger and simply modify the model on shockwave spell? |
| 08-17-2007, 09:25 AM | #3 |
I only took a quick look a found several things, like the following ones JASS:function Trig_Ranged_Attack_Filter takes nothing returns boolean return IsPlayerEnemy(GetOwningPlayer(GetTriggerUnit()), GetOwningPlayer(GetFilterUnit())) and GetWidgetLife(GetFilterUnit()) > 0.405 endfunction also you need to change this part JASS:call AddSpecialEffectTargetUnitBJ("head", GetEnumUnit(), "Objects\\Spawnmodels\\Critters\\Albatrosse\\CritterBloodAlbatross.mdl") Then change this part: JASS:else call SetUnitPositionLoc(r, PolarProjectionBJ(GetUnitLoc(r), 15.00, GetUnitFacing(r))) endif JASS:endif call SetUnitPositionLoc(r, PolarProjectionBJ(GetUnitLoc(r), 15.00, GetUnitFacing(r))) Also you spell contains several leaks and have some senseless parts. |
| 08-17-2007, 11:57 PM | #4 |
Okay thanks. |
| 08-19-2007, 01:09 PM | #5 |
Carrion swarm with a modified damage cap using a missile with a death animation should do exactly what you want, no triggering involved. |
| 08-29-2007, 01:37 AM | #6 |
But then I can't also use this to make spells based on the idea... or can I? Is there a way to make that work? EDIT: Also, sorry I was gone on vacation (last trip of summer T_T) for a week. Also how do I filter it in a loop >_> I tried JASS:call GetUnitsInRangeOfLocMatching(100, GetUnitLoc(r), IsPlayerEnemy(GetOwningPlayer(GetTriggerUnit()), GetOwningPlayer(GetFilterUnit())) and GetWidgetLife(GetFilterUnit()) > 4.05) and it says "Cannot convert boolean to boolexpr." Sorry, I'm, again, really new to this... |
| 08-29-2007, 05:49 AM | #7 |
A boolexpr actually uses a function that returns a boolean based on whether or not certain expressions are true. For what you want to do, you'd do this: JASS:function FilterFunction takes nothing returns boolean return IsPlayerEnemy(GetOwningPlayer(GetTriggerUnit()), GetOwningPlayer(GetFilterUnit())) and GetWidgetLife(GetFilterUnit()) > 4.05 endfunction //In your other function call GetUnitsInRangeOfLocMatching(100, GetUnitLoc(r), Condition(function FilterFunction)) |
| 08-29-2007, 06:10 AM | #8 |
Isn't that different than filtering the units in the loop itself though? |
| 08-30-2007, 05:56 AM | #9 |
Yes, because the units that don't make the filter return true won't be added to the group. If you wanted to get every unit and then sort through them manually, you'd do this: JASS:function FilterFunc takes nothing returns boolean return true //"null" boolexprs leak, apparently endfunction //In your script: set G = GetUnitsInRangeOfLocMatching(100, GetUnitLoc(r), Condition(function FilterFunction)) loop set U = FirstOfGroup(G) exitwhen U == null if (<Your Filter Here>) then call DoSomething() endif call GroupRemoveUnit(G, U) endloop |
