| 01-02-2008, 05:03 AM | #1 |
I reworked it again heavily, it worked for a short time, then i reworked it again to make the lightning jump and now it is really fucked up =( i don't know, it has some problems with target and target 2, somehow it wont work, it says ever that target and target 2 are the same unit. i dunno why :( And the damage is not applied per second. JASS:scope FireChain globals private constant integer FRCH_AbillID = 'A000' private constant string FRCH_lightningModel = "AFOD" // The model path of the lightning. private constant real FRCH_damageUnCalculated = 25.00 //The Damage without level calculate private constant integer FRCH_BurnDur = 10// Duration of the Burn. private constant string FRCH_BurnEffect = "Abilities\\Spells\\Other\\ImmolationRed\\ImmolationRedDamage" //The Model used for the continous burn of the enemies. private constant integer arcs = 3 //number of arcs after the first jump private constant integer arcsExtraJumpWithEveryLevel = 1//Number of Jumps gained per level. endglobals function Trig_Fire_Chain_Conditions takes nothing returns boolean return GetSpellAbilityId() == FRCH_AbillID endfunction function Chain takes real X1, real Y1, real X2, real Y2 returns lightning return AddLightning(FRCH_lightningModel, true, X1, Y1, X2, Y2) endfunction function KeepOrNoKeep takes unit target, player Cowner, group Grp returns boolean return ( IsUnitType(target, UNIT_TYPE_STRUCTURE) == false ) and ( IsUnitType(target, UNIT_TYPE_MAGIC_IMMUNE) == false ) and ( IsUnitAliveBJ(target) == true ) and ( IsUnitEnemy(target, Cowner) == true ) and target != null and ( IsUnitInGroup(target, Grp) == false ) endfunction //function KeepOrNoKeep takes player Cowner returns boolean //return ( IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == false ) and ( IsUnitType(GetFilterUnit(), UNIT_TYPE_MAGIC_IMMUNE) == false ) and ( IsUnitAliveBJ(GetFilterUnit()) == true ) and ( IsUnitEnemy(GetFilterUnit(), Cowner) == true ) and GetFilterUnit() != null //endfunction function GetClosestUnit takes real x, real y, boolexpr e returns unit local real md = 100000 local real d local group g = CreateGroup() local unit u local real dx local real dy local unit a call GroupEnumUnitsInRect(g, bj_mapInitialPlayableArea, e) loop set u = FirstOfGroup(g) exitwhen u == null call GroupRemoveUnit(g, u) set dx = GetUnitX(u) - x set dy = GetUnitY(u) - y if (dx * dx + dy * dy) / 100000 < md then set a = u set md = (dx * dx + dy * dy) / 100000 endif endloop call DestroyGroup(g) call DestroyBoolExpr(e) set g = null return a endfunction function DamageUnitFire takes nothing returns nothing local timer T = GetExpiredTimer() local unit caster = GetHandleUnit(T, "caster") local unit target local player Cowner = GetHandlePlayer(T, "player") local group PickGroup = CreateGroup() local group PickGroup2 = CreateGroup() local integer PickCount = 0 set PickGroup = GetHandleGroup(T, "group") loop exitwhen PickCount == CountUnitsInGroup(PickGroup) set target = FirstOfGroup(PickGroup) call GroupRemoveUnit(PickGroup, target) call GroupAddUnit(PickGroup2, target) call UnitDamageTarget (caster, target, FRCH_damageUnCalculated*GetUnitAbilityLevel(caster, FRCH_AbillID), false, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS) set target = null endloop call SetHandleHandle(T, "group", PickGroup2) set caster = null endfunction function Trig_Fire_Chain_Actions takes nothing returns nothing local timer T = CreateTimer() local real X1 local real Y1 local real X2 local real Y2 local unit target2 = GetSpellTargetUnit() local unit caster = GetSpellAbilityUnit() local unit target = caster local player Cowner = GetOwningPlayer(caster) local lightning array lightning1 local effect array FireBurn local integer TimesArced = 0 local group PickGroup = CreateGroup() local group AlrdyGroup = CreateGroup() set X1 = GetUnitX(target) set Y1 = GetUnitY(target) set X2 = GetUnitX(target2) set Y2 = GetUnitY(target2) set FireBurn[0] = AddSpecialEffectTarget(FRCH_BurnEffect, target2, "head") call GroupAddUnit(PickGroup, target2) call GroupAddUnit(AlrdyGroup, target2) set lightning1[0] = Chain(X1, Y1, X2, Y2) set target = target2 set target2 = null loop set target2 = GetClosestUnit(X2, Y2, Condition(null)) if target2 == null then set TimesArced = arcs + arcsExtraJumpWithEveryLevel*GetUnitAbilityLevel(caster, FRCH_AbillID) endif exitwhen TimesArced == arcs + arcsExtraJumpWithEveryLevel*GetUnitAbilityLevel(caster, FRCH_AbillID) if KeepOrNoKeep(target2, Cowner, AlrdyGroup) == true then set TimesArced = TimesArced + 1 set FireBurn[TimesArced] = AddSpecialEffectTarget(FRCH_BurnEffect, target2, "head") call GroupAddUnit(PickGroup, target2) set X1 = GetUnitX(target) set Y1 = GetUnitY(target) set X2 = GetUnitX(target2) set Y2 = GetUnitY(target2) set lightning1[TimesArced] = Chain(X1, Y1, X2, Y2) set target = target2 endif call GroupAddUnit(AlrdyGroup, target2) set target2 = null endloop call GroupClear(AlrdyGroup) set TimesArced = 0 call SetHandleHandle(T, "caster", caster) call SetHandleHandle(T, "player", Cowner) call SetHandleHandle(T, "group", PickGroup) call TimerStart(T, 1.00, true, function DamageUnitFire ) call PolledWait(1.00) loop exitwhen TimesArced == arcs + arcsExtraJumpWithEveryLevel*GetUnitAbilityLevel(caster, FRCH_AbillID) call DestroyLightning(lightning1[TimesArced]) set TimesArced = TimesArced + 1 endloop set TimesArced = 0 call PolledWait(I2R(FRCH_BurnDur) - 1.00) call PauseTimer(T) call FlushHandleLocals(T) call DestroyTimer(T) loop exitwhen TimesArced == arcs + arcsExtraJumpWithEveryLevel*GetUnitAbilityLevel(caster, FRCH_AbillID) call DestroyEffect(FireBurn[TimesArced]) set TimesArced = TimesArced + 1 endloop set target2 = null set target = null set Cowner = null endfunction //=========================================================================== function InitTrig_FireChain takes nothing returns nothing local integer i = 0 set gg_trg_FireChain = CreateTrigger( ) call Preload("Abilities\\Spells\\Other\\ImmolationRed\\ImmolationRedDamage") loop exitwhen i>15 call TriggerRegisterPlayerUnitEvent( gg_trg_FireChain, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, null ) set i = i+1 endloop call TriggerAddCondition( gg_trg_FireChain, Condition( function Trig_Fire_Chain_Conditions ) ) call TriggerAddAction( gg_trg_FireChain, function Trig_Fire_Chain_Actions ) endfunction endscope |
| 01-02-2008, 05:05 AM | #2 |
The waitsssss man! Use timers instead! |
| 01-02-2008, 05:11 AM | #3 |
then i should use 2 timers instead of a simple wait, would this not be a bit inefficient? The only time i use waits is to wait on completing the fire burn to remove the effects and the second when i delete the lightning. I am completely confused. |
| 01-02-2008, 06:33 PM | #4 |
bump (sry for this) |
| 01-02-2008, 07:53 PM | #5 |
You can save some lines by changing the order of some variables: JASS://Instead of this: local real X1 local real Y1 local real X2 local real Y2 local unit target2 = GetSpellTargetUnit() local unit caster = GetSpellAbilityUnit() local unit target = caster //... set X1 = GetUnitX(target) set Y1 = GetUnitY(target) set X2 = GetUnitX(target2) set Y2 = GetUnitY(target2) //You should do this: local unit target2 = GetSpellTargetUnit() local unit caster = GetSpellAbilityUnit() local unit target = caster local real X1 = GetUnitX(target) local real Y1 = GetUnitY(target) local real X2 = GetUnitX(target2) local real Y2 = GetUnitY(target2) This might be a problem: set target2 = GetClosestUnit(X2, Y2, Condition(null)) You should do this instead: JASS:private function True takes nothing returns boolean return true endfunction //... set target2 = GetClosestUnit(X2, Y2, Condition(function true)) JASS:function GetClosestUnit takes real x, real y, real distance, player Cowner, group Grp returns unit local real md = distance*distance local real mod = md local real d local group g = CreateGroup() local unit u local real dx local real dy local unit a call GroupEnumUnitsInRect(g, bj_mapInitialPlayableArea, Condition(function True)) //The True function I showed earlier loop set u = FirstOfGroup(g) exitwhen u == null call GroupRemoveUnit(g, u) if KeepOrNoKeep(u, Cowner, Grp) then set dx = GetUnitX(u) - x set dy = GetUnitY(u) - y if (dx * dx + dy * dy) / mod < md then set a = u set md = (dx * dx + dy * dy) / mod endif endif endloop call DestroyGroup(g) call DestroyBoolExpr(e) set g = null return a endfunction //... loop set target2 = GetClosestUnit(X2, Y2, 100, Cowner, AlrdyGroup) //Removed the extra check exitwhen (TimesArced == arcs + arcsExtraJumpWithEveryLevel*GetUnitAbilityLevel(caster, FRCH_AbillID)) or (target2 == null) set TimesArced = TimesArced + 1 set FireBurn[TimesArced] = AddSpecialEffectTarget(FRCH_BurnEffect, target2, "head") call GroupAddUnit(PickGroup, target2) set X1 = GetUnitX(target) set Y1 = GetUnitY(target) set X2 = GetUnitX(target2) set Y2 = GetUnitY(target2) set lightning1[TimesArced] = Chain(X1, Y1, X2, Y2) set target = target2 call GroupAddUnit(AlrdyGroup, target2) set target2 = null endloop Aside from that, I don't see an issue with the waits as they are just for visuals. |
| 01-02-2008, 09:17 PM | #6 |
Nvm, I mislooked, thanks alot, i will write you in the credits for big help! :) Just a bug, when i change the 100 of the GetClosestUnit (which is 100*100 = 10000 range which is considered for the closest unit) to 20 it bugs and somehow stucks, the lightnings do not get deleted etc, check it out by your self, i will add the map. Thats the code: JASS:scope FireChain globals private constant integer FRCH_AbillID = 'A000' private constant string FRCH_lightningModel = "AFOD" // The model path of the lightning. private constant real FRCH_damageUnCalculated = 25.00 //The Damage without level calculate private constant integer FRCH_BurnDur = 10// Duration of the Burn. private constant string FRCH_BurnEffect = "Abilities\\Spells\\Other\\ImmolationRed\\ImmolationRedDamage" //The Model used for the continous burn of the enemies. private constant integer arcs = 3 //number of arcs after the first jump private constant integer arcsExtraJumpWithEveryLevel = 1//Number of Jumps gained per level. endglobals function Trig_Fire_Chain_Conditions takes nothing returns boolean return GetSpellAbilityId() == FRCH_AbillID endfunction function Chain takes real X1, real Y1, real X2, real Y2 returns lightning return AddLightning(FRCH_lightningModel, true, X1, Y1, X2, Y2) endfunction private function True takes nothing returns boolean return true endfunction function KeepOrNoKeep takes unit target, player Cowner, group Grp returns boolean return ( IsUnitType(target, UNIT_TYPE_STRUCTURE) == false ) and ( IsUnitType(target, UNIT_TYPE_MAGIC_IMMUNE) == false ) and ( IsUnitAliveBJ(target) == true ) and ( IsUnitEnemy(target, Cowner) == true ) and target != null and ( IsUnitInGroup(target, Grp) == false ) endfunction function GetClosestUnit takes real x, real y, real distance, player Cowner, group Grp returns unit local real md = distance*distance local real mod = md local real d local group g = CreateGroup() local unit u local real dx local real dy local unit a call GroupEnumUnitsInRect(g, bj_mapInitialPlayableArea, Condition(function True)) //The True function I showed earlier loop set u = FirstOfGroup(g) exitwhen u == null call GroupRemoveUnit(g, u) if KeepOrNoKeep(u, Cowner, Grp) then set dx = GetUnitX(u) - x set dy = GetUnitY(u) - y if (dx * dx + dy * dy) / mod < md then set a = u set md = (dx * dx + dy * dy) / mod endif endif endloop call DestroyGroup(g) set g = null return a endfunction function DamageUnitFire takes nothing returns nothing local timer T = GetExpiredTimer() local unit caster = GetHandleUnit(T, "caster") local unit target local player Cowner = GetHandlePlayer(T, "player") local group PickGroup = CreateGroup() local group PickGroup2 = CreateGroup() set PickGroup = GetHandleGroup(T, "group") loop set target = FirstOfGroup(PickGroup) exitwhen target == null call DestroyEffect(AddSpecialEffectTarget(FRCH_BurnEffect, target, "head")) call GroupRemoveUnit(PickGroup, target) call GroupAddUnit(PickGroup2, target) call UnitDamageTarget (caster, target, FRCH_damageUnCalculated*GetUnitAbilityLevel(caster, FRCH_AbillID), false, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS) set target = null endloop call SetHandleHandle(T, "group", PickGroup2) set caster = null endfunction function Trig_Fire_Chain_Actions takes nothing returns nothing local timer T = CreateTimer() local unit target2 = GetSpellTargetUnit() local unit caster = GetSpellAbilityUnit() local unit target = caster local real X1 = GetUnitX(target) local real Y1 = GetUnitY(target) local real X2 = GetUnitX(target2) local real Y2 = GetUnitY(target2) local player Cowner = GetOwningPlayer(caster) local lightning array lightning1 local integer TimesArced = 0 local group PickGroup = CreateGroup() local group AlrdyGroup = CreateGroup() call GroupAddUnit(PickGroup, target2) call GroupAddUnit(AlrdyGroup, target2) set lightning1[0] = Chain(X1, Y1, X2, Y2) set target = target2 set target2 = null loop set target2 = GetClosestUnit(X2, Y2, 20, Cowner, AlrdyGroup) call DisplayTextToForce( GetPlayersAll(), "0" ) exitwhen TimesArced == arcs + (arcsExtraJumpWithEveryLevel*GetUnitAbilityLevel(caster, FRCH_AbillID)) or target2 == null call GroupAddUnit(AlrdyGroup, target2) set TimesArced = TimesArced + 1 call GroupAddUnit(PickGroup, target2) set X1 = GetUnitX(target) set Y1 = GetUnitY(target) set X2 = GetUnitX(target2) set Y2 = GetUnitY(target2) set lightning1[TimesArced] = Chain(X1, Y1, X2, Y2) set target = target2 set target2 = null endloop call DisplayTextToForce( GetPlayersAll(), "1" ) call GroupClear(AlrdyGroup) set TimesArced = 0 call SetHandleHandle(T, "caster", caster) call SetHandleHandle(T, "player", Cowner) call SetHandleHandle(T, "group", PickGroup) call TimerStart(T, 1.00, true, function DamageUnitFire ) call PolledWait(1.00) call DisplayTextToForce( GetPlayersAll(), "2" ) loop exitwhen TimesArced == arcs + (arcsExtraJumpWithEveryLevel*GetUnitAbilityLevel(caster, FRCH_AbillID) + 1) call DisplayTextToForce( GetPlayersAll(), "3" ) call DestroyLightning(lightning1[TimesArced]) set TimesArced = TimesArced + 1 endloop set TimesArced = 0 call PolledWait(I2R(FRCH_BurnDur) - 1.00) call PauseTimer(T) call FlushHandleLocals(T) call DestroyTimer(T) set target2 = null set target = null set Cowner = null endfunction //=========================================================================== function InitTrig_FireChain takes nothing returns nothing local integer i = 0 set gg_trg_FireChain = CreateTrigger( ) call Preload("Abilities\\Spells\\Other\\ImmolationRed\\ImmolationRedDamage") loop exitwhen i>15 call TriggerRegisterPlayerUnitEvent( gg_trg_FireChain, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, null ) set i = i+1 endloop call TriggerAddCondition( gg_trg_FireChain, Condition( function Trig_Fire_Chain_Conditions ) ) call TriggerAddAction( gg_trg_FireChain, function Trig_Fire_Chain_Actions ) endfunction endscope But you were a great help, when i could i would + rep you! Thanks alot. |
| 01-03-2008, 09:42 AM | #7 |
I know why; the thread's crashing. To fix this, simply change this line in GetClosestUnit: local unit a = null
This will also enable you to remove these lines highlighted in red: JASS:set lightning1[0] = Chain(X1, Y1, X2, Y2) set target = target2 set target2 = null loop set target2 = GetClosestUnit(X2, Y2, 20, Cowner, AlrdyGroup) call DisplayTextToForce( GetPlayersAll(), "0" ) exitwhen TimesArced == arcs + (arcsExtraJumpWithEveryLevel*GetUnitAbilityLevel(caster, FRCH_AbillID)) or target2 == null call GroupAddUnit(AlrdyGroup, target2) set TimesArced = TimesArced + 1 call GroupAddUnit(PickGroup, target2) set X1 = GetUnitX(target) set Y1 = GetUnitY(target) set X2 = GetUnitX(target2) set Y2 = GetUnitY(target2) set lightning1[TimesArced] = Chain(X1, Y1, X2, Y2) set target = target2 set target2 = null endloop |
| 01-03-2008, 10:36 AM | #8 |
Thanks alot, 100% working, my first a bit more complicated jass spell done, hurray ^.^. redscores (with help of many others, so much thanks,) presents: Fire Chain. |
