| 09-05-2004, 06:36 PM | #1 |
Hi! Since this is my first JASS spell, please don't kill me if I've done something stupidly wrong... please... NOOOOOO WAHRG Below is my script. Its a pretty basic knockback type spell, moving the target back and hurting it. I decided to make it JASS in the first place because of the superb local variables ... originally this spell had 9 (!) global variables and i decided this was not acceptable. The working parts are colored blue, and the NOT working ones red. This bitch of a loop just won't let me use my local real treehit, declared and highlighted yellow long before this fucking loop starts. QUESTION: If i do local real treehit multiple times in a trigger, does that affect the setted value of treehit ? QUESTION: Why can't i do local real treehit in that loop ?! If i do, he tells me he expects "endloop" function Trig_Storm_Attack_Conditions takes nothing returns boolean if ( not ( GetSpellAbilityId() == 'A001' ) ) then return false endif return true endfunction function Trig_Storm_Attack_Func014Func003A takes nothing returns nothing local integer treehit set treehit = ( treehit + 1 ) call KillDestructable( GetEnumDestructable() ) endfunction function Trig_Storm_Attack_Actions takes nothing returns nothing local unit caster=GetTriggerUnit() local unit target=GetSpellTargetUnit() local real stormattackdamage = ( 2.00 * I2R(GetUnitAbilityLevelSwapped('A001', caster)) ) local real damagepertree = 5 local real totaldistance = ( I2R(GetUnitAbilityLevelSwapped('A001', caster)) * 300.00 ) local location temploc = GetUnitLoc( caster ) local location temploc2 = GetUnitLoc( target ) local real stormattackangle local effect stunnedeffect set stormattackangle = AngleBetweenPoints(temploc, temploc2) call RemoveLocation(temploc) call RemoveLocation(temploc2) call AddSpecialEffectTargetUnitBJ( "overhead", target, "Abilities\\Spells\\Orc\\StasisTrap\\StasisTotemTarget.mdl" ) call PauseUnitBJ( true, target ) set stunnedeffect = GetLastCreatedEffectBJ() set bj_forLoopAIndex = 1 set bj_forLoopAIndexEnd = 40 loop exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd set temploc = GetUnitLoc( target ) call SetUnitPositionLoc( target, PolarProjectionBJ(temploc, ( totaldistance / 40.00 ), stormattackangle) ) call EnumDestructablesInCircleBJ( 150.00, temploc, function Trig_Storm_Attack_Func014Func003A ) call RemoveLocation(temploc) call UnitDamageTargetBJ( caster, target, ( stormattackdamage + ( treehit * 5.00 ) ), ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNKNOWN ) set treehit = 0.00 call TriggerSleepAction( 0.05 ) set bj_forLoopAIndex = bj_forLoopAIndex + 1 endloop call DestroyEffectBJ( stunnedeffect ) call PauseUnitBJ( false, target ) set caster=null set target=null set temploc=null set temploc2=null set stunnedeffect=null endfunction //=========================================================================== function InitTrig_Storm_Attack takes nothing returns nothing set gg_trg_Storm_Attack = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_Storm_Attack, EVENT_PLAYER_UNIT_SPELL_EFFECT ) call TriggerAddCondition( gg_trg_Storm_Attack, Condition( function Trig_Storm_Attack_Conditions ) ) call TriggerAddAction( gg_trg_Storm_Attack, function Trig_Storm_Attack_Actions ) endfunction |
| 09-05-2004, 08:48 PM | #2 |
you do know that tree hit is set to 1 then set to 0 after the loop runs once right? cause that seems to be the issue... |
| 09-05-2004, 10:34 PM | #3 |
local variables can't work on other functions... and the forloop don't ever use waits, so you can use a global and set treehit = treehit + 1 it will crash the thread because you aren't initializing treehit |
| 09-05-2004, 11:14 PM | #4 |
actually, you could just have the whole treehit part in the main function. and also why do you set it back to 0? it looks like you want some type of increasing damge thing per slide. and you can use waits!!! you just have to have a local var for the looper. so make another local var i and make it say exitwhen i > 40 |
| 09-06-2004, 04:34 PM | #5 |
The thing about the (set treehit = treehit +1) and (set treehit = 0) part is, counting the trees the unit hit in the 0.05 seconds of movement (repeated 40 times = 2 seconds) and damaging the target for that amount x 5, so it really suffers 5 damage per tree hit. If i don't set treehit = 0, it would increase and increase without end and deal much more damage than trees actually were hit. Ah well, I'm going to retrigger this anyway, using a timer. For some reason i can't speed it up or make it slower, it's always the same speed, something about 0.4 or 0.5 second waits... @ Lord Vexorian Hmmm ... if i can't use locals in multiple functions .... wtf ?! I thought theyre only limited to a trigger... Then why can't i declare it in my loop function ? And it DIDN'T ever crash me. |
| 09-06-2004, 05:18 PM | #6 |
you can declare the local in the loop function but it wont carry over to the other function or vice-versa. for what your doing you have to use a global. and also, the way its set up any destructable will damage the unit and stuff. |
| 09-06-2004, 05:37 PM | #7 |
As said above, i somehow can't do "local real treehit" in the loop, because the tells me "endloop expected" when i do. Anyway, I realized I'm going to run into this problem again and again: How do i take a local from 1 function and give it to another function?! I know this is possible!!! |
| 09-06-2004, 05:45 PM | #8 |
actually its not. and the problem is your trying to define it in the loop, all locals have to be defined at the begining |
| 09-06-2004, 06:05 PM | #9 | |
Quote:
Well at least Lord Vexorian is doing it. He uses his Handle Variable functions and some functions of his caster system to do it.... Isn't there an easier way ? Damn. Well the things i wanted to do aren't possible without taking a local from 1 function to another. Since the wait is bugged or something(well it doesn't work right for me...), I have to use a timer. To use a "Timer Expires" function, i need more than 1 trigger or I've got to use locals in multiple functions. But oh well, since that isn't possible and i have to use globals instead, why fucking use JASS in the first place ??? I think I'm frustrated. |
