[HELP] Win Condition

Hi! I am trying to create a victory condition where if you kill the opposing team’s boar the game is over, is there any way I can make the boar the victory condition? The map is for 1vs1.

je ne pense pas que c’est possible.

mai voici le mien moi je déclanche une victoire ou défait par apport a des niveau de point de vie

print(“[WC] LTW_wincondition.scar chargé”)

LTW_WC = LTW_WC or {}
LTW_WC._deadPlayers = LTW_WC._deadPlayers or {}

– fréquence de check (secondes)
LTW_WC.tick = 0.5

– ============================================================
– Helpers
– ============================================================

local function LTW_WC_GetBlueprintName(e)
if not e then return “” end
if Entity_GetBlueprintName then
return tostring(Entity_GetBlueprintName(e) or “”)
end
return “”
end

local function LTW_WC_IsVillager(bp)
– on reste volontairement large (villager / scar_villager / etc.)
bp = string.lower(bp or “”)
return string.find(bp, “villager”, 1, true) ~= nil
end

local function LTW_WC_IsTargetMarket(bp)
return (bp == “building_econ_market_control_byz”)
end


–test–

– Dump propre : liste les entités d’UN joueur (owner) dans le log
local function LTW_WC_DumpPlayerEntities(playerIdx, maxPerPlayer)
maxPerPlayer = maxPerPlayer or 200

local pObj = World_GetPlayerAt(playerIdx)
if not pObj then
    print("\[WC\]\[DUMP\] ERROR: World_GetPlayerAt(" .. tostring(playerIdx) .. ") nil")
    return
end

if not Player_GetEntityCount or not Player_GetEntityName or not Player_GetID then
    print("\[WC\]\[DUMP\] ERROR: Player_GetEntityCount/Name/ID missing")
    return
end

local pid = Player_GetID(pObj)
local n   = Player_GetEntityCount(pObj)

print(string.format("\[WC\]\[DUMP\] PlayerIndex=%d PlayerID=%s Entities=%d", playerIdx, tostring(pid), n))

local limit = n
if limit > maxPerPlayer then limit = maxPerPlayer end

-- IMPORTANT: index 0..(n-1)
for e = 0, (limit - 1) do
    local ename = Player_GetEntityName(pObj, e)
    print(string.format("  - \[%d\] %s", e, tostring(ename)))
end

if n > maxPerPlayer then
    print("  ... (tronqué, maxPerPlayer=" .. tostring(maxPerPlayer) .. ")")
end

end


–test2-----

– ============================================================
– KILL TOUTES LES ENTITES D’UN JOUEUR (SAFE)
– ============================================================
function LTW_WC_KillAllPlayerEntities(playerIdx)
local player = World_GetPlayerAt(playerIdx)
if not player then
print(“[WC][KILL] ERROR: player nil idx=” .. tostring(playerIdx))
return
end

-- EGroup = TOUTES les entités du joueur
local eg = Player_GetAllEntities(player)
if not eg then
    print("\[WC\]\[KILL\] ERROR: Player_GetAllEntities failed p=" .. tostring(playerIdx))
    return
end

local count = EGroup_Count(eg)
print(string.format("\[WC\]\[KILL\] Player %d -> killing %d entities", playerIdx, count))

if count > 0 then
    Util_Kill(eg)
end

end

– ============================================================
– Death handling
– ============================================================

function LTW_WC_KillVillagersAndMarket(playerIdx)
if LTW_WC._deadPlayers[playerIdx] then
return
end
LTW_WC._deadPlayers[playerIdx] = true

local pObj = World_GetPlayerAt(playerIdx)
if not pObj then
    print("\[WC\] ERROR: World_GetPlayerAt(" .. tostring(playerIdx) .. ") returned nil")
    return
end

print(string.format("\[WC\] PLAYER %d DEAD -> kill villager + market", playerIdx))
    print(string.format("\[WC\] PLAYER %d DEAD -> kill villager + market", playerIdx))

-- Dump (debug, déjà OK chez toi)

LTW_WC_DumpPlayerEntities(playerIdx, 300)

– Kill total
LTW_WC_KillAllPlayerEntities(playerIdx)

    -- >>> DUMP au moment exact où il tombe à 0
    LTW_WC_DumpPlayerEntities(playerIdx, 150)

if not Player_GetAllEntities then
    print("\[WC\] ERROR: Player_GetAllEntities = nil")
    return
end

local ents = Player_GetAllEntities(pObj)
if type(ents) \~= "table" then
    print("\[WC\] ERROR: Player_GetAllEntities did not return a table (type=" .. tostring(type(ents)) .. ")")
    return
end

local killedVillagers = 0
local killedMarkets   = 0

for \_, e in ipairs(ents) do
    if Entity_IsValid and Entity_IsValid(e) then
        local bp = LTW_WC_GetBlueprintName(e)

        if LTW_WC_IsTargetMarket(bp) then
            if Util_Kill then Util_Kill(e) end
            killedMarkets = killedMarkets + 1

        elseif LTW_WC_IsVillager(bp) then
            if Util_Kill then Util_Kill(e) end
            killedVillagers = killedVillagers + 1
        end
    end
end

print(string.format(
    "\[WC\] player=%d killedVillagers=%d killedMarkets=%d",
    playerIdx, killedVillagers, killedMarkets
))

end

– ============================================================
– Tick / Init
– ============================================================

function LTW_WC_Tick()
if not LTW_HP or not LTW_HP.lifeByPlayer then
return
end

local pc = World_GetPlayerCount() or 0
for p = 1, pc do
    local hp = LTW_HP.lifeByPlayer\[p\]
    if hp \~= nil and hp <= 0 then
        LTW_WC_KillVillagersAndMarket(p)
    end
end

end

function LTW_WC_Init()
Rule_AddInterval(LTW_WC_Tick, LTW_WC.tick)
print(“[WC] Init OK tick=” .. tostring(LTW_WC.tick))
end

print(“[MAIN] LTW_V15_MOD_2026.scar chargé”)

import(“ScarUtil.scar”)
import(“MissionOMatic/MissionOMatic.scar”)

– Modules LTW
import(“LTW_players.scar”)
import(“LTW_markers.scar”)
import(“LTW_spawn.scar”)
import(“LTW_core.scar”)
import(“LTW_villager_zone.scar”)

import(“LTW_bus.scar”)
import(“LTW_teleport.scar”)
import(“LTW_econ.scar”)
import(“LTW_hp.scar”)
import(“LTW_wincondition.scar”)

– Win conditions vanilla (optionnel si tu utilises ton wincondition)
import(“winconditions/annihilation.scar”)
import(“winconditions/elimination.scar”)
import(“winconditions/surrender.scar”)


– MissionOMatic hooks (souvent laissés vides en skirmish)

function Mission_SetupPlayers() end
function Mission_SetupVariables() end
function Mission_SetRestrictions() end
function Mission_Preset() end


— ============================================================
– DUMP: liste les ENTITIES possédées par chaque joueur
– (nom blueprint) → log SCAR
– ============================================================

function LTW_DumpAllEntitiesByOwner(maxPerPlayer)
maxPerPlayer = maxPerPlayer or 200

local playerCount = World_GetPlayerCount()
print("\[DUMP\] players=" .. tostring(playerCount))

for i = 1, playerCount do
    local player = World_GetPlayerAt(i)         -- Player object
    local pid    = Player_GetID(player)
    local n      = Player_GetEntityCount(player)

    print(string.format("\[DUMP\] PlayerIndex=%d PlayerID=%s Entities=%d", i, tostring(pid), n))

    local limit = n
    if limit > maxPerPlayer then limit = maxPerPlayer end

    -- IMPORTANT: index 0..(n-1)
    for e = 0, (limit - 1) do
        local ename = Player_GetEntityName(player, e)
        print(string.format("  - \[%d\] %s", e, tostring(ename)))
    end

    if n > maxPerPlayer then
        print("  ... (tronqué, maxPerPlayer=" .. tostring(maxPerPlayer) .. ")")
    end
end

end

– ============================================================
– Start (un seul Mission_Start)
– ============================================================

function Mission_Start()
print(“[MAIN] Mission_Start”)

-- tes inits
LTW_Core_Start()
LTW_econ_init()
LTW_HP_Init()
LTW_WC_Init()

-- dump
LTW_DumpAllEntitiesByOwner(100)

LTW_VZ_Init()

end