• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[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