New scripting function: getDerrick()

For AI and campaign script related discussions and questions
Post Reply
Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3776
Joined: 03 Aug 2006, 19:39

New scripting function: getDerrick()

Post by Per » 22 Jan 2011, 15:11

I have added a new script function getDerrick() to master that takes an int index and returns a corresponding derrick or oil resource. This gives a nice way to quickly iterate over all positions known to contain oil. If an index value is passed that is larger than the number of objects, it returns a NULLOBJECT. The semperfi AI has been modified to use this for attacks of opportunity against undefended oil derricks.

Note that it will return a derrick object even if it is not known to the player, and thus can leak vision information (ie cheating). It is up to the script to handle this. For the semperfi AI, I decided that it would merely assume that non-owned oil resources are enemy derricks, so it did not matter.

Chojun
Regular
Regular
Posts: 518
Joined: 25 Nov 2006, 17:49
Contact:

Re: New scripting function: getDerrick()

Post by Chojun » 22 Jan 2011, 17:09

You should add a bool parameter to allow it to check for visibility, for those AIs that do not cheat.

User avatar
Iluvalar
Regular
Regular
Posts: 1811
Joined: 02 Oct 2010, 18:44

Re: New scripting function: getDerrick()

Post by Iluvalar » 23 Jan 2011, 05:06

It depend of what type of information you use on that object. Most players know or ask where oils are on the map. If the AI use that function only to know (x,y) positions of the oil (as Per is doing it i think) there is no much leak of information. There is no use to protect that function independently. Coders know what is omniscience and what is not and there is no much choice but to trust them to make no cheating or low-cheating AI.

I believe all AI are not cheating at the lowest difficulty level. And the difficulty level is just how much cheating you give them. Maybe they have some omniscient power too...
Heretic 2.3 improver and proud of it.

Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3776
Joined: 03 Aug 2006, 19:39

Re: New scripting function: getDerrick()

Post by Per » 23 Jan 2011, 13:25

What Iluvalar said. The function cannot take a vision bool, since it has to return an actually existing object. And the game removes the oil resource feature when it places an oil derrick, so it cannot return that instead. The scripter just has to be responsible with the result to avoid making a cheating AI.

Post Reply