Scripting Question

A forum for discussing map making ideas and problems for the Myth series.
t o x y n
Posts: 146
Joined: Wed Jul 26, 2006 11:26 pm

Scripting Question

Post by t o x y n »

I've been reading through the scripting articles available on vr's website (very cool of you to put/keep those online, btw), and I've went through different examples and found some stuff to work and some other stuff to not work. One thing is that I gone thru Ares' scripting guide more than once. I've triple checked my stuff and for some reason, I just can't get things to work right.

Basically, the level starts out with 2 different groups attacking and 2 others lurking nearby. The first group to attack (melee and arty) doesn't use any Test Unit actions at all. Their attack (MELE) is activated by an 'Activates on Success' from a previous Movement action. That movement action is intially active, but put on a delay to allow the player(s) in the game to get ready/distribute units.

The second group, all melee units, uses a Test Unit action to test for Vitality Less Than (less than 100% culmative health) from the first group to attack that I mentioned above. Basically, I wanted this second group to begin rushing in as soon as the first group takes damage from the player. I have a Test Unit function for Vitality, which upon success will activate a Movement action, which upon success will activate an attack (MELE) action.

Now, the third group, all melee- is set to activate only if the player is really really close to where I stashed them at (on a hill). I started the chain with a Test Unit action for Enemies within a set Radius. Per Ares' scripting tutorial, I linked both this 3rd group of melee and 'The Player Units as Enemies' function I made based off the player's units. When this is activated upon success, this 3rd group of melee should appear via a CTRL function, then the CTRL function is set to activate on success a Movement action (so none of the units in the 3rd group gets stuck on trees). After the movement action is successful, it is set to activate an attack (MELE) function.

I also have a wight sunk in a nearby area of deep water, but only comes out and attack if any of the player(s)' units are really close. The wight uses the same style chain reaction of functions, except that I used the ATTACK function instead of the Suicide function, because I just want him to rush at the player(s) on the level instead of sneaking/wandering around when triggered.

The problem? None of the Test Unit functions I setup seem to work properly. The 3rd group that should only activate when I'm close to them (I even set the radius to 1 last night out of curiousity), activates, appears and attacks even though I'm (player units) a good distance away from them. The wight does the same even though I'm not even close to the water. I tried changing some things around, and one time my units (player units) got confused and even though the wight hadn't surfaced, they had tried to attack it. Regardless of what I do, the 2nd group automatically attacks from the get-go and doesn't even pick up the Movement action, it just goes straight to the attack (MELE) action.

I downloaded Chaos and I guess it was made for a later version of OSX. :(

I've checked through all the action settings, and they are correct. I must be missing something incredibly simple, or shouldn't be using a certain type of action for certain units...? What's making this not work the way I want?

Thanks
A-Red
Posts: 771
Joined: Fri Jul 23, 2004 8:36 pm

Post by A-Red »

It's hard to tell exactly what the problems are for this sort of thing without seeing the script, but I can see a couple of things that might be problematic.

For a radius test with Light Forces as Enemies, you'll need *two* containers in the Link: The monsters being tested around (subj) and the player units to test for (enem). Also, it will not work if the subj monsters are not visible, which it sounds like they aren't. You're testing for a radius around nothing, which is a sure way to make weird things happen.

MELE isn't the most reliable action. I've hardly ever seen it used except by Ares--I don't think it's in any of Bungie's levels. Personally, I always use ATTA. It probably isn't causing your problems, but you could give it a try.
Last edited by A-Red on Mon Apr 09, 2007 6:03 pm, edited 1 time in total.
User avatar
ozone
Posts: 744
Joined: Wed Mar 24, 2004 5:05 pm

Post by ozone »

a movement action succeeds once it is triggered...so by activating the ATTA from a successful MOVE, the ATTA will trigger right after the MOVE.

To check timing of this stuff being triggered add a "debug flag" to the initial MA thats start it all off. Then after playing the map you can open the myth-log and find out when stuff is being triggered...

debug is your friend...
do it.
gugusm
Posts: 487
Joined: Mon Aug 22, 2005 1:16 pm
Location: Klucze, Poland
Contact:

Post by gugusm »

A-Red wrote:MELE isn't the most reliable action. I've hardly ever seen it used except by Ares--I don't think it's in any of Bungie's levels. Personally, I always use ATTA. It probably isn't causing your problems, but you could give it a try.
Well, I think Bungie was using MELE often, especially for Thrall. I use it too and it's good, but i never use "Power Over Distance Treshhold", because it was crashing my game once, when combined with some GEOM.
However, I use it often.
User avatar
haravikk
Site Admin
Posts: 987
Joined: Mon Mar 22, 2004 12:56 pm
Location: Scotland

Post by haravikk »

MOVE actions aren't even as uniform as that. The success of a MOVE depends on the deactivation type.
If it is set to deactivate on trigger then it will do just that, and thus succeeds right away as you say.

However, with other types success is meant to be when the unit arrives at the final waypoint, and failure if the unit can't get to the waypoint. However, neither of these can be used with any certainty, as a unit may get stuck but still think it can get to it's destination, or it might get to the destination but think it hasn't reached it yet.
And even then, sometimes success will go off at the first-waypoint in a multiple waypoint series.
I've even had a MOVE that just wouldn't work because the units were in water, surprisingly tempermental action considering it's relative simplicity.

My advice would be to create a Test Unit (TUNI) action which tests an area, either using a circle centre-point and radius or a polygon, then checking to see if any of the moving units are in it, if they are then trigger the melee.

MELE actions I've never had trouble with, their good for getting forces to attack in some semblance of a formation and are usually okay for what you need them for.
Being Haravikk gets you girls like these:
Image
t o x y n
Posts: 146
Joined: Wed Jul 26, 2006 11:26 pm

Post by t o x y n »

A-Red wrote:It's hard to tell exactly what the problems are for this sort of thing without seeing the script, but I can see a couple of things that might be problematic.

For a radius test with Light Forces as Enemies, you'll need *two* containers in the Link: The monsters being tested around (subj) and the player units to test for (enem). Also, it will not work if the subj monsters are not visible, which it sounds like they aren't. You're testing for a radius around nothing, which is a sure way to make weird things happen.

MELE isn't the most reliable action. I've hardly ever seen it used except by Ares--I don't think it's in any of Bungie's levels. Personally, I always use ATTA. It probably isn't causing your problems, but you could give it a try.
Is there a way to access the actual script so I can c&p it on here?

I've setup the needed containers for the player units (subj and enem), and linked them. Didn't make a difference at all. I'm confused when you say 'subj monsters are not visible...' - are you talking about the spiders? If so, yes, they are not visible at first. I wanted them only to appear when an enemy unit is detected nearby, then after appearing to activate a MOVE function, which activates a ATTACK function. I tried making them visible and testing it like that, it didn't make a difference. All player units (with the exception of the ones that don't/do show up on different diff levels) are visible from the start.

I tried the ATTACK action instead of the MELEE action, and it didn't help.

I'll just list out some updated details about how things are now to make this a little more clear to you all. I can't figure out why I'm having so much trouble with TUNI and other actions.

My updated scripting setup and results...

First, I have 2 opening actions. Currently, only one of them work (the one that isn't triggered/activated by a TUNI action).
One is a movement (MOVE) action for a group of enemy units (melee and arty). I set a trigger time of 10 for this action and made it intially active. This MOVE action uses 3 parameters: link (to the enemy units that are moving); waypoints; activates on execution (activates a MELE attack action). This chain of 2 different Actions works 100%, and, is the only action that doesn't use a TUNI action to trigger it.
The second opening action is the one I mentioned before. I made some changes after reading people's responses. However, it still doesn't work.

What is supposed to happen: A TUNI action tests for vitality among the first attacking group (what I mentioned in the paragraph above). I set it so that as soon as that first group takes damage from the player (Parameter: Vitality Less Than - Value: 1.0), that a MOVE action is executed (Activates on Success). The MOVE action is there to navigate this secondary attack group to the area where fighting has occured between the first attack group and the player. The MOVE action, when finished, should trigger the MELE action so this secondary group can start attacking.

Current script setup for that reinforcement group:
•TUNI.need reinforcements? (intially active, no intial delay; expiration mode: on execution)
**Link: First Attack Squad
**Vitality Less Than: 1.00001
**Activates on Success: Reinforcements Move
MOVE.Reinforcements Move (expiration mode: on execution)
**Link: Secondary Squad
**Waypoints: (coordinates)
**Activates on Execution: Second Squad Attacks
MELE.Second Squad Attacks (expiration mode: never)
**Link: Secondary Squad
**Power Over Distance Threshold: 2.001

What happens: South squad moves after short delay then attacks player like it should. The reinforcements never even budge even if I kill every other unit on the map, heh. None of the units involved are invinsible.

The invinciible spiders nearby are setup like this:

•TUNI.Is player nearby? (intially active, no initial delay; expiration mode: on trigger)
**Link: Hidden Spiders South, Player units as Enemies, Player units as Targets.
**Enemy Closer Than Radius: 10.001
**Activates on Success: Spiders Appear
CTRL.Spiders Appear (expiration mode: on execution)
**Link: Hidden Spiders South
**Visible Flag: true
**Activates on Success: Spiders Move
MOVE.Spiders Move (expiration mode: on execution)
**Link: Hidden Spiders South
**Waypoints: (coordinates)
**Activates on Execution: Spiders Attack
ATTA.Spiders Attack (expiration mode: never)
**Link: Hidden Spiders South
**Attack Team: 0

What should happen: When a player(s) unit/units gets nearby the location the invisi spiders are at (on a very tall hill), the spiders should then appear, start moving and attack the player via a chain of actions in the scripting.

What happens: Nothing. They don't even appear regardless of how close I put units near the hill when testing. I even tried making the radius some outrageous number.

For the wight, I deleted all the actions out of frustration a little earlier. All I want the stupid wight to do is check for enemy (the player) units nearby the deep pool of water he's hiding in, and then attack if there are units within a nearby distance. I had a TUNI action setup, which triggered an attack action. I actually tried attack, melee and suicide for actions to be triggered by the TUNI. One time the wight came a little ways out of the water but didn't attack, and started to run only when I got really close to it. wtf?
A-Red
Posts: 771
Joined: Fri Jul 23, 2004 8:36 pm

Post by A-Red »

Ok, that helps. First off, I think you'll want that first TUNI to expire on successful execution rather than just execution. They way you have it, they'll deactivate even if they fail, which will happen instantly because your enemies will start with full health. That shouldn't be causing them to trigger the other actions early...but it is a problem. The second TUNI should also expire on success--you've got it expiring on trigger.

Also, the Light Forces as Targets should not be in your enemy radius test--only subjects and enemies. That may be your problem.
t o x y n
Posts: 146
Joined: Wed Jul 26, 2006 11:26 pm

Post by t o x y n »

Ok I'll give it a try here in a few after I do some site updates for my tournament.

Thanks
t o x y n
Posts: 146
Joined: Wed Jul 26, 2006 11:26 pm

Post by t o x y n »

Sweet, the TUNI action for the reinforcements works great now. The spiders however did not work. I tried changing the radius to 100 just incase I didnt make it big enough, but they still didn't activate (they didnt appear). So, something wrong with the variables I have the link parameter under the TUNI action, maybe?

Inside of that Link parameter, I used: Hidden Spiders South, Player units as Enemies. Did I use the wrong link? Maybe something wrong with the 'Player Units as Enemies' action I made? When I open up that action, the expiration mode is set to trigger, and all my other unit identify actions are set to that as well.

Inside of the 'Player Units as Enemies' action, the parameter looks like this: 'monster_identifier enem', and the variables are just all of the player's units.
A-Red
Posts: 771
Joined: Fri Jul 23, 2004 8:36 pm

Post by A-Red »

Well, like I said, your subjects aren't technically on the map--they're invisible. So you can't test for a radius around them. You could use a circle centerpoint or a polygon or something instead.
t o x y n
Posts: 146
Joined: Wed Jul 26, 2006 11:26 pm

Post by t o x y n »

errr.. oh yea, heh. Fixed it to activate off of another action, works great now. I went on to script some more stuff after I fixed those initial probs. Now I can start making progress again!

Thanks guys
Graydon
Posts: 1605
Joined: Sun Mar 21, 2004 5:10 pm

Post by Graydon »

Nice. Ared took this whole one for the team! Nice work man.

I was browsing through your problems and issues and all those things that caused fixes jumped out at me straight away. Looks like it's been fully sorted though.

For future reference: You can go under Mesh---Export Map Actions, to save your script as a .txt file on your computer. You can then open said text file, scroll to the areas in question and copy/paste... if you have more problems that is.

As some other people have pointed out, 'Success' of a MOVEment action is quite questionable. I find it's far better to find other methods of triggering actions that follow MOVEs than with an ACOS in the MOVE itself.

Another problem that might occur for you is with ATTAck actions and their expiration modes.... I generally ALWAYS set ATTAs to deactivate 'never', or 'on trigger'.... anything else and you risk the potential problem of your attackers going to the closest targets.. killing them, and then if there's no more enemies within their range, they just stand there. it's no good.

GL.
Image
A-Red
Posts: 771
Joined: Fri Jul 23, 2004 8:36 pm

Post by A-Red »

Graydon wrote:Another problem that might occur for you is with ATTAck actions and their expiration modes.... I generally ALWAYS set ATTAs to deactivate 'never', or 'on trigger'.... anything else and you risk the potential problem of your attackers going to the closest targets.. killing them, and then if there's no more enemies within their range, they just stand there. it's no good.
Are you sure trigger is ok? Trigger is the default expiration for an attack, and I've occasionally run into problems with it. I always use never.

On that note, there's an easy way to set attacks to always use never as the default. Go into the "templates" folder in Fear, find the one for "attack" and set never as the expiration mode there, replacing trigger.
User avatar
Fury IX
Posts: 254
Joined: Thu Oct 19, 2006 7:37 pm

Post by Fury IX »

some of my observation about attack:

If you have your attack linked to obje and subj with no flags it seems to work fine with deactivate on trigger. If you set it to attack all enemies, you have to set it never or they will quit fighting after their first target is killed or the attack action is reactivated.

Each combination of flags seems to produce slightly different AI, but attack all enemies seems to work the best in my opinion for most circumstances. Melee actions can produce some verrry bad AI if not fine tuned perfectly for the situation at hand.

As a side note, when I set it to never deactivate even when it runs out of subjects, it seems to still be on; like if you munger more subjects into that action way down the line it still works fine. So if you have a huge number of attack actions, it could slow your script down maybe if you didnt deactivate some of them.
t o x y n
Posts: 146
Joined: Wed Jul 26, 2006 11:26 pm

Post by t o x y n »

I set all my ATTACK functions to expiration mode of 'Never' and haven't run into any problems.

I put a link to a beta of my first solo/coop map in another thread. I think it came out pretty good for my first try at scripting. Thanks a bunch everyone.
Post Reply