Jump to content


Photo

Scar file to store map infos


2 replies to this topic

#1 troubadour

troubadour
  • Members
  • 88 posts

Posted 05 October 2007 - 09:44 AM

I have a question for a scar guru
i know that it is possible to create a scar file with mapname usually to set the music to be played when playing the map in DC
I have also noticed that in AI mod AIHighspeed.scar is used to set g_bHighSpeedAI = true using Cpu_DoString function

I would like to do the same with a table that contains impassable terrain circular zone.
I think it could be a good way store information that are map-related without the problem of the map name.

For instance : my_custom_map.sgb
Create a file my_custom_map.scar :
__init()
{
CpuDoString(AIplayerID, "m_impassableTerrainTable = {(CenterPos1, Radius1) ; ...;(CenterPosN, RadiusN) }
}

The "problem' is to create a table related to terrain in the first available AI player whereas it shall be placed in cpu_manager :-/
self.m_impassableTerrainTable = {}

I think it shall be possible since AI mod team successfully read information aihighspeed setting from scar to cpu_manager but i would like your advice Arkhan ? Larkin ?
am i dreaming or there is a way to code it ?

Edited by troubadour, 05 October 2007 - 09:54 AM.


#2 ArkhanTheBlack

ArkhanTheBlack

    title available

  • Members
  • 814 posts

Posted 05 October 2007 - 11:26 AM

It should work although I don't know how you want to get the info about the impassable terrain zones.

#3 troubadour

troubadour
  • Members
  • 88 posts

Posted 05 October 2007 - 12:57 PM

I am afraid i will have to manually build this file myseld ie open a map with missioneditor, activate impassable layer and with the grid note down coordinates for circles our bounding box that defined impassable zone.
It is not easy but you do the same when you design in the mission editor your map you manually defined impassable zone cause the engine does not compute them

My first try would be :
1/ make a map with a big impassable rectangle in the middle

2/ create a scar file with these coordinates

3/ store them in table in aiplayer or cpu_manager

4/ before calling HasThreatOnPath(pos1, pos2, range) make a collision test (using separator axis collision detection theory in 2D it shal be "easy") between the axis (pos1; pos2) and all the bboxes (or circles) in m_impassableTerrainTable

5/ if there is not an intersection everything is fine it means the real path is a straight line between pos1 and pos2 if not it means the real path will go around one or several impassable zone in that case i think i will compute the intersection point and then call HasThreatOnPath(pos1, intersectPoint) and HasThreatOnPath(intersectPoint, pos2)

I dont pretend to solve all pathing problems this way, it will works only if you got 1 or 2 obstacles

Moreover due to real life work i am not sure i will find the dedication and energy to achieve these goals



Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users