HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Umm Straight Bullet?

11-24-2007, 03:49 AM#1
Tiku
I need the formula for making a bullet go straight down a path rather than move with the terrain, like in elimination tournament....

I tried a couple of things:
  • Start Height - New Height + UnitHeight
  • New Height - Start Height + UnitHeight

which both didnt work, they just followed the terrain, and going higher and lower then normal.... please help me... i need it :D
11-24-2007, 04:08 AM#2
Ammorth
Set your start height to be the units height plus the starting z height. This will be the "true" height of the bullet in regards to wc3s cords. Then apply any height changes to this starting height (aim up or down) and then subtract the z height and set the unit height to the remaining height.
11-24-2007, 04:25 AM#3
Tiku
okay so i still have the problem... its still kinda wierd...
heres my trigger:

Collapse JASS:
constant function Shootid takes nothing returns integer
    return 'h001'
endfunction

function Trig_Shoot_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A000'
endfunction

function IsUnitImmune takes nothing returns boolean
    return IsUnitType(GetFilterUnit(), UNIT_TYPE_ANCIENT) == false
endfunction

function Bulletmove takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local unit u = GetHandleUnit(t, "u")
    local player up = GetOwningPlayer(u)
    local unit bullet = GetHandleUnit(t, "bullet")
    local real MoveX = GetHandleReal(t, "MoveX")
    local real MoveY = GetHandleReal(t, "MoveY")
    local real fx = GetUnitX(bullet)
    local real fy = GetUnitY(bullet)
    local group g = CreateGroup()
    local unit dmg
    local integer dist = GetUnitUserData(bullet)
    local boolexpr check = Condition(function IsUnitImmune)
    local boolean hit = false
    local real height = GetHandleReal(t, "height")
    local real newheight = GetLocationZ( Location(fx+50.0*MoveX, fy+50.0*MoveY))-height
    local real uh = GetHandleReal(t, "uh")
    local real nuh = GetLocationZ( Location(fx+50.0*MoveX, fy+50.0*MoveY))-uh
     
    call SetUnitX(bullet, fx+30.0*MoveX)
    call SetUnitY(bullet, fy+30.0*MoveY)
    call SetUnitFlyHeight(bullet, nuh, 0.0)
    call SetUnitUserData(bullet, dist+30)
    
    call GroupEnumUnitsInRange(g, fx+30.0*MoveX, fy+30.0*MoveY, 75.0, check)
   if newheight <= 0 then  
     loop
      set dmg = FirstOfGroup(g)
      exitwhen dmg == null or dist >= 800.0
       if IsUnitEnemy(dmg, up) then
        call UnitDamageTarget(u, dmg, 100.0, true, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_FIRE, WEAPON_TYPE_WHOKNOWS)
        call GroupRemoveUnit(g, dmg)
        call ExplodeUnitBJ(bullet)
        set hit = true
       endif 
      endloop
    endif  
      if hit == true or dist >= 800.0 or newheight > 0 then
       call ExplodeUnitBJ(bullet)
       call FlushHandleLocals(t)
       call DestroyGroup(g)
       call PauseTimer(t)
       call DestroyTimer(t)
       set t = null
      endif
      
      set u = null
      set bullet = null
      set dmg = null
      set g = null 
      set up = null  
endfunction

function Trig_Shoot_Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local player up = GetOwningPlayer(u)
    local real ux = GetUnitX(u)
    local real uy = GetUnitY(u)
    local location loc = GetSpellTargetLoc()
    local real locx = GetLocationX(loc)
    local real locy = GetLocationY(loc)
    local real angle = Atan2((locy-uy),(locx-ux))
    local real MoveX = Cos(angle)
    local real MoveY = Sin(angle)
    local real face = AngleBetweenPoints(GetUnitLoc(u), loc)
    local unit bullet = CreateUnit(up, Shootid(), ux+75.0*MoveX, uy+75.0*MoveY, face)
    local timer t = CreateTimer()
    local real height = GetLocationZ( Location(ux+50.0*MoveX, uy+50.0*MoveY))+50.0
    local real uh = GetLocationZ( Location(ux+50.0*MoveX, uy+50.0*MoveY))+50.0
   
    call SetHandleReal(t, "height", height)
    call SetHandleReal(t, "uh", uh)
    call SetHandleHandle(t, "bullet", bullet)
    call SetHandleHandle(t, "u", u)
    call SetHandleReal(t, "MoveX", MoveX)
    call SetHandleReal(t, "MoveY", MoveY)
    
    call TimerStart(t, 0.03, true, function Bulletmove)
    
    set u = null
    set up = null
    set bullet = null
endfunction

//===========================================================================
function InitTrig_Shoot takes nothing returns nothing
    set gg_trg_Shoot = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Shoot, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Shoot, Condition( function Trig_Shoot_Conditions ) )
    call TriggerAddAction( gg_trg_Shoot, function Trig_Shoot_Actions )
endfunction


this is the part that sets first height:
Collapse JASS:
local real uh = GetLocationZ( Location(ux+50.0*MoveX, uy+50.0*MoveY))+50.0

then this is the difference:
Collapse JASS:
local real uh = GetHandleReal(t, "uh")
    local real nuh = GetLocationZ( Location(fx+50.0*MoveX, fy+50.0*MoveY))-uh

then setting the units new height:
Collapse JASS:
call SetUnitFlyHeight(bullet, nuh, 0.0)

i dont understand... it still kinda bounces up and down on the height...

oh and the units height is set to 0.0; fly type
11-24-2007, 06:42 AM#4
Pyrogasm
It doesn't work if the unit has flying movement by default. Make it have ground movement and then use the flyheight trick to be able to set its height.

Also make sure it has no "Height Minimum" value.
11-24-2007, 02:41 PM#5
Tiku
Thanks so much Pyro! unfortunatly... i can't give you rep :'(
and thanks to Ammorth! :D