- Joined
- Oct 11, 2012
- Messages
- 711
Hey all. I am new to vJass and am trying to make a spell by using Nes's DDS. The effect is to absorb a certain amount of damage and then reflect the damage to enemies.
So, I would like to know if the following scope is correct? Do I need to use "create" and "onDestroy" methods in the struct? How about an initializer for the scope? Thanks.
So, I would like to know if the following scope is correct? Do I need to use "create" and "onDestroy" methods in the struct? How about an initializer for the scope? Thanks.
JASS:
scope dddd
private function groupfilter takes nothing returns boolean
return IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetTriggerUnit())) and (GetWidgetLife(GetFilterUnit()) > 0.405)
endfunction
struct DamageDetection extends array
private static real dam=0
private static method onDamage takes nothing returns nothing
local group g=CreateGroup()
local unit u
local real x
local real y
if (archetype == Archetype.PHYSICAL) and target==gg_unit_Obla_0016 then
set x=GetUnitX(target)
set y=GetUnitY(target)
if dam<=1000 then
set dam=damage+dam
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60,"Damage received"+R2S(dam))
else
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60,"Damage exceeds 1000: "+R2S(dam))
call GroupEnumUnitsInRange(g,x,y,800.,function groupfilter)
loop
set u=FirstOfGroup(g)
exitwhen u==null
call GroupRemoveUnit(g,u)
call UnitDamageTarget(target,u,dam,true,false,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_DEMOLITION,null)
endloop
call DestroyGroup(g)
set dam=0
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60,"Damage returns 0")
endif
endif
set g=null
endmethod
implement DDS
endstruct
endscope