Nexus Modding > Scripting

The AI and You

(1/20) > >>

The_Small_Time_Modder:
I had a few questions on scripting the AI.

1. Can you set it so the AI activates when any ship you have enters a certain area in the scene?

2. How do you code for a fleet to enter the scene via jump?

And a question out of curiosity....

3. Could it be possible to create a program sort of like the trigger/condition/event programs found in editors of games, such as AOE 3, that can be used to easily create code for an AI? if so that could be a really neat tool. If not it was just an idea.  :-\

Mularac:
1- That can easily be done. Just create the areas and then use the AreaEntered event.
For example, let's have a look at this piece of code, using my default_AI as basis:


--- Code: ---MACHINE "AI"
STATE Start
RULE event in
:action
SetAreaAbs(0, <x>, <y>, <z>, <radius>);
SetAreaAbs(1, <x>, <y>, <z>, <radius>);
SetAreaAbs(2, <x>, <y>, <z>, <radius>);
SetAreaAbs(3, <x>, <y>, <z>, <radius>);
//We declare here the areas in the scene.
:end
END

//For example, we want to boot the ai when one of the players ships reach the 2 area
RULE event AreaEntered
condition e.ship:race=#race_player&e.area=2
:action
M:GetMachine("InnerAI"):ChangeState(Battle,
e.ownMachine := M:GetMachine("InnerAI");
e.oRace := #race_gorg;
e.oRaceList := -1;
e.oShipList := -1;
e.eRace := #race_player;
e.eRaceList := -1;
e.eShipList := -1;
e.parentMachine := M:GetMachine("AI");
);
//Simple declaration of the AI, this will make the gorg ships launch towards the player ships.
:end
END
END
END


MACHINE "InnerAI"
#include "defaultAI.mach"
END

--- End code ---

2- You mean ip jump or gate jump?

3- I don't think I follow.... you mean like a more user-friendly IDE?

The_Small_Time_Modder:
 2- More like an IP jump, sorry i didnt clarify that!  :(

 3- i think so, im talking about how some editors allow you to create triggers, then create conditions (what sets off the trigger) and events (the result of the trigger) to make an in-depth mission, i have quite a bit of experience with that such system thanks to the editor from starcraft II (excellent editor in my opinion, i figured it all out in less than two days!)

Edit: on a side note, would you put that coding IN the default_ai.mach? or make it a seperate .mach? i just dont want to wind up doing the wrong thing and end up stumped again. I hate it when i wind up like that. >:(

Edit #2: If you can make the program i was talking about earlier, that would be a true honor! i think you're an absolute genius with coding this stuff! :D

That includes Aparso, if you're reading this Aparso... YOU'RE AWESOME! :D

Mularac:
well... it COULD be done. But it'd mean a shitload of work... probably too much. Not a priority right now, actually...
Working with a single text file is simple enough, once you get used to it and find a proper environment to ease up on the things (I recommend notepad++)

About the other thing: yeah, this code is meant to go someplace else, a .mach file or inside the .mission one. Just take care that the path to the default_ai.mach file in the #include line is the correct one (that file is located on this forum. somewhere)

and the ip drive arrival:

first, select the ships to jump (for example, all the player ships), then go through the list applying the longRangeArrive(ship) command to each item of the list:

--- Code: ---e.shipsToJump := getFreeSel();
SelectShips(e.shipsToJump, s.race = #race_player);
Execlist(e.shipsToJump,
longrangearrive(s.this);
);

--- End code ---

Or you could issue that command to a ship in particular, for example, m.ship:

--- Code: ---LongRangeArrive(m.ship);

--- End code ---

The_Small_Time_Modder:
Okie dokie, Thanks!

just a few more questions...

1. How would you code capturing a idle ship? (i.e. a battleship thats just floating around doing nothing, i tried this myself and fouled up...)

2. would you create a list for a specific group of ships to have the code you just stated affect it?

Edit: for #2, i have a group of raptor ships i specifically wanted to have jump in once the raptor ships that are present in the first place are destroyed, if that narrows your answer down...

Navigation

[0] Message Index

[#] Next page

Go to full version