• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] [How to]Smoothen missle

Status
Not open for further replies.
Level 29
Joined
Jul 29, 2007
Messages
5,174
JASS:
local unit u

//
//

set units = GetUnitsInRangeOfLocMatching(110.00, mmpoint,null)
loop
        set u = FirstOfGroup(units)
        exitwhen u == null
        call GroupRemoveUnit(units, u)

        if IsUnitEnemy(u,GetOwningPlayer(kd.u)) and IsUnitAliveBJ(u) then
              call UnitDamageTarget(kd.u,u, damage,true,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
              call KillUnit( md.u )
              call md.destroy()
              set Total = Total - 1
              set Missle[i] = Missle[Total]       
        endif

endloop
 
JASS:
local unit u

//
//

set units = GetUnitsInRangeOfLocMatching(110.00, mmpoint,null)
loop
        set u = FirstOfGroup(units)
        exitwhen u == null
        call GroupRemoveUnit(units, u)

        if IsUnitEnemy(u,GetOwningPlayer(kd.u)) and IsUnitAliveBJ(u) then
              call UnitDamageTarget(kd.u,u, damage,true,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
              call KillUnit( md.u )
              call md.destroy()
              set Total = Total - 1
              set Missle[i] = Missle[Total]       
        endif

endloop

Thanks =) It works now but wc3 crash after using once.
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
I made that code especially for your second loop, just copy and paste it, you changed it and it's obvious it won't work now.

You do "set hurt = FirstOfGroup(units)" only if the current unit is an enemy, so if it's an ally it gets into an infinite loop AND it tries to remove a unit that isn't in the group for infinite times (although it probably crashes at the first time... I guess).
You also destroy the projectile whether it's an enemy or an ally (I guess that isn't what you want?).

As to improving your code, remove all this BJs:
PolarProjectionBJ
IsTerrainPathableBJ
UnitDamageTargetBJ (I even gave you the freaking code for the non BJ...).

You also might as well use coordinates instead of locations.

if ( not ( IsUnitGroupEmptyBJ(units) == true ) ) then why not simply put != ? if IsUnitGroupEmptyBJ(units) != true then.
 
Status
Not open for further replies.
Top