- Joined
- Jun 19, 2009
- Messages
- 556
So, I was reading a bunch of tutorials for JASS scripting here and also Vexorian's and am trying to get the hang of things.
In my new project I have a simple GUI spell based on Entangling Roots that hides the caster, creates 4 visible dummies around the target and damage the area, then it shows the caster again. So I decided to script this spell in JASS, as close as I could get to a JESP format, from scratch (without simply converting the trigger to JASS using WE).
This is the code i end up with:
I could not test this in WC as I don't have my gaming computer here, but I'm interested in some help identifying if this would work, could be improved and where it leaks, as I am not yet familiar with the JASS scripting good practices.
Would appreciate any feedback.
Thanks!
In my new project I have a simple GUI spell based on Entangling Roots that hides the caster, creates 4 visible dummies around the target and damage the area, then it shows the caster again. So I decided to script this spell in JASS, as close as I could get to a JESP format, from scratch (without simply converting the trigger to JASS using WE).
This is the code i end up with:
vJASS:
//==================================================================================================//
//---------------------------------------------OVERPOWER--------------------------------------------//
//==================================================================================================//
//===============================================CONF===============================================//
//OVERPOWER ID
private function OP_AbilityID takes nothing returns integer
return = 'a000'
endfunction
//PROJECTION EFFECT
private function OP_FXProjection takes nothing returns string
return = "ProjFX" //PRETEND THIS IS THE INVISIBILITY EFFECT PATH
endfunction
//HIDE UNIT EFFECT
private function OP_FXHide takes nothing returns string
return = "HideFX" //PRETEND THIS IS THE MASS TELEPORT CASTER EFFECT PATH
endfunction
//AOE EFFECT 1
private function OP_FXBlast1 takes nothing returns string
return = "BlastFX1" //PRETEND THIS IS THE THUNDER CLAP EFFECT PATH
endfunction
//AOE EFFECT 2
private function OP_FXBlast2 takes nothing returns string
return = "BlastFX2" //PRETEND THIS IS THE MANA FLARE EFFECT PATH
endfunction
//PROJECTION DUMMY UNIT ID
private function OP_ProjectionDummy takes nothing returns integer
return = 'u000'
endfunction
//AOE DAMAGE TYPE
private function OP_DamageType takes nothing returns damagetype
return = DAMAGE_TYPE_MAGIC
endfunction
//AOE WEAPON TYPE
private function OP_WeaponType takes nothing returns weapontype
return = WEAPON_TYPE_WHOKNOWS
endfunction
//AOE ATTACK TYPE
private function OP_AttackType takes nothing returns attacktype
return = ATTACK_TYPE_MAGIC
endfunction
//RADIUS OF THE AOE
private function OP_Range takes nothing returns real
return = 300.
endfunction
//DAMAGE OF THE AOE
private function OP_DamageAOE takes nothing returns real
return = 100. + 100. * GetUnitAbilityLevel(GetTriggerUnit(), OP_AbilityID())
endfunction
//===============================================COAC===============================================//
//VARIABLES
local unit op_Caster = GetTriggerUnit()
local player op_Owner = GetOwningPlayer(op_Caster)
local integer op_OwnerID = GetPlayerId(op_Caster)
local unit array op_Dummy
local unit op_Target = GetSpellTargetUnit()
local location op_PointTarget = GetUnitLoc(op_Target())
local location op_PointCaster = GetUnitLoc(op_Caster)
local integer i = 1
local real tx
local real ty
local effect array effectOP
//CONDITION
private function Trig_OP_Condition takes nothing returns boolean
call GetSpellAbilityId() == OP_AbilityID
endfunction
//ACTIONS
private function Trig_OP_Actions takes nothing returns nothing
//CREATE FX ON CASTER LOCATION, PAUSE AND HIDE THE CASTER
set effectOP[1] = AddSpecialEffectLoc(OP_FXHide(), op_PointCaster)
call DestroyEffect(effectOP[1])
call PauseUnit(op_Caster, true)
call UnitAddAbility(op_Caster, 'a001') //PRETEND THIS IS INVULNERABLE
call ShowUnit(op_Caster, false)
//CREATE FX ARROUND THE TARGET FOR THE DUMMY UNITS AND CREATE THE DUMMY UNITS
loop
exitwhen i > 4
set i = i + 1
if i == 1
set tx = GetUnitX(op_Target)
set ty = GetUnitY(op_Target) + 100
elseif i == 2
set tx = GetUnitX(op_Target) + 100
set ty = GetUnitY(op_Target)
elseif i == 3
set tx = GetUnitX(op_Target)
set ty = GetUnitY(op_Target) - 100
elseif i == 4
set tx = GetUnitX(op_Target) - 100
set ty = GetUnitY(op_Target)
endif
set effectOP[i+1] = AddSpecialEffect(OP_FXProjection(), tx, ty)
call DestroyEffect(effectOP[i+1])
set op_Dummy[i] = CreateUnit(op_OwnerID, OP_ProjectionDummy(), tx, ty, op_PointTarget)
call SetUnitAnimation(op_Dummy[i], "spell")
endloop
//CREATE THE BLAST FX ON TARGET LOCATION
set effectOP[6] = AddSpellEffectLoc(OP_FXBlast1(), op_PointTarget)
call DestroyEffect(effectOP[6])
set effectOP[7] = AddSpellEffectLoc(OP_FXBlast2(), op_PointTarget)
call DestroyEffect(effectOP[7])
//DAMAGE THE AREA AROUND THE TARGET
set tx = GetUnitX(op_Target)
set ty = GetUnitY(op_Target)
call UnitDamagePoint(op_Caster, OP_Range(), tx, ty, OP_DamageAOE, false, false, OP_AttackType(), OP_DamageType(), OP_WeaponType())
//CREATE FX FOR THE DUMMY UNITS AND REMOVE THEM
loop
exitwhen i > 4
set i = i + 1
if i == 1
set tx = GetUnitX(op_Target)
set ty = GetUnitY(op_Target) + 100
elseif i == 2
set tx = GetUnitX(op_Target) + 100
set ty = GetUnitY(op_Target)
elseif i == 3
set tx = GetUnitX(op_Target)
set ty = GetUnitY(op_Target) - 100
elseif i == 4
set tx = GetUnitX(op_Target) - 100
set ty = GetUnitY(op_Target)
endif
set effectOP[i+1] = AddSpecialEffect(OP_FXProjection(), tx, ty)
call DestroyEffect(effectOP[i+1])
call RemoveUnit(op_Dummy[i])
endloop
//CREATE FX ON CASTER LOCATION, UNPAUSE AND UNHIDE THE CASTER
set effectOP[1] = AddSpecialEffectLoc(OP_FXHide(), op_PointCaster)
call DestroyEffect(effectOP[1])
call ShowUnit(op_Caster, true)
call UnitRemoveAbility(op_Caster, 'a001') //PRETEND THIS IS INVULNERABLE
call PauseUnit(op_Caster, false)
endloop
endfunction
//===============================================INIT===============================================//
private function InitTrig_OP takes nothing returns nothing
set gg_trg_OP = CreateTrigger()
call TriggerRegisterPlayerUnitEvent(gg_trg_OP, Player(0), EVENT_UNIT_SPELL_EFFECT, Trig_OP_Condition)
call TriggerAddAction(gg_trg_OP, function Trig_OP_Actions)
endfunction
I could not test this in WC as I don't have my gaming computer here, but I'm interested in some help identifying if this would work, could be improved and where it leaks, as I am not yet familiar with the JASS scripting good practices.
Would appreciate any feedback.
Thanks!
Last edited: