function interface OnImpact takes Object id, unit Impact returns nothing
struct Object
private static method UnitGroup takes nothing returns nothing
call DamageFilter(dummy_id, GetEnumUnit())
if dummy_id.DestroyOnImpact then
call Release(dummy_id) // ignore all that, its statics stuff, just read the 2 lines below.
else
call dummy_id.On_Impact.execute(dummy_id, GetEnumUnit())
endif
endmethod
endstruct
interface objects
method something returns nothing
endinterface
struct object extends objects
call object.something()
endstruct
static method setEffect takes Object id, string eff returns nothing
if id.Effect != null then
call DestroyEffect(id.Effect)
endif
if eff != "" then
set id.Effect = AddSpecialEffectTarget(eff, id.Object, "origin")
endif
call BJDebugMsg("|c00FF0000[DEBUG] Initialized a new effect|r")
endmethod
private static constant string Missle_Creation_Model_Path = "Abilities\\Spells\\Undead\\DeathCoil\\DeathCoilMissile.mdl" // the model automaticly created to the object on creation.
call Object.setEffect(id, Missle_Creation_Model_Path)
JASS:static method setEffect takes Object id, string eff returns nothing if id.Effect != null then call DestroyEffect(id.Effect) endif if eff != "" then set id.Effect = AddSpecialEffectTarget(eff, id.Object, "origin") endif call BJDebugMsg("|c00FF0000[DEBUG] Initialized a new effect|r") endmethod
and this is how i call it
JASS:call Object.setEffect(id, Missle_Creation_Model_Path)
method setEffect takes string eff returns nothing
if this.Effect != null then
call DestroyEffect(this.Effect)
endif
if eff != "" then
set this.Effect = AddSpecialEffectTarget(eff, this.Object, "origin")
endif
call BJDebugMsg("|c00FF0000[DEBUG] Initialized a new effect|r")
endmethod
call id.setEffect(Missle_Creation_Model_Path)
private static constant string Missle_Creation_Model_Path
donno.. i dont think it matters much o.o
and its not like i get it as Object.XXXX
i get it regular (Missle_Creation_Model_Path)
and so on.. so i dont find it as it matters much..
private static method FindMaxDistance takes real Distance, real Duration returns real
// this function caculates max distance using distance and duration.
// this is by diehard@azeroth from hiveworkshop.
return (Distance/0.032) * Duration
endmethod
private static method JumpParabola takes real dist, real maxdist,real curve returns real
// This function calculates the unit Z for a parabolic arc, by Shadow1500
// brought to me by diehard@azeroth from hiveworkshop.com
local real t = (dist*2)/maxdist-1
return (-t*t+1)*(maxdist/curve)
endmethod
private static method CaculateArc takes Object id returns nothing
local real dx = 0
local real dy = 0
local real dx2 = 0
local real dy2 = 0
local real x = 0
local real d = 0
local real md = 0
local real pa = 0
if id.RunOnDuration then
set md = FindMaxDistance(id.Speed, id.Duration)
else
set md = id.MaxDist
endif
set dx = id.startX - id.x
set dy = id.startY - id.y
set x = SquareRoot(dx * dx - dy * dy)
set dx2 = (id.startX + md * Cos (id.angle)) - id.startX
set dy2 = (id.startY + md * Sin (id.angle)) - id.startY
set d = SquareRoot(dx2 * dx2 - dy2 * dy2)
set pa = JumpParabola(x, d, id.curve)
call SetUnitFlyHeight(id.Object, pa, 0)
endmethod
function ParabolaZ takes real h, real d, real x returns real
return (4 * h / d) * (d - x) * (x / d)
endfunction
library Grenade initializer OnInit requires ObjectSystem
private function OnImpactFunction takes Object id, unit target returns nothing
local Object new = 0
local real angle = 0
local integer c = 0
local real c2 = 0
local real minaoe = 235
local real maxaoe = 275
loop
set c = c + 1
set c2 = c2 + 60
set angle = GetRandomReal(c2 - 59, c2)
set new = Object.create(GetOwningPlayer(id.Object), id.x, id.y, angle)
call new.maxdistance(GetRandomReal(minaoe, maxaoe))
call new.setEffect("Abilities\\Weapons\\FireBallMissile\\FireBallMissile.mdl")
call new.damage(85, 0)
call new.arc(true)
call new.arcCurve(0.539)
call new.distance(7)
call new.heightDiffrence(25)
exitwhen c == 6
endloop
endfunction
private function OnCast takes nothing returns nothing
local unit u = udg_u
local Object dat = Object.create(GetOwningPlayer(u), GetUnitX(u), GetUnitY(u), GetUnitFacing(u))
call dat.arc(true)
call dat.arcCurve(1.8)
call dat.heightDiffrence(25)
call dat.TriggerAddImpactAction(OnImpact.OnImpactFunction)
set u = null
endfunction
private function OnCond takes nothing returns boolean
return GetSpellAbilityId() == 'A002'
endfunction
private function OnInit takes nothing returns nothing
local trigger DM = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(DM, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(DM, Condition(function OnCond))
call TriggerAddAction(DM, function OnCast)
set DM = null
endfunction
endlibrary
return IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(dummy_id.Object)) and GetWidgetLife(GetFilterUnit()) > 0.405 /*
*/ and GetUnitFlyHeight(GetFilterUnit()) - dummy_id.Height >= dummy_id.HeightDiffrence /*
*/ and dummy_id.Height - GetUnitFlyHeight(GetFilterUnit()) <= dummy_id.HeightDiffrence
return IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(dummy_id.Object)) and GetWidgetLife(GetFilterUnit()) > 0.405 /*
*/ and GetUnitFlyHeight(GetFilterUnit()) - dummy_id.Height >= dummy_id.HeightDiffrence /*
*/ and dummy_id.Height - GetUnitFlyHeight(GetFilterUnit()) <= dummy_id.HeightDiffrence
300 - 100 = 200 > >= 25
obj tar diff hd
100 - 300 = -200 > <= 25
tar obj diff hd
ohh.. thanks xD my bad..
and wait.. 25 > diff > -25?
lets say caster height is 15, and unit height is 10
diffrence = 15 - 10 = 5
height diffrence > diffrence > - height diffrence?
so basicly:
25 > 5 > -25
25 is bigger then 5, and 5 is bigger then -25.
oh, that should work..
example if diffrence is 200
25 < 200 > -25,
so 1 check fails, that means it returns false, nice, thanks alot =]
i would've +rep you, but i allready did![]()
private static method DamageBoolexpr takes nothing returns boolean
local real diffrence = dummy_id.Height - GetUnitFlyHeight(GetFilterUnit())
local boolean result = dummy_id.HeightDiffrence > diffrence and diffrence > -dummy_id.HeightDiffrence
if dummy_id.EnemiesOnly then
set result = IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(dummy_id.Object)) /*
*/ and dummy_id.HeightDiffrence > diffrence and diffrence > -dummy_id.HeightDiffrence
endif
return GetWidgetLife(GetFilterUnit()) > 0.405 and result
endmethod
well.. the problem is,
all works perfectly, the only thing that doesnt work is the check of height ;/
(cuz i got 7 other abilities i can test with..)
and all of them fails, but some of them got OnImpact triggers, (added a function interface, as the name of this thread), but it works.
basicly, if its true (it hits a target), it calls the OnImpact of the missle,
but if its false, it returns it on collide with terrain.
edit: putted a higher number then 25, it works.. but now its too high, ill try to balance it ;p
wait, the bigger the number is, the more height diffrence it needs? so 55 = really big,
100 = small? ;o
well, 100 - 500 has hitted units no matter what height they are,
while lower then or equal to 50 doesnt hit,
and 55 is too high.
any idea?
JASS:private static constant string Missle_Creation_Model_Path
just want to know why you made it static when its already a constant... ^^
Cause crappy vJass won't compile it.
private static integer array example
Arrays cannot be constant.private static integer array example
Arrays cannot be constant.
The difference between including the static keyword and not is this:
globals
integer myvar
integer array myvar2
endglobals
That's basically the same as:
struct x
static integer myvar
integer myvar2
endstruct
Notice the omission of the "static" keyword turns the variable into an array.