Advertisement
Janne252

Untitled

Feb 17th, 2015
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 18.46 KB | None | 0 0
  1. function Player_IsLocalPlayer(player)
  2.     local pid = Player_GetID(player)
  3.     if pid == Game_GetLocalPlayerID() then
  4.         return true
  5.     end
  6.     return false
  7. end
  8.  
  9. function Player_GetUniqueKey(player)
  10.     return "player_" .. Player_GetID(player) .. "_" .. Player_GetName(player)
  11. end
  12.  
  13. function Player_GetName(player)
  14.     return Player_GetDisplayName(player)[1]
  15. end
  16.  
  17. function Players_ForEach(f)
  18.     for i = 1, World_GetPlayerCount() do
  19.         local player = World_GetPlayerAt(i)
  20.         local pid = Player_GetID(player)
  21.         f(pid, i, player)
  22.     end
  23. end
  24.  
  25. function Players_ForEachInTeam(team, f)
  26.     Players_ForEach(function(pid, idx, player)
  27.         if Player_GetTeam(player) == team then
  28.             f(pid, idx, player)
  29.         end
  30.     end)
  31. end
  32. function Player_AddPopulation(player, amount)
  33.     local population = Player_GetMaxPopulation(player, CT_Personnel)
  34.     Player_SetPopCapOverride(player, population + amount)
  35. end
  36.  
  37. function Team_GetEntitiesNearPoint(team, pos, radius)
  38.     radius = radius or 15
  39.     local eg_villagers = EGroup_CreateIfNotFound("eg_villagers_near_farm")
  40.     local eg_villagers_temp = EGroup_CreateIfNotFound("eg_villagers_temp")
  41.     EGroup_Clear(eg_villagers)
  42.  
  43.     Players_ForEachInTeam(team, function(pid, idx, player)
  44.         EGroup_Clear(eg_villagers_temp)
  45.         World_GetEntitiesNearPoint(player, eg_villagers_temp, pos, radius, OT_Player)
  46.         EGroup_AddGroup(eg_villagers, eg_villagers_temp)
  47.     end)
  48.     return eg_villagers
  49. end
  50.  
  51. function Team_GetSquadsNearPoint(team, pos, radius)
  52.     radius = radius or 15
  53.     local sg_villagers = SGroup_CreateIfNotFound("sg_villagers_near_farm")
  54.     local sg_villagers_temp = SGroup_CreateIfNotFound("sg_villagers_temp")
  55.     SGroup_Clear(sg_villagers)
  56.  
  57.     Players_ForEachInTeam(team, function(pid, idx, player)
  58.         SGroup_Clear(sg_villagers_temp)
  59.         World_GetSquadsNearPoint(player, sg_villagers_temp, pos, radius, OT_Player)
  60.         SGroup_AddGroup(sg_villagers, sg_villagers_temp)
  61.     end)
  62.     return sg_villagers
  63. end
  64.  
  65.  
  66. function EGroup_GetClosest(pos, egroup)
  67.     local entities = {}
  68.     EGroup_ForEach(egroup, function(egid, idx, entity)
  69.         table.insert(entities, entity)
  70.     end)
  71.     return World_GetClosest(pos, entities)
  72. end
  73.  
  74. function EGroup_AddGroup(egroup, grouptoadd)
  75.     EGroup_ForEach(grouptoadd, function(egid, idx, entity)
  76.         EGroup_Add(egroup, entity)
  77.     end)
  78.     return egroup
  79. end
  80.  
  81. function Entity_GetUniqueKey(entity)
  82.     return "entity_" .. Entity_GetGameID(entity)
  83. end
  84.  
  85. function Entity_GetGarrisonedSquads(entity)
  86.     local sgroup = SGroup_CreateIfNotFound("sg_villagers_squads_held")
  87.     SGroup_Clear(sgroup)
  88.     Entity_GetSquadsHeld(entity, sgroup)
  89.     return sgroup
  90. end
  91.  
  92. function Entity_AddHealth(entity, health)
  93.     local max_health = Entity_GetHealthMax(entity)
  94.     local current_health = Entity_GetHealth(entity)
  95.     local new_health = current_health + health
  96.     if (new_health > max_health) then
  97.         new_health = max_health
  98.     elseif (new_health < 0) then
  99.         new_health = 0
  100.     end
  101.     local percentage = new_health / max_health
  102.     Entity_SetHealth(entity, percentage)
  103.     return percentage
  104. end
  105.  
  106. function Entity_AutoAlign(entity)
  107.     Entity_SetHeading(entity, Entity_GetHeading(entity), false)
  108. end
  109.  
  110. function Entity_CheckForParentSquad(target)
  111.     if scartype(target) == ST_ENTITY then
  112.         if Entity_GetSquad(target) then
  113.             return Entity_GetSquad(target)
  114.         else
  115.             return target
  116.         end
  117.     else
  118.         return target
  119.     end
  120. end
  121.  
  122. function Entity_CreateAndSpawnToward(ebp, player, pos, toward, force_construct)
  123.     force_construct = force_construct or true
  124.     local neutral = false
  125.     if not player then
  126.         neutral = true
  127.         player = World_GetPlayerAt(1)
  128.     end
  129.     local entity entity = Entity_Create(ebp, player, pos, toward)
  130.    
  131.     if neutral then
  132.         Entity_SetWorldOwned(entity)
  133.     end
  134.     Entity_Spawn(entity)
  135.     if force_construct then
  136.         Entity_ForceConstruct(entity)
  137.     end
  138.     return entity
  139. end
  140.  
  141. function Entity_GatherResource(caster, entity, amount)
  142.     if not amount then
  143.         amount = 1
  144.     end
  145.     local rt = Villagers_GetEntityResourceType(entity)
  146.     if Entity_IsOfType(entity, "salvageable_object") then
  147.         if rt == RT_FOOD then -- FOOD
  148.             Player_AddResource(caster, RT_Manpower, amount)
  149.             return RT_Manpower
  150.         elseif rt == RT_GOLD then -- GOLD
  151.             Player_AddResource(caster, RT_Munition, amount)
  152.             return RT_Munition
  153.         elseif RT_WOOD then -- WOOD
  154.             Player_AddResource(caster, RT_Fuel, amount)
  155.             return RT_Fuel
  156.         end
  157.     end
  158. end
  159.  
  160. function Entity_GetName(entity)
  161.     local bp = Entity_GetBlueprint(entity)
  162.     return Util_GetBPName(bp)
  163. end
  164.  
  165. function Entity_GetTempEGroup(entity, index)
  166.     if not index then
  167.         index = 1
  168.     end
  169.     local egroup = EGroup_CreateIfNotFound("eg_temp_villagers_" .. World_GetGameTime() .. index)
  170.     EGroup_Clear(egroup)
  171.     EGroup_Add(egroup, entity)
  172.     return egroup
  173. end
  174.  
  175. function Squad_GetUniqueKey(squad)
  176.     return "squad_" .. Squad_GetGameID(squad)
  177. end
  178.  
  179. function Squad_GetName(squad)
  180.     local bp = Squad_GetBlueprint(squad)
  181.     return Util_GetBPName(bp)
  182. end
  183.  
  184. function Squad_GetTempSGroup(squad, index)
  185.     if not index then
  186.         index = 1
  187.     end
  188.    
  189.     local sgroup = SGroup_CreateIfNotFound("sg_temp_villagers_" .. World_GetGameTime() .. index)
  190.     SGroup_Clear(sgroup)
  191.     SGroup_Add(sgroup, squad)
  192.     return sgroup
  193. end
  194.  
  195. function Util_GlobalMessage(title, displaytime)
  196.     Game_TextTitleFade(title, 0, displaytime, 2)
  197. end
  198.  
  199. function Util_GetBPName(bp)
  200.     local name = BP_GetName(bp)
  201.     return name:gsub(g_guid .. ":", "Villagers:")  
  202. end
  203.  
  204. function Util_CreateLocString(text)
  205.     local tmpstr = LOC(text)
  206.     tmpstr[1] = text
  207.     return tmpstr
  208. end
  209.  
  210. function Game_GetLocalPlayerID()
  211.     return Player_GetID(Game_GetLocalPlayer())
  212. end
  213.  
  214. function World_GetEntitiesByBlueprint(ebp)
  215.     local result = {}
  216.     if scartype(ebp) == ST_STRING then
  217.         ebp = BP_GetEntityBlueprint(ebp)
  218.     end
  219.     for i = 0, World_GetNumEntities() -1 do
  220.         local entity = World_GetEntity(i)
  221.         if Entity_GetBlueprint(entity) == ebp then
  222.             table.insert(result, entity)
  223.         end
  224.     end
  225.    
  226.     return result
  227. end
  228.  
  229. function World_ForEachEntities(f)
  230.     for i = 0, World_GetNumEntities() -1 do
  231.         local entity = World_GetEntity(i)
  232.         f(Entity_GetGameID(entity), i, entity)
  233.     end
  234. end
  235.  
  236. function World_ForEachEntitiesByBlueprint(ebp, f)
  237.     for i = 0, World_GetNumEntities() -1 do
  238.         local entity = World_GetEntity(i)
  239.         if Entity_GetBlueprint(entity) == ebp then
  240.             f(Entity_GetGameID(entity), i, entity)
  241.         end
  242.     end
  243. end
  244.  
  245. function Msg(text)
  246.     if g_enable_messages then
  247.         g_text_line_count = g_text_line_count + 1
  248.         if g_text_line_count == 100 then
  249.             g_text = ""
  250.             g_text_line_count = 0
  251.         end
  252.         g_text = text.."\n"..g_text
  253.         dr_clear("VILLAGERS")
  254.         dr_setautoclear("VILLAGERS", 0)
  255.         dr_text2d("VILLAGERS", 0.615, 0.025, g_text, 0, 255, 0)
  256.     end
  257. end
  258.  
  259. function Villagers_GetIcon(icon)
  260.     return "ModIcons_"..g_guid.."_"..icon
  261. end
  262.  
  263. function Villagers_GetAbilityBlueprint(blueprint)
  264.     return BP_GetAbilityBlueprint(g_guid .. ":" .. blueprint)
  265. end
  266.  
  267. function Villagers_GetSquadBlueprint(blueprint)
  268.     return BP_GetSquadBlueprint(g_guid .. ":" .. blueprint)
  269. end
  270.  
  271. function Villagers_GetEntityBlueprint(blueprint)
  272.     return BP_GetEntityBlueprint(g_guid .. ":" .. blueprint)
  273. end
  274.  
  275. function Villagers_GetUpgradeBlueprint(blueprint)
  276.     return BP_GetUpgradeBlueprint(g_guid .. ":" .. blueprint)
  277. end
  278.  
  279. function Villagers_DeleteResourceEntity(entity, when)
  280.     local key = Entity_GetUniqueKey(entity)
  281.     local rt = Villagers_GetEntityResourceType(entity)
  282.     if rt == RT_FOOD then -- FOOD
  283.         g_delete_resource_entity[key] = {id = Entity_GetGameID(entity), when = when or 4}
  284.         return true
  285.     elseif rt == RT_GOLD then -- GOLD
  286.         g_delete_resource_entity[key] = {id = Entity_GetGameID(entity), when = when or 4}
  287.         return true
  288.     elseif rt == RT_WOOD then -- WOOD
  289.         return false
  290.     else
  291.         g_delete_resource_entity[key] = {id = Entity_GetGameID(entity), when = when or 24}
  292.         return true
  293.     end
  294. end
  295.  
  296. function Villagers_GetVillagersGatheringResource(entityId)
  297.     local result = {}
  298.     for key, item in pairs(g_resource_gather) do
  299.         if item.target == entityId then
  300.             table.insert(result, item)
  301.         end
  302.     end
  303.     return result
  304. end
  305.  
  306. function Villagers_GetResourceTypeGatherAbility(rt)
  307.     for key, resource in pairs(g_resources) do
  308.         if resource.resource_type == rt then
  309.             return resource.ability
  310.         end
  311.     end
  312. end
  313.  
  314. function Villagers_GetEntityResourceType(entity)
  315.     if Entity_IsOfType(entity, "salvageable_object") then
  316.         if Entity_IsOfType(entity, "supply_accessory_1") then -- FOOD
  317.             return RT_FOOD
  318.         elseif Entity_IsOfType(entity, "supply_accessory_2") then -- GOLD
  319.             return RT_GOLD
  320.         elseif Entity_IsOfType(entity, "supply_accessory_3") then -- WOOD
  321.             return RT_WOOD
  322.         end
  323.     end
  324. end
  325.  
  326. function Villagers_GetResourceTypeEBPFilter(rt)
  327.     for key, resource in pairs(g_resources) do
  328.         if resource.resource_type == rt then
  329.             return resource.ebp
  330.         end
  331.     end
  332. end
  333.  
  334. function Villagers_FindResource(pos, rt, radius, entity)
  335.     radius = radius or 25
  336.  
  337.     local eg_resources = EGroup_CreateIfNotFound("eg_villagers_resources")
  338.     World_GetEntitiesNearPoint(player_generic, eg_resources, pos, radius, OT_Neutral)
  339.     local ebpFilter = Villagers_GetResourceTypeEBPFilter(rt)
  340.     EGroup_Filter(eg_resources, ebpFilter, FILTER_KEEP)
  341.     if entity then
  342.         EGroup_Remove(eg_resources, entity)
  343.     end
  344.    
  345.     EGroup_ForEach(eg_resources, function(egid, idx, egEntity)
  346.         local villagers = Villagers_GetVillagersGatheringResource(Entity_GetGameID(egEntity))
  347.         if table.getn(villagers) >= g_max_villagers_per_resource then
  348.             EGroup_Remove(eg_resources, egEntity)
  349.         end
  350.     end)
  351.     if not EGroup_IsEmpty(eg_resources) then
  352.         local entity = EGroup_GetClosest(pos, eg_resources)
  353.         return entity
  354.     end
  355.     return nil
  356. end
  357.  
  358. function Villager_FindNewResources(villager, oldEntity, pos)
  359.     local rt
  360.     if scartype(oldEntity) == ST_NUMBER then
  361.         rt = oldEntity
  362.     else
  363.         rt = Villagers_GetEntityResourceType(oldEntity)
  364.         pos = Entity_GetPosition(oldEntity)
  365.     end
  366.    
  367.     local newResource = Villagers_FindResource(pos, rt, nil, nil)
  368.     local sg_villager = Squad_GetTempSGroup(villager)
  369.     if newResource then
  370.         local eg_newResource = Entity_GetTempEGroup(newResource)
  371.         local ability = Villagers_GetResourceTypeGatherAbility(rt)
  372.        
  373.         Cmd_Move(sg_villager, eg_newResource, true)
  374.         g_villager_ability_call[Squad_GetUniqueKey(villager)] = {squadId = Squad_GetGameID(villager), ability = ability, target = Entity_GetGameID(newResource), when = 8}
  375.         return true
  376.     end
  377.     EventCue_Create(CUE.VILLAGER_IDLE, Util_CreateLocString("Idle Villager"), nil, sg_villager)
  378.     return false
  379. end
  380.  
  381. function Villagers_GetFarmRectangle(farm)
  382.     local pos = farm.pos
  383.     local rectangle = {}
  384.     local result = {}
  385.    
  386.    
  387.     rectangle[0] = Util_GetOffsetPosition(pos, OFFSET_FRONT_LEFT, farm.diagonalDistance)
  388.     rectangle[1] = Util_GetOffsetPosition(pos, OFFSET_FRONT_RIGHT, farm.diagonalDistance)
  389.     rectangle[2] = Util_GetOffsetPosition(pos, OFFSET_BACK_RIGHT, farm.diagonalDistance)
  390.     rectangle[3] = Util_GetOffsetPosition(pos, OFFSET_BACK_LEFT, farm.diagonalDistance)
  391.  
  392.     for key, value in pairs(rectangle) do
  393.         Msg("inserted at " .. key)
  394.         result[key] = {[0] = value.x, [1] = value.z}
  395.     end
  396.    
  397.     local increaseY = 1
  398.     for i = 0, 3 do
  399.         rectangle[i].y = rectangle[i].y + increaseY
  400.     end
  401.    
  402.     local _posString = function(pos)
  403.         return "X: " .. (math.floor(pos.x * 100) / 100) .. ", Y: " .. (math.floor(pos.z * 100) / 100)
  404.     end
  405.     dr_drawline(rectangle[0], rectangle[1], 255, 255, 255, "view" )
  406.     dr_drawline(rectangle[1], rectangle[2], 255, 255, 255, "view" )
  407.     dr_drawline(rectangle[2], rectangle[3], 255, 255, 255, "view" )
  408.     dr_drawline(rectangle[3], rectangle[0], 255, 255, 255, "view" )
  409.    
  410.     for i = 0, 3 do
  411.         dr_text3dpos("view", rectangle[i], _posString(rectangle[i]), 255, 255, 255)
  412.     end
  413.  
  414.     return result
  415. end
  416.  
  417. function Villagers_SquadIsInFarm(farm, squad)
  418.     local sid = Squad_GetGameID(squad)
  419.     for key, slot in ipairs(farm.slots) do
  420.         if slot.squadId == sid then
  421.             return true
  422.         end
  423.     end
  424.     return false
  425. end
  426. function Villagers_Farm_GetAvailableSlot(farm, squad)
  427.     local sid = Squad_GetGameID(squad)
  428.     for key, slot in ipairs(farm.slots) do
  429.         if slot.squadId == sid then
  430.             return slot.entity
  431.         end
  432.     end
  433.     for key, slot in ipairs(farm.slots) do
  434.         if slot.occupied == false then
  435.             slot.occupied = true
  436.             slot.squadId = sid
  437.             farm.villagerCount = farm.villagerCount + 1
  438.             Msg("slot " .. key .. " is now taken!")
  439.             return slot.entity
  440.         end
  441.     end
  442. end
  443.  
  444. function Villagers_FindAvailableFarm(farm)
  445.     if Entity_IsValid(farm.entityId) then
  446.         local farmEntity = Entity_FromWorldID(farm.entityId)
  447.         local eg_farms = Team_GetEntitiesNearPoint(farm.team, farm.pos, 25)
  448.         local result = nil
  449.         EGroup_Remove(eg_farms, farmEntity)
  450.  
  451.         local filter = nil
  452.         if farm.type == FARMTYPE.FOOD then
  453.             filter = g_ebp_farm
  454.         elseif farm.type == FARMTYPE.GOLD then
  455.             filter = g_ebp_plantation
  456.         end
  457.         EGroup_Filter(eg_farms, filter, FILTER_KEEP)
  458.        
  459.         local eg_farms_not_full = EGroup_CreateIfNotFound("eg_farms_not_full")
  460.         EGroup_Clear(eg_farms_not_full)
  461.         for i = 1, EGroup_CountSpawned(eg_farms) do
  462.             local entity = EGroup_GetSpawnedEntityAt(eg_farms, i)
  463.             local farmKey = Entity_GetUniqueKey(entity)
  464.             local _farm = g_villager_farm[farmKey]
  465.             if _farm and _farm.villagerCount < g_configuration.max_villagers_per_farm then
  466.                 EGroup_Add(eg_farms_not_full, entity)
  467.             end
  468.         end
  469.         return EGroup_GetClosest(farm.pos, eg_farms_not_full)
  470.     end
  471. end
  472.  
  473. function Pos_AddHeight(pos, height)
  474.     return World_Pos(pos.x, pos.y + height, pos.z)
  475. end
  476.  
  477. function Repeat(times, f)
  478.     for i = 1, times do
  479.         f()
  480.     end
  481. end
  482.  
  483. function Delay(delay, task)
  484.     table.insert(g_delayed_task, {when = delay, f = task})
  485. end
  486.  
  487. function dr_text3dpos(frame, pos, text, r, g, b)
  488.     return dr_text3d(frame, pos.x, pos.y, pos.z, text, 255, 255, 255)
  489. end
  490.  
  491. function PointInPolygon(polygon, x, y)
  492.     --// ray-casting algorithm based on
  493.     --// http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
  494.    
  495.     --local x = point[0], y = point[1]
  496.    
  497.     local inside = false
  498.     local length = table.getn(polygon)
  499.     local j = length
  500.     for i = 0, length do
  501.         if i == 0 then
  502.             j = length
  503.         else
  504.             j = i - 1
  505.         end
  506.         local xi, yi = polygon[i][0], polygon[i][1]
  507.         local xj, yj = polygon[j][0], polygon[j][1]
  508.        
  509.         local intersect = ((yi > y) ~= (yj > y))
  510.             and (x < (xj - xi) * (y - yi) / (yj - yi) + xi);
  511.         if (intersect) then inside = not inside end
  512.     end
  513.    
  514.     return inside
  515. end
  516.  
  517. function Heading_Rotate(heading, amount)
  518.     local _heading = World_Pos(heading.x, heading.y, heading.z)
  519.     local angle = math.atan2(_heading.z, _heading.x) + math.rad(amount)
  520.     _heading.z = math.sin(angle)
  521.     _heading.x = math.cos(angle)
  522.     return _heading
  523. end
  524.  
  525. function GetDirectionalOffset(pos, heading, offset, angle)
  526.     angle = math.rad(angle)
  527.     local alpha = math.atan2(heading.z, heading.x)
  528.     local x = offset * math.cos(alpha + angle)
  529.     local y = offset * math.sin(alpha + angle)
  530.     Msg("Offsets: X:" .. x .. ", Y: " .. y)
  531.     return World_Pos(pos.x + x, pos.y, pos.z + y)
  532. end
  533.  
  534. function GetDirectionalOffsetPosition(pos, heading, offset, direction)
  535.     --heading = heading or {x = 0, y = 0, z = 0}
  536.     local angle = 0
  537.     if direction == OFFSET_FRONT then
  538.         angle = 0
  539.     elseif direction == OFFSET_FRONT_RIGHT then
  540.         angle = 45
  541.     elseif direction == OFFSET_RIGHT then
  542.         angle = 90
  543.     elseif direction == OFFSET_BACK_RIGHT then
  544.         angle = 135
  545.     elseif direction == OFFSET_BACK then
  546.         angle = 180
  547.     elseif direction == OFFSET_BACK_LEFT then
  548.         angle = 225
  549.     elseif direction == OFFSET_LEFT then
  550.         angle = 270
  551.     elseif direction == OFFSET_FRONT_LEFT then
  552.         angle = 315
  553.     end
  554.     Msg("using angle " .. angle)
  555.     return GetDirectionalOffset(pos, heading, offset, angle)
  556. end
  557.  
  558.        
  559.     --table.insert(g_delayed_task, {when = 8, f = function()
  560.     -- 
  561.     --end})
  562.    
  563.     --Msg("X: " .. math.deg(heading.x) .. ", Y: " .. math.deg(heading.y) .. ", Z: " .. math.deg(heading.z))
  564.     --local angle = math.atan2(heading.z, heading.x)
  565.     --Msg("Angle: " .. math.deg(angle))
  566.     --Msg("New Heading Z: " .. math.deg(math.sin(angle)))
  567.     --Msg("New Heading X: " .. math.deg(math.cos(angle)))
  568.     --Msg("Gate Pos: X: " .. pos.x .. ", Y: " .. pos.y .. ", Z: " .. pos.z)
  569.     --local pos1 = GetDirectionalOffsetPosition(pos, heading, 2, OFFSET_FRONT_RIGHT)
  570.     --local pos2 = GetDirectionalOffsetPosition(pos, heading, 2, OFFSET_BACK_RIGHT)
  571.     --local pos3 = GetDirectionalOffsetPosition(pos, heading, 2, OFFSET_BACK_LEFT)
  572.     --local pos4 = GetDirectionalOffsetPosition(pos, heading, 2, OFFSET_FRONT_LEFT)
  573.     --[[local pos1 = GetDirectionalOffset(pos, heading, 2, 67.5)
  574.     local pos2 = GetDirectionalOffset(pos, heading, 2, 112.5)
  575.     local pos3 = GetDirectionalOffset(pos, heading, 2, 247.5)
  576.     local pos4 = GetDirectionalOffset(pos, heading, 2, 292.5)
  577.     dr_text3dpos("view", pos1, 67.5 .. "°", 255, 255, 255)
  578.     dr_text3dpos("view", pos2, 112.5 .. "°", 255, 255, 255)
  579.     dr_text3dpos("view", pos3, 247.5 .. "°", 255, 255, 255)
  580.     dr_text3dpos("view", pos4, 292.5 .. "°", 255, 255, 255)
  581.     local pos_check_wall_back = GetDirectionalOffset(pos, heading, 3, 90)
  582.     local pos_check_wall_front = GetDirectionalOffset(pos, heading, 3, -90)
  583.     pos_check_wall_back.y = pos_check_wall_back.y + 2
  584.     pos_check_wall_front.y = pos_check_wall_front.y + 2
  585.     dr_text3dpos("view", pos_check_wall_back, "check back", 255, 255, 255)
  586.     dr_text3dpos("view", pos_check_wall_front, "check front", 255, 255, 255)
  587.     dr_drawline(pos, pos_check_wall_back, 255, 255, 255, "view" )
  588.     dr_drawline(pos, pos_check_wall_front, 255, 255, 255, "view" )
  589.    
  590.     --World_GetEntitiesNearPoint( Player* player, EGroup* egroup, ScarPosition pos, float radius, <a href="enum_list.htm#OwnerType">OwnerType</a> ownerType
  591.     local eg_back = EGroup_Create("eb_back")
  592.     local eg_front = EGroup_Create("eg_front")
  593.    
  594.    
  595.     --g_gates[gateKey] = {entityId = Entity_GetGameID(gate), owner = owner, isOpen = false, closed = {pos = pos, heading = heading}, open = {pos = pos_open, heading = heading_open}}
  596.     World_GetEntitiesNearPoint(owner, eg_back, pos_check_wall_back, 1, OT_Player)
  597.     World_GetEntitiesNearPoint(owner, eg_front, pos_check_wall_front, 1, OT_Player)
  598.    
  599.     EGroup_Filter(eg_back, g_ebp_west_german_wall_gate, FILTER_KEEP)
  600.     EGroup_Filter(eg_front, g_ebp_west_german_wall_gate, FILTER_KEEP)
  601.    
  602.     --if not EGroup_IsEmpty(eg_back) and EGroup_IsEmpty(eg_front)
  603.    
  604.     Msg("Pos4 Pos: X: " .. pos4.x .. ", Y: " .. pos4.y .. ", Z: " .. pos4.z)
  605.     --local pos2 = Util_GetOffsetPosition(pos, OFFSET_FRONT_RIGHT, 5)
  606.     --local pos3 = Util_GetOffsetPosition(pos, OFFSET_BACK_RIGHT, 5)
  607.     --local pos4 = Util_GetOffsetPosition(pos, OFFSET_BACK_LEFT, 5)
  608.    
  609.    
  610.     local posList = {pos1, pos2, pos3, pos4}
  611.     for key, value in ipairs(posList) do
  612.         value.y = value.y + 1
  613.     end
  614.     dr_drawline(pos1, pos2, 255, 255, 255, "view" )
  615.     dr_drawline(pos2, pos3, 255, 255, 255, "view" )
  616.     dr_drawline(pos3, pos4, 255, 255, 255, "view" )
  617.     dr_drawline(pos4, pos1, 255, 255, 255, "view" )
  618.     --]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement