Hey everyone - I wanted to make a quick guide to introduce the paradigm of building lists in Forge scripts to select TARGETS and OBJECTS for your scripts to execute against. I've interacted with a few people in parties and on the forums who view this as really intimidating, but I'm hoping that this quick example can demonstrate a few simple examples that you can start applying right away. THE SETUP Here's the situation: So let's say I've challenged some Forgehub admins to a 2v2 game on a custom map. The map has a script brain with a boundary in the middle. We've played for a little bit, one person on each team is on respawn, and Warholic just entered the middle boundary. Here's the layout of the map and team members. Red Team (Team 1, Defender) Nitro (Alive) Sn1p3r C (Dead) Blue Team (Team 2, Defender) Warholic (Alive) SIR IRON WOLF (Dead) Finally, here's the the script settings. WHEN (Enter, Player, 0.05) THEN (Damage: Ratio -> [OBJECTS], 10.00 Spoiler: See the Forge screenshot So, in English... the script brain is checking every 0.05 seconds to see if a player enters the boundary. If that happens, then it executes the action. Which is whacking anyone who's in the Objects list for 10% of their health. THE BASICS - SELECTING OBJECTS USING 1 MOD CONDITION To decide who's going to take damage, we need to select players. First, we need to select/click the "OBJECTS" menu item... and we're left with this menu. The easiest way to understand this screen is to look at it this way. We have a lot of objects (both forge pieces and players) on the map that could potentially be targeted by our script. We start with an empty list of targets, and this menu let's us add objects. Here's a few basic choices we have for the first option: -THIS[add] -ACTIVATOR[add] -Players[add] -Team[add] This isn't everything, but it's a good start for the topic. Let's go through each one. THIS[Add] Any time you see "THIS" - it means the object that is executing the script. In our setup, THIS means the script brain itself. Since script brains don't have health, we won't use it. But if I was placing a script on a Warthog, then using THIS might make more sense. ACTIVATOR[Add] ACTIVATOR means the object (piece or player) that triggered the condition. Here, our WHEN is only checking for players, so this would add the player who entered the script to the damage list. Let's take a look. Spoiler In our scenario, Warholic is the one who activiated the condition since he stepped in the boundary, so he gets placed on the list. Therefore, only Warholic takes damage. Players[Add] Players[add] is a big blanket, and is a good building block for some of the advanced stuff. It's really straightforward - all it does is add every single player (both living and dead) to the list. Let's take a look. Spoiler In our scenario, everyone gets put on the list, since they are all players. Therefore everyone takes damage because everyone is on the list. Team[Add] Team[add] lets you add objects of a specific team to the list of targets. Notice, I said "objects" and not just players. So if you've tagged a Warthog as "Team 1" or an invisble blocker, or... you get the point. They should end up on this list. This can be really powerful, but you can also step on your own toes. Let's take a look. Spoiler In our scenario, adding all objects from Team 2 should add both Warholic and Sir Iron Wolf, since they have their team property "Team 2." Sn1per C, Nitro, have team properties set to "Team 1" (red team) and the script brain's team property is neutral, so it won't be affected wither. Therefore, Warholic and Sir Iron Wolf take damage. There are other Mod conditions available to use for building lists, but I won't cover them in detail here. For some examples, the Team[Activator] will add to the list everything that shares a team property with the object that activated the condition, you can add anything that matches a specific label, and there are a few boundary-related options that are particularly helpful for proximity scripts. ADVANCED - SELECTING SPECIFIC OBJECTS USING 2 OR MORE MOD CONDITIONS You'll notice that scrolling through Mod 2, 3, and so on gives you access to other some more Mod Conditions, especially ones that exclude objects from the list. A good starting pattern for selecting just the right objects to target is to use the first couple mod conditions to build up a list of candidate objects, and then use later mod conditions to narrow down the list to just the ones you want to target. I'll cover just a few examples here that might be interesting for mini games to hopefully demystify some of this. Here's what I'll cover -ACTIVATOR[exclude] -Team: ACTIVATOR[exclude] -Dead[include] ACTIVATOR[exclude] So let's say we don't want to punish a player for reaching the zone, but reward them instead. One way to do that would be to deal damage to all the players EXCEPT the person who made it to the zone. You could do a Musical Chairs game pretty easily this way. What we want to do is first add all the players, and then remove the person who activated it. Let's take a look: Spoiler In our scenario, all four players are added to the list at first, but then Warholic is removed because he is the ACTIVATOR. Therefore, Nitro, Sir Iron Wolf, and Sn1p3r C all take damage. Team: ACTIVATOR [Exlude] This one's let's us reward an entire team for activating our damage zone. We're going to start by adding all the players, then remove all the objects that share a team with the Activator. Remember, the team conditions don't discriminate between pieces and players - it handles all objects. Let's take a look: Spoiler In our scenario, all 4 players are added to the list. Warholic is the Activator, so the Mod 2 condition checks Warholic's team property find that he is on Team 2. Then, it goes through the 4 players on the list, and removes anyone who has a team proprty of "Team 2," which pulls off Warholic and Sir Iron Wolf. Therefore, only Nitro and Sn1p3r C (the non-Blue guys) take damage. This one's definitely more complicated, but I think it really shows how powerful building up a list and then filtering can be. Dead: Include Okay, so the last example of selecting players I want to show will let us select all the players who are dead at the time the script executes. This one might not make sense right away, but I can see it being helpful for minigames. Feel free to ask for more details in the comments. We're going to use the [NOTHING] condition as Mod 1, which creates an empty list and gives us access to the advanced options in Mod 2. Then, we're going to use the Dead [include] condition as Mod 2 to build all the players that are dead. Let's take a look: Spoiler In our scenario, the outcome is that Sn1p3r C and Sir Iron Wolf are on the list. Obviously they are dead and will not take damage, but the action could be to apply a custom label, or move an object to their dead bodies, or any number of things. What went on here was the the fist condition added nobody to the list, and then the second condition added the dead players. We could further limit the list by using another mod condition like a Select: RANDOM 1, Select NEAREST, etc, but this post is long enough already. =) TL;DR To sum it all up, the OBJECTS and TARGETS menus give you options to add groups of objects (players and pieces) to a list. The best way to get started is to use the first couple Mod conditions to build a big list of candidates, and then use the later ones to narrow down the list by removing things you don't want to target. If you've got questions on how to select a specific group of objects for a scenario, I'm happy to answer them, expand on the details from above, or add corrections as needed. Hope this helps someone!
If you want to execute scripts on one or more specific objects, you can use Label [Add]. Then, for each desired Object (s), go into the object properties, go into labels, and add the appropriate label. Some labels are called things like Slayer:Exclude, and I haven't tried using them, but there are a number of custom user labels (User Label:Alpha, for instance).
great tips, guys! Scripting cool stuff is where it's at, even if no one ends up playing my maps, it is fun to make stuff using scripts!
For some odd reason when I try to use this as a guide to scripting custom powerups I get a problem that causes it to not work. I'm using the minigame gamemode. It's set to add alpha traits to Team 8 when interacted but won't work. Does anyone know if there's a bug or have an already scripted custom powerup they could prefab?
Good write up and very informative. Although for clarity I'd put some sort of colored box around the pictures of the players to help identify who's on the same team in addition to putting the teammates closer to each other on the diagram. Either that or you need some sort of key for the picture to indicate who the hell is who rather than just assuming I'm supposed to know who they are based on a profile picture. I was honestly under the impression that nitro and war were on the same team due to the check marks and their proximity to each other until I was almost done reading. I realize it may seem obvious to some, but my focus was on understanding the new terms and rules for this new script rather than trying to decode the pictures. And that's coming from someone who would probably recognize your logos if asked any other day. Someone new to forge hub may have a hard time as well.
Great writeup! What a good way to get people started into this thing as it can be daunting. I had a question about how the mods work. Are they prioritized by order? So say for instance I have 2 teams of 4. Team 1 are ABCD and Team 2 are WXYZ. I have a boundary that deals damage when entered. Player A is the activator as well as closest to THIS, and players Z and B are next closest in that order. If the first target is nothing Second mod is nearest 2 And third is exclude activator. Will it remove the activator without adding the next closest person, resulting in damage only being dealt to Z? What if the order is Nothing Exclude activator Nearest 2 Does that result in both Z and B taking damage? Also PS this is my first post on these forums in ages. It's good to be back. Place looks nice and plays much better on mobile than it once did.
Good writeup but I can't apply it well to what I want to do. I'd like to have a minigame where two teams fight to damage targets. I have it working so that hitting the target awards points, but the points go to red AND blue teams, instead of just the team that hit the target. How can I get it to check teams?
If they're trying to destroy separate targets, then go into the script that adds points and make the target the team you want the points to go to.
Someone told me on another thread that you can't have neutral targets that award score based on whichever team destroys them, is that true?
I think the problem is that I don't have a way to determine who shot the target. The action is the target breaking, but it doesn't (to my knowledge) get an ACTIVATOR object, which means we can't tag the shooter to gain points --- Double Post Merged, Dec 17, 2016 --- You could have them on opposite sides, weld a red target and a blue target back-to-back, and then have the destruction of one despawn the other. Can't think of how to do side by side shooters on the same range though.