• 🏆 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!

[JASS] free gold every 8 seconds trigger

Status
Not open for further replies.
Level 2
Joined
Sep 30, 2006
Messages
9
hi,

i'm new here, how do i make trigger for every 8 seconds the bots will have 1200 gold. below is a script but tried it and wont workd. any help would be much appreciated.


thanks,
chickie



//===========================================================================
// Trigger: -free gold
//===========================================================================
function Trig_Free_Gold_FuncA takes nothing returns boolean
return ( InsaneMode_On == true )
endfunction


function Trig_Free_Gold_FuncB takes nothing returns nothing
call AdjustPlayerStateBJ( udg_TempInteger, GetEnumPlayer(), PLAYER_STATE_RESOURCE_GOLD )
endfunction

function Trig_Free_Gold_Actions takes nothing returns nothing
set udg_TempInteger = 8
if ( Trig_Free_Gold_FuncA() ) then
set udg_TempInteger = 1200
else
call DoNothing( )
endif
call ForForce( bj_FORCE_ALL_PLAYERS, function Trig_Free_Gold_FuncB)
endfunction

//===========================================================================
function InitTrig_Free_Gold_mtf takes nothing returns nothing
set gg_trg_Free_Gold_mtf = CreateTrigger( )
call DisableTrigger( gg_trg_Free_Gold_mtf)
call TriggerRegisterTimerEventPeriodic( gg_trg_Free_Gold_mtf, 8.00 )
call TriggerAddAction( gg_trg_Free_Gold_mtf, function Trig_Free_Gold_Actions )
endfunction
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
why did you post converted GUI?

anyways, first, a tip - put JASS in JASS tags.

also, assuming InsaneMode_On is a global, you have to add a udg_ to the beggining.

JASS:
//=========================================================================== 
// Trigger: -free gold 
//=========================================================================== 
function Trig_Free_Gold_FuncB takes nothing returns nothing
call SetPlayerState( GetEnumPlayer(), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState( GetEnumPlayer(), PLAYER_STATE_RESOURCE_GOLD ) + udg_TempInteger )
endfunction

function Trig_Free_Gold_Actions takes nothing returns nothing
set udg_TempInteger = 8
if udg_InsaneMode_On then
set udg_TempInteger = 1200
endif
call ForForce( bj_FORCE_ALL_PLAYERS, function
Trig_Free_Gold_FuncB)
endfunction

//===========================================================================
function InitTrig_Free_Gold_mtf takes nothing returns nothing
set gg_trg_Free_Gold_mtf = CreateTrigger( )
call DisableTrigger( gg_trg_Free_Gold_mtf)
call TriggerRegisterTimerEvent( gg_trg_Free_Gold_mtf, 8.00, true )
call TriggerAddAction( gg_trg_Free_Gold_mtf, function Trig_Free_Gold_Actions )
endfunction
 
Level 2
Joined
Sep 30, 2006
Messages
9
Hi Purplepoot,

thanks for your reply. I tried to put your corrections, but it seems not working.

Below is the trigger for insane mode. am i missing something?

Code:
[code=jass]
//===========================================================================
// Trigger: -Insane mode
//===========================================================================
function Trig_Command_Insane_Mode takes nothing returns boolean
    if ( not ( udg_InsaneMode_On == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_Insane_Actions_mtf takes nothing returns nothing
	if ( Trig_Command_Insane_Mode() ) then
		call DisplayTimedTextToForce(bj_FORCE_ALL_PLAYERS,20,"Insane mode On false.\n\n")   
    else
		call DisplayTimedTextToForce(bj_FORCE_ALL_PLAYERS,20,"Insane bot activated.\n\n")   
 		set udg_InsaneMode_On=true
	call DestroyTrigger(gg_trg_Insane_mtf)
    endif
endfunction

//===========================================================================
function InitTrig_Insane_mtf takes nothing returns nothing
    set gg_trg_Insane_mtf = CreateTrigger(  )
	call TriggerRegisterPlayerChatEvent(gg_trg_Insane_mtf,Player(1),"-mtf",true)
    call TriggerAddAction( gg_trg_Insane_mtf, function Trig_Insane_Actions_mtf )
endfunction


//=========================================================================== 
// Trigger: -free gold 
//=========================================================================== 
function Trig_Free_Gold_FuncB takes nothing returns nothing  
	call SetPlayerState( GetEnumPlayer(), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState( GetEnumPlayer(), PLAYER_STATE_RESOURCE_GOLD ) + udg_TempInteger ) 
endfunction   

function Trig_Free_Gold_Actions takes nothing returns nothing  
	set udg_TempInteger = 8 
	if udg_InsaneMode_On then  
		set udg_TempInteger = 1200 
	endif  
	call ForForce( bj_FORCE_ALL_PLAYERS, function  Trig_Free_Gold_FuncB) 
endfunction   

//=========================================================================== 
function InitTrig_Free_Gold_mtf takes nothing returns nothing  
	set gg_trg_Free_Gold_mtf = CreateTrigger( )  
	call DisableTrigger( gg_trg_Free_Gold_mtf)  
	call TriggerRegisterTimerEvent( gg_trg_Free_Gold_mtf, 8.00, true )  
	call TriggerAddAction( gg_trg_Free_Gold_mtf, function Trig_Free_Gold_Actions ) 
endfunction
[/code][/code]
 
Level 5
Joined
May 22, 2006
Messages
150
Of course.
The trigger has to be turned off on game start, as the effect shall not take place until "insane mode" is activated.
Once this occurs, the trigger has to be activated, but not a piece of a second before. ^^
 
Level 2
Joined
Sep 30, 2006
Messages
9
guys you are correct. thank you very much. i didn't see that. it is working now.

my question is how do I set it to only bots, the human players should not get the free gold?



best regards,
chickie
 
Level 5
Joined
May 22, 2006
Messages
150
JASS:
function Trig_Free_Gold_FuncB takes nothing returns nothing
  if GetPlayerController(GetEnumPlayer()) == MAP_CONTROL_COMPUTER then
    call SetPlayerState(GetEnumPlayer(),PLAYER_STATE_RESOURCE_GOLD,GetPlayerState(GetEnumPlayer(),PLAYER_STATE_RESOURCE_GOLD) + udg_TempInteger)
endfunction

OR

JASS:
function Trig_Free_Gold_Actions takes nothing returns nothing
  if udg_InsaneMode_On then
    set udg_TempInteger = 1200
  else
    set udg_TempInteger = 8
  endif
  call ForForce(GetPlayersByMapControl(MAP_CONTROL_COMPUTER),function Trig_Free_Gold_FuncB)
endfunction

OR (better)

JASS:
globals
  force udg_ComputerPlayers = null
  [...]
endglobals

function Trig_Free_Gold_Actions takes nothing returns nothing
  if udg_InsaneMode_On then
    set udg_TempInteger = 1200
  else
    set udg_TempInteger = 8
  endif
  call ForForce(udg_ComputerPlayers,function 
Trig_Free_Gold_FuncB)
endfunction

function InitTrig_Free_Gold_mtf takes nothing returns nothing
  set udg_ComputerPlayers = GetPlayersByMapControl(MAP_CONTROL_COMPUTER)
  [...]
endfunction
 
Level 5
Joined
May 22, 2006
Messages
150
Look into blizzard.j . (seek for "GetPlayersByMapControl")
They wrote not only dumb stuff into. ^^

It returns a force, which collects all players for (PlayerController(Player(x)) == MAP_CONTROL_COMPUTER) with x being 0 - 15.
 
Level 2
Joined
Sep 30, 2006
Messages
9
Guys,

This is so sweet. It works now like a charm. Now I have to concentrate on other AI.

Thank you very much gurus.
chickie
 
Status
Not open for further replies.
Top