"Receive lumber"-trigger

krog99

New Member
Reaction score
2
Hi everyone :)

What should a trigger, which provides player with 25 lumber per second, if the player builded a specific building?


Events: Time - Every 1.00 seconds of game time

Actions: If ..................... then do (Player - Add 25 to Player 1 (Red) Current lumber) else (Do nothing)

Krog99
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Just pick all units of that type, and then give 25 lumber to the onwer of the picked unit ;)
 

krog99

New Member
Reaction score
2
What do you mean, or rather how do i do that?

I think of it a bit like Vampirism Zero's. You build a lumberbase, and then receive some lumber, until the lumberbase has been destroyed.
 

Komaqtion

You can change this now in User CP.
Reaction score
469
This should work ;)

Trigger:
  • Lumber Income
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Set LumberMillCount[(Integer A)] = 0
      • Set TempGroup = (Units of type Lumber Mill)
      • Unit Group - Pick every unit in TempGroup and do (Actions)
        • Loop - Actions
          • Set LumberMillCount[(Player number of (Owner of (Picked unit)))] = (LumberMillCount[(Player number of (Owner of (Picked unit)))] + 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • LumberMillCount[(Player number of (Owner of (Picked unit)))] Greater than 1
            • Then - Actions
              • Unit - Kill (Picked unit)
              • Set LumberMillCount[(Player number of (Owner of (Picked unit)))] = 1
            • Else - Actions
              • Player - Add 25 to (Owner of (Picked unit)) Current lumber
      • Custom script: call DestroyGroup(udg_TempGroup)
 

krog99

New Member
Reaction score
2
Ain't there a more simplified way to do it?

A boolean-condition that is true, if red builds a lumbermill, and then turns false, if the lumbermill is destroyed or upgraded?
 

Sui-cookie

You can change this now in User CP.
Reaction score
49
its a variable that is set, in the "all" tab of actions, its just a couple down. called "set variable"

the "LumberMillCount[(Player number of (Owner of (Picked unit)))]" is the variable, which is an array (hoping you know what all that is) and the rest is just sectioned off.
 

Sui-cookie

You can change this now in User CP.
Reaction score
49
when you go to put in the number in the array(ed) variable, you can just go up to the drop down box and select "for loop integer A" and that becomes "integer A" :]
 

Sui-cookie

You can change this now in User CP.
Reaction score
49
no, its a small line of jass that removes the leak that is in your trigger. too many leaks makes your warcraft crash :/
 

Bogrim

y hello thar
Reaction score
154
Follow my instructions and I'll explain it to you step-by-step:

You already have the periodic time event fixed, but the actions need to be the following:

First find the action, "For Each (Integer A) from 1 to 10, do (Actions)" under the general tab. This allows you to create a loop of actions, allowing you to repeat said actions for every player in the game. This is helpful because players not only have color index, but also have a number index. Player numbers range from 1 to 12 (the maximum number of players), so by running a loop 12 times, you can perform an action for each player. These loops also have a number of their own, allowing you to match them to the player's indexes. Your loop should look like this:
Trigger:
  • For each (Integer A) from 1 to 12, do (Actions)
    • Loop - Actions

Next you will want to create a handle for your units. Using a handle is the key to how the game perform actions in the game. We typically refer to handles as variables. Because you are handling multiple units, you need a unit group variable with the action "Set [/u]Variable[/u] = Value". To do this you first need to create the variable by opening the variable window (CTRL + B). Create a new variable (CTRL + N) and find "Unit Group" on the drop down list, name it "Temp_Group".

The reason for I name it "Temp_Group" is because you don't want to create a bunch of handles (as it lags), so you want a handle for temporary use. Hence the popular name, "Temp_Group".

Begin creating your handle in the loop with the Set Variable action:
Trigger:
  • For each (Integer A) from 1 to 12, do (Actions)
    • Loop - Actions
      • Set Temp_Group = Value

The next following parts are tricky.

We need to "select" the units in a way that players only gain lumber for the buildings that belong to them, and that the building is in fact alive and not deceased. For this we need conditions to "filter out" what we don't need. The trick here is that we are not limited to a single condition. For this, choose the group handle "Units In Region Matching Condition"

Trigger:
  • Set Temp_Group = (Units in (Playable map area) matching (Condition)


Units in (Playable map area) will cover every unit in the game.

In order to insert multiple conditions, find the condition "And". "And" splits the input choices into two, which is something you're allowed to do more than once, inserting multiple conditions this way. The conditions we are looking for are:

1. A Unit-type comparison. This will allow you to compare the unit-type of your ideal unit to the unit-type you want to provide lumber, filtering out any other unit type. The condition should look like this:
Trigger:
  • (Unit-type of (Matching unit)) Equal to Your Unit Type

Make sure it's "Matching unit". It's important to use the right references when setting up things like conditions, as the game won't otherwise know which unit to use. When you're comparing a unit through a condition, you're basically looking for units "matching a condition", henceforth "matching unit".

2. A player comparison. This is the most tricky part, using the loop's index to our advantage. When we compare players, we compare the owner of the unit in question to the owner matching the current loop. (Each loop has a number of its own, which matches that of a player. First loop is 1, which will correspond to player 1.) To do this, make the following player comparison saying:
Trigger:
  • (Owner of (Matching unit)) Equal to (Player((Integer A)))

You need to use the "Conversion - Convert Player to Index" in order to insert "Integer A", which is actually called "For Loop A" on the list of integer values. Integer A is the variable containing the current loop's number.

3. A Boolean comparison, a condition essential to make sure the building doesn’t grant any lumber while it’s dead but still in the game. In the list of Boolean comparisons, find:
Trigger:
  • ((Matching unit) is alive) Equal to True

And your conditions are good to go. Now the unit group handle be complete and look like this:
Trigger:
  • Set Temp_Group = (Units in (Playable map area) matching (((Unit-type of (Matching unit)) Equal to Lumber Mill) and (((Owner of (Matching unit)) Equal to (Player((Integer A)))) and (((Matching unit) is alive) Equal to True))))

It’s a pretty long line, but it doesn’t matter. Make sure they're identical, though. Once you created the handle, create make the player action called “Add Property”. It’s going to say “Add 1000 to Player 1 (Red) Current Gold[color/]
There are three fields to edit here. Take the integer value (“1000”) first:

1. Choose "Arithmetic" on the dropdown list. This is how you insert a mathematic equation into the trigger. You'll notice how the area below suddenly changes to allow for several fields to be adjusted. What you have to do is to multiply the number of units in your group handle with the number you wish players to gain per building. I'll explain:

In the red "Value" field, simply scroll down to the first unit-type value called "Unit - Count Units In Unit Group”, and choose your handle Temp_Group in the new window. Change the plus to an “x” for multiplication, and replace the 1 with the desired number of lumber per building.

Trigger:
  • Player - Add ((Number of units in (Units in (Playable map area))) x 25) …


2. Next in the action line, you need to repeat the same trick with the player index. Convert the player to an index and choose For Loop Integer A on the list.

Trigger:
  • Player - Add ((Number of units in (Units in (Playable map area))) x 25) to (Player((Integer A))) …


3. Lastly, change “Current Gold” to “Current Lumber”.

Trigger:
  • Player - Add ((Number of units in (Units in (Playable map area))) x 25) to (Player((Integer A))) Current lumber

You're almost done and your trigger in fact works, but it’s leaking a lot of handles, which generates lag. To prevent this, you have to "delete" the handle in the game. This isn't part of the user interface, so you have to insert a custom line of code using the “Custom Script” action from the General actions. Insert this exact text:

call DestroyGroup( udg_Temp_Group )
Trigger:
  • Custom script: call DestroyGroup( udg_Temp_Group )

This is Jass language and you should consider reading this tutorial for better insight.

Your finished trigger should look like this:
Trigger:
  • Your Trigger
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Set Temp_Group = (Units in (Playable map area) matching (((Unit-type of (Matching unit)) Equal to Lumber Mill) and (((Owner of (Matching unit)) Equal to (Player((Integer A)))) and (((Matching unit) is alive) Equal to True))))
          • Player - Add ((Number of units in Temp_Group) x 25) to (Player((Integer A))) Current lumber
          • Custom script: call DestroyGroup( udg_Temp_Group )

I hope this helps you.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • 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!
    +1
  • 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
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top