Page 5 of 6

Posted: Mon Jun 04, 2007 4:27 pm
by Cmdr. Maegil
Is there any chance of this aberration to work on the AI?
If not, would you be so kind as to tell me why not and the right way to do it?
:oops:

Code: Select all

    "IDENTIFY_HOSTILES" = {
	  ENTER = (fightOrFleeHostiles),
		    "scanForNearestShipWithRole: slaver",
		    conditions = ("shipsFound_number" greaterthan 0),
		      do = (
			  setTargetToFoundTarget, "commsMessage: [maegil-mark]",
			  "setStateTo: ATTACK_SLAVER"
			); 
		      else = (
			  scanForHostiles,
			  setTargetToPrimaryAggressor,
			  conditions = ("shipsFound_role" equal police),
			    do = ("commsMessage: [maegil-police]"); 
			    else = (
				conditions = ("shipsFound_role" equal pirate);
			        do = ("commsMessage: [maegil-pirate]"); 
			        else = ("commsMessage: [maegil-threat]");
			  "setStateTo: ATTACK_SHIP"
			  );
			);
	  EXIT = ();
	UPDATE = ("scanForNearestShipWithRole: slaver, pirate", "pauseAI: 1.0");
	};

Posted: Mon Jun 04, 2007 4:47 pm
by Arexack_Heretic
don't know the 'shipsFound_role' return message for scanForHostiles...

Posted: Mon Jun 04, 2007 4:48 pm
by Cmdr. Maegil
I know, I made it up as an example of what I wanted to do... :oops:

Posted: Mon Jun 04, 2007 5:01 pm
by JensAyton
Modified code with comments. I don’t know whether it does anything useful, but the syntax at least makes sense.

Code: Select all

"IDENTIFY_HOSTILES" =
{
    ENTER =
    (
        fightOrFleeHostiles,  // Lose the closing paren
        "scanForNearestShipWithRole: slaver",
        {	// Conditions are a dictionary, they need braces
            conditions = ("shipsFound_number greaterthan 0");  // Semicolon, not comma, because we're in a dictionary. Also, quotation marks must surround the whole statement, not just the variable.
            do =
            (
                setTargetToFoundTarget, "commsMessage: [maegil-mark]",
                "setStateTo: ATTACK_SLAVER"
            );
            else =
            (
                scanForHostiles,
                setTargetToPrimaryAggressor,
                {  // Conditions still need braces
                    conditions = ("shipsFound_role equal police");  // Semicolon, not comma, because we're in a dictionary. Also, quotation marks must surround the whole statement, not just the variable.
                    do = ("commsMessage: [maegil-police]");
                    else =
                    (
                        {  // And again
                            conditions = ("shipsFound_role equal pirate");  // Quotation marks must surround the whole statement, not just the variable.
                            do = ("commsMessage: [maegil-pirate]");
                            else = ("commsMessage: [maegil-threat]");
                        }
                    );  // Closing bracket was missing
                },
                "setStateTo: ATTACK_SHIP"  // Not sure if this is in the right place
            );
        }
    );
    
    EXIT = ();
    UPDATE = ("scanForNearestShipWithRole: slaver, pirate", "pauseAI: 1.0");
};
There were a number of systematic property list syntax errors. To create working scripts, you need to understand the property list structure.

Your conditions were not in dictionaries. Key-value pairs (foo = bar) only make sense in dictionaries, i.e. surrounded by {} pairs.

Several of your conditions took the form "method" operator value instead of "method operator value. A condition is a string; it must be surrounded by quotation marks.

The trailing paren after fightOrFleeHostiles near the top makes no sense.

I reccomend finding and learning to use a programmer’s text editor. The single most important function of such an editor is to maintain consistent indentation, i.e. the number of tabs at the beginning of each line. This helps line up the opening and closing parens/brackets as I’ve done above. This makes it much, much easier to keep the structure “balanced” and properly nested, and to understand the structure.

Posted: Mon Jun 04, 2007 5:09 pm
by Cmdr. Maegil
Thanks, Big A!
It's been well over a decade since I last done something in Turbo Pascal, and even if I remembered something I really don't know the local lingo, so...

This was just an experiment, I'll take one of the tools on the wiki and try to do it in a more consistent way with the code sample you posted - but don't expect too much!

Posted: Mon Jun 04, 2007 5:37 pm
by Arexack_Heretic
Don't forget to add other states, so that your character has something to do when there is nothing around.

Maybe add to script.plist something like:

Code: Select all

{
 conditions = ("government_number lessThan 3", "d100_number greaterThan 90");
 do = ("checkForShips: Meagil",
  {
   conditions = ("shipsFound_number equal 1");
   do = ("check for ships: slaver",
    {
      conditions = ("shipsFound_number lessThan 1");
      do = ("add systemShips: slaver 2 0.5");
     } 
    );
    else = ("addShips: meagil 1");
  }
}
more complex offcourse, so that slavers appear not only at that one point.
Or make an independent script for slavers and Meagil.

NOW.
Stop this hijack immediately and start your own "character_OXPs thread"
This one is about thumbles. ;)

Posted: Mon Jun 04, 2007 5:51 pm
by Captain Hesperus
Arexack_Heretic wrote:
Stop this hijack immediately and start your own "character_OXPs thread"
This one is about thumbles. ;)
And killing me off in proxy......

Captain Hesperus

Posted: Mon Jun 04, 2007 6:11 pm
by LittleBear
Going back to A_H's question, think "become: Explosion" probably would trigger the ship's death actions, but "landonplanet" would take it out of the game without (I think) triggering death_actions.

Posted: Mon Jun 04, 2007 8:12 pm
by Commander McLane
May I derail this thread once again and for a second return to Maegils question?

I wouldn't work with conditions at all in an AI. I'm not even sure it's possible. At least AFAIK there is no AI like this out there.

What you want to do can be achieved much easier with the usual set of AI methods. You just have to define three states instead of your single state and roll between them.

So: first state "IDENTIFY_SLAVER" has "scanForNearestShipWithRole: slaver" in the ENTER-part. Then it needs a "TARGET_FOUND" with whatever you want to do to that target, e.g. setTargetToFoundTarget, "commsMessage: ...". Then it needs a "NOTHING_FOUND", which serves as the else-part of your condition and contains a "setStateTo: IDENTIFY_POLICE".

Second state would be said "IDENTIFY_POLICE", having "scanForNearestShipWithRole: police" in the ENTER-part, then "TARGET_FOUND" with whatever you want to do to the police, e.g. setTargetToFoundTarget, "commsMessage: ...", then "NOTHING_FOUND" as the else-part of that condition and containing a "setStateTo: IDENTIFY_PIRATE".

Third state is called "IDENTIFY_PIRATE" (you wouldn't have guessed, would you?) and looks the same. In the "NOTHING_FOUND" it has (guess!) "setStateTo: IDENTIFY_SLAVER".

You probably should insert some pauseAI before rolling to the next state, so that the AI won't be continuously busy, using system resources continuously.

Generally you should have a look into stations' and rock hermits' AI for getting examples of how to scan for various items interchangingly rather than at the same time.

Posted: Mon Jun 04, 2007 8:50 pm
by Arexack_Heretic
Oo scary. I just had a BSoD experience.
Turns out a sector on my OS-HDD died.
In the process trashing a few jpg's and somehow corruption firefox.
Fresh install worked thankfully and the files lost not critical.
Hopefully this is all the damage done.

Coming back to McL's:
What he is saing about the states is right. You want seperate stages for this, as well as a pause to give the gameengine time to process the request before scanning again.

I seem to recall scripting in an AI...or rather a shipdata.plist's *_actions section,
it involves calling the method 'performScriptAction' <array> IIRC.
However generally using script in the AI is not recomended as this only updates every 'somany' seconds.

Posted: Tue Jun 05, 2007 8:43 am
by Arexack_Heretic
Just want to say I created a new thread in the Expansions forum conserning this Get_Hesperus.oxp.

It starts out fairly codeheavy, as you may expect from me by now, but I would highly appreciate ideas and suggestions.

I have one doubt about the way I set up the whole premiss of the OXP.
I have used the trumble mission as a trigger for the script, and added code to reset that in-built mission a few times.
Q: Should I at all interfere with and rely on the inbuilt mission or code a mirrored occasion myself, independent of the trumble mission.

Q2: Do I need to trick players into buying a trumble?
If everyone refuses to buy one, the OXP would never be activated. :(

Reasons I reset the trumblemision on several occasions:
Buying the trumble activates the script.
Many hardcore players (that are not affraid of trumbles) have already bought and exterminated theirs.
These are exactly the people that would enjoy hunting Hesperus and thus the target-audience of this OXP.
Thus the need to reset the trumble mission.
The trumble mission re-offers itself 1/100jumps of itself if turned down, so that is fine.

Posted: Tue Jun 05, 2007 11:36 am
by TGHC
I've never done the trumble thingy, my original Amstrad version never had it, and I'd read on this BBS that they were a real pain in the bum, so whenever I was offered one for sale, I always refused. Now I'm never offered any, so something has kicked in somewhere to stop them being offered.
I guess I ought to have a crack at the little blighters at some stage and perhaps Get Hesperus is the answer. Mind you I suppose I ought to try the real thing, in which case how would I go about that, can I advertise somewhere?

Trumbles Wanted best prices paid - clear out your space lockers.

Or are there any ship boot sales I could visit?

Posted: Tue Jun 05, 2007 11:48 am
by Arexack_Heretic
lol.

IIRC the trumble script goes into NOTNOW mode when you refuse the offer.
This rolls a d100 everytime you dock at the mainstation at D100<2 it offers you again.
....given the odds you are overdue for an offer.

GetHesperus (currently) will actively reset the trumble at 500-1000score intervals, if you already bought one....If not, then you'll need to be patient untill the native-mission kicks in.


....I was just thinking of a junkyard sale for a second encounter option.

... In some galaxies I may just script H to appear and dissapear at certain planets.

Posted: Tue Jun 05, 2007 1:15 pm
by Wiggy
Arexack_Heretic wrote:
Q2: Do I need to trick players into buying a trumble?
If everyone refuses to buy one, the OXP would never be activated.
Well, I've always turned them down, but they seem to be breeding in my saved character's plist anyway, even though they don't appear on screen.

Is this normal?

Posted: Tue Jun 05, 2007 1:30 pm
by Arexack_Heretic
If you have Aegidian's X-ships (Cobra2 etc) installed, then yes.

Otherwise your computer has been hacked and a malicious agent has edited your commanders' savefile to have EQ_TRUMBLE. ;)