• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Creating an income that loops

Level 13
Joined
Jun 10, 2007
Messages
780
Creating a looping income

This tutorial will show you how to make a income system that will loop after a certain amount of time and your amount earned will be determined by your condition. This tutorial would be the best for games like Hero Line Wars or tower defenses.

First, I will show you how to create an income system based on a unit you buy. This again is the best for tower defenses or Hero Line War types of games. Before triggering you will need a variable that is an integer and is at 0 default. First you will need an event... We will make it so when a unit enters a specific region it will trigger.
  • Unit - A unit enters TriggerRegion <gen>
If a unit enters that region the trigger will begin. Next, the conditions will vary depending on what you are making but, here are some common ones.
  • ((Entering unit) is A structure) Equal to False
Any hero that goes into that region will be unaffected. Now its time for the hard part of the tutorial, (not really) the actions. I want it to give me income if a certain type of unit enters that region. I will create a condition so that the unit that passes through will give a picked gold amount.
  • If ((Unit-type of (Entering unit)) Equal to Peon) then do (Set Income[(Player number of (Owner of (Entering unit)))] = (Income[(Player number of (Owner of (Entering unit)))] + 1)) else do (Do nothing)
I dont know why the trigger is like that can an admin please fix. Under that action put this one.
  • Set TriggerRegion = (Random integer number between 1 and 2)
I just made it if a peon goes into that region your income will go up by 1. This will activate everytime a peon goes into that region and will always add 1 to your income. Note that you will have to make that with every unit. Now you may be asking, how do I get my income? Well, ill show you right now.
  • Income
    • Events
      • Time - Every 10.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 10, do (Player - Add Income[(Integer A)] to (Player((Integer A))) Current gold)
      • For each (Integer A) from 1 to 10, do (Game - Display to (Player group((Player((Integer A))))) the text: (Your income is : + (String(Income[(Integer A)]))))
This will give you your income EVERY 10 seconds. Change the event if you want it to wait longer or wait less. The game will also have a appearing message telling you your income. You may want it so players can type
-Income or .Myincome and it will show there income then and there.
  • income
    • Events
      • Player - Player 1 (Red) types a chat message containing -income as An exact match
      • Player - Player 2 (Blue) types a chat message containing -income as An exact match
      • Player - Player 3 (Teal) types a chat message containing -income as An exact match
      • Player - Player 4 (Purple) types a chat message containing -income as An exact match
      • Player - Player 5 (Yellow) types a chat message containing -income as An exact match
      • Player - Player 6 (Orange) types a chat message containing -income as An exact match
      • Player - Player 7 (Green) types a chat message containing -income as An exact match
      • Player - Player 8 (Pink) types a chat message containing -income as An exact match
      • Player - Player 9 (Gray) types a chat message containing -income as An exact match
      • Player - Player 10 (Light Blue) types a chat message containing -income as An exact match
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 10, do (Game - Display to (Player group((Triggering player))) for 6.00 seconds the text: (((String((Integer A))) + ) ) + (String(Income[(Integer A)]))))
I may update this tutorial and show other ways to upgrade income.
 
Top