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

simple moving a unit, but im stuck lol

Status
Not open for further replies.
Level 5
Joined
Nov 14, 2007
Messages
161
so a skill i have creates a dummy unit (has model) and that unit goes in a line until it's expiration timer is done and it dies. i have made the spell to work just fine in GUI but i need it MUI and my GUI method isnt so im changing it to JASS.

  • BoomStick
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to BoomStick
    • Actions
      • Set BoomStickerUnit = (Triggering unit)
      • Animation - Play BoomStickerUnit's Spell animation
      • Set BoomStickerPoint = (Position of BoomStickerUnit)
      • Set BoomStickPoint = (Target point of ability being cast)
      • Set DirectionOfBoomstick = (Angle from BoomStickerPoint to BoomStickPoint)
      • Unit - Create 1 Boom Stick for (Owner of BoomStickerUnit) at BoomStickerPoint facing DirectionOfBoomstick degrees
      • Set BoomStickDummy = (Last created unit)
      • Unit - Add a 2.00 second Generic expiration timer to BoomStickDummy
      • Set BoomStickInt = 0
      • Trigger - Turn on BoomStick effect <gen>
      • Wait 3.00 seconds
      • Trigger - Turn off BoomStick effect <gen>
      • Set BoomStickerUnit = No unit
      • Set BoomStickDummy = No unit
      • Set DirectionOfBoomstick = 0.00
      • Custom script: call RemoveLocation(udg_BoomStickerPoint)
and
  • BoomStick effect
    • Events
      • Time - Every 0.04 seconds of game time
    • Conditions
    • Actions
      • Set BoomStickInt = (BoomStickInt + 1)
      • Unit - Move BoomStickDummy instantly to (BoomStickerPoint offset by ((Real(BoomStickInt)) x 15.00) towards DirectionOfBoomstick degrees), facing DirectionOfBoomstick degrees
what would the jass look like that would loop that correctly? (im guessing with timers which i dont have much experience with)

My JASS Attempt:
JASS:
function Trig_BoomStick_JASS_Actions takes nothing returns nothing
    local unit BSUnit = GetTriggerUnit()
    local unit BSDummy
    local location BSCasterLoc = GetUnitLoc(BSUnit)
    local location BSTargetLoc = GetSpellTargetLoc()
    local real BSReal = AngleBetweenPoints(BSCasterLoc, BSTargetLoc)
    local integer i = 0
       
    call SetUnitAnimation( BSUnit, "Spell" )
    set BSDummy = CreateUnitAtLoc(GetOwningPlayer(BSUnit), 'h005', BSCasterLoc, BSReal)
    call UnitApplyTimedLife(BSDummy, 'BTLF', 3.00)
    
loop
    exitwhen BSDummy == null
    set i = i + 1
    call SetUnitPositionLocFacingBJ( BSDummy, PolarProjectionBJ(BSCasterLoc, ( I2R(i) * 15.00 ), BSReal), BSReal)
    call TriggerSleepAction( 0.01 ) 
endloop

    set BSUnit = null
    set BSDummy = null
    set BSReal = 0.00
    call RemoveLocation(BSCasterLoc)
    call RemoveLocation(BSTargetLoc)
endfunction
Thanks
YO_MA_MA

EDIT: 20 views and no reply :( i know it isnt THAT hard.... is it? *gulp*
 
Last edited:
Level 5
Joined
Nov 14, 2007
Messages
161
just a little bump.... still 25+ views and no body knows how to make a unit move in a line?

some idea's i have (by looking at other skills) are "private functions" or "structs" or "scopes" but i havent dealt with those before so any advice is good advice.
thanks again
 
Level 5
Joined
Dec 18, 2007
Messages
205
Well, could you post the whole trigger? Because you just posted the actions.
And then can you describe where you got stuck exactly? I mean does the function work? Or what happens instead?

And something that you should improve:

JASS:
    set BSUnit = null
    set BSDummy = null
    set BSReal = 0.00
    call RemoveLocation(BSCasterLoc)
    call RemoveLocation(BSTargetLoc)

should be

JASS:
set BSUnit = null
    set BSDummy = null
    call RemoveLocation(BSCasterLoc)
    call RemoveLocation(BSTargetLoc)
    set BSCasterLoc = null
    set BSTargetLoc = null

Reals don't leak, so you don't have to set them to 0. But instead locations that are not nulled do leak.

greetz
 
Level 5
Joined
Nov 14, 2007
Messages
161
whole trigger:
JASS:
function Trig_BoomStick_JASS_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A002' ) ) then
        return false
    endif
    return true
endfunction

function Trig_BoomStick_JASS_Actions takes nothing returns nothing
    local unit BSUnit = GetTriggerUnit()
    local unit BSDummy
    local location BSCasterLoc = GetUnitLoc(BSUnit)
    local location BSTargetLoc = GetSpellTargetLoc()
    local real BSReal = AngleBetweenPoints(BSCasterLoc, BSTargetLoc)
    local integer i = 0
       
    call SetUnitAnimation( BSUnit, "Spell" )

    set BSDummy = CreateUnitAtLoc(GetOwningPlayer(BSUnit), 'h005', BSCasterLoc, BSReal)
    call UnitApplyTimedLifeBJ( 3.00, 'BTLF', BSDummy )
    
    
loop
    exitwhen BSDummy == null
    set i = i + 1
    call SetUnitPositionLocFacingBJ( BSDummy, PolarProjectionBJ(BSCasterLoc, ( I2R(i) * 15.00 ), BSReal), BSReal)
    call TriggerSleepAction( 0.01 ) 
endloop

    set BSUnit = null
    set BSDummy = null
    call RemoveLocation(BSCasterLoc)
    call RemoveLocation(BSTargetLoc)
    set BSCasterLoc = null
    set BSTargetLoc = null
endfunction

//===========================================================================
function InitTrig_BoomStick_JASS takes nothing returns nothing
    set gg_trg_BoomStick_JASS = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_BoomStick_JASS, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_BoomStick_JASS, Condition( function Trig_BoomStick_JASS_Conditions ) )
    call TriggerAddAction( gg_trg_BoomStick_JASS, function Trig_BoomStick_JASS_Actions )
endfunction

ok, skill works but as i said its very choppy and doesnt go as fast as i want it too. im debating how i want the damage to be done either keep it from the skill or use jass and damage units around the missile effect.
 
Level 5
Joined
Dec 18, 2007
Messages
205
first of all:
change the condition to a simple one. Replace
JASS:
function Trig_BoomStick_JASS_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A002' ) ) then
        return false
    endif
    return true
endfunction
with
JASS:
function Trig_BoomStick_JASS_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A002'
endfunction
It's the same, but shorter and faster.
You could order the dummy to move to the location again and again instead of moving him instantly. So it looks more "fluently".
Doing the damage with JASS is your choice:p

greetz

EDIT: A little hint:
Order the dummy just to move to a point far behind target location, then set movespeed to whatever you need. So you dont' need a loop anymore. Your dummy must just be able to fly
 
Last edited:
Level 5
Joined
Nov 14, 2007
Messages
161
after taking your hint, the dummy isnt going strait anymore, i have a model (to small for my liking) on the skill, so i know where it should be, but the dummy goes off in a wrong direction. i dont think "fly" movement type will go in a strait line as does the skill and the move instantly loop will.

JASS:
function Trig_BoomStick_JASS_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A002'
endfunction

function Trig_BoomStick_JASS_Actions takes nothing returns nothing
    local unit BSUnit = GetTriggerUnit()
    local unit BSDummy
    local location BSCasterLoc = GetUnitLoc(BSUnit)
    local location BSTargetLoc = GetSpellTargetLoc()
    local real BSReal = AngleBetweenPoints(BSCasterLoc, BSTargetLoc)
    local integer i = 0
       

    call SetUnitAnimation( BSUnit, "Spell" )
    set BSDummy = CreateUnitAtLoc(GetOwningPlayer(BSUnit), 'h005', BSCasterLoc, BSReal)
    call UnitApplyTimedLifeBJ( 3.00, 'BTLF', BSDummy )
    call IssuePointOrderLoc( BSDummy, "move", PolarProjectionBJ(BSCasterLoc, 2000, BSReal) )
    
    
    set BSUnit = null
    set BSDummy = null
    call RemoveLocation(BSCasterLoc)
    call RemoveLocation(BSTargetLoc)
    set BSCasterLoc = null
    set BSTargetLoc = null

endfunction

//===========================================================================
function InitTrig_BoomStick_JASS takes nothing returns nothing
    set gg_trg_BoomStick_JASS = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_BoomStick_JASS, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_BoomStick_JASS, Condition( function Trig_BoomStick_JASS_Conditions ) )
    call TriggerAddAction( gg_trg_BoomStick_JASS, function Trig_BoomStick_JASS_Actions )
endfunction
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
I would like to suggest to you to use reals instead of locations.
Locations are simply objects containing coordinates (x,y,z), which you can get in almost every case and use with functions that take coordinates instead of locations.
This removes the need of removing each location, as basic variables (int, real, boolean, etc) don't need to be removed.

Another suggestion is to stop using all this BJ functions. Most of the BJ functions (again, not all of them) are simply calling the non BJ functions, which simply makes your code less efficient.

For example, 'UnitApplyTimedLifeBJ' simply calls 'UnitApplyTimedLife' with your parameters. Less calls = happy computer.

After telling you this two things, you'd probably want to change this UnitApplyTimedLifeBJ and CreateUnitAtLoc to their natives:
UnitApplyTimedLife (I think that's the name)
CreateUnit (notice that this takes coordinates, not a location).

On another note, PolarProjectionBJ isn't really a nice function. You can make your own function with sin and cos, if you know how they work (or also if you don't know how they work).

A polar projection using coordinates would be coded like this
JASS:
x  = x + distance * cos(angle_in_radians)
y  = y + distance * sin(angle_in_radians)

// to make the angle in radians, we multiply it by the constant bj_DEGTOARD
// here's the final result

x  = x + distance * cos(angle * bj_DEGTORAD)
y  = y + distance * sin(angle * bj_DEGTORAD)

As to your usage of AngleBetweenPoints, since we (I) said we (I) don't like points, you can use this function to get an angle between coordinates

JASS:
function AngleBetweenCoordinates takes real x1, real y1, real x2, real y2 returns real
    return bj_RADTODEG * Atan2(y2 - y1, x2 - x1)
endfunction

And just in case you want a distance function

JASS:
function DistanceBetweenCoordinates takes real x1, real y1, real x2, real y2 returns real
    local real dx = x1 - x2
    local real dy = y1 - y2
    return SquareRoot(dx * dx + dy * dy)
endfunction

Anyway, have fun coding.
 
Level 5
Joined
Nov 14, 2007
Messages
161
Another suggestion is to stop using all this BJ functions. Most of the BJ functions (again, not all of them) are simply calling the non BJ functions, which simply makes your code less efficient.

For example, 'UnitApplyTimedLifeBJ' simply calls 'UnitApplyTimedLife' with your parameters. Less calls = happy computer.

well i feel good that i remembered the dont use BJ rule and had it changed before reading this post, but......
im having a small problem though, vJASS.. well it download (from here) but will not run on my computer, any ideas? i have the latest warcraft 3 patch (1.22) and Vista 64bit. it will start to load and ill have the window open up with a few boxes in it, then vista says it's not responding and i cant do anything with it. any ideas?
 
Status
Not open for further replies.
Top