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

Custom Harvest System for Multiple Resources

Status
Not open for further replies.
Level 11
Joined
Mar 31, 2016
Messages
657
normal warcraft food or your custom food, explain more
lol no. default food is population. it needs to be linked to gold because its unused right now. lumber is linked to lumber, cant you link another resource to gold?

food is a custom resource that works like food from Age of Empires, harvested from fish/animals/plants/farms.
Instead of linking it to the leaderboard like most the resources in your harvest system, I want it to be linked to gold.
 
Level 18
Joined
Nov 21, 2012
Messages
835
well..... my friend
  • you didn't import new Bribe's UnitEvent
  • you didn't set correct value in library CustomResources for DUMMY_TREE_CHECKER
  • you didn't follow instruction from this post Custom Harvest System for Multiple Resources when importind CR library update
  • you tryed to harvest food from "barrel" which is DEBRIS!, must be a tree
  • you didn't set ability "Return Lumber" for all 3 Granary buildings
UmbraUnda I did this libraries for you, but as it is public resource now, you have to remember to make your map-specific changes also read descripion carefully. Don't get me wrong but you're requesting very sophisticated systems that require more attention from you as a creator
 

Attachments

  • MRv01i.w3x
    16.5 MB · Views: 64
Level 11
Joined
Mar 31, 2016
Messages
657
well..... my friend
  • you didn't import new Bribe's UnitEvent
  • you didn't set correct value in library CustomResources for DUMMY_TREE_CHECKER
  • you didn't follow instruction from this post Custom Harvest System for Multiple Resources when importind CR library update
  • you tryed to harvest food from "barrel" which is DEBRIS!, must be a tree
  • you didn't set ability "Return Lumber" for all 3 Granary buildings
UmbraUnda I did this libraries for you, but as it is public resource now, you have to remember to make your map-specific changes also read descripion carefully. Don't get me wrong but you're requesting very sophisticated systems that require more attention from you as a creator

Thanks mate. I feel you, however you don't exactly give easy to follow instructions.
Also the map I sent you was an older version because the new one was too broken - this excuses the barrel food destructible and granary missing return lumber.
And remember I'm not that skilled in triggering - although I do need to get better.

Appreciate all the help, I'll do my best to get better.

Just one issue - food starting amount resets from 400 to 0 when resource is dropped off for the first time.
 
Last edited:
Level 18
Joined
Nov 21, 2012
Messages
835
its for leaderboard, just forgot to make it inside the map:
  • lb
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Set tempInt = (Player number of (Picked player))
          • Leaderboard - Create a leaderboard for (Player group((Picked player))) titled Resources
          • Set lb[tempInt] = (Last created leaderboard)
          • Leaderboard - Add Player 12 (Brown) to lb[tempInt] with label Clay and value 0
          • Leaderboard - Add Player 9 (Gray) to lb[tempInt] with label Stone and value 0
          • Leaderboard - Add Player 10 (Light Blue) to lb[tempInt] with label Ore and value 0
          • Leaderboard - Add Player 5 (Yellow) to lb[tempInt] with label Gold and value 0
update leaderboard:
JASS:
function Trig_update2_Actions takes nothing returns nothing
    local integer i = GetPlayerId(udg_Resource_Player)+1
    local integer Clay = GetPlayerCustomResource(udg_Resource_Player, 2)
    local integer Stone = GetPlayerCustomResource(udg_Resource_Player, 3)
    local integer Ore = GetPlayerCustomResource(udg_Resource_Player, 4)
   local integer Gold = GetPlayerCustomResource(udg_Resource_Player, 5)
   
    call LeaderboardSetPlayerItemValueBJ( Player(11), udg_lb[i], Clay)
    call LeaderboardSetPlayerItemValueBJ( Player(8), udg_lb[i], Stone)
    call LeaderboardSetPlayerItemValueBJ( Player(9), udg_lb[i], Ore)
    call LeaderboardSetPlayerItemValueBJ( Player(4), udg_lb[i], Gold)
   
endfunction
//==============================================================
function InitTrig_update2 takes nothing returns nothing
    set gg_trg_update2 = CreateTrigger(  )
    call TriggerRegisterVariableEvent( gg_trg_update2, "udg_Resource_Event", EQUAL, 2.00 )
    call TriggerRegisterVariableEvent( gg_trg_update2, "udg_Resource_Event", EQUAL, 3.00 )
    call TriggerRegisterVariableEvent( gg_trg_update2, "udg_Resource_Event", EQUAL, 4.00 )
    call TriggerRegisterVariableEvent( gg_trg_update2, "udg_Resource_Event", EQUAL, 5.00 )
    call TriggerAddAction( gg_trg_update2, function Trig_update2_Actions )
endfunction

  • FoodGold
    • Events
      • Game - Resource_Event becomes Equal to 6.00
    • Conditions
    • Actions
      • Custom script: set udg_tempInt = GetPlayerCustomResource(udg_Resource_Player, 6)
      • Player - Set Resource_Player Current gold to tempInt
if you need starting food: 400 please use this
  • startingFood
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Custom script: call AdjustPlayerCustomResource(GetEnumPlayer(), 6, 400)
 
Level 11
Joined
Mar 31, 2016
Messages
657
its for leaderboard, just forgot to make it inside the map:
  • lb
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Set tempInt = (Player number of (Picked player))
          • Leaderboard - Create a leaderboard for (Player group((Picked player))) titled Resources
          • Set lb[tempInt] = (Last created leaderboard)
          • Leaderboard - Add Player 12 (Brown) to lb[tempInt] with label Clay and value 0
          • Leaderboard - Add Player 9 (Gray) to lb[tempInt] with label Stone and value 0
          • Leaderboard - Add Player 10 (Light Blue) to lb[tempInt] with label Ore and value 0
          • Leaderboard - Add Player 5 (Yellow) to lb[tempInt] with label Gold and value 0
update leaderboard:
JASS:
function Trig_update2_Actions takes nothing returns nothing
    local integer i = GetPlayerId(udg_Resource_Player)+1
    local integer Clay = GetPlayerCustomResource(udg_Resource_Player, 2)
    local integer Stone = GetPlayerCustomResource(udg_Resource_Player, 3)
    local integer Ore = GetPlayerCustomResource(udg_Resource_Player, 4)
   local integer Gold = GetPlayerCustomResource(udg_Resource_Player, 5)
  
    call LeaderboardSetPlayerItemValueBJ( Player(11), udg_lb[i], Clay)
    call LeaderboardSetPlayerItemValueBJ( Player(8), udg_lb[i], Stone)
    call LeaderboardSetPlayerItemValueBJ( Player(9), udg_lb[i], Ore)
    call LeaderboardSetPlayerItemValueBJ( Player(4), udg_lb[i], Gold)
  
endfunction
//==============================================================
function InitTrig_update2 takes nothing returns nothing
    set gg_trg_update2 = CreateTrigger(  )
    call TriggerRegisterVariableEvent( gg_trg_update2, "udg_Resource_Event", EQUAL, 2.00 )
    call TriggerRegisterVariableEvent( gg_trg_update2, "udg_Resource_Event", EQUAL, 3.00 )
    call TriggerRegisterVariableEvent( gg_trg_update2, "udg_Resource_Event", EQUAL, 4.00 )
    call TriggerRegisterVariableEvent( gg_trg_update2, "udg_Resource_Event", EQUAL, 5.00 )
    call TriggerAddAction( gg_trg_update2, function Trig_update2_Actions )
endfunction

  • FoodGold
    • Events
      • Game - Resource_Event becomes Equal to 6.00
    • Conditions
    • Actions
      • Custom script: set udg_tempInt = GetPlayerCustomResource(udg_Resource_Player, 6)
      • Player - Set Resource_Player Current gold to tempInt
if you need starting food: 400 please use this
  • startingFood
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Custom script: call AdjustPlayerCustomResource(GetEnumPlayer(), 6, 400)

Thanks master Yoda
 
Level 11
Joined
Mar 31, 2016
Messages
657
Dam, one more thing - got an error on save.

Undeclared variable: gg_trg_update2

I'm guessing I should just add it in - what kind of variable is it? Also are gg_trg tags or should i name the new variable gg_trg_update2 ?
EDIT: Tried to add it in variable list and got another error saying gg_ is a tag for internal functions. Tried trimming it as trg_update2 and update2 but those did nothing. I'm stumped although I think it might just be a typo, missing a tag, or some detail.
 
Last edited:
Level 11
Joined
Mar 31, 2016
Messages
657
Did more testing - double checked everything. Tried changing variables to troubleshoot however I still get the same error - Undeclared variable: gg_trg_update2
Also tried to play the map by saving with jasshelper off however it wouldn't load in the game menu.

Do you have a solution or should I send map again?
 
Level 18
Joined
Nov 21, 2012
Messages
835
ah sorry, didn't look here yesterday,
its simple: when you create new trigger named UpdateLB , its name in jass is gg_trg_UpdateLB
so create new trigger with name update2 convert it to jass, delete all, and paste this:
JASS:
function Trig_update2_Actions takes nothing returns nothing
    local integer i = GetPlayerId(udg_Resource_Player)+1
    local integer Clay = GetPlayerCustomResource(udg_Resource_Player, 2)
    local integer Stone = GetPlayerCustomResource(udg_Resource_Player, 3)
    local integer Ore = GetPlayerCustomResource(udg_Resource_Player, 4)
   local integer Gold = GetPlayerCustomResource(udg_Resource_Player, 5)
   
    call LeaderboardSetPlayerItemValueBJ( Player(11), udg_lb[i], Clay)
    call LeaderboardSetPlayerItemValueBJ( Player(8), udg_lb[i], Stone)
    call LeaderboardSetPlayerItemValueBJ( Player(9), udg_lb[i], Ore)
    call LeaderboardSetPlayerItemValueBJ( Player(4), udg_lb[i], Gold)
   
endfunction
//==============================================================
function InitTrig_update2 takes nothing returns nothing
    set gg_trg_update2 = CreateTrigger(  )
    call TriggerRegisterVariableEvent( gg_trg_update2, "udg_Resource_Event", EQUAL, 2.00 )
    call TriggerRegisterVariableEvent( gg_trg_update2, "udg_Resource_Event", EQUAL, 3.00 )
    call TriggerRegisterVariableEvent( gg_trg_update2, "udg_Resource_Event", EQUAL, 4.00 )
    call TriggerRegisterVariableEvent( gg_trg_update2, "udg_Resource_Event", EQUAL, 5.00 )
    call TriggerAddAction( gg_trg_update2, function Trig_update2_Actions )
endfunction
then you can change trigger's name if you want to
 
Level 11
Joined
Mar 31, 2016
Messages
657
ah sorry, didn't look here yesterday,
its simple: when you create new trigger named UpdateLB , its name in jass is gg_trg_UpdateLB
so create new trigger with name update2 convert it to jass, delete all, and paste this:
JASS:
function Trig_update2_Actions takes nothing returns nothing
    local integer i = GetPlayerId(udg_Resource_Player)+1
    local integer Clay = GetPlayerCustomResource(udg_Resource_Player, 2)
    local integer Stone = GetPlayerCustomResource(udg_Resource_Player, 3)
    local integer Ore = GetPlayerCustomResource(udg_Resource_Player, 4)
   local integer Gold = GetPlayerCustomResource(udg_Resource_Player, 5)
 
    call LeaderboardSetPlayerItemValueBJ( Player(11), udg_lb[i], Clay)
    call LeaderboardSetPlayerItemValueBJ( Player(8), udg_lb[i], Stone)
    call LeaderboardSetPlayerItemValueBJ( Player(9), udg_lb[i], Ore)
    call LeaderboardSetPlayerItemValueBJ( Player(4), udg_lb[i], Gold)
 
endfunction
//==============================================================
function InitTrig_update2 takes nothing returns nothing
    set gg_trg_update2 = CreateTrigger(  )
    call TriggerRegisterVariableEvent( gg_trg_update2, "udg_Resource_Event", EQUAL, 2.00 )
    call TriggerRegisterVariableEvent( gg_trg_update2, "udg_Resource_Event", EQUAL, 3.00 )
    call TriggerRegisterVariableEvent( gg_trg_update2, "udg_Resource_Event", EQUAL, 4.00 )
    call TriggerRegisterVariableEvent( gg_trg_update2, "udg_Resource_Event", EQUAL, 5.00 )
    call TriggerAddAction( gg_trg_update2, function Trig_update2_Actions )
endfunction
then you can change trigger's name if you want to

Nice - I just learned something new. Works now!
 
Last edited:
Level 11
Joined
Mar 31, 2016
Messages
657
Just found a minor bug - the first time a unit harvests a custom resource, it uses the harvest ability for lumber and returns lumber to the lumber mill, instead of custom resource to granary/stone mill.

Will do some more testing to see what's causing it because i don't remember ever getting this bug.
EDIT2: When the first thing you do in the game is harvest, harvest works fine 100%. However if the first thing you do in the game is construct a building, then harvest glitches as described above. Also right click (smart order) works for building construction up until the harvest system is used. I think the two systems may be conflicting.
 
Last edited:
Level 11
Joined
Mar 31, 2016
Messages
657
It happened with the same version... Its very odd - it worked last night and now it won't work. Is there another way to make starting food (gold) 400?

Also, any thoughts on the conflicting systems bug?

When the first thing you do in the game is harvest, harvest works fine 100%. However if the first thing you do in the game is construct a building, then harvest glitches as described above. Also right click (smart order) works for building construction up until the harvest system is used. I think the two systems may be conflicting.
 
Level 18
Joined
Nov 21, 2012
Messages
835
just made 2 test with harvest as 1st and build as 1st, it works fine for me
send map
you got 2 options:
  • Melee Initialization
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Melee Game - Use melee time of day (for all players)
      • Melee Game - Limit Heroes to 1 per Hero-type (for all players)
      • Melee Game - Enforce victory/defeat conditions (for all players)
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Custom script: call AdjustPlayerCustomResource(GetEnumPlayer(), 6, 400)
          • Player - Set (Picked player) Current gold to 400
          • Player - Set (Picked player) Current lumber to 250
          • Player - Set (Picked player) Food cap to 15
          • Player - Set (Picked player) Food max to 300
OR

keep your event "Map Initialization" for "Melee Initialization" trigger and move whole category "HarvestSYSTEM" above "Initialization" category. Then: save map-->close map-->open map-->save map-->run game to test

(In both cases delete trigger "Food" inside "Initialization" category.)
 
Last edited:
Level 11
Joined
Mar 31, 2016
Messages
657
just made 2 test with harvest as 1st and build as 1st, it works fine for me
send map
you got 2 options:
  • Melee Initialization
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Melee Game - Use melee time of day (for all players)
      • Melee Game - Limit Heroes to 1 per Hero-type (for all players)
      • Melee Game - Enforce victory/defeat conditions (for all players)
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Custom script: call AdjustPlayerCustomResource(GetEnumPlayer(), 6, 400)
          • Player - Set (Picked player) Current gold to 400
          • Player - Set (Picked player) Current lumber to 250
          • Player - Set (Picked player) Food cap to 15
          • Player - Set (Picked player) Food max to 300
OR

keep your event "Map Initialization" for "Melee Initialization" trigger and move whole category "HarvestSYSTEM" above "Initialization" category. Then: save map-->close map-->open map-->save map-->run game to test

(In both cases delete trigger "Food" inside "Initialization" category.)

Woot! Starting resources work fine now.

Still have the conflict bug though where if you build first, then harvest with a single right click - worker used harvest lumber and returns lumber instead of used harvest custom resource and returns custom resource. Still this is a minor bug so no rush. Fixed when you right click on destructible again or double right click the first time.
 
Status
Not open for further replies.
Top