• 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.

Feeding System

Status
Not open for further replies.
Level 1
Joined
Jan 15, 2013
Messages
61
Hi guys. I am making a tag map and i want to ask you how to make an easy system of feeding on walls. Like in Troll and Elves or other maps of thys type, where you get gold by attacking enemies buildings. And the gold you get depends on your damage. So more damage means more gold. Thx in advance and +rep whor those who will help me)
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
And I do not know where your problem lies. The above are some of the actions/events/functions that you may use to solve your issue.

There is an event type called "Unit takes damage", which triggers when a specific unit takes damage. Register all possible units with that event. The event response "Taken Damage" (real) then gives you how many damage the unit took/the damage source caused, "Damage Source" (unit) is available. Get it's owning player with "Owner of Unit" function and place that inside a "Player - Add Property" action to add the resource. Yes, it is very easy. Another thing you should do though is to catch when a new building enters the game, maybe via "Unit completes construction" event.
 
Level 4
Joined
Jan 5, 2014
Messages
79
Actually you could also try edited Pillage ability (the passive of orcs)

EDIT: U can also try this

  • Unit enters game actions
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Unit-type of (Entering unit)) Equal to YourUnitType
              • (Unit-type of (Entering unit)) Equal to YourUnitType2
        • Then - Actions
          • Trigger - Add to Resource adding <gen> the event (Unit - (Picked unit) Takes damage)
        • Else - Actions
u surely need this and the last trigger, u can ad as many unit type comparisions as u want

  • Map inicialization actions
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set TempGroup1 = (Units in (Playable map area))
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Unit-type of (Picked unit)) Equal to YourUnitType
                  • (Unit-type of (Picked unit)) Equal to YourUnitType2
            • Then - Actions
              • Trigger - Add to Resource adding <gen> the event (Unit - (Picked unit) Takes damage)
            • Else - Actions
this is usefull just if u have some of the units already in game on the start

  • Resource adding
    • Events
    • Conditions
    • Actions
      • Player - Add ((Integer((Damage taken))) x YourMultiplier) to (Owner of (Damage source)) Current gold
      • Player - Add ((Integer((Damage taken))) x YourMultiplier) to (Owner of (Damage source)) Current lumber
multiplier can be virtually diffrent for both gold and lumber
 
  • Set TempGroup1 = (Units in (Playable map area))
  • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
The above is not the correct use of groups.
You never clean the leak at the end of the group loop either.
Either do this.
  • Set TempGroup1 = (Units in (Playable map area))
  • Unit Group - Pick every unit in TempGroup1 and do (Actions)
    • Loop - Actions
  • Custom script: call DestroyGroup(udg_TempGroup1)
Or do this.
  • Custom script: set bj_wantDestroyGroup = true
  • Unit Group - Pick every unit in TempGroup1 and do (Actions)
    • Loop - Actions
Do not use entering unit use triggering unit as it is faster and triggering unit is MUI.
Anything used twice or more should be stored in a variable and the variable should be used.
 
Status
Not open for further replies.
Top