HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Giving item to AI

01-29-2006, 01:31 PM#1
SmileyJeff
Trigger:
AI get item
Collapse Events
Time - Every 5.00 seconds of game time
Conditions
Collapse Actions
Collapse For each (Integer A) from 3 to 5, do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
((Player((Integer A))) controller) Equal to Computer
((Player((Integer A))) Current gold) Greater than or equal to 1000
((Player((Integer A))) Current lumber) Greater than or equal to 1
Collapse Then - Actions
Collapse Unit Group - Pick every unit in (Units owned by (Player((Integer A))) matching ((((Matching unit) is A Hero) Equal to True) and (((Matching unit) is alive) Equal to True))) and do (Actions)
Collapse Loop - Actions
Hero - Create Item and give it to (Picked unit)
Player - Add -1000 to (Owner of (Picked unit)) Current gold
Player - Add -1 to (Owner of (Picked unit)) Current lumber
Else - Actions

The above trigger got a big problem. It will still give human players an item. Why??

Smiley
01-29-2006, 04:08 PM#2
PCPharaoh
Does it give items to all human players, or just to the one's in 3 - 5 positions (teal, purple, yellow)? I'm asking because it could be because GUI refers to players in 1, 2, 3, and JASS refers to them 0, 1, 2. Just guessing here, but it could be you want comp players @ purple, yellow, orange to get items, and not teal purple yellow. GetConvertedPlayerId, which is the function used in GUI to have a number specify a player, adds 1 to the number you specify. I know this has confused me on more than one occasion.
01-29-2006, 04:13 PM#3
SmileyJeff
3 - 5.
Example:
If player 3 and 4 is human players, while player 5 is AI. When player 3 or 4 gets the gold and lumber condition, it will give the item automatically to the players. While ignoring the condition "Player interger A controller equals to computer". It works fine for AI too. But i just don't want this trigger to work on human players. Since they can buy items thier own.

I tried pick every player action. I tried like 3 other methods, but it just ignore the condition if controller = computer..
01-29-2006, 04:17 PM#4
PCPharaoh
It could be that there's something wrong with computer-controlled function. Maybe try doing Condition: Player controller is not user.
01-29-2006, 04:31 PM#5
SmileyJeff
I don't think its the condition prob, cos i used alot in other AI func. But i tried it out, still not working. Can't firgure it out @@
01-29-2006, 05:10 PM#6
Zoxc
Try to convert it to Custom Script and post it here. With the neat [jass]-tag ;)
01-30-2006, 05:42 AM#7
SmileyJeff
Collapse JASS:
function Trig_Untitled_Trigger_001_Func001Func001Func001001002001 takes nothing returns boolean
    return ( IsUnitType(GetFilterUnit(), UNIT_TYPE_HERO) == true )
endfunction

function Trig_Untitled_Trigger_001_Func001Func001Func001001002002 takes nothing returns boolean
    return ( IsUnitAliveBJ(GetFilterUnit()) == true )
endfunction

function Trig_Untitled_Trigger_001_Func001Func001Func001001002 takes nothing returns boolean
    return GetBooleanAnd( Trig_Untitled_Trigger_001_Func001Func001Func001001002001(), Trig_Untitled_Trigger_001_Func001Func001Func001001002002() )
endfunction

function Trig_Untitled_Trigger_001_Func001Func001Func001A takes nothing returns nothing
    call UnitAddItemByIdSwapped( 'texp', GetEnumUnit() )
    call AdjustPlayerStateBJ( -1000, GetOwningPlayer(GetEnumUnit()), PLAYER_STATE_RESOURCE_GOLD )
    call AdjustPlayerStateBJ( -1, GetOwningPlayer(GetEnumUnit()), PLAYER_STATE_RESOURCE_LUMBER )
endfunction

function Trig_Untitled_Trigger_001_Func001Func001C takes nothing returns boolean
    if ( not ( GetPlayerController(ConvertedPlayer(GetForLoopIndexA())) == MAP_CONTROL_COMPUTER ) ) then
        return false
    endif
    if ( not ( GetPlayerState(ConvertedPlayer(GetForLoopIndexA()), PLAYER_STATE_RESOURCE_GOLD) >= 1000 ) ) then
        return false
    endif
    if ( not ( GetPlayerState(ConvertedPlayer(GetForLoopIndexA()), PLAYER_STATE_RESOURCE_LUMBER) >= 1 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing
    set bj_forLoopAIndex = 3
    set bj_forLoopAIndexEnd = 5
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        if ( Trig_Untitled_Trigger_001_Func001Func001C() ) then
            call ForGroupBJ( GetUnitsOfPlayerMatching(ConvertedPlayer(GetForLoopIndexA()), Condition(function Trig_Untitled_Trigger_001_Func001Func001Func001001002)), function Trig_Untitled_Trigger_001_Func001Func001Func001A )
        else
        endif
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
endfunction

//===========================================================================
function InitTrig_Untitled_Trigger_001 takes nothing returns nothing
    set gg_trg_Untitled_Trigger_001 = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Untitled_Trigger_001, 5.00 )
    call TriggerAddAction( gg_trg_Untitled_Trigger_001, function Trig_Untitled_Trigger_001_Actions )
endfunction

Here it is.
01-31-2006, 07:55 AM#8
SmileyJeff
Sorry for Double Post, hope someone would help.
01-31-2006, 01:53 PM#9
Vexorian
The thing is that it should be working all right, mind attaching a map with the failing trigger and an evnironment where it fails? so I/we could look for a cause? The reason is that the trigger seems all right so it might be caused by other things