Lone Wolf Development Forums

Lone Wolf Development Forums (http://forums.wolflair.com/index.php)
-   Army Builder (http://forums.wolflair.com/forumdisplay.php?f=16)
-   -   Mirroring a child from another child of a different parent? (http://forums.wolflair.com/showthread.php?t=6215)

ratboy April 30th, 2006 10:36 AM

Mirroring a child from another child of a different parent?
 
Situation:

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
|---Sergeant
|----Assault Rifle
|-----Grenade Launcher

rob May 20th, 2006 02:12 PM

Mirroring a child from another child of a different parent?
 
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,
Rob


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

Quote:

Situation:

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
|---Sergeant
|----Assault Rifle
|-----Grenade Launcher


All times are GMT -8. The time now is 04:54 AM.

Powered by vBulletin® - Copyright ©2000 - 2024, vBulletin Solutions, Inc.
wolflair.com copyright ©1998-2016 Lone Wolf Development, Inc. View our Privacy Policy here.