Members | Sign In
All Forums > Mission Scripting
avatar

I'm obviously doing it wrong... please help

posted Apr 06, 2012 14:20:21 by TommyWilliams
Thought I would try my hand ad a simple script and begin understanding how things go together, but my script does not result in my expected events. This appears to follow the mission scripting guide lines, and is logically sound. So there is something I am missing.

<mission_data version="1.61">
<start>
<create type ="player" x="50000" y="0" z="50000" angle="270" name="Artemis"/>
<create type="neutral" x="49500" y="0" z="50000" name="test" hulltype="1" raceKeys="friendly" hullKeys="Scout" angle="270" fleetnumber="2"/>
</start>
<event>
<direct name="test" pointX="49500" pointY="0" pointZ="45000" scriptThrottle="1"/>
<set_object_property name="test" property="topSpeed" value="6"/>
</event>
<mission_data>
page   1
7 replies
avatar
Hissatsu said Apr 06, 2012 15:32:21
Generally, when you are asking "Where am i wrong" or "how do i solve this problem", you'd prefer to provide information not only about what you are doing, but also what do you expect to happen, and what happens instead.

Judging only from your code, I only see two potential problems:

1) You use hulltype attribute. Hulltype seems to be a deprecated field or just a typo, i am not 100% sure but noone was willing to confirm it for me. It never worked for me. Use HullID if you want to specify a ship by its vessel id.

2) Your event has no "if" block, which means it will either be executed each "tick" (numerous times per scond) or it wont be executed at all. You'd want to add some variable, and maybe a timer in start block, and check if variable is equal to whatever you set it in start block and set the variable to something else in the event so the event doesnt repeat.
[Last edited Apr 06, 2012 15:33:35]
avatar
TommyWilliams said Apr 06, 2012 18:12:44
On point #1: This resolves some randomness I was encountering in the non-player ship's hull.
On point #2, I have added:
<if_distance name1="test" name2="Artemis" comparator="LESS" value="1000"/>


What I expect, quite simply is that the non-player ship will turn towards and fly at the point given in the direct statement. Instead if flies straight in the heading it was created with (even if I remove the angle property).
avatar
Hissatsu said Apr 06, 2012 19:43:50
Maybe (maybe!) it has something to do with "AI BRAIN STACK". I'm not sure, but try cleaning its brain stack before giving it orders.

Also, use debug (aka, add big_messages to scripts you arent sure are working or logging into mission log) beccause sometimes you just mistype something (like, player ship name or target name) and you dont understand why it doesnt work and spend minutes and minutes hitting the wall with your head... while it shouldnt ever work because you check for wrong variable/ship/etc...

Editing in good editor like Notepad++ also helps because it can highlight syntax (of XML files for example) and it will, for example, highlight all occurences of certain attribute in the text when you put your cursor on one, like, if you put your cursor on "test" it will highlight all cases of "test" automatically so you can check quickly that you dont have a typo (that "test" in create statement is the same as in if_distance statement), etc
avatar
Mike_Substelny said Apr 11, 2012 16:16:08
The direct block is old. It is being deprecated in favor of the AI stack. It never was very reliable because your script's direct commands would sometimes conflict with the old AI system.

I suggest doing everything through the new AI stack. I think the add_ai block you want is called POINT_THROTTLE (or something like that).
"Damn the torpedoes! Four bells, Captain Drayton!"

(Likely actual words of Admiral David Farragut, USN, at the battle of Mobile Bay. Four bells was the signal for the engine room to make full steam ahead).
avatar
Hissatsu said Apr 12, 2012 08:03:44
So direct statement currently does nothing, right?
Maybe all "direct" should be just replaced with "add_ai" blocks in missions?
[Last edited Apr 12, 2012 08:04:01]
avatar
Mike_Substelny said Apr 18, 2012 20:23:39
The direct command still works for generic objects, but that may go away in the future.

I hope that Thom comes up with an AI block that duplicates what the direct command did. Right now there isn't a good way to instruct a ship to chase after a specific named target that is moving.

Frankly I'd like an "intercept" block. The math is a little harder, but it would make enemies smarter.
"Damn the torpedoes! Four bells, Captain Drayton!"

(Likely actual words of Admiral David Farragut, USN, at the battle of Mobile Bay. Four bells was the signal for the engine room to make full steam ahead).
avatar
ThomRobertson said Apr 22, 2012 17:49:57
Hulltype seems to be a deprecated field or just a typo, i am not 100% sure but noone was willing to confirm it for me.


Yes, hulltype has been removed from the code, superceded by hullKeys, raceKeys, and/or hullID.

The direct command still works for generic objects, but that may go away in the future.


Yes, I intend to use the new brain stack for more than just enemies and neutrals.

Frankly I'd like an "intercept" block.


I've added TARGET_THROTTLE to my version. I'll think about plotting an intercept course, sure.

Creator of Artemis
Login below to reply: