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

[Spell] Skill that gives passive income

Status
Not open for further replies.
Level 2
Joined
Apr 9, 2014
Messages
8
Hello and sorry if this has already been answered somewhere but i couldnt find anything. The idea is to make a trigger that will give gold passively every X seconds when an ability is leveled. I tried basing the trigger on the one people use for getting income from X amount of buildings by changing it so the requirment is that the skill has been leveled but it doesnt seem to work. I also tried making the event "a unit learns a skill" but that didnt seem to work either. Still new to this so a little help would be appreciated. Also not sure if it matters but i decided to base the skill on Attribute Bonus since i could just remove the stats and use it just to trigger the gold from the trigger.

TLDR - Basic Skill with 3 levels that gives gold which increases depending on the level.
 
Level 12
Joined
Jun 15, 2016
Messages
472
Is the ability for heroes or normal units?

In any case, you can try saving all current living units with the 'income' ability in a couple of arrays (say an array for the units themselves, and an array for the player owner). If there are units in the array, loop over it and give X gold to the owning player of each unit every Z seconds. If a unit learns the skill, add it to the array, and if a unit in the array dies, remove it from the array. You can see more technical details about how to implement this with arrays in the amazing dynamic indexing tutorial.
 
Level 2
Joined
Apr 9, 2014
Messages
8
Is the ability for heroes or normal units?

In any case, you can try saving all current living units with the 'income' ability in a couple of arrays (say an array for the units themselves, and an array for the player owner). If there are units in the array, loop over it and give X gold to the owning player of each unit every Z seconds. If a unit learns the skill, add it to the array, and if a unit in the array dies, remove it from the array. You can see more technical details about how to implement this with arrays in the amazing dynamic indexing tutorial.

I guess i didnt explain it very well. The ability is for a hero and i dont want it to be based on amount of units but on the level of the spell. Example the hero levels the ability and now it gives passively X gold every Y seconds on level 1 and so on. The amount of gold will increase with the rank of the ability.
 
Level 39
Joined
Feb 27, 2007
Messages
5,013
What you tried was right. I would use a group array not a unit array to store the different levels. The if block in the periodic trigger can be deleted if the units that supply gold income on your map can never die, you just need to move the "else" action below "Set TempU = (Picked unit)".
  • Events
    • Unit - A unit learns a skill
  • Conditions
    • (Learned hero skill) equal to YOUR_ABIL
  • Actions
    • Set TempU = (Triggering Unit)
    • Set Level = (Level of YOUR_ABIL for TempU)
    • If (All conditions are true) then do (then actions) else (else actions)
      • If - Conditions
        • Level > 1
      • Then - Actions
        • Unit Group - Remove TempU from GoldGroups[(Level - 1)]
      • Else - Actions
    • Unit Group - Add TempU to GoldGroups[Level]
  • Events
    • Time - Every PERIOD seconds of game-time
  • Conditions
  • Actions
    • For each (integer A) from 1 to MAX_GOLDABIL_LEVELS do (Actions)
      • Loop - Actions
        • Unit Group - Pick every unit in GoldGroups[(Integer A)] and do (Actions)
          • Loop - Actions
            • Set TempU = (Picked Unit)
            • If (All conditions are true) then do (then actions) else (else actions)
              • If - Conditions
                • (Unit-type of TempU) equal to No Unit
              • Then - Actions
                • Unit Group - Remove TempU from GoldGroups[(Integer A)]
              • Else - Actions
                • Player - Add GOLD_PER_PERIOD[(Integer A)] to (Owner of TempU) current gold
Make sure the GoldGroups[] array has a size equal to MAX_GOLDABIL_LEVELS in the editor else some of the groups will not be initialized and this method will fail.
 
Level 11
Joined
May 16, 2016
Messages
730
Hello and sorry if this has already been answered somewhere but i couldnt find anything. The idea is to make a trigger that will give gold passively every X seconds when an ability is leveled. I tried basing the trigger on the one people use for getting income from X amount of buildings by changing it so the requirment is that the skill has been leveled but it doesnt seem to work. I also tried making the event "a unit learns a skill" but that didnt seem to work either. Still new to this so a little help would be appreciated. Also not sure if it matters but i decided to base the skill on Attribute Bonus since i could just remove the stats and use it just to trigger the gold from the trigger.

TLDR - Basic Skill with 3 levels that gives gold which increases depending on the level.

Here is a MUI system that generates gold passively.
1. It generates gold only if the unit is alive.
2. The system tracks all ways to get the ability (like spawn unit with the ability, add the ability with triggers) or all ways to unlearn it.
3. It shouldn't load memory.
4. The system also counts "Real" variables. For example you need 20% of level and you hero is 1st level. 20% from 1 is 0.2, but the income can be only "Integer" like 1,2,3. The system saves "real" variable and add it to nex income. So the period goes 5 times (5*0.2=1) and gives you a gold. So you don't need afraid about the income is lesser than 1.
 

Attachments

  • Money from Air.w3x
    20.8 KB · Views: 46
Last edited:
Status
Not open for further replies.
Top