Creating an income that loops [Awaiting Improving: Ralle]

How well did this help?

• Needs Alot of Work 1/5

• Total voters
16

Level 13
Creating a Looping Income

Don't vote on numbers, but on how it would help someone in need of this. Even if this wouldn't help you, it just might help somebody else. Don't write retarded comments like "Oh my god so easy!!1". I DON'T care if you know how to do it. If you can, good for you.

Requirements
World Editor [Comes with Wc3]
General Trigger Knowledge
General Variable Knowledge

Difficullty:3/10

Contents
-Introduction
-Step 1
-Step 2
-Step 3
-Extras
-Closing

Introduction

Income is an amount of money (gold in this case ) that you obtain over a certain period of time. In this short tutorial, I will show you the basics of making an income that can loop if needed.

Step 1

Before we make any part of the income, we will need a variable, which stores the amount of income.
Steps
1)Open the trigger editor
2)Press Ctrl+B
Once your there you create a new variable. I'm naming mine Income just for the purpose of the tutorial. Now, make the variable an integer because its storing a number (our income number). Make it array if you have multiple incomes.
Now your variable should look a little like this:

Change the initial value if you want to have a starting income. Now that we have the variable we can move onto step 2.

Step 2

Now we will need to diagnose what we need the income for. Some may need a looping income for a tower defense, some may need it for there job income. Ill show you the basic use for it.

• Income Give
• Events
• Time - Every 30.00 seconds of game time
• Conditions
• Actions
• For each (Integer A) from 1 to 6, do (Player - Add Income[(Integer A)] to (Player((Integer A))) Current gold)
This will give players 1-5 an income every 30 seconds. Of course you would add income to each player on your game and you would change the time but this is a basic use. Now comes the harder part of the tutorial.. This part requires you to add the income. To add income, we will require a different trigger.

Step 3

Create a new trigger and name it adding income or something by that means. You will need a specific event for giving income. Heres a small example

• Example1
• Events
• Unit - A unit Dies
• Conditions
• ((Owner of (Killing unit)) is an ally of (Owner of (Dying unit))) Equal to False
• (Owner of (Killing unit)) Not equal to (Owner of (Dying unit))
• Actions
• For each (Integer A) from 1 to 6, do (If ((Owner of (Killing unit)) Equal to (Player((Integer A)))) then do (Set Income[(Player number of (Owner of (Killing unit)))] = Income[(Income[(Player number of (Owner of (Killing unit)))] + 1)]) else do (Do nothing))
When the unit dies, it will add +1 to the killing unit's owner's income. So if red kills teals Blademaster, red will gain an extra +1 income. The event is very flexible and even add conditions to change what you want the income to affect.

All you have to do is give value to the integer and it will give income! to add to an already existing income then do this

Extras

I have some extra actions and information if you would like to add them to your triggers.

Having an initial income value
If you would like your players to start out with an initial (beginning) income value, there are two ways of doing it.

1:Go into your variable editor and change the income variables default value to any number.

2: Use this trigger
• For each (Integer A) from 1 to 10, do (Set Income[(Integer A)] = 30)
This changes the income for players 1-10 (Red - LB)'s income to 30.

Closing

I hoped this tutorial has helped someone and thanks for reading! Reply in the thread so that I can make this tutorial better!
UPDATE: I added more to the testmap and fixed things up a bit. I added some more sections as well . Heres the demo map for the income View attachment Income Version 2.0.w3x

OLD VERSION: View attachment Income.w3x

Last edited:

Level 13

August 23, 2008
-New and improved triggers.

~Parrot

Last edited:

Hoernchen

Level 10
Sorry to say this, but this tutorial is hardly even near useful and I don't think it is 4/10 difficulty, more like 1/10. Also, people don't really need a tutorial for something so easy.

AJalex

Level 7
Sorry to say this, but this tutorial is hardly even near useful and I don't think it is 4/10 difficulty, more like 1/10. Also, people don't really need a tutorial for something so easy.

there are people which don't know such simple things and this may help them ...

Amnesia_Dracor

Level 1

I am new to mapping and it was very helpful, there are no tutorials I have found for what should be simple concepts.

Thanks Again

Belgarath

Level 21
An easier way for the actual income is this:

• Event
• Time - Every 30.00 seconds of game time
• Conditions
• Actions
• Player Group - Pick every player in (All Players) and add ((Picked Player)'s gold + (Income(Player Number of Picked Player))) to (Picked Player)'s gold.
...something like that...

Killing_Spree22

Level 2
An easier way for the actual income is this:

• Event
• Time - Every 30.00 seconds of game time
• Conditions
• Actions
• Player Group - Pick every player in (All Players) and add ((Picked Player)'s gold + (Income(Player Number of Picked Player))) to (Picked Player)'s gold.
...something like that...

This leaks, quite a bit, it leaks a player group, you would need to add the player to a variable, of a player group.

• Income
• Events
• Time - Every (What ever you want) seconds of game time
• Conditions
• Actions
• Set Income_Group = (All players)
• Player Group - Pick every player in Income_Group and do (Actions)
• Loop - Actions
• Player - Add (Whatever you want) to (Picked player) Current gold
• Custom script: call DestroyForce(udg_Income_Group)
That would fix the problem

Level 21
Omg, You guys should learn how to build algorithms.

Achtung, Kinder!
JASS:
``````function Unit_Dies_Actions takes nothing returns nothing
local integer i = GetPlayerId(GetOwningPlayer(GetAttacker()))
set Income[i] = Income[i] + 1
endfunction``````

and for the 30 seconds timer

JASS:
``````function Income_Actions takes nothing returns nothing
local integer i = 0
local player p
loop
exitwhen i > 12 //use 16 if you want to use every neutral as well.
set p = Player(i)
call SetPlayerState(p, PLAYER_STATE_GOLD_GATHERED, GetPlayerState(p, PLAYER_STATE_GOLD_GATHERED) + Income[i])
call SetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD) + Income[i])
set i = i + 1
endloop
//don't use forces for useless things like this. Forces are used for administrating players.
//I normally use them for alliences and things that require to group players(very few).
endfunction``````

Note: I never use non-native functions for actions that must be extremely fast.

PurplePoot

Level 40
Either way, you need something for the GUI peeps (a Jasser won't need this tutorial anyways), which is a part of the problem. But yes, the triggers could be improved.

Ralle

Owner
Level 77
When setting up the array you didn't set it to how many players you want, didn't note it either.
Please use the new [h1][h2][h3] tags, read the The Hive Workshop - A Warcraft III Modding Site - Announcements in Forum : Tutorial Submission.
- Pick all players from all players and add income[number of player] to picked player's gold
- Also, set income[ owner of killing unit ]*to income[ owner of killing unit ]+1 and remember to check that you didn't kill your own unit.

Seth21

Level 3
This leaks, quite a bit, it leaks a player group, you would need to add the player to a variable, of a player group.

• Income
• Events
• Time - Every (What ever you want) seconds of game time
• Conditions
• Actions
• Set Income_Group = (All players)
• Player Group - Pick every player in Income_Group and do (Actions)
• Loop - Actions
• Player - Add (Whatever you want) to (Picked player) Current gold
• Custom script: call DestroyForce(udg_Income_Group)
That would fix the problem

You just destroyed "All players" . You shouldnt

Hoernchen

Level 10
Yea, don't lecture people about leaks if you don't know that All Players doesn't leak. It's a constant variable.

Replies
3
Views
1K
Replies
17
Views
4K
Replies
5
Views
2K
Replies
14
Views
1K