Is anyone find a way to convert neutral building to a player when a goal is completed ? For exemple : i build a neutral village with 10 maa in, if the player 3 kill all maa of the village, all the buildings of the village is converted to Player 3. If someone have the method it would be awesome to share, thx .
I made a quick code example how you could achieve this (it worked for me when I tested).
Assuming this is a single player (like a campaign map), you could do something like this:
Create an entity group for the buildings that we can name “eg_villagebuildings” with the EGroup_Create() function and add the buildings to the group using the EGroup_Add() function
Create a squad group for the MAA that we can name “sg_villagemilitary” with the SGroup_Create() function and add the MAA to it in the function UnitEntry_DeploySquads() that spawns them.
Create a function that we can call “village_maa_isAlive” that checks and returns true/false if all MAA in the village is dead or not with the built-in SGroup_IsAlive() function:
Create a function that we can call “take_over_buildings” that change ownership of the village buildings from the A.I to the player, it also first checks if all village MAA is dead by calling the first function we created:
if village_maa_isAlive() == false then
for i, player in pairs(PLAYERS) do
if AI_IsAIPlayer(player.id) == false then
Add a global event in your init / game start function that listens for units being killed and make it call your take_over_buildings() function:
Look in Content Editor’s scardocs to see exactly how you use the built-in functions and thier parameters.