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.

      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