Jass Passive Spell Help

D.V.D

Make a wish
Reaction score
73
Ok, i made this trigger and im getting errors on the locals and the damage part. Here's the code:
JASS:

function Trig_Critical_Strike_Conditions takes nothing returns boolean
    if ( not ( IsUnitAliveBJ(GetAttackedUnitBJ()) == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_Critical_Strike_Func001Func001C takes nothing returns boolean
    if ( not ( GetRandomInt(1, 100) <= 10 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Critical_Strike_Func001C takes nothing returns boolean
    if ( not ( GetUnitAbilityLevelSwapped('AOcr', GetTriggerUnit()) == 1 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Critical_Strike_Actions takes nothing returns nothing
    if ( Trig_Critical_Strike_Func001C() ) then
        if ( Trig_Critical_Strike_Func001Func001C() ) then
        else
        endif
             local interger Strength = GetHeroStatBJ(bj_HEROSTAT_STR, GetTriggeringUnit(), true)
             call UnitDamageTargetBJ( GetAttacker(), GetAttackedUnitBJ(), I2R(Strength), ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
    else
    endif
endfunction

//===========================================================================
function InitTrig_Critical_Strike takes nothing returns nothing
    set gg_trg_Critical_Strike = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Critical_Strike, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( gg_trg_Critical_Strike, Condition( function Trig_Critical_Strike_Conditions ) )
    call TriggerAddAction( gg_trg_Critical_Strike, function Trig_Critical_Strike_Actions )
endfunction


The local gives me an error saying expects a endif and the damage function expects a name because the local doesn't work. Thanks in advance :).
 

Nina

New Member
Reaction score
8
Also its integer not interger and I think you want your call UnitDamage..blablbla within the 2nd if otherwise it's just worthless. To help yourself find problems you should rename your function names and remove the weird not 's in your conditions.
 

saw792

Is known to say things. That is all.
Reaction score
280
I don't think a converted GUI trigger with some locals added really qualifies as a 'Jass Passive'...
 

D.V.D

Make a wish
Reaction score
73
First of all, im learning jass so this is what im doing. Second of all, i get more errors when i put the local at the top.
JASS:

function Trig_Critical_Strike_Conditions takes nothing returns boolean
    if ( not ( IsUnitAliveBJ(GetAttackedUnitBJ()) == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_Critical_Strike_Func001Func001C takes nothing returns boolean
    if ( not ( GetRandomInt(1, 100) <= 10 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Critical_Strike_Func001C takes nothing returns boolean
    if ( not ( GetUnitAbilityLevelSwapped('AOcr', GetTriggerUnit()) == 1 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Critical_Strike_Actions takes nothing returns nothing
    local integer Strength = GetHeroStatBJ(bj_HEROSTAT_STR, GetTriggeringUnit(), true)
    if ( Trig_Critical_Strike_Func001C() ) then
        if ( Trig_Critical_Strike_Func001Func001C() ) then
        else
        endif
             call UnitDamageTargetBJ( GetAttacker(), GetAttackedUnitBJ(), I2R(Strength), ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
    else
    endif
endfunction

//===========================================================================
function InitTrig_Critical_Strike takes nothing returns nothing
    set gg_trg_Critical_Strike = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Critical_Strike, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( gg_trg_Critical_Strike, Condition( function Trig_Critical_Strike_Conditions ) )
    call TriggerAddAction( gg_trg_Critical_Strike, function Trig_Critical_Strike_Actions )
endfunction


Is it right?
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
You could remove those condition functions and use them directly in the if statements instead. Also checking if the attacked unit is alive with a "A unit is attacked" event seems rather unneccessary to me.
 

Flare

Stops copies me!
Reaction score
662
JASS:
GetTriggeringUnit()

No such unit - it's GetTriggerUnit ()

And you can handle alot of those things within your actions function i.e.

JASS:
function Trig_Critical_Strike_Actions takes nothing returns nothing
    local integer Strength = GetHeroStatBJ(bj_HEROSTAT_STR, GetAttacker(), true)
    if ( GetUnitAbilityLevel(GetAttacker(), 'AOcr') == 1 ) then //I assume you want to get the attacker's abil level here, and not the attacked unit?
        if (GetRandomInt(1, 100) <= 10 ) then
        else
        endif
             call UnitDamageTargetBJ( GetAttacker(), GetTriggerUnit(), I2R(Strength), ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL ) //And BJ could be replaced, but I can't remember the parameter order in the native, so I won't do it so as not to add to any confusion :\
    else
    endif
endfunction


And this:
JASS:
function Trig_Critical_Strike_Conditions takes nothing returns boolean
    if ( not ( IsUnitAliveBJ(GetAttackedUnitBJ()) == true ) ) then
        return false
    endif
    return true
endfunction

can become
JASS:
function Trig_Critical_Strike_Conditions takes nothing returns boolean
return GetWidgetLife (GetTriggerUnit ()) > .405
endfunction
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
Your code could be shortened a lot.

JASS:
function Trig_Critical_Strike_Conditions takes nothing returns boolean
    return GetUnitAbilityLevel(GetAttacker(), 'AOcr') > 0 and GetRandomInt(1, 100) <= 10
endfunction

function Trig_Critical_Strike_Actions takes nothing returns nothing
    call UnitDamageTarget(GetAttacker(), GetTriggerUnit(), GetHeroStr(GetAttacker(), true), true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
endfunction

//===========================================================================
function InitTrig_Critical_Strike takes nothing returns nothing
    local trigger trig = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(trig, EVENT_PLAYER_UNIT_ATTACKED)
    call TriggerAddCondition(trig, Condition(function Trig_Critical_Strike_Conditions))
    call TriggerAddAction(trig, function Trig_Critical_Strike_Actions)
endfunction


Since I know myself I must've missed something since that's freehanded, but you get the idea.
 

D.V.D

Make a wish
Reaction score
73
Thanks for the fixes guys Im going to see if I don't get any more errors.

EDIT: The only problem was GetTriggeringUnit. It was supposed to be, like said before GetTriggerUnit. Thanks for the help guys and I'll make the code shorter :).
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top