View Single Post
Senior Member
Lone Wolf Staff
Join Date: May 2005
Posts: 8,264

Old May 20th, 2006, 02:12 PM
Based on your diagram, I'm going to assume that the Sergeant is a child of the Trooper unit. I'm also going to assume that the rifle option has an earlier evaluation priority than the sergeant, given the order that you've listed things in. If so, then the trick is to do as follows:

1. Define a tag that will be used to indicate that a grenade launcher is selected (e.g. "misc.grenade").

2. Within the Grenade Launcher option's Evaluate script, have it assign to tag to the grandparent entity. Alternately, you could have it assigned to the "unit", which will bypass the rifle (since its an "item"), or you could assign the tag directly to the "root" (i.e. the top-level entity/unit). How you choose to do this depends on what situations you're trying to cover.

3. Within the PreLinks script of the Assault Rifle, you need to essentially mirror the state of the "misc.grenade" tag. Since the PreLinks script for an entity is evaluated before any options, the rifle beneath the Trooper will not be affected - only the one beneath the Sergeant. This is accomplished by simply having an "if" statement that checks for the tag on the "root" and assigns it to the current entity, if present.

4. Within the link to the Grenade Launcher on the Assault Rifle, designate a link nature of "auto". Now add a "live" test that checks for the presence of the "misc.grenade" tag.

This will cause the grenade launcher to be auto-selected when it's chosen for the rifle equipped by the Trooper. Note that this solution assumes the evaluation sequence is conducive to it working.

Hope this helps,

At 11:36 AM 4/30/2006, you wrote:


A trooper has an assault rifle. The assault rifle has an option to add a grenade launcher.

The Sgt of the trooper squad has the same assault rifle. If the grenade launcher is selected for the trooper(s), I would like it to be automatically added to the Sgt's assault rifle.

I can't use the mirror tag because that only works with the parent-child relationship.

I assume I would have to use a script, but for the life of me I can't figure it out.

+ Squad
|-- Trooper
|---Assault Rifle
|----Grenade Launcher
|----Assault Rifle
|-----Grenade Launcher
rob is offline   #2 Reply With Quote