Siefer
New Member
- Reaction score
- 8
Not sure if any of you guys remember me, but I used to hang around here a lot. I pretty much only used GUI though except for the occasional leak correction. But I've decided to switch to full-on JASS now. So I've been going through all the tutorials and everything trying to get the hang of it.
Here's my first JASS spell. It seems to be working correctly and everything, but I was hoping that you guys who are more experienced with it could help me out anyways.
Just because code is functional, doesn't mean it is the most efficient or leak-proof way of doing it.
Also (the main reason i'm switching to JASS) I was hoping you could tell me whether this is multi-unit instanceable, and if not, how I could make it so (I think it is...)
Finally, there is one thing that's been especially annoying me. I used the Rescue sound when this code was in GUI, but the Syntax Checker doesn't seem to like it. I'm guessing because it's a global sound variable, but I'm not exactly positive how to make and use sounds as local variables.
So please: Tell me how it is, how to make it better, etc. I mostly looking for help with JASS and coding, but if you have any comments about the spell itself, that's cool too. It's all appreciated.
I made this from 60-70% of converting GUI into custom text and working my through it that way, and the other 40-30% has been looking at basic tutorials, JASS manual, and the NewGen function list.
Storm!:
The unit brings the battle to the inside of the selected enemy or nuetral building, raiding its supplies and slaughtering its denizens as it goes. As it begins to take it over from the inside, the building will lose health. If the building lowers to a certain amount, then the unit will exit the building with some damage taken and the building will be yours. If the building is destroyed through some other means that is not this ability, then the unit will exit and you will not gain control of the building (considering making it so the unit dies, as the building collapses on it while it is inside).
Sorry for all the reading; thanks for the help in advance!
tl;dr : Help me make the code/spell better.
PS. The NewGenWorldEditor has been nice and all (a definite improvement), but I was wondering if people can educate me, or direct me to the place where I can be educated on, some features I'm confused on (the advantages of free global declarations, libraries and structs)
EDIT: Btw, the spell itself, if anyone wants to try it out, is just some modified damaging channeling spell. I used Drain Life.
Here's my first JASS spell. It seems to be working correctly and everything, but I was hoping that you guys who are more experienced with it could help me out anyways.
Just because code is functional, doesn't mean it is the most efficient or leak-proof way of doing it.
Also (the main reason i'm switching to JASS) I was hoping you could tell me whether this is multi-unit instanceable, and if not, how I could make it so (I think it is...)
Finally, there is one thing that's been especially annoying me. I used the Rescue sound when this code was in GUI, but the Syntax Checker doesn't seem to like it. I'm guessing because it's a global sound variable, but I'm not exactly positive how to make and use sounds as local variables.
So please: Tell me how it is, how to make it better, etc. I mostly looking for help with JASS and coding, but if you have any comments about the spell itself, that's cool too. It's all appreciated.
JASS:
function Trig_Storm_Conditions takes nothing returns boolean
if ( not ( GetSpellAbilityId() == 039;A005039; ) ) then
return false
endif
return true
endfunction
function Trig_Storm_Func005001001 takes unit storm_target returns boolean
return ( GetUnitStateSwap(UNIT_STATE_LIFE, storm_target) <= 8.00 )
endfunction
function Trig_Storm_Func005001002 takes unit storm_target returns boolean
return ( GetUnitStateSwap(UNIT_STATE_LIFE, storm_target) >= 1.00 )
endfunction
function Trig_Storm_Func005001 takes unit storm_target returns boolean
return GetBooleanAnd( Trig_Storm_Func005001001(storm_target), Trig_Storm_Func005001002(storm_target) )
endfunction
function alreadyOwnTarget takes unit storm_target, unit storm_caster returns boolean
return IsUnitInGroup(storm_target, GetUnitsOfPlayerAll(GetOwningPlayer(storm_caster)))
endfunction
function Trig_Storm_Actions takes nothing returns nothing
local unit storm_caster = GetSpellAbilityUnit()
local unit storm_target = GetSpellTargetUnit()
call ShowUnitHide( storm_caster )
call SetUnitInvulnerable( storm_caster, true )
loop
exitwhen ( GetBooleanOr( GetBooleanOr( Trig_Storm_Func005001(storm_target), (IsUnitDeadBJ(storm_target)) ), alreadyOwnTarget(storm_target, storm_caster) ))
call TriggerSleepAction(RMaxBJ(bj_WAIT_FOR_COND_MIN_INTERVAL, 0.50))
endloop
call SetUnitOwner( storm_target, GetOwningPlayer(storm_caster), true )
call ShowUnitShow( storm_caster )
call SetUnitInvulnerable( storm_caster, false )
call SetUnitLifePercentBJ( storm_target, 5.00 )
call PlaySoundBJ( gg_snd_Rescue )
call SetUnitLifeBJ( storm_caster, ( GetUnitStateSwap(UNIT_STATE_MAX_LIFE, storm_caster) - ( 0.05 * GetUnitStateSwap(UNIT_STATE_MAX_LIFE, storm_target) ) ) )
set storm_caster = null
set storm_target = null
endfunction
//===========================================================================
function InitTrig_Storm_Building takes nothing returns nothing
local trigger Storm_Building
set Storm_Building = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( Storm_Building, EVENT_PLAYER_UNIT_SPELL_CHANNEL )
call TriggerAddCondition( Storm_Building, Condition( function Trig_Storm_Conditions ) )
call TriggerAddAction( Storm_Building, function Trig_Storm_Actions )
endfunction
I made this from 60-70% of converting GUI into custom text and working my through it that way, and the other 40-30% has been looking at basic tutorials, JASS manual, and the NewGen function list.
Storm!:
The unit brings the battle to the inside of the selected enemy or nuetral building, raiding its supplies and slaughtering its denizens as it goes. As it begins to take it over from the inside, the building will lose health. If the building lowers to a certain amount, then the unit will exit the building with some damage taken and the building will be yours. If the building is destroyed through some other means that is not this ability, then the unit will exit and you will not gain control of the building (considering making it so the unit dies, as the building collapses on it while it is inside).
Sorry for all the reading; thanks for the help in advance!
tl;dr : Help me make the code/spell better.
PS. The NewGenWorldEditor has been nice and all (a definite improvement), but I was wondering if people can educate me, or direct me to the place where I can be educated on, some features I'm confused on (the advantages of free global declarations, libraries and structs)
EDIT: Btw, the spell itself, if anyone wants to try it out, is just some modified damaging channeling spell. I used Drain Life.