object in sight

For AI and campaign script related discussions and questions
Post Reply
User avatar
Prot
Trained
Trained
Posts: 167
Joined: 29 Nov 2010, 12:41

object in sight

Post by Prot » 15 Jan 2018, 14:19

I want to ask, if we have the opportunity to receive information, does one player seen object to another player?
At the moment I see only one solution. enumStruct/Droid/Whatever(player, type, view), but it requires a lot of cycles if I need reverse to find out whether the object in view, or under the fog of war one player by another.
I'm not very strong in qtscript functions, is it difficult to do such a function to the JS API isSight(object, who_sight)?

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

Re: object in sight

Post by Per » 15 Jan 2018, 19:00

I'm not entirely sure what you're asking. enumStruct and enumDroid both have an optional third parameter that filters the list of droids by the vision information of the player parameter passed in. Other functions have similar filters.

User avatar
Prot
Trained
Trained
Posts: 167
Joined: 29 Nov 2010, 12:41

Re: object in sight

Post by Prot » 16 Jan 2018, 06:40

Per wrote:I'm not entirely sure what you're asking. enumStruct and enumDroid both have an optional third parameter that filters the list of droids by the vision information of the player parameter passed in. Other functions have similar filters.
With the increasing of code in my bot, i have to think about optimizing more and more.
For example: eventObjectSeen we saw strategically important objects memorized in a array. Next, we need to know if you can see it or whether anyone from this array or not. Of course you can just query the object and get its coordinates etc, this API allows you to do, whether we see the object or not, but it's something like cheating. And I all the details I want to make a bot without the advantage over man.
Therefore is to ensure that the object in view, we need to interrogate all the objects through the filter enum...(obj,type,VIEW) with the third option, and that's a lot of cycles through the obj.filter(), or obj.forEach() etc.

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

Re: object in sight

Post by Per » 17 Jan 2018, 00:33

For script performance, you should try to use enumArea() and enumRange(), as they iterate over fewer objects.

User avatar
Prot
Trained
Trained
Posts: 167
Joined: 29 Nov 2010, 12:41

Re: object in sight

Post by Prot » 17 Jan 2018, 05:34

Ohh.. Right. I still don't have the habit to consider code under the v3.1.5

Post Reply