IKilledKEnny's JASS Question Theard, I love to give +REP :)

Status
Not open for further replies.
I

IKilledKEnny

Guest
So when do / don't I use it? Also 4th question, I improved Air a lot but now there is 1 line that disables the whole Trigger.

Code:
function Trig_Air_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A000' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Air_Actions takes nothing returns nothing
    local location AP1
    local location AP2
    local unit AT
    local unit cast
    local player AO
    local real AR1
    local real AR2
    set cast = GetSpellAbilityUnit()
    set AT = GetSpellTargetUnit()
    set AP1 = GetUnitLoc(AT)
    set AP2 = GetUnitLoc(cast)
    set AO = GetOwningPlayer(cast)
    set AR1 = GetUnitMoveSpeed(cast)
    set AR2 = ( GetUnitFlyHeight(AT))
    call SetUnitOwner( cast, Player(PLAYER_NEUTRAL_PASSIVE), false )
    call SetUnitMoveSpeed( cast, ( GetUnitMoveSpeed(cast) + I2R(GetUnitAbilityLevelSwapped('A000', cast)) * 50.00 ) )
    call SetUnitInvulnerable( cast, true )
    call SetUnitPathing( cast, false )
    call SetUnitVertexColorBJ( cast, 75.00, 75.00, 75.00, 65.00 ) 
    call SetUnitTimeScalePercent( cast, ( 100.00 + ( I2R(GetUnitAbilityLevelSwapped('A000', cast)) * 50.00 ) ) ) 
[B]    call SetUnitFlyHeightBJ( cast, AR2, ( DistanceBetweenPoints(AP1), (AP2)), / GetUnitMoveSpeed( cast) ) )[/B]
    call IssuePointOrderLocBJ( cast, "move", AP1 )
    call TriggerSleepAction( ( DistanceBetweenPoints(AP1, AP2) / GetUnitMoveSpeed(cast) ) )
    call IssueTargetOrderBJ( cast, "attack", AT)
    call UnitDamageTargetBJ( cast, AT, GetRandomReal(( I2R(GetUnitAbilityLevelSwapped('A000', GetTriggerUnit())) * 20.00 ), ( I2R(GetUnitAbilityLevelSwapped('A000', GetTriggerUnit())) * 25.00 )), ATTACK_TYPE_MAGIC, DAMAGE_TYPE_ENHANCED )
    call SetUnitOwner( cast, AO, false )   
    call SetUnitInvulnerable( cast, false )
    call SetUnitPathing( cast, true )
    call SetUnitVertexColorBJ( cast, 100.00, 100, 100, 0 )
    call SetUnitMoveSpeed( cast, AR1)
    set AP1 = null
    set AP2 = null
    set cast = null
    set AT = null
    set AO = null
    set AR1 = null
    set AR2 = null
endfunction

//===========================================================================
function InitTrig_Air takes nothing returns nothing
    set gg_trg_Air = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Air, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Air, Condition( function Trig_Air_Conditions ) )
    call TriggerAddAction( gg_trg_Air, function Trig_Air_Actions )
endfunction

JassCraft says:
1. not enough arguments passed on function.
2. ')' missing
3. too many arguments passed on function
4. Syntax error.

It supposes to make cast reach AT flying height.
 
I

IKilledKEnny

Guest
Well I can get the Trigger enabled, but the unit wno't go up! It would stay on the ground!
 
I

IKilledKEnny

Guest
No, but what I'm trying to understand at the moment is why won't my unit if it's ordered to using chocobo's line.
 

Steel

Software Engineer
Reaction score
109
Whats this air ability supposed to do? Fly through units and damage them basically? You should base the ability off of a dummy, then have a dummy unit cast shockwave after the unit is going in the direction you want. This way you can properly time it to look like theres that yellow blur behind the unit.
 

chovynz

We are all noobs! in different states of Noobism!
Reaction score
130
Can you see the difference between the two?

Yours
Code:
call SetUnitFlyHeightBJ(cast,AR2,(DistanceBetweenPoints(AP1),(AP2)),/GetUnitMoveSpeed(cast)))
Choco's
Code:
 call SetUnitFlyHeightBJ(cast,AR2,DistanceBetweenPoints(AP1,AP2)/GetUnitMoveSpeed(cast))

And...
Is your unit set to flying?
 
I

IKilledKEnny

Guest
Chovynz, what do you mean? In GUI you can set unit's flying hieght without any problems, and thanks I'll try that new line. :)

Edit: Nope, still doesn't work!
 

Chocobo

White-Flower
Reaction score
409
Can you see the difference between the two?

Yours
Code:
call SetUnitFlyHeightBJ(cast,AR2,(DistanceBetweenPoints(AP1),(AP2)),/GetUnitMoveSpeed(cast)))
Choco's
Code:
 call SetUnitFlyHeightBJ(cast,AR2,DistanceBetweenPoints(AP1,AP2)/GetUnitMoveSpeed(cast))

And...
Is your unit set to flying?

I will bold the error so he can see it :

Code:
call SetUnitFlyHeightBJ(cast,AR2,(DistanceBetweenPoints(AP1),(AP2))[B][U],[/U][/B]/GetUnitMoveSpeed(cast)))
Choco's
Code:
 call SetUnitFlyHeightBJ(cast,AR2,DistanceBetweenPoints(AP1,AP2)/GetUnitMoveSpeed(cast))

SetUnitFlyHeightBJ takes 3 parameters and not 4.


Chovynz, what do you mean? In GUI you can set unit's flying hieght without any problems, and thanks I'll try that new line. :)

Edit: Nope, still doesn't work!

If your unit is ground, you will add the ability 'Arav' to be added and removed to the unit.
 
I

IKilledKEnny

Guest
lol, how could I forgot! I even did a tutorial on that! Thanks! :)

Now another question, here is a big Trigger, that I got from GUI (convereted it to text) and just made variables local. No need to say it doesn't work, and there just too many errors shown for me to write them down. I woud be grateful if someone could tell me what the problem is.

Now in this Trigger I'm pasuing units for level of ability X 2, and casuing every 2 secondsa damage to those unit. The Trigger won't be enabled.

Code:
function Trig_Harden_Air_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A001' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Harden_Air_Func005A takes nothing returns nothing
    call PauseUnitBJ( true, GetEnumUnit() )
endfunction

function Trig_Harden_Air_Func006Func001A takes nothing returns nothing
    call UnitDamageTargetBJ( GetSpellAbilityUnit(), GetEnumUnit(), GetRandomReal(20.00, 25.00), ATTACK_TYPE_NORMAL, DAMAGE_TYPE_FORCE )
    call TriggerSleepAction( 2 )
endfunction

function Trig_Harden_Air_Func009A takes nothing returns nothing
    call PauseUnitBJ( false, GetEnumUnit() )
endfunction

function Trig_Harden_Air_Actions takes nothing returns nothing
    call Location HLoc
    call group UnGr
    call unit c
    call unit HU
    set c = GetSpellAbilityUnit()
    set HLoc = GetSpellTargetLoc()
    set HUnGr = GetUnitsInRangeOfLocAll(( I2R(GetUnitAbilityLevelSwapped('A001', GetSpellAbilityUnit())) * 200.00 ), c)
    call CreateNUnitsAtLoc( 1, udg_UT[GetUnitAbilityLevelSwapped('A001', c)], Player(PLAYER_NEUTRAL_PASSIVE), HLoc, bj_UNIT_FACING )
    set HU = GetLastCreatedUnit()
    call ForGroupBJ( HUnGr, function Trig_Harden_Air_Func005A )
    set bj_forLoopAIndex = 0
    set bj_forLoopAIndexEnd = GetUnitAbilityLevelSwapped('A001', c)
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        call ForGroupBJ( HUnGr, function Trig_Harden_Air_Func006Func001A )
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
    call TriggerSleepAction( 1.00 )
    call RemoveUnit( HU )
    call ForGroupBJ( HUnGr, function Trig_Harden_Air_Func009A )
endfunction

//===========================================================================
function InitTrig_Harden_Air takes nothing returns nothing
    set gg_trg_Harden_Air = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Harden_Air, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Harden_Air, Condition( function Trig_Harden_Air_Conditions ) )
    call TriggerAddAction( gg_trg_Harden_Air, function Trig_Harden_Air_Actions )
endfunction
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
Code:
function Trig_Harden_Air_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A001' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Harden_Air_Func005A takes nothing returns nothing
    call PauseUnitBJ( true, GetEnumUnit() )
endfunction

function Trig_Harden_Air_Func006Func001A takes nothing returns nothing
    call UnitDamageTargetBJ( GetSpellAbilityUnit(), GetEnumUnit(), GetRandomReal(20.00, 25.00), ATTACK_TYPE_NORMAL, DAMAGE_TYPE_FORCE )
    call TriggerSleepAction( 2 )
endfunction

function Trig_Harden_Air_Func009A takes nothing returns nothing
    call PauseUnitBJ( false, GetEnumUnit() )
endfunction

function Trig_Harden_Air_Actions takes nothing returns nothing
    [COLOR="Red"]local location[/COLOR] HLoc
    [COLOR="Red"]local group[/COLOR] [B][COLOR="Red"]UnGr[/COLOR][/B]
    [COLOR="Red"]local unit[/COLOR] c
    [COLOR="Red"]local unit[/COLOR] HU
    set c = GetSpellAbilityUnit()
    set HLoc = GetSpellTargetLoc()
    set UnGr = GetUnitsInRangeOfLocAll(( I2R(GetUnitAbilityLevelSwapped('A001', GetSpellAbilityUnit())) * 200.00 ), [COLOR="Red"]GetUnitLoc(c)[/COLOR])
    call CreateNUnitsAtLoc( 1, udg_UT[GetUnitAbilityLevelSwapped('A001', c)], Player(PLAYER_NEUTRAL_PASSIVE), HLoc, bj_UNIT_FACING )
    set HU = GetLastCreatedUnit()
    call ForGroupBJ( [B][COLOR="Red"]UnGr[/COLOR][/B], function Trig_Harden_Air_Func005A )
    set bj_forLoopAIndex = 0
    set bj_forLoopAIndexEnd = GetUnitAbilityLevelSwapped('A001', c)
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        call ForGroupBJ( [B][COLOR="Red"]UnGr[/COLOR][/B], function Trig_Harden_Air_Func006Func001A )
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
    call TriggerSleepAction( 1.00 )
    call RemoveUnit( HU )
    call ForGroupBJ( [B][COLOR="Red"]UnGr[/COLOR][/B], function Trig_Harden_Air_Func009A )
endfunction

//===========================================================================
function InitTrig_Harden_Air takes nothing returns nothing
    set gg_trg_Harden_Air = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Harden_Air, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Harden_Air, Condition( function Trig_Harden_Air_Conditions ) )
    call TriggerAddAction( gg_trg_Harden_Air, function Trig_Harden_Air_Actions )
endfunction

You have to declare locals like this: local <variable type> <variable name> (= value ).

Also, if you declare a local location UnGr, you cannot use HUnGr, because it does not exist. UnGr does.

Lastly, function GetUnitsInRangeOfLocAll takes real and location, not real and unit.

And you should get rid of those nasty bj functions...:p
 
I

IKilledKEnny

Guest
Thanks AndrewGosu, so is your Trigger the right one, or my Trigger with the errors pointed out? Lol I'm not sure I saw few changes but...

Thanks :)
 

SFilip

Gone but not forgotten
Reaction score
634
You can also simplify it a bit.
For instance the condition
Code:
function Trig_Harden_Air_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A001' ) ) then
        return false
    endif
    return true
endfunction
can be put this way
Code:
function Trig_Harden_Air_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A001'
endfunction

The locals can be declared immediately as Andew said...and you don't need GetLastCreatedUnit() in Jass...never.
So this code
Code:
    local location HLoc
    local group UnGr
    local unit c
    local unit HU
    set c = GetSpellAbilityUnit()
    set HLoc = GetSpellTargetLoc()
    set UnGr = GetUnitsInRangeOfLocAll(( I2R(GetUnitAbilityLevelSwapped('A001', GetSpellAbilityUnit())) * 200.00 ), GetUnitLoc(c))
    call CreateNUnitsAtLoc( 1, udg_UT[GetUnitAbilityLevelSwapped('A001', c)], Player(PLAYER_NEUTRAL_PASSIVE), HLoc, bj_UNIT_FACING )
    set HU = GetLastCreatedUnit()
can easily be turned intro
Code:
    local location HLoc = GetSpellTargetLoc()
    local group UnGr = GetUnitsInRangeOfLocAll(( I2R(GetUnitAbilityLevelSwapped('A001', GetSpellAbilityUnit())) * 200.00 ), GetUnitLoc(c))
    local unit c = GetSpellAbilityUnit()
    local unit HU = CreateNUnitsAtLoc( 1, udg_UT[GetUnitAbilityLevelSwapped('A001', c)], Player(PLAYER_NEUTRAL_PASSIVE), HLoc, bj_UNIT_FACING )
 
I

IKilledKEnny

Guest
Ok, thanks to you both, it's now enabled, I hope it'll do what is supposes to do. :D Now I got if then else problem (sorry for just keep posting, I suck at JASS, hope you are not too annoyed all)

Code:
function Trig_Air_Shield_Conditions takes nothing returns boolean
    if ( not ( UnitHasBuffBJ(GetSpellTargetUnit(), 'B000') == true ) ) then
        return false
    endif
    if ( not ( GetUnitAbilityLevelSwapped('ANab', GetSpellTargetUnit()) >= GetUnitAbilityLevelSwapped(GetSpellAbilityId(), GetSpellAbilityUnit()) ) ) then
        return false
    endif
    return true
endfunction

function Trig_Air_Shield_Actions takes nothing returns nothing
    local location AHLoc
    local unit dum
    local unit vic
    local unit ref
    if ( GetRandomInt(1, 100) <= ( GetUnitAbilityLevelSwapped('A002', GetSpellTargetUnit()) * 15 ) ) ) [B]then[/B]
        set vic = GetSpellAbilityUnit()
        set ref = GetSpellTargetUnit()
        set AHLoc = GetUnitLoc(GetSpellTargetUnit())
        call CreateNUnitsAtLoc( 1, 'h001', GetOwningPlayer(GetSpellTargetUnit()), AHLoc, GetUnitFacing(GetSpellTargetUnit()) )
        set dum = GetLastCreatedUnit()
        call UnitAddAbilityBJ( GetSpellAbilityId(), dum )
        call SetUnitAbilityLevelSwapped( GetSpellAbilityId(), dum, GetUnitAbilityLevelSwapped(GetSpellAbilityId(), GetSpellAbilityUnit()) )
        call TriggerSleepAction (1.00)
        call SetUnitAnimation( ref, "cast" )
        call IssueTargetOrderBJ( dum, AbilityId2String(GetSpellAbilityId()), vic)
[B]    endif[/B]
endfunction

//===========================================================================
function InitTrig_Air_Shield takes nothing returns nothing
    set gg_trg_Air_Shield = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Air_Shield, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Air_Shield, Condition( function Trig_Air_Shield_Conditions ) )
    call TriggerAddAction( gg_trg_Air_Shield, function Trig_Air_Shield_Actions )
endfunction


It tells me expected if and then at the lines that I got them already!
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
Code:
function Trig_Air_Shield_Actions takes nothing returns nothing
    local location AHLoc
    local unit dum
    local unit vic
    local unit ref
    if [B][COLOR="Red"](([/COLOR][/B]GetRandomInt(1, 100) <= (GetUnitAbilityLevelSwapped('A002', GetSpellTargetUnit()) * 15[B][COLOR="Red"])))[/COLOR][/B] then
        set vic = GetSpellAbilityUnit()
        set ref = GetSpellTargetUnit()
        set AHLoc = GetUnitLoc(GetSpellTargetUnit())
        call CreateNUnitsAtLoc( 1, 'h001', GetOwningPlayer(GetSpellTargetUnit()), AHLoc, GetUnitFacing(GetSpellTargetUnit()) )
        set dum = GetLastCreatedUnit()
        call UnitAddAbilityBJ( GetSpellAbilityId(), dum )
        call SetUnitAbilityLevelSwapped( GetSpellAbilityId(), dum, GetUnitAbilityLevelSwapped(GetSpellAbilityId(), GetSpellAbilityUnit()) )
        call TriggerSleepAction (1.00)
        call SetUnitAnimation( ref, "cast" )
        call IssueTargetOrderBJ( dum, AbilityId2String(GetSpellAbilityId()), vic)
    endif
endfunction

You had a few parenthesis missing.
 
I

IKilledKEnny

Guest
ROFL! SO SIMPLE! Thanks I would have given you +REP again if I could. :p

I'll post if any of those spells won't work, but at the moment it seems fine. :D
 
I

IKilledKEnny

Guest
I didn't get a chance to test all of the abilities yet but I got that "Air" ability, the one that I had problem making units fly. :) Well I just tested it and unit still won't fly, I guess I'm just stupid... Anyway:

Code:
function Trig_Air_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A000' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Air_Actions takes nothing returns nothing
    local location AP1
    local location AP2
    local unit AT
    local unit cast
    local player AO
    local real AR1
    local real AR2
    set cast = GetSpellAbilityUnit()
    set AT = GetSpellTargetUnit()
    set AP1 = GetUnitLoc(AT)
    set AP2 = GetUnitLoc(cast)
    set AO = GetOwningPlayer(cast)
    set AR1 = GetUnitMoveSpeed(cast)
    set AR2 = ( GetUnitFlyHeight(AT))
    call SetUnitOwner( cast, Player(PLAYER_NEUTRAL_PASSIVE), false )
    call SetUnitMoveSpeed( cast, ( GetUnitMoveSpeed(cast) + I2R(GetUnitAbilityLevelSwapped('A000', cast)) * 50.00 ) )
    call SetUnitInvulnerable( cast, true )
    call SetUnitPathing( cast, false )
    call SetUnitVertexColorBJ( cast, 75.00, 75.00, 75.00, 65.00 ) 
    call SetUnitTimeScalePercent( cast, ( 100.00 + ( I2R(GetUnitAbilityLevelSwapped('A000', cast)) * 50.00 ) ) ) 
    call PauseUnit(AT, true)    
    call UnitShareVisionBJ( true, cast, AO )
    call IssuePointOrderLocBJ( cast, "move", AP1 )
[B]    call UnitAddAbilityBJ( 'Arav', cast )
    call SetUnitFlyHeightBJ(cast,AR2,DistanceBetweenPoints(AP1,AP2)/GetUnitMoveSpeed(cast))[/B]
    call TriggerSleepAction( ( DistanceBetweenPoints(AP1, AP2) / GetUnitMoveSpeed(cast) ) )
    call PauseUnit(AT, false)
[B]    call UnitRemoveAbilityBJ( 'Arav', cast )[/B]
    call UnitDamageTargetBJ( cast, AT, GetRandomReal(( I2R(GetUnitAbilityLevelSwapped('A000', GetTriggerUnit())) * 20.00 ), ( I2R(GetUnitAbilityLevelSwapped('A000', GetTriggerUnit())) * 25.00 ) + 25), ATTACK_TYPE_MAGIC, DAMAGE_TYPE_ENHANCED )
    call SetUnitOwner( cast, AO, false )   
    call SetUnitInvulnerable( cast, false )
    call SetUnitPathing( cast, true )
    call SetUnitVertexColorBJ( cast, 100.00, 100, 100, 0 )
    call SetUnitMoveSpeed( cast, AR1)
    set AP1 = null
    set AP2 = null
    set cast = null
    set AT = null
    set AO = null
    set AR1 = 0.00
    set AR2 = 0.00
endfunction

//===========================================================================
function InitTrig_Swift_Attack takes nothing returns nothing
    set gg_trg_Swift_Attack = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Swift_Attack, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Swift_Attack, Condition( function Trig_Air_Conditions ) )
    call TriggerAddAction( gg_trg_Swift_Attack, function Trig_Air_Actions )
endfunction
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
You really should assign values to the locals when declaring them.

local location p
set p = GetUnitLoc(GetTriggerUnit())

Waste of space. You can have that all in one line.

local location p = GetUnitLoc(GetTriggerUnit())

Also, local locations need to be removed aswell.

call RemoveLocation(p)
set p = null

In addition, You need to nullify all local variables, which are not integers, booleans, reals or strings.

In your case, "set AR1 = 0.00" and set "AR2 = 0.00" are not needed.


Well, I can give You another pointer - use constants functions, when working
with ability rawcodes. It later makes editing easier, because you have to change only one function. (e.g)

Code:
constant function [B]Swift_Rawcode[/B] takes nothing returns integer
    return 'A000'
endfunction

Code:
function Example_Condition takes nothing returns boolean
    return GetSpellAbilityId() == [B]Swift_Rawcode()[/B]
endfunction

function Example_Actions takes nothing returns nothing
    local unit a = GetTriggerUnit()
    local integer i = GetUnitAbilityLevel(a, [B]Swift_Rawcode()[/B] )
    ...
    ...
    ...
    call SetUnitAbilityLevel( a, [B]Swift_Rawcode()[/B], i + 1 )
    ...
    ...
endfunction

Wouldn't it be a pain to change 'A000' in all the functions, if You should replace the ability in the Object Editor for some reason?


The unit still wont fly? What does it do then? Nothing?

EDIT:

Just realized, You did not add the "Crow Form" ability to the unit. Maybe that is why it never lifts off the ground.
 
Status
Not open for further replies.
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top