Need help with an income system

ants

New Member
Reaction score
0
Good day community, i am looking for some help.. i recently thought i'd start making a map and i thought about about making a bit unusual/different income system. Basically it will be a survival or pvp map, building a base and aquiring equipment for your hero, however, i don't want it to be a typical "wall yourself in and repair them walls while your 50 hp towers attack enemies".
The income system would be something a bit similar to markets in age of empires:
1. Every player has a limit of one (main)building where all the resources are brought
2. there are only certain points in where you can build.. lets call them markets, however they are scattered across the map so widely, and walling it all would be nearly impossible (because walls will be extremely expensive, so it would be more useful and reasonable to build/maintain a small fortress)
3. Every, say 30 seconds there would be a peasant(uncontrollable) running with a stack of cash from each market a player owns to their main building, when they reach the main building, they dissapear and the owner gains gold based on how far did the peasant come from.
4. this is so players would have to open gates during daytime when peasants bring resources and it would be disabled during night-time because then there will be intense waves of enemies roaming and attacking bases.

I am not lazy, it would just take too much time and i'm not exactly familiar with variables.. would make a huge unreasonable mess and i'm pretty sure it's a problem that could be solved way easier than i'd do it, so please someone assist me/give suggestions on this, thank you!
 

jonas

You can change this now in User CP.
Reaction score
67
We all need help with an income system, buddy.

Anyway, what you want is easy to do and sounds like a good project to learn about coding. I would suggest you to use an array and custom unit values: just give each peasant on the map a unique number, and use that number as an array index for the array that stores how much gold he would give and what his destination is.
Make him walk towards his destination.
Check on all peasants on the map and see how far they are from their destination. If the distance is small enough, remove them, add the gold.
 

Accname

2D-Graphics enthusiast
Reaction score
1,463
Just make those markets gold mines and have a peasant collect gold the regular way.
I dont see a need to use any custom triggers for this.
 

jonas

You can change this now in User CP.
Reaction score
67
Just make those markets gold mines and have a peasant collect gold the regular way.
I dont see a need to use any custom triggers for this.

I also thought of this, but the amount of gold should depend on the distance...
If you want to get 80/20 you could do this
 

afisakov

You can change this now in User CP.
Reaction score
37
3. Every, say 30 seconds there would be a peasant(uncontrollable) running with a stack of cash from each market a player owns to their main building, when they reach the main building, they dissapear and the owner gains gold based on how far did the peasant come from.
4. this is so players would have to open gates during daytime when peasants bring resources and it would be disabled during night-time because then there will be intense waves of enemies roaming and attacking bases.

How does a player control a market?
If doing so requires keeping it safe then the market would have to be within your walls.

The triggering concept I came up with:

Basic idea, have regions for all players pre-placed at map start. Then assign them to an array in the initialization trigger.
Once players build their base, move the region under that base. Periodically have all markets (fruit stand in example trigger) create a peasant and order peasants to move to region of market controller.
Assign custom value to distance calculation and pay based on that value once peasant reaches target region
Code:
init
  Events
  Conditions
  Actions
  Set player_base[1] = Region 000 <gen>
  Set player_base[2] = Region 001 <gen>
... assigning regions to array

move region
  Events
  Unit - A unit Finishes construction
  Conditions
  (Unit-type of (Triggering unit)) Equal to Fruit Stand
  Actions
  Region - Center player_base[(Player number of (Owner of (Triggering unit)))] on (Position of (Triggering unit))
--assumes players can have only one base, and point leak minor issue since this would rarely run

periodic sp
  Events
  Time - Every 30.00 seconds of game time
  Conditions
  And - All (Conditions) are true
  Conditions
  (In-game time of day) Greater than or equal to 7.00
  (In-game time of day) Less than or equal to 21.00
  Actions
  Set Temp_Group = (Units in (Playable map area) matching ((Unit-type of (Matching unit)) Equal to Fruit Stand))
  Unit Group - Pick every unit in (Units in (Playable map area) matching ((Unit-type of (Matching unit)) Equal to Fruit Stand)) and do (Actions)
  Loop - Actions
  Set temp_point1 = (Position of (Picked unit))
  Unit - Create 1 Peasant for (Owner of (Picked unit)) at temp_point1 facing Default building facing degrees
  Set temp_point2 = (Center of player_base[(Player number of (Owner of (Picked unit)))])
  Unit - Set the custom value of (Last created unit) to (Integer((Distance between temp_point1 and temp_point2)))
  Unit - Make (Last created unit) Invulnerable
  Unit - Order (Last created unit) to Move To (Center of player_base[(Player number of (Owner of (Picked unit)))])
  Custom script:  call RemoveLocation (udg_temp_point1)
  Custom script:  call RemoveLocation (udg_temp_point2)
  Custom script:  call DestroyGroup (udg_Temp_Group)
--creates peasant and forces movement (I forgot how to make non-selectable, something to do with locust ability)

award gold
  Events
  Unit - A unit enters Region 000 <gen>
  Unit - A unit enters Region 001 <gen>
  Unit - A unit enters Region 002 <gen>
  Unit - A unit enters Region 003 <gen>
... other used player regions
  Conditions
  (Unit-type of (Triggering unit)) Equal to Peasant
  Actions
  Wait 0.10 game-time seconds
  If (All Conditions are True) then do (Then Actions) else do (Else Actions)
  If - Conditions
  (player_base[(Player number of (Owner of (Triggering unit)))] contains (Triggering unit)) Equal to True
  Then - Actions
  Player - Add ((Custom value of (Triggering unit)) / 10) to (Owner of (Triggering unit)) Current gold
  Unit - Remove (Triggering unit) from the game
  Else - Actions
--awards gold and removes peasant. I would recommend also adding a message to the player in final version.
Hopefully I did not miss anything important, and I hope it works for you.
 

ants

New Member
Reaction score
0
@ afisakov: Thanks for your reply, you kind of got what i was trying to figure out, markets are scattered across the map and the main building(resource gathering point) is within your walls.
Your example of triggers has been useful (Thank you for that) but i have run into trouble, currently my peasants move straght to the center of the map, Player_base is region variable with array, right? there should'nt be anything going wrong with the first trigger, so where does it? :(
(i also see that you replaced the main building with fruit stand aswell in "move region" trigger)
Gonna try to figure this out for now, thanks anyway for your help ya'll.

!!!EDIT!!! i apologize, im retarded, forgot to put event - map initialization on the first trigger

edit edit: when i test it now, it works on initialization (i have markets and player 1 region set, there is no main building yet) and everything works as intended, however, when i build the main building, peasants start moving towards it, but it doesnt seem to work since it appears that player 1 <gen> is still in its original location while player_base moved to the main building so the event in the final trigger "unit enters player 1 <gen>" doesn't work.
Is this somehow my mistake or it's somekind of a bug?
Could i use an alternative of event "unit comes within range"?
 
Last edited:

afisakov

You can change this now in User CP.
Reaction score
37
@ afisakov: Thanks for your reply, you kind of got what i was trying to figure out, markets are scattered across the map and the main building(resource gathering point) is within your walls.
Your example of triggers has been useful (Thank you for that) but i have run into trouble, currently my peasants move straght to the center of the map, Player_base is region variable with array, right? there should'nt be anything going wrong with the first trigger, so where does it? :(
(i also see that you replaced the main building with fruit stand aswell in "move region" trigger)
Gonna try to figure this out for now, thanks anyway for your help ya'll.

!!!EDIT!!! i apologize, im retarded, forgot to put event - map initialization on the first trigger

edit edit: when i test it now, it works on initialization (i have markets and player 1 region set, there is no main building yet) and everything works as intended, however, when i build the main building, peasants start moving towards it, but it doesnt seem to work since it appears that player 1 <gen> is still in its original location while player_base moved to the main building so the event in the final trigger "unit enters player 1 <gen>" doesn't work.
Is this somehow my mistake or it's somekind of a bug?
Could i use an alternative of event "unit comes within range"?

Odd, I thought it would let you move the region...
there are alternative ways to try to duplicate the effect, though I thought this one was the most straightforward.
Option 1: Order the peasants to attack the main base (instead of move) (with atk of 1, base would have regen) and use the event a unit is attacked
downside: you will keep getting prompts that main base under attack, u are forced to give it at least some regen, cannot make it invulnerable
Option 2:
use a periodic timer to check distance for all player owned peasants to base, for this method you would want to assign the main base of each player to an array, method for calculating distance without leaking in one of my prev triggers.
downside: this is far more processor intensive then unit enters region and if you leave any memory leaks in it will add up fast.
Option 3:
Use Trigger-add event to add the event unit enters playerbase[playernumber...] when market built (afterregion move step) to the award gold trigger
come to think of it, this may be the easiest solution; though I am still unsure why it did not work in first place.
 

ants

New Member
Reaction score
0
Odd, I thought it would let you move the region...
there are alternative ways to try to duplicate the effect, though I thought this one was the most straightforward.
Option 1: Order the peasants to attack the main base (instead of move) (with atk of 1, base would have regen) and use the event a unit is attacked
downside: you will keep getting prompts that main base under attack, u are forced to give it at least some regen, cannot make it invulnerable
Option 2:
use a periodic timer to check distance for all player owned peasants to base, for this method you would want to assign the main base of each player to an array, method for calculating distance without leaking in one of my prev triggers.
downside: this is far more processor intensive then unit enters region and if you leave any memory leaks in it will add up fast.
Option 3:
Use Trigger-add event to add the event unit enters playerbase[playernumber...] when market built (afterregion move step) to the award gold trigger
come to think of it, this may be the easiest solution; though I am still unsure why it did not work in first place.
Thanks for all your help, buddy.. i made a unit array variable and ordered peasants to attack it, works like a charm, it's the best solution actually and the downsides don't exist because when your own units attack your base, you don't get the "base under attack" messages, also regen won't be necessary because the event "a unit is attacked" is when the animation begins, the peasants won't be able to finish the animation because they'll be removed :p
 

afisakov

You can change this now in User CP.
Reaction score
37
Thanks for all your help, buddy.. i made a unit array variable and ordered peasants to attack it, works like a charm, it's the best solution actually and the downsides don't exist because when your own units attack your base, you don't get the "base under attack" messages, also regen won't be necessary because the event "a unit is attacked" is when the animation begins, the peasants won't be able to finish the animation because they'll be removed :p
Did not think of that. Glad it works for you.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top