- Joined
- Mar 18, 2012
- Messages
- 1,716
Missile Manual - v.1.4.2
Creators, destructors and module MissileStruct
[self=http://www.hiveworkshop.com/forums/jass-resources-412/missile-265370/]Back to the Missile main thread[/self]
A new Missile instance can be allocated by one the following struct allocators.
Creators & destroy
JASS:
|
Missile.create()
Missile.create(x, y, z, angle, distance, impactZ)
is the core creator of Missile and used in most cases.Let's check out an example and you understand it at a glance.
JASS:
private function OnCast takes nothing returns nothing
local unit caster = GetTriggerUnit()
local real x = GetUnitX(caster)
local real y = GetUnitY(caster)
local real angle = Atan2(GetSpellTargetY() - y, GetSpellTargetX() - x)
local Missile missile = Missile.create(x, y, 50., angle, 1000., 50.)
//
set missile.speed = 10
set missile.model = ""
set missile.collision = 32.
call MySpell.launch(missile)
endfunction
Missile.createXYZ(x, y, z, impactX, impactY, impactZ)
is a wrapper function to Missile.create,which can be handy in cases where you want to calculate neither angle nor distance of the missile.
Instead you hand to work over to library Missile.
Let's check out an example.
JASS:
private function OnCast takes nothing returns nothing
local unit caster = GetTriggerUnit()
local real x = GetUnitX(caster)
local real y = GetUnitY(caster)
local Missile missile = Missile.createXYZ(x, y, 50., GetSpellTargetX(), GetSpellTargetY(), 50.)
//
set missile.speed = 10
set missile.model = ""
set missile.collision = 32.
call MySpell.launch(missile)
endfunction
Missile.createEx(dummy, angle, distance, impactZ)
is a very interesting function with much potential.It allows you to pass in a unit of your choice and transform it into a Missile. For example a hero.
That unit will perform the same physiks like an ordinary missile dummy.
Missile will not recycle that unit when it finished its flight.
I made use of that in my leap spell for the blademaster ( link ).
Let's check an example
JASS:
private function OnCast takes nothing returns nothing
local Missile missile = Missile.createEx(GetTriggerUnit(), GetSpellTargetX(), GetSpellTargetY(), 50.)
//
set missile.speed = 10
set missile.model = ""
set missile.arc = 45*bj_DEGTORAD
set missile.collision = 32.
call Leap.launch(missile)
endfunction
In order to make use of Missile you must declare a new struct and implement module MissileStruct into it.
Then you can declare any of the available static methods for missile behaviours, such as static method onCollide.
Missiles fired from this struct will only behave as defined in that struct.
Let's check an example.
JASS:
private struct Fireball extends array
private static method onCollide takes Missile missile, unit hit returns boolean
if IsUnitEnemy(hit, missile.owner) and UnitAlive(hit) then
return UnitDamageTarget(missile.source, hit, missile.damage, false, false, null, null, null)
endif
return false
endmethod
// Enables missile behaviour for struct Fireball.
// Now onCollide will run, if a missile launched from this struct
// collides with a unit.
implement MissileStruct
endstruct
private function OnCast takes nothing returns nothing
local unit caster = GetTriggerUnit()
local real x = GetUnitX(caster)
local real y = GetUnitY(caster)
local Missile missile = Missile.createXYZ(x, y, 50., GetSpellTargetX(), GetSpellTargetY(), 50.)
//
set missile.source = caster
set missile.owner = GetTriggerPlayer()
set missile.speed = 20
set missile.model = "Abilities\\Weapons\\FireBallMissile\\FireBallMissile.mdl"
set missile.collision = 32.
call Fireball.launch(missile)// Launches for struct Fireball.
endfunction
Last edited: