• 🏆 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!
  • ✅ Time to vote for the top 3 models! The POLL for Hive's 6th HD Modeling Contest: Mechanical is now open! 📅 Poll close on July 16, 2024! 🔗 Cast your vote now!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

[Solved] Script not executing fully

Status
Not open for further replies.
Level 17
Joined
Feb 11, 2011
Messages
1,860
Hi guys,

I am fairly new to JASS and I am beginning to develop spells. I have created one which is like Shockwave except it has a different model. I want to use the model "Farseer Missile" for my Shockwave. One problem is that if I simply change to model of the Shockwave to Farseer Missile, the effect is half underground and half above ground. To fix this I have created a unit with the Farseer Missile model and changed the height. It also has the "Locust" ability. This ability is cast every second. I create the unit just after the dummy casts the shockwave and I make the unit move along the same path as the shockwave. It works, but half of the time only the unit is created and the shockwave isn't casted. Here is my script:

JASS:
function Fury_of_the_Storm takes nothing returns nothing
    local real r = GetRandomReal(1, 360)
    local real x = GetUnitX(udg_Boss_Unit)
    local real y = GetUnitY(udg_Boss_Unit)
    local real x2 = GetLocationX(Location(x, y)) + 2000 * Cos(r * bj_DEGTORAD)
    local real y2 = GetLocationY(Location(x, y)) + 2000 * Sin(r * bj_DEGTORAD)
    call CreateNUnitsAtLoc(1, 'h003', GetOwningPlayer(udg_Boss_Unit), Location(x, y), bj_UNIT_FACING)
    call UnitAddAbility(GetLastCreatedUnit(), 'A04X')
    call IssuePointOrder(GetLastCreatedUnit(), "shockwave", x2, y2)
    call UnitApplyTimedLife(GetLastCreatedUnit(), 'BTLF', 4)
    call CreateNUnitsAtLoc(1, 'h00M', GetOwningPlayer(udg_Boss_Unit), Location(x, y), bj_UNIT_FACING)
    call IssuePointOrder(GetLastCreatedUnit(), "move", x2, y2)
    call UnitApplyTimedLife(GetLastCreatedUnit(), 'BTLF', 3.83)
endfunction
"udg_Boss_Unit" is the hero that "casts" this ability every second.

I know it is messy - please help me fix it! Thanks!
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Use this to create the unit:
JASS:
set bj_lastCreatedUnit = CreateUnit(GetOwningPlayer(udg_Boss_Unit), 'h003', x, y, bj_UNIT_FACING)

Use bj_lastCreatedUnit instead of GetLastCreatedUnit() and CreateUnit() instead of CreateNUnitsAtLoc. Don't use locations , use coordinates. Currently you leak locations.

The problem might be that the dummy doesn't have vision over the target point. Try creating the point nearer and giving the dummy some vision range to test whether that is the issue or not.
 
Level 17
Joined
Feb 11, 2011
Messages
1,860
Use this to create the unit:
JASS:
set bj_lastCreatedUnit = CreateUnit(GetOwningPlayer(udg_Boss_Unit), 'h003', x, y, bj_UNIT_FACING)
Use bj_lastCreatedUnit instead of GetLastCreatedUnit() and CreateUnit() instead of CreateNUnitsAtLoc. Don't use locations , use coordinates. Currently you leak locations.

The problem might be that the dummy doesn't have vision over the target point. Try creating the point nearer and giving the dummy some vision range to test whether that is the issue or not.

Thanks a lot! Would I then need to null bj_lastCreatedUnit?

EDIT: It casts shockwave much more often now, but still not every time :/

EDIT 2: Never mine, looks like I have fixed it. Thanks guys!
 
Level 26
Joined
Mar 19, 2008
Messages
3,140
Additionaly, to what Maker has already told you:
If you wanted to get 'random angle', you have to use local real r = GetRandomReal(0, 360) - from 0 to 360, not from 1.

You do not have to use GetLocationX and GetLocationY if you already set the x and y.
JASS:
    local real x2 = x + 2000 * Cos(r * bj_DEGTORAD)
    local real y2 = y + 2000 * Sin(r * bj_DEGTORAD)
 
Status
Not open for further replies.
Top