GetThreatMapValue(x, y, index)

Download scenarios and talk about scenario design.

Moderators: Slitherine Core, BA Moderators

Post Reply
jcb989
Colonel - Fallschirmjäger
Colonel - Fallschirmjäger
Posts: 1423
Joined: Fri Nov 05, 2010 12:02 am
Location: Bradenton, Florida

GetThreatMapValue(x, y, index)

Post 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-
jcb989
Colonel - Fallschirmjäger
Colonel - Fallschirmjäger
Posts: 1423
Joined: Fri Nov 05, 2010 12:02 am
Location: Bradenton, Florida

Re: GetThreatMapValue(x, y, index)

Post 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
AndrewGardner
Slitherine
Slitherine
Posts: 535
Joined: Tue Nov 13, 2012 6:24 pm

Re: GetThreatMapValue(x, y, index)

Post 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.
jcb989
Colonel - Fallschirmjäger
Colonel - Fallschirmjäger
Posts: 1423
Joined: Fri Nov 05, 2010 12:02 am
Location: Bradenton, Florida

Re: GetThreatMapValue(x, y, index)

Post 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
AndrewGardner
Slitherine
Slitherine
Posts: 535
Joined: Tue Nov 13, 2012 6:24 pm

Re: GetThreatMapValue(x, y, index)

Post 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.
jcb989
Colonel - Fallschirmjäger
Colonel - Fallschirmjäger
Posts: 1423
Joined: Fri Nov 05, 2010 12:02 am
Location: Bradenton, Florida

Re: GetThreatMapValue(x, y, index)

Post 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.
AndrewGardner
Slitherine
Slitherine
Posts: 535
Joined: Tue Nov 13, 2012 6:24 pm

Re: GetThreatMapValue(x, y, index)

Post 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.
jcb989
Colonel - Fallschirmjäger
Colonel - Fallschirmjäger
Posts: 1423
Joined: Fri Nov 05, 2010 12:02 am
Location: Bradenton, Florida

Re: GetThreatMapValue(x, y, index)

Post 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,
Post Reply

Return to “Battle Academy : Scenario Design”