Need help with KaM economy´s system

Level 13
Joined
Oct 28, 2019
Messages
523
Anyone played KaM (Knights and merchants). It's a game in which you don't control the peasants. A exemple:
You order to build a woodcutter´s hut, so the labores (iddle) will go there and repair the building until its finished.
Then you train a woodcutter, it will chop trees near the woodcutter´s hut ( only one woodcutter allowed per hut)
When it brings wood to the hut, creates an item (wood) so a idle serf takes the wood and brings to the town center, then a table shows the custom resources
(when a maximimum 5 woods is stocked in the hut (whithout the serfs take it, the woodcutterr stops cut wood).

I know that make this system will bem a pain, and hard to work, cause theres many kind of buildings and units, I´ve made basic things,
But one thing I would like to know, How I can set a variable to each wood (1 to 5) and make the woodcuter stop cut wood when reach 5 woods.
 
Last edited:

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,860
I don't know how others have done it in the past, but at the end of the day a tree is just a Destructable and you can make an ability target Trees. So with that in mind, there's no reason you have to use Warcraft 3's standard Harvest ability, you can always trigger your own.

I'm pretty sure we don't have any Events like "A peasant gathered X wood" or any way to determine the exact moment a Peasant damages a tree and increases their lumber capacity, which is why I lean towards going completely custom.

Edit: Here's a demo map showcasing a basic lumber harvesting system with a 1 worker limit per tree. There's no "return lumber" mechanic but it wouldn't be too difficult to add. Quick summary: I use the War Club and Channel abilities along with a Unit Indexer to mimic the behavior of the standard lumber harvesting system.
 

Attachments

  • Custom Lumber System 1.w3m
    29.7 KB · Views: 7
Last edited:
Level 13
Joined
Oct 28, 2019
Messages
523
I don't know how others have done it in the past, but at the end of the day a tree is just a Destructable and you can make an ability target Trees. So with that in mind, there's no reason you have to use Warcraft 3's standard Harvest ability, you can always trigger your own.

I'm pretty sure we don't have any Events like "A peasant gathered X wood" or any way to determine the exact moment a Peasant damages a tree and increases their lumber capacity, which is why I lean towards going completely custom.

Edit: Here's a demo map showcasing a basic lumber harvesting system with a 1 worker limit per tree. There's no "return lumber" mechanic but it wouldn't be too difficult to add. Quick summary: I use the War Club and Channel abilities along with a Unit Indexer to mimic the behavior of the standard lumber harvesting system.
Its a really nice system can be usefull, the part that the woodcutter stop gatter can be usefull. thanks. But it stops gather no with 5 wood axes and yes 5 lumber carried to the woodcutter hut
 
Level 13
Joined
Oct 28, 2019
Messages
523
1731278725403.png


So here´s a exemple, when the woodcutter hut is builded, the woodcutter starts cut wood automatically (its a ally player) When he brings wood to the hut, he creates a dummy that drops an item (wood) near the hut. So a serf takes the wood(item) and brings it to the towncenter. The question is. How can I make the woodcutter stop cutting wood when the wood stored in the hut reaches 5 wood? Because there is no such trigger (number of items in that position is equal to or greater than 5)
  • DummyCreateItem1
    • Events
      • Player - Player 3 (Teal)'s Current lumber becomes Greater than or equal to ((Real((Player 3 (Teal) Current lumber))) + 10.00)
    • Conditions
    • Actions
      • Unit - Create 1 Serf Dummy for Player 3 (Teal) at PointWoodCutters facing Default building facing degrees
      • Hero - Create Wood and give it to (Last created unit)
      • Hero - Drop (Item carried by (Last created unit) of type Wood) from (Last created unit).
  • FinishesWoodcutterHut
    • Events
      • Unit - A unit owned by Player 3 (Teal) Finishes construction
    • Conditions
      • (Unit-type of (Constructed structure)) Equal to Woodcutter´s
    • Actions
      • Set VariableSet PointWoodCutters = ((Position of (Constructed structure)) offset by (0.00, -50.00))
      • Set VariableSet UnitWoodCutterHut1 = (Constructed structure)
      • Set VariableSet IntegerWoodCuterHut = 1
  • Enter WoodCutterHut1
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
      • IntegerWoodCuterHut Equal to 1
    • Actions
      • Trigger - Turn off (This trigger)
      • Unit - Order UnitWoodCutter1 to Right-Click (Random destructible in (Region centered at (Position of UnitWoodCutterHut1) with size (800.00, 800.00)))
  • SerfsGetItem
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • Set VariableSet UnitSerfWood = (Random unit from UGIddleSerfs)
      • Unit - Order UnitSerfWood to Right-Click ItemWood
 
Level 30
Joined
Aug 29, 2012
Messages
1,380
I'm not quite sure about the need of creating a dummy unit and give them the item to drop it afterwards instead of just creating the item directly on the ground, but anyway in DummyCreateItem1, you can have an Integer variable and increment it by 1 every time lumber is created (also disabling the Harvest ability from the AI player), add as a condition that Integer < 5, then substracting 1 every time a lumber item is picked up

If you can have multiple woodcutter huts, you'll need to find a way to make it MUI
 
Level 13
Joined
Oct 28, 2019
Messages
523
I'm not quite sure about the need of creating a dummy unit and give them the item to drop it afterwards instead of just creating the item directly on the ground, but anyway in DummyCreateItem1, you can have an Integer variable and increment it by 1 every time lumber is created (also disabling the Harvest ability from the AI player), add as a condition that Integer < 5, then substracting 1 every time a lumber item is picked up

If you can have multiple woodcutter huts, you'll need to find a way to make it MUI
I tried just directly creating the item. But I couldn't create a variable, so the "last dropped item" can be created as a variable
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,860
I added some more stuff to the original map I posted before. I'm not too interested in developing it further but I may get bored and add more features eventually.

The main purpose of the map is for you to learn how to do something like this yourself. It's a much more enjoyable experience when you can come up with your own solutions.

This particular map idea is going to be rather complicated throughout all of it's development, at least if you want things to work smoothly.
 

Attachments

  • Custom Lumber System 3.w3m
    33.5 KB · Views: 6
Last edited:
Top