Page 1 of 1

GetThreatMapValue(x, y, index)

Posted: Thu Apr 18, 2013 12:08 am
by jcb989
Question about the above command. What range of values can I expect to be returned?
And, what is "index" used for? player side? 0 = allies, 1 = axis?

Do I have to do anything behind the scenes to determine the threat map values themselves?
Or can I just call them with this function for any given hex location.

My thought is to use the function to semi-automate my reinforcement location arrivals,
such that folks experienced with the given scenario can't park "campers" at the arrival point,
and make an unhappy day for their opponent.

Thanks-

Re: GetThreatMapValue(x, y, index)

Posted: Thu Apr 18, 2013 12:14 am
by jcb989
And I suppose as an alternate, I could build some logic tree with IF statements using this command? If the above is not the proper understood potential use of that 'threat' command:

GetDistanceFromUnit(id, x, y)


Maybe I could run a cumulative function; add up the distances to specific units, if the min max or mean etc etc are below such and such, then move the reinforcement entry location to over here

Re: GetThreatMapValue(x, y, index)

Posted: Thu Apr 18, 2013 12:55 am
by AndrewGardner
The index parameter to GetThreatMapValue is the side being 'threatened'.

If you are using it in multiplayer, I think you will need to call MakeEnemyThreatMap(side) first to update it as it only gets called regularly for an AI side.

Re: GetThreatMapValue(x, y, index)

Posted: Thu Apr 18, 2013 12:03 pm
by jcb989
Okay let me try it. Can you roughly describe how the value is calculated? I see the returned value range is 0-255

Re: GetThreatMapValue(x, y, index)

Posted: Thu Apr 18, 2013 3:50 pm
by AndrewGardner
The function is in data/scripts/AITools.bsf. Some of the details of the calculation are somewhat AI specific and probably not exactly what you will want for your purpose, so you actually might be better off just using it to get some ideas for your own calculation.

Re: GetThreatMapValue(x, y, index)

Posted: Thu Apr 18, 2013 11:39 pm
by jcb989
this function here looks more advanced choice to try:

MakeEnemyThreatMap2(side, me)

so allies , side = 0
axis, side would = 1

how do I define the variable, "me" ? what's that? how do I define it? It seems like it is a self-reference to the current unit being considered.
hope I'm not asking a dumb question.

Re: GetThreatMapValue(x, y, index)

Posted: Fri Apr 19, 2013 12:08 am
by AndrewGardner
If you are using this in multiplayer, you must not call MakeEnemyThreatMap2 as it will behave differently based on what the players have their AI option set to. If you want the enhanced version, call MakeEnemyThreatMap_Enhanced directly.

It looks like me can be -1 to get the general threat against the side.

Re: GetThreatMapValue(x, y, index)

Posted: Fri Apr 19, 2013 1:49 am
by jcb989
Thanks! I have MakeEnemyThreatMap(side) working as planned.
Reinforcements displace if their entry area is threatened more than another location.
I had to make sure the logic was <= and not only < otherwise when neither location was threatened,
the pre-frightened troops, they were going to the reserve location... =)

I will leave it as-is for now, I guess. Thanks again,