• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Translate this in to Trigger

Status
Not open for further replies.
Level 8
Joined
Jun 16, 2008
Messages
333
JASS:
function Trig_Stats_Func001001002 takes nothing returns boolean
    return ( IsUnitType(GetFilterUnit(), UNIT_TYPE_HERO) == true )
endfunction

function Trig_Stats_Func001002 takes nothing returns nothing
    set udg_hero = GetEnumUnit()
endfunction


All you have to do is tell me what it means or make it into a trigger
 
That is just part of the code. Well, I'll explain it in comments since I can't directly translate it. (I need the group creation code)

JASS:
function Trig_Stats_Func001001002 takes nothing returns boolean
    return ( IsUnitType(GetFilterUnit(), UNIT_TYPE_HERO) == true )
//This is a filter/"matching condition" part for the unit group
//It checks if the "Matching unit" is a Hero equal to True
endfunction

function Trig_Stats_Func001002 takes nothing returns nothing
    set udg_hero = GetEnumUnit()
//This sets the variable "hero" to (Picked Unit)
//This function is the "Loop - Actions" of a Pick Every Unit in...
endfunction

=)
 
Level 8
Joined
Jun 16, 2008
Messages
333
JASS:
function Trig_Stats_Conditions takes nothing returns boolean
    if ( not ( GetPlayerState(GetTriggerPlayer(), PLAYER_STATE_RESOURCE_GOLD) > 100 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Stats_Func001001002 takes nothing returns boolean
    return ( IsUnitType(GetFilterUnit(), UNIT_TYPE_HERO) == true )
endfunction

function Trig_Stats_Func001002 takes nothing returns nothing
    set udg_hero = GetEnumUnit()
endfunction

function Trig_Stats_Func003001 takes nothing returns boolean
    return ( GetEventPlayerChatString() == "-agi max" )
endfunction

function Trig_Stats_Func004001 takes nothing returns boolean
    return ( GetEventPlayerChatString() == "-str max" )
endfunction

function Trig_Stats_Func005001 takes nothing returns boolean
    return ( GetEventPlayerChatString() == "-int max" )
endfunction

function Trig_Stats_Actions takes nothing returns nothing
    call ForGroupBJ( GetUnitsOfPlayerMatching(GetTriggerPlayer(), Condition(function Trig_Stats_Func001001002)), function Trig_Stats_Func001002 )
    if ( Trig_Stats_Func003001() ) then
        call ConditionalTriggerExecute( gg_trg_agi )
    else
        call DoNothing(  )
    endif
    if ( Trig_Stats_Func004001() ) then
        call ConditionalTriggerExecute( gg_trg_str )
    else
        call DoNothing(  )
    endif
    if ( Trig_Stats_Func005001() ) then
        call ConditionalTriggerExecute( gg_trg_int )
    else
        call DoNothing(  )
    endif
endfunction

//===========================================================================
function InitTrig_Stats takes nothing returns nothing
    set gg_trg_Stats = CreateTrigger(  )
    call TriggerRegisterPlayerChatEvent( gg_trg_Stats, Player(2), "max", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_Stats, Player(3), "max", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_Stats, Player(4), "max", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_Stats, Player(5), "max", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_Stats, Player(6), "max", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_Stats, Player(7), "max", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_Stats, Player(8), "max", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_Stats, Player(9), "max", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_Stats, Player(10), "max", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_Stats, Player(11), "max", false )
    call TriggerAddCondition( gg_trg_Stats, Condition( function Trig_Stats_Conditions ) )
    call TriggerAddAction( gg_trg_Stats, function Trig_Stats_Actions )
endfunction
thats the full code... dam i should really learn jass
 
Level 31
Joined
May 3, 2008
Messages
3,155
remove the do nothing, they're useless call that call another call that does particallly nothing.

JASS:
function Trig_Stats_Conditions takes nothing returns boolean
    if ( not ( GetPlayerState(GetTriggerPlayer(), PLAYER_STATE_RESOURCE_GOLD) > 100 ) ) then
        return false
    endif
    return true
endfunction

Cut it right this.

JASS:
function Trig_Stats_Conditions takes nothing returns boolean
    return ( GetPlayerState(GetTriggerPlayer(), PLAYER_STATE_RESOURCE_GOLD) > 100 )
endfunction
 
Here you go:
  • Trigger
    • Events
      • Player - Player 3 (Teal) types a chat message containing max as A substring
      • Player - Player 4 (Purple) types a chat message containing max as A substring
      • Player - Player 5 (Yellow) types a chat message containing max as A substring
      • Player - Player 6 (Orange) types a chat message containing max as A substring
      • Player - Player 7 (Green) types a chat message containing max as A substring
      • Player - Player 8 (Pink) types a chat message containing max as A substring
      • Player - Player 9 (Gray) types a chat message containing max as A substring
      • Player - Player 10 (Light Blue) types a chat message containing max as A substring
      • Player - Player 11 (Dark Green) types a chat message containing max as A substring
      • Player - Player 12 (Brown) types a chat message containing max as A substring
    • Conditions
      • ((Triggering player) Current gold) Greater than 100
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True)) and do (Actions)
        • Loop - Actions
          • Set hero = (Picked unit)
      • If ((Entered chat string) Equal to -agi max) then do (Trigger - Run agi <gen> (checking conditions)) else do (Do nothing)
      • If ((Entered chat string) Equal to -str max) then do (Trigger - Run str <gen> (checking conditions)) else do (Do nothing)
      • If ((Entered chat string) Equal to -int max) then do (Trigger - Run int <gen> (checking conditions)) else do (Do nothing)
Enjoy. =) The custom script is just to fix the leak.
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
JASS:
function Is_Hero_Unit_Util takes unit whichHero returns boolean
    if (IsUnitType(whichHero,UNIT_TYPE_HERO)) then
        set udg_hero = whichHero
    endif
    return false
endfunction
 
function Is_Hero_Unit takes nothing returns boolean
    return Is_Hero_Unit_Util(GetFilterUnit())
endfunction
 
function Trig_Stats_Actions takes nothing returns nothing
    local player p = GetTriggerPlayer()
    local string chatStr = GetEventPlayerChatString()
    if(GetPlayerState(p,PLAYER_STATE_RESOURCE_GOLD) > 100)then
        call GroupEnumUnitsOfPlayer(bj_lastCreatedGroup,p,Filter(function Is_Hero_Unit))
        //
        if(chatStr == "-agi max" and TriggerEvaluate(gg_trg_agi))then
            call TriggerExecute(gg_trg_agi)
        //
        elseif(chatStr == "-str max" and TriggerEvaluate(gg_trg_str))then
            call TriggerExecute(gg_trg_str)
        //
        elseif(chatStr == "-int max" and TriggerEvaluate(gg_trg_int))then
            call TriggerExecute(gg_trg_int)
        endif
    endif
endfunction
 
//===========================================================================
function InitTrig_Stats takes nothing returns nothing
    local integer i = 11
    local trigger t = CreateTrigger()
    call TriggerAddAction(t,function Trig_Stats_Actions)
    loop
        call TriggerRegisterPlayerChatEvent(t,Player(i),"max",false)
        exitwhen(i == 2)
        set i = i - 1
    endloop
endfunction
 
Level 8
Joined
Jun 16, 2008
Messages
333
function Is_Hero_Unit_Util takes unit whichHero returns boolean
if (IsUnitType(whichHero,UNIT_TYPE_HERO)) then
set udg_hero = whichHero
endif
return false
endfunction

function Is_Hero_Unit takes nothing returns boolean
return Is_Hero_Unit_Util(GetFilterUnit())
endfunction

function Trig_Stats_Actions takes nothing returns nothing
local player p = GetTriggerPlayer()
local string chatStr = GetEventPlayerChatString()
if(GetPlayerState(p,PLAYER_STATE_RESOURCE_GOLD) > 100)then
call GroupEnumUnitsOfPlayer(bj_lastCreatedGroup,p,Filter(function Is_Hero_Unit))
//
if(chatStr == "-agi max" and TriggerEvaluate(gg_trg_agi))then
call TriggerExecute(gg_trg_agi)
//
elseif(chatStr == "-str max" and TriggerEvaluate(gg_trg_str))then
call TriggerExecute(gg_trg_str)
//
elseif(chatStr == "-int max" and TriggerEvaluate(gg_trg_int))then
call TriggerExecute(gg_trg_int)
endif
endif
endfunction

//===========================================================================
function InitTrig_Stats takes nothing returns nothing
local integer i = 11
local trigger t = CreateTrigger()
call TriggerAddAction(t,function Trig_Stats_Actions)
loop
call TriggerRegisterPlayerChatEvent(t,Player(i),"max",false)
exitwhen(i == 2)
set i = i - 1
endloop
endfunction
it is working... idk is it supposed to be 2 -12 or what? cuz i need 1 -10
 
For the "InitTrig" function, it would be this for players 1-10:
JASS:
function InitTrig_Stats takes nothing returns nothing
    local integer i = 9
    local trigger t = CreateTrigger()
    call TriggerAddAction(t,function Trig_Stats_Actions)
    loop
        call TriggerRegisterPlayerChatEvent(t,Player(i),"max",false)
        exitwhen i == 0
        set i = i - 1
    endloop
endfunction
 
Status
Not open for further replies.
Top