- Joined
- Sep 9, 2007
- Messages
- 6,759
method onWallHit takes unit theUnit returns nothing
call .spellInst.destroy()
endmethod
wrong, use it without parameter.
call .spellInst.destroy()
endmethod
wrong, use it without parameter.
(10 ratings)
Nope, just set .alive to false.i though call .spellInst.destroy() would dobut you are right. do i need to clean anything after setting .alive to false?
added a arc to 1 spell? ^^Increased testmap.
Well, the onTargetReach does not have anything as parameter because you have to store the target manually.I will give you some spell samples from my map so you can put it in your sample map for better demonstration (checkin the entries it seems people complain a lot of it's lack of
flashy-stuff-it-can-easilly-do.) like the rubber ball (i'm working on that, could not do because onTargetReach does not accept destructables, so i'd have to make my own method to do so. i could use the "no target missile", but it is not currently fully functional.)
public static method new takes spell ins, unit caster, real spellx, real spelly returns thistype
local real x = GetUnitX(caster)
local real y = GetUnitY(caster)
local real angle = bj_RADTODEG * Atan2(spelly - y, spellx - x)
local real xloc = x + 2500 * Cos(angle * bj_DEGTORAD)
local real yloc = y + 2500 * Sin(angle * bj_DEGTORAD)
local thistype this = thistype.create(x, y, GetLocZ(x, y) + 75., 0.)
set .source = caster
set .spellInst = ins
call .setTargetPos(xloc, yloc)
call BJDebugMsg("curren shot angle= " + R2S(angle))
return this
endmethod
The angle is 0 (radians) and will change to the aim angle as fast as it can be.local thistype this = thistype.create(x, y, GetLocZ(x, y) + 75., 0.)
local thistype this = thistype.create(x, y, GetLocZ(x, y) + 75., angle * bj_DEGTORAD)
public static method new takes spell ins, unit caster, real spellx, real spelly returns thistype
local real x = GetUnitX(caster)
local real y = GetUnitY(caster)
local real angle = Atan2(spelly - y, spellx - x)
local real xloc = x + 2500. * Cos(angle)
local real yloc = y + 2500. * Sin(angle)
local thistype this = thistype.create(x, y, GetLocZ(x, y) + 75., angle)
set .source = caster
set .spellInst = ins
call .setTargetPos(xloc, yloc)
call BJDebugMsg("curren shot angle= " + R2S(angle * bj_RADTODEG))
return this
endmethod
private struct spellMissile extends CustomMissile
private spell spellInst = 0
private unit source = null
public static method new takes spell ins, unit caster, real spellx, real spelly returns thistype
local real x = GetUnitX(caster)
local real y = GetUnitY(caster)
local real angle = Atan2(spelly - y, spellx - x)
local real xloc = x + 1500. * Cos(angle)
local real yloc = y + 1500. * Sin(angle)
local real rangethrueshold = 1500
local thistype this = thistype.create(x, y, GetLocZ(x, y) + 75., angle)
local real xth = spellx - x
local real yth = spelly - y
local real thdistance = SquareRoot(xth * xth + yth * yth)
set .source = caster
set .spellInst = ins
if thdistance > rangethrueshold then
call .setTargetPos(xloc, yloc)
else
call .setTargetPos(spellx, spelly)
endif
return this
endmethod
method onCreate takes nothing returns nothing
set .sfx = "Abilities\\Weapons\\Arrow\\ArrowMissile.mdl"
set .movespeed = 1000. // the best = 2000 , but i'm using 1000 for testing.
set .hitrange = 32. // collision size of basic model.
set .decay = 20. // The missle will be destroied 20 seconds after it's creation, no matter if it stops or not.
set .height = 50.
set .hitunits = true
set .hitdests = true
set .autoface = true
set .zarc = 0.03
set .checkheight = false
set .hitwalls = true
endmethod
method onDestTouch takes destructable theDestructable returns nothing
local real realhigh = .z - GetLocZ(x,y)
set .active = false
call BJDebugMsg("TREE HIT!!!")
call BJDebugMsg("X= " + R2S(.x) + " Y= " + R2S(.y) + " Real Projectile Height= " + R2S(realhigh))
set .colorR = 0 //
set .colorG = 255 // needed to make the missile more visible so it changes the color to green when it hit's the tree.
set .colorB = 0 //
endmethod
method onTargetReach takes nothing returns nothing
local real realhigh = .z - GetLocZ(x,y)
call BJDebugMsg("X= " + R2S(.x) + " Y= " + R2S(.y) + " Real Projectile Height=" + R2S(realhigh)) // real height will always be a number close to 0.00 unless the terrain's height at missile's creation is different from the terrain's height at onTargetReach. (need to solve this)
set .active = false
set .alive = true
endmethod
method onUnitTouch takes unit theUnit returns nothing
local real realhigh = .z - GetLocZ(x,y) // the real heigh makes the terrain heigh be equal to 0.00 so i can calculate the relative height of the missile when it hit's the target.(not fully functional - only works if terrain's height at missile's creation is equal to the terrain's height at onUnitTouch.)
if GetUnitState(theUnit, UNIT_STATE_LIFE) <= 0 then
return
endif
if theUnit == .source then
return
endif
call UnitDamageTarget(.source, theUnit, 100., false, false, ATTACK_TYPE_PIERCE, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_METAL_LIGHT_SLICE)
set .active = false // sets the missile static so i can se where it hit the target.
call BJDebugMsg("UNIT HIT!!!")
call BJDebugMsg("X= " + R2S(.x) + " Y= " + R2S(.y) + " Real Projectile Height= " + R2S(realhigh))
set .colorR = 255 //
set .colorG = 0 // needed to make the missile more visible so it changes the color to red when it hit's the target.
set .colorB = 0 //
return
endmethod
endstruct
Oh wait, you always get the ABSOLUTE height of the missile at ANY missile location withSo, i discovered that GetLocZ(x,y) is a relative parameter between the current location and the "cast" location.
that means that the "real height" (.z - GetLocZ(x,y)) of the current missile location only works if the current terrain height
of the missile's location is equal to the "cast" terrain height location. Is there any way to solve this?
call BJDebugMsg("Missiles absolute height is: " + R2S(.z))
Nope, they should not, because the one unit is standing on the hill. It's a feature that you will always hit the correct vector.notice that both are practically at the same Y, and as the image shows, they should be at almost the same "Z" aswell.
Nope, it's NOT relative to any position.The calcule .z - GetLocZ(x,y) suppose to set the minimum real height to approximally 0, but in the picture is negative (because the GetLocZ(x,y) is relative to the "cast" location). Is ther anyway to the GetLocZ be a universal parameter?
method onUnitTouch takes unit theUnit returns nothing
local real realhigh = GetUnitFlyHeight(.getEffUnit())
if GetUnitState(theUnit, UNIT_STATE_LIFE) <= 0 then
return
endif
if theUnit == .source then
return
endif
call UnitDamageTarget(.source, theUnit, 100., false, false, ATTACK_TYPE_PIERCE, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_METAL_LIGHT_SLICE)
set .active = false // sets the missile static so i can se where it hit the target.
call BJDebugMsg("UNIT HIT!!!")
call BJDebugMsg("X= " + R2S(.x) + " Y= " + R2S(.y) + " Real Projectile Height= " + R2S(realhigh))
set .colorR = 255 //
set .colorG = 0 // needed to make the missile more visible so it changes the color to red when it hit's the target.
set .colorB = 0 //
return
endmethod
Sadly there is no way to get an units model height, even with vJass.well, ok i get it, but can you help me with that? the z is fixed no matter the terrain high right? that means the height check (how tall a unit is for onUnitTouch purposes) of units in terrain above or bellow normal should be different. but it isn't. check out the graphic. The way it is a projectile may pass through an unit's head or shoulderss and not touch it if the unit's is in higher terrain while it would on lower terrain.
There is no constant height, it's based on terrain height and fly height from the missile (Plus missile height).the "constant" height of the missile according to the terrain
You mean you want to aim the missile for units head and not for the feet?Example: if a unit is in elevated ground, it's head is at same "height" value than at lower ground. .z does not does that. i wanna know which value/variable do i use to measure that![]()
Well, I don't really know what you are talking about, sadly, could you make a quick draw?i think (you tell me) capturing the arrow's flying height would do but i dunno how you call the "missile" (.what?)
Well you can just create an effect and use the 'oTip' destructable to move it to the corrospondenting z height.i also want to know how to call for an special effect using your customeffects system. (I wanna blood splash effects at the exact same location and .z the missile hits the widget)
You can't really do that with my engine right now. I'll add x, y and z-Offsets in the next version. Thanks for telling.He wants to account for changes in the terrain height from the source of the missile to the target of the missile so that the height offset at both of those locations is a certain, predefined amount (he has given the example of 100).
Well, I don't really know what you are talking about, sadly, could you make a quick draw?
GetUnitFlyHeight(variablename)
I will use an offset that always is added after calculation, so it hasn't anything to do with start/endloc and can be removed in flight.If you used vectors it wouldn't really be a problem, the way I have it set up is so that the user chooses both the 3D location that the projectile starts, and the 3D location that the projectile finishes.
dude, whats the variable name of the missile? so I can try
JASS:GetUnitFlyingHeight(variablename)
Anachron said:JASS:method onUnitTouch takes unit theUnit returns nothing local real realhigh = GetUnitFlyHeight(.getEffUnit())
local real realhigh = GetUnitFlyHeight(.getEffUnit())