Adding triggers in Jass issue

General talk about editing, cheating, and deprotecting maps.

Moderator: Cheaters

Mordred
Newcomer
Posts: 4
Joined: September 18th, 2008, 12:16 am

Adding triggers in Jass issue

Post by Mordred »

Alright. So I'm working on editing a version of Village Builder gold; added in a new race and everythings working except for one part. For income on the map, you need to build certain units and for each unit built, every x amount of seconds it generates anywhere from 2-4 gold. I've pinpointed these down to these triggers

Spoiler:
Under Globals
integer udg_twomoney=2

Under endglobals
function Trig_ResidentTroll_Conditions takes nothing returns boolean
return ((IsUnitAliveBJ(GetTrainedUnit())))and((GetUnitTypeId(GetTrainedUnit())=='e00B'))
endfunction
function Trig_ResidentTroll_Actions takes nothing returns nothing
call AdjustPlayerStateBJ(udg_twomoney,GetOwningPlayer(GetTriggerUnit()),PLAYER_STATE_RESOURCE_GOLD)
call TriggerSleepAction(35.00)
call ConditionalTriggerExecute(GetTriggeringTrigger())
endfunction

Under Function Main
set gg_trg_ResidentTroll=CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(gg_trg_ResidentTroll,EVENT_PLAYER_UNIT_TRAIN_FINISH)
call TriggerAddCondition(gg_trg_ResidentTroll,Condition(function Trig_ResidentTroll_Conditions))
call TriggerAddAction(gg_trg_ResidentTroll,function Trig_ResidentTroll_Actions)
From what I can gather the sleep action is the time between it adds the set amount gold, which is defined by udg_twomoney, and e00B is the rawcode for the unit that gives it.

So, to add in the new data for the new units, I added this in.
Spoiler:
Under Globals
integer udg_fivemoney=5

Under endglobals
function Trig_ResidentBonus_Conditions takes nothing returns boolean
return ((IsUnitAliveBJ(GetTrainedUnit())))and((GetUnitTypeId(GetTrainedUnit())=='h03E'))
endfunction
function Trig_ResidentBonus_Actions takes nothing returns nothing
call AdjustPlayerStateBJ(udg_fivemoney,GetOwningPlayer(GetTriggerUnit()),PLAYER_STATE_RESOURCE_GOLD)
call TriggerSleepAction(30.00)
call ConditionalTriggerExecute(GetTriggeringTrigger())
endfunction

Under Function Main
set gg_trg_ResidentBonus=CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(gg_trg_ResidentBonus,EVENT_PLAYER_UNIT_TRAIN_FINISH)
call TriggerAddCondition(gg_trg_ResidentBonus,Condition(function Trig_ResidentBonus_Conditions))
call TriggerAddAction(gg_trg_ResidentBonus,function Trig_ResidentBonus_Actions)
If I do not add these in, the map works fine. However when I do add these, the map does not work. The way it does not work is that if I select it from single player it dosen't show that there is any player slots at all and if I click okay to play it, it just instantly returns back to map selection. Any ideas, thoughts?
User avatar
Kryptonyte
Forum Staff
Posts: 1400
Joined: March 17th, 2008, 12:07 am

Re: Adding triggers in Jass issue

Post by Kryptonyte »

Ever bother to run a syntax error check? Add those to a map's .j file, and press F9,
you have an error here; set gg_trg_ResidentBonus=CreateTrigger()
Image
Made by the late ILikeHacking

My quote from SKillER
Spoiler:
Chat wrote:(19:12:41) SKillER: newfags cant triforce
(19:20:30) SKillER: ▲
▲ ▲
(19:20:35) SKillER: aww
(19:20:37) FatherSpace: FAIL
(19:20:43) Kryptonyte: Wow stop failing.
(19:20:47) SKillER: ▲
▲ ▲
(19:21:41) Kryptonyte: .

. ▲
▲ ▲
(19:22:20) Kryptonyte: I guess you were right, newfags can't triforce.
(19:22:29) SKillER: . . ▲
▲ ▲
(19:23:04) SKillER: OMFG
(19:23:06) SKillER: ... THIS CHAT
(19:23:06) SKillER: !
(19:23:36) SKillER: ▲
▲ ▲
(19:23:46) SKillER: ▲
.▲ ▲
Apparently, SKillER is a newfag.
Mordred
Newcomer
Posts: 4
Joined: September 18th, 2008, 12:16 am

Re: Adding triggers in Jass issue

Post by Mordred »

Ah, forgot to declare it at the top. Thanks!
Also, one more quick question if I can, the units are technically buildings and built; should it still be GetTrainedUnit or something like GetBuiltUnit?
User avatar
Kryptonyte
Forum Staff
Posts: 1400
Joined: March 17th, 2008, 12:07 am

Re: Adding triggers in Jass issue

Post by Kryptonyte »

If it's built, then go with GetBuiltUnit.
Image
Made by the late ILikeHacking

My quote from SKillER
Spoiler:
Chat wrote:(19:12:41) SKillER: newfags cant triforce
(19:20:30) SKillER: ▲
▲ ▲
(19:20:35) SKillER: aww
(19:20:37) FatherSpace: FAIL
(19:20:43) Kryptonyte: Wow stop failing.
(19:20:47) SKillER: ▲
▲ ▲
(19:21:41) Kryptonyte: .

. ▲
▲ ▲
(19:22:20) Kryptonyte: I guess you were right, newfags can't triforce.
(19:22:29) SKillER: . . ▲
▲ ▲
(19:23:04) SKillER: OMFG
(19:23:06) SKillER: ... THIS CHAT
(19:23:06) SKillER: !
(19:23:36) SKillER: ▲
▲ ▲
(19:23:46) SKillER: ▲
.▲ ▲
Apparently, SKillER is a newfag.
Mordred
Newcomer
Posts: 4
Joined: September 18th, 2008, 12:16 am

Re: Adding triggers in Jass issue

Post by Mordred »

Spoiler:
Under endglobals
function Trig_ResidentBonus_Conditions takes nothing returns boolean
return ((IsUnitAliveBJ(GetTrainedUnit())))and((GetUnitTypeId(GetTrainedUnit())=='h03E'))
endfunction

Under Function Main
set gg_trg_ResidentBonus=CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(gg_trg_ResidentBonus,EVENT_PLAYER_UNIT_TRAIN_FINISH)
call TriggerAddCondition(gg_trg_ResidentBonus,Condition(function Trig_ResidentBonus_Conditions))
call TriggerAddAction(gg_trg_ResidentBonus,function Trig_ResidentBonus_Actions)


Changed EVENT_PLAYER_UNIT_TRAIN_FINISH to EVENT_PLAYER_UNIT_CONSTRUCT_FINISH, and GetTrainedUnit to GetConstructedStructure, but still nothing.
Mordred
Newcomer
Posts: 4
Joined: September 18th, 2008, 12:16 am

Re: Adding triggers in Jass issue

Post by Mordred »

Any ideas?