Jass actions and Jasscraft (was: Ninja_Sheeps Jass-Question thread.)

Ninja_sheep

Heavy is credit to team!
Reaction score
64
okaaaaaay, thx, but that's not really that what i want to know.
I those triggers: (short form)

Code:
Mytrigger1

Event:
   doesn't matter
Condition:
Action:
Do some actions
Run MyTrigger2

Code:
Mytrigger2

Event:
Condition:
Action:
   Add event: A unit comes within range of MyUnit to MyTrigger3

Code:
Event:
   (event added)
Condition:
Action:
   Do some actions.
   (Remove the event of this trigger)

Those are the triggers.

Code:
local trigger trig = CreateTrigger()

call DestroyTrigger(trig)

set trig = CreateTrigger()

Those are my weapons. how do i get those actions inside the trigger?! Im really confused

edit: I will make a new question in http://www.thehelper.net/forums/showthread.php?p=396600#post396600, wich can solve the problem 2
editedit: problem is solved in 1. edit, but im still curius for the answer :)
 

Ninja_sheep

Heavy is credit to team!
Reaction score
64
Question 6: Solved

Why this trigger line doesn't works?!

Code:
native SetPlayerState   takes player TriggPlayer, gold whichPlayerState, ( TriggPlayer_Gold +  R2I(TriggUnit_MaxLife)) value returns nothing

"code-order needed"
 

Doom-Angel

Jass User (Just started using NewGen)
Reaction score
167
well i see u copied it from JassCraft and seem to added a few stuff well if u wanna use it simply do this:

i might have mistaked a bit but basically it's like this:
SetPlayerState( Player, PlayerState (Gold or Lumber), Integer (the new Value)
hope i helped u figure it out

and btw the "native" thing is not needed to be added, it just tells u if this action is native if it doesn't then most likely it's a BJ (i hope u know what BJ is :p)
 

Ninja_sheep

Heavy is credit to team!
Reaction score
64
thanks, but that's not actually the solution :(

JASS:
function Trig_Assigment_Conditions takes nothing returns boolean
    if ( not ( IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_Assigment_Func012C takes nothing returns boolean
    if ( not ( udg_Random_Number == 1.00 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Assigment_Func013C takes nothing returns boolean
    if ( not ( udg_Random_Number == 2.00 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Assigment_Func014C takes nothing returns boolean
    if ( not ( udg_Random_Number == 3.00 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Assigment_Actions takes nothing returns nothing
    local unit TriggUnit = GetTriggerUnit()
    local player TriggPlayer = GetOwningPlayer(udg_TriggUnit)
    local integer TriggPlayer_Wood = GetPlayerState(udg_TriggPlayer, PLAYER_STATE_RESOURCE_LUMBER)
    local integer TriggPlayer_Gold = GetPlayerState(udg_TriggPlayer, PLAYER_STATE_RESOURCE_GOLD)
    local real TriggUnit_MaxLife = GetUnitStateSwap(UNIT_STATE_MAX_LIFE, udg_TriggUnit)
    local real TriggUnit_MaxMana = GetUnitStateSwap(UNIT_STATE_MAX_MANA, udg_TriggUnit)




    call SetPlayerState   takes player TriggPlayer, gold whichPlayerState, ( TriggPlayer_Gold +  R2I(TriggUnit_MaxLife)) value returns nothing

-----------------------------------------------------------------------------

     call SetPlayerStateBJ( udg_TriggPlayer, PLAYER_STATE_RESOURCE_GOLD, ( udg_TriggPlayer_Gold + R2I(udg_TriggUnit_MaxLife) ) )
    call SetPlayerStateBJ( udg_TriggPlayer, PLAYER_STATE_RESOURCE_LUMBER, ( udg_TriggPlayer_Wood + R2I(udg_TriggUnit_MaxMana) ) )
    call SetUnitLifeBJ( udg_TriggUnit, udg_TriggUnit_MaxLife )
    call SetUnitManaBJ( udg_TriggUnit, udg_TriggUnit_MaxMana )
    set udg_Random_Number = GetRandomReal(1.00, 3.00)
    if ( Trig_Assigment_Func012C() ) then
        call ModifyHeroStat( bj_HEROSTAT_STR, udg_TriggUnit, bj_MODIFYMETHOD_ADD, 1 )
    else
    endif
    if ( Trig_Assigment_Func013C() ) then
        call ModifyHeroStat( bj_HEROSTAT_AGI, udg_TriggUnit, bj_MODIFYMETHOD_ADD, 1 )
    else
    endif
    if ( Trig_Assigment_Func014C() ) then
        call ModifyHeroStat( bj_HEROSTAT_INT, udg_TriggUnit, bj_MODIFYMETHOD_ADD, 1 )
    else
    endif
endfunction

//===========================================================================
function InitTrig_Assigment_Kopieren takes nothing returns nothing
    set gg_trg_Assigment_Kopieren = CreateTrigger(  )
    call TriggerAddCondition( gg_trg_Assigment_Kopieren, Condition( function Trig_Assigment_Conditions ) )
    call TriggerAddAction( gg_trg_Assigment_Kopieren, function Trig_Assigment_Actions )
endfunction


that's the full trigger. till the -------------- it's allmost finished. the rest not. I changed the "native" to "call" but it still didn't work :( What's wrong with it?!
 

Ninja_sheep

Heavy is credit to team!
Reaction score
64
Yeah :) it works. But i cant trust JC anymore :(

edit:
oO im still working on this trigger, but then more i work, then more triggers wich dont work i get -.- that's really annoying -.-

Question 7:

Why those triggers don't work?!

JASS:

    local real Random_Number = GetRandomReal(1.00, 3.00)


Code-order needed

JASS:

    call local integer = GetHeroAgi(TriggUnit, false)


function name needed

and here again the full trigger:

JASS:

function Trig_Assigment_Conditions takes nothing returns boolean
    if ( not ( IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_Assigment_Func012C takes nothing returns boolean
    if ( not ( udg_Random_Number == 1.00 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Assigment_Func013C takes nothing returns boolean
    if ( not ( udg_Random_Number == 2.00 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Assigment_Func014C takes nothing returns boolean
    if ( not ( udg_Random_Number == 3.00 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Assigment_Actions takes nothing returns nothing
    local unit TriggUnit = GetTriggerUnit()
    local player TriggPlayer = GetOwningPlayer(udg_TriggUnit)
    local integer TriggPlayer_Wood = GetPlayerState(udg_TriggPlayer, PLAYER_STATE_RESOURCE_LUMBER)
    local integer TriggPlayer_Gold = GetPlayerState(udg_TriggPlayer, PLAYER_STATE_RESOURCE_GOLD)
    local real TriggUnit_MaxLife = GetUnitStateSwap(UNIT_STATE_MAX_LIFE, udg_TriggUnit)
    local real TriggUnit_MaxMana = GetUnitStateSwap(UNIT_STATE_MAX_MANA, udg_TriggUnit)
    call SetPlayerState( TriggPlayer, PLAYER_STATE_RESOURCE_GOLD, TriggPlayer_Gold +  R2I(TriggUnit_MaxLife))
    call SetPlayerState( TriggPlayer, PLAYER_STATE_RESOURCE_LUMBER, TriggPlayer_Wood +  R2I(TriggUnit_MaxMana))
    call SetUnitState( TriggUnit, UNIT_STATE_LIFE, TriggUnit_MaxLife)
    call SetUnitState( TriggUnit, UNIT_STATE_MANA, TriggUnit_MaxMana)
    
// (>^.^>) (>^.^>) (>^.^>) (>^.^>) (>^.^>) (>^.^<) (<^.^<)(<^.^<) (<^.^<) (<^.^<) (<^.^<)    
// Till here the trigger is done
// (>^.^>) (>^.^>) (>^.^>) (>^.^>) (>^.^>) (>^.^<) (<^.^<)(<^.^<) (<^.^<) (<^.^<) (<^.^<)    

    local real Random_Number = GetRandomReal(1.00, 3.00)
    if ( Trig_Assigment_Func012C() ) then
    

    call local integer = GetHeroAgi(TriggUnit, false)

    call SetHeroAgi( TriggUnit, // AGI OF HERO + 1 //j_MODIFYMETHOD_ADD, 1 )



     else
    endif
    if ( Trig_Assigment_Func013C() ) then
        call ModifyHeroStat( bj_HEROSTAT_AGI, udg_TriggUnit, bj_MODIFYMETHOD_ADD, 1 )
    else
    endif
    if ( Trig_Assigment_Func014C() ) then
        call ModifyHeroStat( bj_HEROSTAT_INT, udg_TriggUnit, bj_MODIFYMETHOD_ADD, 1 )
    else
    endif
endfunction

//===========================================================================
function InitTrig_Assigment_Kopieren takes nothing returns nothing
    set gg_trg_Assigment_Kopieren = CreateTrigger(  )
    call TriggerAddCondition( gg_trg_Assigment_Kopieren, Condition( function Trig_Assigment_Conditions ) )
    call TriggerAddAction( gg_trg_Assigment_Kopieren, function Trig_Assigment_Actions )
endfunction
 

Duwenbasden

Ver 6 CREATE energy AS SELECT * FROM u.energy
Reaction score
165
JASS:
call local integer = GetHeroAgi(TriggUnit, false)

1. function call or variable declaration?
2. variable name?

JASS:
local real Random_Number = GetRandomReal(1.00, 3.00)

variable declarations must be the first items in the function
 

Ninja_sheep

Heavy is credit to team!
Reaction score
64
>1. function call or variable declaration?

oO, i removed the "call"

>2. variable name?

fixed :)

but still doesn't works :(
Endif' needed...

JASS:
local integer HeroAgi= GetHeroAgi(TriggUnit, false)


code-order needed...

>variable declarations must be the first items in the function

I dont understand. :(

thx anyway ;)
 

SFilip

Gone but not forgotten
Reaction score
634

Ninja_sheep

Heavy is credit to team!
Reaction score
64
yeah yeah yeah, it works















but not all...
New trigger now:
JASS:
function Trig_Assigment_Conditions takes nothing returns boolean
    if ( not ( IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_Assigment_Func012C takes nothing returns boolean
    if ( not ( udg_Random_Number == 1.00 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Assigment_Func013C takes nothing returns boolean
    if ( not ( udg_Random_Number == 2.00 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Assigment_Func014C takes nothing returns boolean
    if ( not ( udg_Random_Number == 3.00 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Assigment_Actions takes nothing returns nothing
    local unit TriggUnit = GetTriggerUnit()
    local player TriggPlayer = GetOwningPlayer(udg_TriggUnit)
    local integer TriggPlayer_Wood = GetPlayerState(udg_TriggPlayer, PLAYER_STATE_RESOURCE_LUMBER)
    local integer TriggPlayer_Gold = GetPlayerState(udg_TriggPlayer, PLAYER_STATE_RESOURCE_GOLD)
    local real TriggUnit_MaxLife = GetUnitStateSwap(UNIT_STATE_MAX_LIFE, udg_TriggUnit)
    local real TriggUnit_MaxMana = GetUnitStateSwap(UNIT_STATE_MAX_MANA, udg_TriggUnit)
    local integer HeroAgi
    local integer HeroStr
    local integer HeroInt
    call SetPlayerState( TriggPlayer, PLAYER_STATE_RESOURCE_GOLD, TriggPlayer_Gold +  R2I(TriggUnit_MaxLife))
    call SetPlayerState( TriggPlayer, PLAYER_STATE_RESOURCE_LUMBER, TriggPlayer_Wood +  R2I(TriggUnit_MaxMana))
    call SetUnitState( TriggUnit, UNIT_STATE_LIFE, TriggUnit_MaxLife)
    call SetUnitState( TriggUnit, UNIT_STATE_MANA, TriggUnit_MaxMana)
    
// (>^.^>) (>^.^>) (>^.^>) (>^.^>) (>^.^>) (>^.^<) (<^.^<)(<^.^<) (<^.^<) (<^.^<) (<^.^<)    
//                             Till here the trigger is done.
// (>^.^>) (>^.^>) (>^.^>) (>^.^>) (>^.^>) (>^.^<) (<^.^<)(<^.^<) (<^.^<) (<^.^<) (<^.^<)    

    local real Random_Number = GetRandomReal(1.00, 3.00)
    

    if ( Trig_Assigment_Func012C() ) then
        set HeroAgi = GetHeroAgi(TriggUnit, false)
        call SetHeroAgi( TriggUnit, (HeroAgi + 1) )
     else
    endif

    if ( Trig_Assigment_Func013C() ) then
        set HeroStr = GetHeroStr(TriggUnit, false)
        call SetHeroStr( TriggUnit, (HeroStr + 1) )
     else
    endif

    if ( Trig_Assigment_Func014C() ) then
        set HeroInt = GetHeroInt(TriggUnit, false)
        call SetHeroStr( TriggUnit, (HeroInt + 1))
    else
    endif
endfunction


in those 3 lines of the "if, then, else" (not those at start) the error is:
not-working number of arguments.

and the random number still doesn't works...
 

Chocobo

White-Flower
Reaction score
409
in those 3 lines of the "if, then, else" (not those at start) the error is:
not-working number of arguments.

and the random number still doesn't works...

You are missing an argument in SetHeroStr, Agi, and Int. (is permanent boolean)

Btw, you are not using RandomNumber, and udg_RandomNumber is ever 1.00.

Code:
function Trig_Assigment_Conditions takes nothing returns boolean
    return IsUnitType(GetTriggerUnit(),UNIT_TYPE_HERO)==true
endfunction

function Trig_Assigment_Actions takes nothing returns nothing
    local unit TriggUnit = GetTriggerUnit()
    local player TriggPlayer = GetOwningPlayer(udg_TriggUnit)
    local integer TriggPlayer_Wood = GetPlayerState(udg_TriggPlayer, PLAYER_STATE_RESOURCE_LUMBER)
    local integer TriggPlayer_Gold = GetPlayerState(udg_TriggPlayer, PLAYER_STATE_RESOURCE_GOLD)
    local real TriggUnit_MaxLife = GetUnitState(udg_TriggUnit,UNIT_STATE_MAX_LIFE)
    local real TriggUnit_MaxMana = GetUnitState(udg_TriggUnit,UNIT_STATE_MAX_MANA)
    local integer HeroAgi
    local integer HeroStr
    local integer HeroInt
    call SetPlayerState( TriggPlayer, PLAYER_STATE_RESOURCE_GOLD, TriggPlayer_Gold +  R2I(TriggUnit_MaxLife))
    call SetPlayerState( TriggPlayer, PLAYER_STATE_RESOURCE_LUMBER, TriggPlayer_Wood +  R2I(TriggUnit_MaxMana))
    call SetUnitState( TriggUnit, UNIT_STATE_LIFE, TriggUnit_MaxLife)
    call SetUnitState( TriggUnit, UNIT_STATE_MANA, TriggUnit_MaxMana)
[B]    local real Random_Number=GetRandomReal(1.00, 3.00)[/B]
    if [B]udg_[/B]Random_Number==1.0 then [B]//remove prefix[/B]
        set HeroAgi = GetHeroAgi(TriggUnit,false)
        call SetHeroAgi( TriggUnit,HeroAgi+1,true)
     else
    endif

    if [B]udg_[/B]Random_Number==2.0 then [B]//remove prefix[/B]
        set HeroStr = GetHeroStr(TriggUnit,false)
        call SetHeroStr(TriggUnit,HeroStr+1,true )
     else
    endif

    if [B]udg_[/B]Random_Number==3.0 then [B]//remove prefix[/B]
        set HeroInt = GetHeroInt(TriggUnit,false)
        call SetHeroStr( TriggUnit,HeroInt+1,true)
    else
    endif
endfunction
 

Ninja_sheep

Heavy is credit to team!
Reaction score
64
ok, i tried out you trigger. the if,then,else without using the if,then,elses of the top of the trigger is nice, but the problems are still the same...
If i remove the udgs it means, it needs a name...
and the randomnumber still doesn't works...
thx anyway...

JASS:
function Trig_Assigment_Conditions takes nothing returns boolean
    if ( not ( IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) == true ) ) then
        return false
    endif
    return true
endfunction


function Trig_Assigment_Actions takes nothing returns nothing
    local unit TriggUnit = GetTriggerUnit()
    local player TriggPlayer = GetOwningPlayer(udg_TriggUnit)
    local integer TriggPlayer_Wood = GetPlayerState(udg_TriggPlayer, PLAYER_STATE_RESOURCE_LUMBER)
    local integer TriggPlayer_Gold = GetPlayerState(udg_TriggPlayer, PLAYER_STATE_RESOURCE_GOLD)
    local real TriggUnit_MaxLife = GetUnitStateSwap(UNIT_STATE_MAX_LIFE, udg_TriggUnit)
    local real TriggUnit_MaxMana = GetUnitStateSwap(UNIT_STATE_MAX_MANA, udg_TriggUnit)
    local integer HeroAgi
    local integer HeroStr
    local integer HeroInt
    call SetPlayerState( TriggPlayer, PLAYER_STATE_RESOURCE_GOLD, TriggPlayer_Gold +  R2I(TriggUnit_MaxLife))
    call SetPlayerState( TriggPlayer, PLAYER_STATE_RESOURCE_LUMBER, TriggPlayer_Wood +  R2I(TriggUnit_MaxMana))
    call SetUnitState( TriggUnit, UNIT_STATE_LIFE, TriggUnit_MaxLife)
    call SetUnitState( TriggUnit, UNIT_STATE_MANA, TriggUnit_MaxMana)
    
// (>^.^>) (>^.^>) (>^.^>) (>^.^>) (>^.^>) (>^.^<) (<^.^<)(<^.^<) (<^.^<) (<^.^<) (<^.^<)    
//                             Till here the trigger is done.
// (>^.^>) (>^.^>) (>^.^>) (>^.^>) (>^.^>) (>^.^<) (<^.^<)(<^.^<) (<^.^<) (<^.^<) (<^.^<)    

    local real Random_Number=GetRandomReal(1.00, 3.00)
    

    if udg_Random_Number==1.0 then
        set HeroAgi = GetHeroAgi(TriggUnit, false)
        call SetHeroAgi( TriggUnit, (HeroAgi + 1) )
     else
    endif

    if udg_Random_Number==2.0 then
        set HeroStr = GetHeroStr(TriggUnit, false)
        call SetHeroStr( TriggUnit, (HeroStr + 1) )
     else
    endif

    if udg_Random_Number==3.0 then
        set HeroInt = GetHeroInt(TriggUnit, false)
        call SetHeroStr( TriggUnit, (HeroInt + 1))
    else
    endif
endfunction
 

Chocobo

White-Flower
Reaction score
409
GetRandomReal() instead of GetRandomInt()?

In theory, you have 3/301 chance to get on one of the if then elses.


JASS:
local integer RandomInt=GetRandomInt(1,3)



JASS:
function Trig_Assigment_Conditions takes nothing returns boolean
    return IsUnitType(GetTriggerUnit(),UNIT_TYPE_HERO)==true
endfunction

function Trig_Assigment_Actions takes nothing returns nothing
    local unit TriggUnit = GetTriggerUnit()
    local player TriggPlayer = GetOwningPlayer(udg_TriggUnit)
    local integer TriggPlayer_Wood = GetPlayerState(udg_TriggPlayer, PLAYER_STATE_RESOURCE_LUMBER)
    local integer TriggPlayer_Gold = GetPlayerState(udg_TriggPlayer, PLAYER_STATE_RESOURCE_GOLD)
    local real TriggUnit_MaxLife = GetUnitState(udg_TriggUnit,UNIT_STATE_MAX_LIFE)
    local real TriggUnit_MaxMana = GetUnitState(udg_TriggUnit,UNIT_STATE_MAX_MANA)
    local integer HeroAgi
    local integer HeroStr
    local integer HeroInt
    call SetPlayerState( TriggPlayer, PLAYER_STATE_RESOURCE_GOLD, TriggPlayer_Gold +  R2I(TriggUnit_MaxLife))
    call SetPlayerState( TriggPlayer, PLAYER_STATE_RESOURCE_LUMBER, TriggPlayer_Wood +  R2I(TriggUnit_MaxMana))
    call SetUnitState( TriggUnit, UNIT_STATE_LIFE, TriggUnit_MaxLife)
    call SetUnitState( TriggUnit, UNIT_STATE_MANA, TriggUnit_MaxMana)
    local integer RandomInt=GetRandomInt(1,3)
    if RandomInt==1.0 then
        set HeroAgi = GetHeroAgi(TriggUnit,false)
        call SetHeroAgi( TriggUnit,HeroAgi+1,true)
    endif

    if RandomInt==2.0 then
        set HeroStr = GetHeroStr(TriggUnit,false)
        call SetHeroStr(TriggUnit,HeroStr+1,true )
    endif

    if RandomInt==3 then
        set HeroInt = GetHeroInt(TriggUnit,false)
        call SetHeroStr( TriggUnit,HeroInt+1,true)
    endif
endfunction



And also, the else are useless since there is nothing that happens if the conditions aren't true.
 

Ninja_sheep

Heavy is credit to team!
Reaction score
64
>GetRandomReal() instead of GetRandomInt()?
Omg, i got the error! it's the same what sflip said allready: all locals have to be created at the begin...

>In theory, you have 3/301 chance to get on one of the if then elses.

i dont understand

New version:
JASS:
function Trig_Assigment_Conditions takes nothing returns boolean
    if ( not ( IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) == true ) ) then
        return false
    endif
    return true
endfunction


function Trig_Assigment_Actions takes nothing returns nothing
    local unit TriggUnit = GetTriggerUnit()
    local player TriggPlayer = GetOwningPlayer(udg_TriggUnit)
    local integer TriggPlayer_Wood = GetPlayerState(udg_TriggPlayer, PLAYER_STATE_RESOURCE_LUMBER)
    local integer TriggPlayer_Gold = GetPlayerState(udg_TriggPlayer, PLAYER_STATE_RESOURCE_GOLD)
    local real TriggUnit_MaxLife = GetUnitStateSwap(UNIT_STATE_MAX_LIFE, udg_TriggUnit)
    local real TriggUnit_MaxMana = GetUnitStateSwap(UNIT_STATE_MAX_MANA, udg_TriggUnit)
    local integer HeroAgi
    local integer HeroStr
    local integer HeroInt
    local real Random_Number
    call SetPlayerState( TriggPlayer, PLAYER_STATE_RESOURCE_GOLD, TriggPlayer_Gold +  R2I(TriggUnit_MaxLife))
    call SetPlayerState( TriggPlayer, PLAYER_STATE_RESOURCE_LUMBER, TriggPlayer_Wood +  R2I(TriggUnit_MaxMana))
    call SetUnitState( TriggUnit, UNIT_STATE_LIFE, TriggUnit_MaxLife)
    call SetUnitState( TriggUnit, UNIT_STATE_MANA, TriggUnit_MaxMana)
    
// (>^.^>) (>^.^>) (>^.^>) (>^.^>) (>^.^>) (>^.^<) (<^.^<)(<^.^<) (<^.^<) (<^.^<) (<^.^<)    
//                             Till here the trigger is done.
// (>^.^>) (>^.^>) (>^.^>) (>^.^>) (>^.^>) (>^.^<) (<^.^<)(<^.^<) (<^.^<) (<^.^<) (<^.^<)    

    set Random_Number=GetRandomReal(1.00, 3.00)
    

    if Random_Number==1.0 then
        set HeroAgi = GetHeroAgi(TriggUnit, false)
        call SetHeroAgi( TriggUnit, (HeroAgi + 1) )
     else
    endif

    if Random_Number==2.0 then
        set HeroStr = GetHeroStr(TriggUnit, false)
        call SetHeroStr( TriggUnit, (HeroStr + 1) )
     else
    endif

    if Random_Number==3.0 then
        set HeroInt = GetHeroInt(TriggUnit, false)
        call SetHeroStr( TriggUnit, (HeroInt + 1))
    else
    endif
endfunction

//===========================================================================
function InitTrig_Assigment_Kopieren takes nothing returns nothing
    set gg_trg_Assigment_Kopieren = CreateTrigger(  )
    call TriggerAddCondition( gg_trg_Assigment_Kopieren, Condition( function Trig_Assigment_Conditions ) )
    call TriggerAddAction( gg_trg_Assigment_Kopieren, function Trig_Assigment_Actions )
endfunction


all works fine, beside the if,then,elses

>And also, the else are useless since there is nothing that happens if the conditions aren't true.

i know, but i cant test the trigger if it's unactivateble. I fixed that now, but the elses are still bugged...
 

Duwenbasden

Ver 6 CREATE energy AS SELECT * FROM u.energy
Reaction score
165
Never compare equality of reals, it will never work. Instead, use integers from 1-300.
 

Ninja_sheep

Heavy is credit to team!
Reaction score
64
k, i did it:
JASS:
function Trig_Assigment_Conditions takes nothing returns boolean
    if ( not ( IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) == true ) ) then
        return false
    endif
    return true
endfunction


function Trig_Assigment_Actions takes nothing returns nothing
    local unit TriggUnit = GetTriggerUnit()
    local player TriggPlayer = GetOwningPlayer(udg_TriggUnit)
    local integer TriggPlayer_Wood = GetPlayerState(udg_TriggPlayer, PLAYER_STATE_RESOURCE_LUMBER)
    local integer TriggPlayer_Gold = GetPlayerState(udg_TriggPlayer, PLAYER_STATE_RESOURCE_GOLD)
    local real TriggUnit_MaxLife = GetUnitStateSwap(UNIT_STATE_MAX_LIFE, udg_TriggUnit)
    local real TriggUnit_MaxMana = GetUnitStateSwap(UNIT_STATE_MAX_MANA, udg_TriggUnit)
    local integer HeroAgi
    local integer HeroStr
    local integer HeroInt
    local real Random_Number
    call SetPlayerState( TriggPlayer, PLAYER_STATE_RESOURCE_GOLD, TriggPlayer_Gold +  R2I(TriggUnit_MaxLife))
    call SetPlayerState( TriggPlayer, PLAYER_STATE_RESOURCE_LUMBER, TriggPlayer_Wood +  R2I(TriggUnit_MaxMana))
    call SetUnitState( TriggUnit, UNIT_STATE_LIFE, TriggUnit_MaxLife)
    call SetUnitState( TriggUnit, UNIT_STATE_MANA, TriggUnit_MaxMana)
    
    set Random_Number=R2I(GetRandomReal(1.00, 3.00))
    
// (>^.^>) (>^.^>) (>^.^>) (>^.^>) (>^.^>) (>^.^<) (<^.^<)(<^.^<) (<^.^<) (<^.^<) (<^.^<)    
//                             Till here the trigger is done.
//                              Come on! It's allmost done!
// (>^.^>) (>^.^>) (>^.^>) (>^.^>) (>^.^>) (>^.^<) (<^.^<)(<^.^<) (<^.^<) (<^.^<) (<^.^<)    



    if Random_Number==1.0 then
        set HeroAgi = GetHeroAgi(TriggUnit, false)
        call SetHeroAgi( TriggUnit, (HeroAgi + 1) )
     else
    endif

    if Random_Number==2.0 then
        set HeroStr = GetHeroStr(TriggUnit, false)
        call SetHeroStr( TriggUnit, (HeroStr + 1) )
     else
    endif

    if Random_Number==3.0 then
        set HeroInt = GetHeroInt(TriggUnit, false)
        call SetHeroStr( TriggUnit, (HeroInt + 1))
    else
    endif
endfunction

//===========================================================================
function InitTrig_Assigment_Kopieren takes nothing returns nothing
    set gg_trg_Assigment_Kopieren = CreateTrigger(  )
    call TriggerAddCondition( gg_trg_Assigment_Kopieren, Condition( function Trig_Assigment_Conditions ) )
    call TriggerAddAction( gg_trg_Assigment_Kopieren, function Trig_Assigment_Actions )
endfunction


THE ENDIFS ARE STILL BUGGED /CRY!!!!!:mad: :mad: :mad: :( :( :mad: :mad: :nuts: :banghead: :banghead:
 

Doom-Angel

Jass User (Just started using NewGen)
Reaction score
167
well i don't get it why do u still use reals?
use integers....
also remove the 'else' u don't need it if u don't use it
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
Damn, this is a kind of weird code. Here is a better, non-syntaxing trigger:
JASS:
function Trig_Assigment_Conditions takes nothing returns boolean
    if ( not ( IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) == true ) ) then
        return false
    endif
    return true
endfunction


function Trig_Assigment_Actions takes nothing returns nothing
    local unit TriggUnit = GetTriggerUnit()
    local player TriggPlayer = GetOwningPlayer(TriggUnit)
    local integer TriggPlayer_Wood = GetPlayerState(TriggPlayer, PLAYER_STATE_RESOURCE_LUMBER)
    local integer TriggPlayer_Gold = GetPlayerState(TriggPlayer, PLAYER_STATE_RESOURCE_GOLD)
    local real TriggUnit_MaxLife = GetUnitStateSwap(UNIT_STATE_MAX_LIFE, TriggUnit)
    local real TriggUnit_MaxMana = GetUnitStateSwap(UNIT_STATE_MAX_MANA, TriggUnit)
    local real Random_Number = GetRandomReal(1.00, 3.00)
    local integer HeroAgi
    local integer HeroStr
    local integer HeroInt
    call SetPlayerState( TriggPlayer, PLAYER_STATE_RESOURCE_GOLD, TriggPlayer_Gold +  R2I(TriggUnit_MaxLife))
    call SetPlayerState( TriggPlayer, PLAYER_STATE_RESOURCE_LUMBER, TriggPlayer_Wood +  R2I(TriggUnit_MaxMana))
    call SetUnitState( TriggUnit, UNIT_STATE_LIFE, TriggUnit_MaxLife)
    call SetUnitState( TriggUnit, UNIT_STATE_MANA, TriggUnit_MaxMana)
    
// (>^.^>) (>^.^>) (>^.^>) (>^.^>) (>^.^>) (>^.^<) (<^.^<)(<^.^<) (<^.^<) (<^.^<) (<^.^<)    
//                             Till here the trigger is done.
// (>^.^>) (>^.^>) (>^.^>) (>^.^>) (>^.^>) (>^.^<) (<^.^<)(<^.^<) (<^.^<) (<^.^<) (<^.^<)    
    

    if Random_Number==1.0 then
        set HeroAgi = GetHeroAgi(TriggUnit, false)
        call SetHeroAgi( TriggUnit, (HeroAgi + 1), true )
    endif

    if Random_Number==2.0 then
        set HeroStr = GetHeroStr(TriggUnit, false)
        call SetHeroStr( TriggUnit, (HeroStr + 1), true )
    endif

    if Random_Number==3.0 then
        set HeroInt = GetHeroInt(TriggUnit, false)
        call SetHeroStr( TriggUnit, (HeroInt + 1), true )
    endif
endfunction


You don't use "udg_" for locals. Also, the "call SetHeroStr" has an invalid number of arguements, you must set whether it is permanent or not (boolean). I put true in the code given. Enjoy! :D

(The Real has to be set before any actions unless you set it during the code but create it at the beginning)
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1

      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