• 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.

[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,243
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!
 
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