| 11-16-2007, 04:28 AM | #1 | ||
Okay i have a triggered spell that basically makes a bunch of effects that damage units around him for a certain amount of time. Problem: For some reason this spell instantly kills units regardless of how much hp they have. The spell starts off by removing leaks and then doing 7 random effects. It begins the effects in a for loop and make a random int to decide which it will do. it adds any dummy casters to a group which will later be killed at the end of the spell. The first ttrigger initiates the second which will do the effects then goes back to the first to finish off the spell. Sorry if im not too descriptive but ive made the trigger into jass so i can post it here. If anyone needs anything clarified i can do it. TY in advance
|
| 11-16-2007, 01:56 PM | #2 |
JASS:call ForGroupBJ( udg_MF_Kill, function Trig_Mega_Flare_Func009A ) I couldn't find where you set the variable "udg_MF_Kill", but if that is includes all units around the caster, then all units will go through this function JASS:function Trig_Mega_Flare_Func009A takes nothing returns nothing call KillUnit( GetEnumUnit() ) endfunction I didn't wade through all of your random effects stuff, but that would possibly be the problem. Disable that function and see what happens (put "//" in front of it, and it will be read as a comment not code) As far as the rest of your code, I highly suggest you read some of our JASS tutorials, seeing as how it seems that all your code is GUI --> JASS written (which is fine for learning JASS, but there are alot of ways you can optimize your code). Read how to use local variables, which can work wonders for optimization. Here's some ways you can change your code JASS:function Trig_Mega_Flare_Conditions takes nothing returns boolean if ( not ( GetSpellAbilityId() == 'A00J' ) ) then return false endif return true endfunction change to JASS:function Trig_Mega_Flare_Conditions takes nothing returns boolean return GetSpellAbilityId() == 'A00J' endfunction I'd personally also rename all your functions to names you can recognize, instead of "Trig_Mega_Flare_cont_Func020Func005Func003A" name it "MegaFlareGroupRemoval" |
| 11-16-2007, 03:30 PM | #3 |
PLEASE, next time dont post converted GUI code, this really hurts my eyes. Ok, I've looked through your code and changed it a little bit (should run faster now, I didnt change functionality) New Code:function Trig_Mega_Flare_Func009A takes nothing returns nothing call KillUnit( GetEnumUnit() ) endfunction function Trig_Mega_Flare_Actions takes nothing returns nothing if GetSpellAbilityId() == 'A00J' then call RemoveLocation (udg_MF_Point[8]) set udg_MF_Unit = GetSpellAbilityUnit() call UnitDamageTarget(udg_MF_Unit, udg_MF_Unit, ( ( 2.00 * GetUnitAbilityLevel(udg_MF_Unit, 'A00J') ) * GetHeroInt(udg_MF_Unit, true) ), true, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_DIVINE, WEAPON_TYPE_WHOKNOWS) set udg_MF_Point[8] = GetUnitLoc(GetSpellAbilityUnit()) call EnableTrigger( gg_trg_Mega_Flare_cont ) call TriggerSleepAction( 3 + ( 3.00 * GetUnitAbilityLevel(udg_MF_Unit, 'A00J') ) ) call ForGroup( udg_MF_Kill, function Trig_Mega_Flare_Func009A ) endif endfunction //=========================================================================== function InitTrig_Mega_Flare takes nothing returns nothing local trigger gg_trg_Mega_Flare = CreateTrigger( ) local integer index = 0 loop call TriggerRegisterPlayerUnitEvent( gg_trg_Mega_Flare, Player(index), ConvertPlayerUnitEvent(274), null ) set index=index+1 exitwhen index>7 endloop call TriggerAddAction( gg_trg_Mega_Flare, function Trig_Mega_Flare_Actions ) endfunction ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// // 20 4 3a function Trig_Mega_Flare_cont_GroupRemoveUnit takes nothing returns nothing if ( (GetUnitState(GetEnumUnit(),ConvertUnitState(0) ) <= 0) or ( IsUnitAlly(GetEnumUnit(), GetOwningPlayer(udg_MF_Unit)) ) or (IsUnitType(GetEnumUnit(), UNIT_TYPE_STRUCTURE)) or (IsUnitAlly(GetEnumUnit(), GetOwningPlayer(udg_MF_Unit))) or IsUnitType(GetEnumUnit(), UNIT_TYPE_MAGIC_IMMUNE) ) then call GroupRemoveUnit( udg_MF_Group[bj_forLoopAIndex], GetEnumUnit() ) endif endfunction // 20 4 6a function Trig_Mega_Flare_cont_UnitDamageTarget takes nothing returns nothing call UnitDamageTarget(udg_MF_Unit, GetEnumUnit(), udg_MF_Damage[bj_forLoopAIndex], true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS) endfunction function Trig_Mega_Flare_cont_Actions takes nothing returns nothing local integer index=0 if OrderId2StringBJ(GetUnitCurrentOrder(udg_MF_Unit)) == "starfall" then loop call KillUnit( udg_MF_Dummy[index] ) call DestroyEffect( udg_MF_Effect[index] ) set udg_MF_Dummy[index] = null set udg_MF_Extra[index] = null set index = index + 1 exitwhen index > 7 endloop call DestroyGroup(udg_MF_Group[0] ) call DestroyGroup(udg_MF_Group[1] ) call DestroyGroup(udg_MF_Group[2] ) call DestroyGroup(udg_MF_Group[3] ) call DestroyGroup(udg_MF_Group[4] ) call DestroyGroup(udg_MF_Group[5] ) call DestroyGroup(udg_MF_Group[6] ) call DestroyGroup(udg_MF_Group[7] ) call RemoveLocation(udg_MF_Point[0]) call RemoveLocation(udg_MF_Point[1]) call RemoveLocation(udg_MF_Point[2]) call RemoveLocation(udg_MF_Point[3]) call RemoveLocation(udg_MF_Point[4]) call RemoveLocation(udg_MF_Point[5]) call RemoveLocation(udg_MF_Point[6]) call RemoveLocation(udg_MF_Point[7]) set index = 0 loop set bj_forLoopAIndex = index set udg_MF_Point[index] = Location(GetLocationX(udg_MF_Point[8]) + GetRandomReal(100.00, 700.00) * Cos(GetRandomReal(0,360) * 0.01745328), GetLocationY(udg_MF_Point[8]) + GetRandomReal(100.00, 700.00) * Sin(GetRandomReal(0,360) * 0.01745328)) set udg_MF_Chance = GetRandomInt(1, 60) if ( udg_MF_Chance < 6 ) then set udg_MF_Extra[index] = CreateUnitAtLoc( GetOwningPlayer(udg_MF_Unit), 'ewsp', udg_MF_Point[index], 270 ) call ShowUnit( udg_MF_Extra[index], false ) call SetUnitAbilityLevelSwapped( 'A00F', udg_MF_Extra[index], 4 ) call IssuePointOrderLoc( udg_MF_Extra[index], "earthquake", udg_MF_Point[index] ) call GroupAddUnit( udg_MF_Kill, udg_MF_Extra[index] ) endif if ( ( udg_MF_Chance < 14 ) and ( udg_MF_Chance >= 6 ) ) then set udg_MF_Damage[index] = ( GetHeroInt(udg_MF_Unit, true) * 1.40 ) call GroupEnumUnitsInRangeOfLoc( udg_MF_Group[index], udg_MF_Point[index], 300, null) call ForGroup( udg_MF_Group[index], function Trig_Mega_Flare_cont_GroupRemoveUnit ) set udg_MF_Effect[index] = AddSpecialEffectLoc( "Objects\\Spawnmodels\\Naga\\NagaDeath\\NagaDeath.mdl", udg_MF_Point[index] ) call ForGroup( udg_MF_Group[index], function Trig_Mega_Flare_cont_UnitDamageTarget ) endif if ( ( udg_MF_Chance < 22 ) and ( udg_MF_Chance >= 14 ) ) then set udg_MF_Damage[index] = ( GetHeroInt(udg_MF_Unit, true) + 50.00 ) call GroupEnumUnitsInRangeOfLoc(udg_MF_Group[index],udg_MF_Point[index], 300, null) call ForGroup( udg_MF_Group[index], function Trig_Mega_Flare_cont_GroupRemoveUnit ) set udg_MF_Effect[index] = AddSpecialEffectLoc( "Abilities\\Spells\\Human\\MarkOfChaos\\MarkOfChaosTarget.mdl", udg_MF_Point[index] ) call ForGroup( udg_MF_Group[index], function Trig_Mega_Flare_cont_UnitDamageTarget ) endif if ( ( udg_MF_Chance < 42 ) and ( udg_MF_Chance >= 22 ) ) then set udg_MF_Damage[index] = GetHeroInt(udg_MF_Unit, true) * 2.00 call GroupEnumUnitsInRangeOfLoc( udg_MF_Group[index], udg_MF_Point[index], 300, null) call ForGroup( udg_MF_Group[index], function Trig_Mega_Flare_cont_GroupRemoveUnit ) set udg_MF_Dummy[index] = GroupPickRandomUnit(udg_MF_Group[index]) set udg_MF_Effect[index] = AddSpecialEffectTarget( "Abilities\\Spells\\Other\\Tornado\\TornadoElementalSmall.mdl", udg_MF_Dummy[index], "overhead" ) call ForGroup( udg_MF_Group[index], function Trig_Mega_Flare_cont_UnitDamageTarget ) endif if ( ( udg_MF_Chance < 53 ) and ( udg_MF_Chance >= 42 ) ) then call GroupEnumUnitsInRangeOfLoc( udg_MF_Group[index], udg_MF_Point[index], 300, null) call ForGroup( udg_MF_Group[index], function Trig_Mega_Flare_cont_GroupRemoveUnit ) set udg_MF_Dummy[index] = GroupPickRandomUnit(udg_MF_Group[index]) set udg_MF_Extra[index] = CreateUnitAtLoc( GetOwningPlayer(udg_MF_Unit), 'ewsp', udg_MF_Point[index], 270 ) call ShowUnit( udg_MF_Extra[index], false ) call IssueTargetOrder( udg_MF_Extra[index], "frostnova", udg_MF_Dummy[index] ) call GroupAddUnit( udg_MF_Kill, udg_MF_Extra[index] ) endif if ( ( udg_MF_Chance <= 60 ) and ( udg_MF_Chance >= 53 ) ) then set udg_MF_Dummy[index] = CreateUnitAtLoc( GetOwningPlayer(udg_MF_Unit), 'ewsp', udg_MF_Point[8], 270 ) call ShowUnit( udg_MF_Dummy[index], false ) if ( GetHeroInt( udg_MF_Unit, true) <= 65 ) then call SetUnitAbilityLevel( udg_MF_Dummy[index], 'A00I', 1 ) else call SetUnitAbilityLevel( udg_MF_Dummy[index], 'A00I', 2 ) endif call IssuePointOrderLoc( udg_MF_Dummy[index], "shockwave", udg_MF_Point[index] ) call GroupAddUnit( udg_MF_Kill, udg_MF_Dummy[index] ) endif call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, 5.00, R2S(udg_MF_Damage[index]) ) set index = index + 1 exitwhen index > 7 endloop set index = 0 loop set udg_MF_Damage[index] = 0.00 call DestroyEffect( udg_MF_Effect[index] ) set index = index + 1 exitwhen index > 7 endloop endif endfunction //=========================================================================== function InitTrig_Mega_Flare_cont takes nothing returns nothing set gg_trg_Mega_Flare_cont = CreateTrigger( ) call DisableTrigger( gg_trg_Mega_Flare_cont ) call TriggerRegisterTimerEvent( gg_trg_Mega_Flare_cont, 1.00, true ) call TriggerAddAction( gg_trg_Mega_Flare_cont, function Trig_Mega_Flare_cont_Actions ) endfunction I dont know if this solves your problems, you will have to test it. Regards, Deaod |
| 11-19-2007, 10:19 PM | #4 |
Thank you guys for attempting to help me but the glich still happens and i have no idea on how to fix it but i will keep going at it untill i find a way. ______________________ Okay i finally found my error after fixing damage and stuff to 0 and making nothing do damage units still died so i knew it wasnt anything to do with that. So i looked at the starting if my main function and saw my error. call KillUnit( udg_MF_Dummy[GetForLoopIndexA()] ) I kill Dummy unit which in some cases is the actualy target of trigger damage done(this was done to use less vars). ty for the help anyways guys really appreciate it. |
