Login

russian armor

Neutral minefield (SCAR problem)

23 Feb 2019, 18:45 PM
#1
avatar of Bullaman

Posts: 3

FIFIHello

So i had a map in COH 1 that had a neutral minefield. That the mines didnt have a player assigned so the enemy doesnt get points when someone dies on the mine.
I wanted to apply this to COH 2 but couldnt make it work. I only had some SCAR code in my email because the forum had been deleted. So i dont know if its all there, or is it still relevant or outdated.

Basicly i have mines in the map and i made an entity group called (eg_mines).

Then there is the code that i thought was the final version of the working one in COH 1.
Hope someone here could help me i still dont know anything about SCAR basicly so someone helped me the last time i did this too.

import("ScarUtil.scar")

function custom_CheckMines()
local AllSquads = {} -- we need a blank helper table to store all the player squads

-- first check if the list of mines is still actual, removing all no more existing mines
if EGroup_CountAlive(eg_mines) < EGroup_Count(eg_mines) then
local tmp_mineslist = {}
local MinesList = function(egroupid, itemindex, entityID)
if Entity_IsAlive(entityID) then
table.insert(tmp_mineslist, entityID)
end
end
EGroup_ForEach(eg_mines, MinesList)
eg_mines = tmp_mineslist
end

for i = 1, table.getn(eg_mines) do
local entityID = eg_mines
local entityPos = Entity_GetPosition(entityID) -- now you have the actual position of each mine in your table

-- this is a loop through all existing players onto the map
for n = 1, World_GetPlayerCount() do
local PlayerID = World_GetPlayerAt(n) -- that's the actual plyer we check

-- now we need all squads of the actual player
local PlayerSquads = function(sgroupid, itemindex, squadID)
table.insert(AllSquads, squadID) -- adding a new squad to our squad list
end

Player_GetAll(PlayerID) -- this function creates a list of all objects assigned to a player
SGroup_ForEach(sg_allsquads, PlayerSquads) -- we only need the squads, these are stored in sg_allsquads by the function above
-- with this list we are calling now the subfunction PlayerSquads above (foreach)
end

-- now we have all existing player squads for each player in our helper table AllSquads

-- we have to check now, which squad is nearby and the closest one to each of our mines
local dist -- it's a helper variable which should store our distance value
local closest = 99999 -- it's a helper variable which should help us to identify the closest squad
local ClosestSquad -- it's a helper variable which should store the actual closest squad (ID)

for x = 1, table.getn(AllSquads) do
local AllSquadsPos = Util_GetPosition(AllSquads) -- getting the position of the actual squad from the list of squads
dist = World_DistancePointToPoint(entityPos, AllSquadsPos) -- getting the distance between our actual mine and the actual squad
if dist < closest then
closest = dist -- the actual lowest distance will be stored here
ClosestSquad = AllSquads -- the actual closest squad (ID) will be stored here
end
end

-- now we know, which squad is the closest one to this mine
local SquadOwner_PlayerID = Squad_GetPlayerOwner(ClosestSquad) -- getting the PlayerID of the owner of the closest squad
local Enemy_PlayerID = Player_FindFirstEnemyPlayer(SquadOwner_PlayerID) -- getting the PlayerID of any enemy of this player

-- second check if the actual mine still exist, before we perform any action on it
if Entity_IsAlive(entityID) then
Entity_SetPlayerOwner(entityID, Enemy_PlayerID) -- setting the mine to be owned by an enemy player
end

end
end

Rule_AddInterval(custom_CheckMines, 1)


THANK YOU
1 user is browsing this thread: 1 guest

SHOUT IT OUT!

No ProfanityNumber of ShoutsRefresh Shout Box
Rosbone: I would like to join in celebration with the 9% of Coh3 MP players who are getting ALL of the new maps. Woohoo! #3Tards
Last Friday, 19:22 PM
OKSpitfire: I hope that at least one of heavies is a like-for-like reskin of the coh 2 ISU-152. I miss that thing.
Last Friday, 10:23 AM
Rosbone: Buy our cool new large tanks that will never get played on the 4 new 1v1 maps added. Perfect synergy! :facepalm:
Last Thursday, 19:23 PM
Rosbone: Everyone ready for some deep penetration :snfPeter:
Last Thursday, 17:13 PM
Lady Xenarra: I'm sure the ppl who defended it as balanced for Allies will be screaming like they got scaled with boiling water, in COH3. How the tables turn.
Last Thursday, 11:33 AM
Willy Pete: I think it was nuts with any engine damage. Especially on superheavies
Last Thursday, 07:03 AM
aerafield: Personally I think without the ram ability, it's worse than loiters for example
Last Thursday, 00:09 AM
Willy Pete: It combined well with most slowing abilities, not just ram stuns
Last Wednesday, 23:36 PM
Willy Pete: Only??? I think not being able to shoot it down and the ramp up effect also had something to do with it
Last Wednesday, 23:34 PM
Willy Pete: Really
Last Wednesday, 23:30 PM
aerafield: AT overwatch was broken only because it came with the faction of T34 ramming
Last Wednesday, 22:29 PM
Willy Pete: Love to see Relic really learning from their past mistakes. Let's bring back the dumbest ability in coh2, and charge money for it
Last Wednesday, 20:34 PM
Willy Pete: New DAK commander will have AT overwatch as alternate choice to elefant
Last Wednesday, 20:33 PM
aaa: Funy thing new players dont know that. And are trying to compete vs hacks
Last Wednesday, 10:33 AM
aaa: Online gaming is trash in general, not just coh. On high level there are all cheats in most games
Last Wednesday, 10:24 AM
aaa: 2 cheaters in 3 days. MH and DH
Last Wednesday, 09:57 AM
aerafield: I am a simple man, I build Humvees with Pathfinders and Missile Launchers inside, I am happy
Last Tuesday, 20:57 PM
Lady Xenarra: aerafield lamevee spammer confirmed :nahnah:
Last Tuesday, 20:42 PM
aerafield: those who know, know: https://www.reddit.com/r/CompanyOfHeroes/s/fPk4yLIgmK
Last Tuesday, 15:40 PM
adamírcz: Might be onto somethin here, combine side armour existing, maps where flanking is a viable option, and hopefully also heavies actually being less manouverable than mediums (lookin at you coh2), and it might be fun gameplay
17 Feb 2025, 13:39 PM

Ladders Top 10

  • #
    Steam Alias
    W
    L
    %
    Streak
Data provided by Relic Relic Entertainment

Replay highlight

VS
  • U.S. Forces flag cblanco ★
  • The British Forces flag 보드카 중대
  • Oberkommando West flag VonManteuffel
  • Ostheer flag Heartless Jäger
uploaded by XXxxHeartlessxxXX

Board Info

588 users are online: 588 guests
1 post in the last 24h
3 posts in the last week
42 posts in the last month
Registered members: 51923
Welcome our newest member, kajaawa2
Most online: 2043 users on 29 Oct 2023, 01:04 AM