After you learn lua, here is another solution:
win.lua:
function win_init(e)
End_Game_Global = 0
end
function win_main(e)
Prompt(End_Game_Global)
if End_Game_Global >= 3 then
Prompt("Level has been completed.")
FinishLevel()
end
end
and then make a copy from ai_soldier.lua in another folder and change following lines:
1.
function ai_soldier_exit(e)
if ai_soldier_state[e] ~= "deathanim" then
PlayCharacterSound(e,"onDeath")
end
end
to
function ai_soldier_exit(e)
if ai_soldier_state[e] ~= "deathanim" then
PlayCharacterSound(e,"onDeath")
end
if End_Game_Global ~= nil and ai_soldier_name[e] == "KillToFinish" then
End_Game_Global = End_Game_Global+1
end
end
2.
-- globals for AI enemies
ai_newdest_time = {}
ai_cover_on = {}
to
-- globals for AI enemies
ai_newdest_time = {}
ai_cover_on = {}
local ai_soldier_name = {}
3.
-- init when level first runs
function ai_soldier_init(e)
ai_soldier_state[e] = "patrol";
ai_soldier_pathindex[e] = -1;
ai_start_x[e] = nil
ai_starting_heath[e] = nil
ai_ran_to_cover[e] = 0
ModulateSpeed(e,1.0)
ai_old_health[e] = 0
CharacterControlStand(e)
ai_returning_home[e] = 0
ai_newdest_time[e] = -1
ai_cover_on[e] = 0
ai_alerted_spoken[e] = 0
SetCharacterSoundSet(e)
ai_soldier_name[e]=name
end
to
-- init when level first runs
function ai_soldier_init_name(e,name)
ai_soldier_state[e] = "patrol";
ai_soldier_pathindex[e] = -1;
ai_start_x[e] = nil
ai_starting_heath[e] = nil
ai_ran_to_cover[e] = 0
ModulateSpeed(e,1.0)
ai_old_health[e] = 0
CharacterControlStand(e)
ai_returning_home[e] = 0
ai_newdest_time[e] = -1
ai_cover_on[e] = 0
ai_alerted_spoken[e] = 0
SetCharacterSoundSet(e)
ai_soldier_name[e]=name
end
and at least name you enemies in the property field name(for standard character there stand "Combat Soldier")
to "KillToFinish". If you want to name them different, go to 1. and change the name here
if End_Game_Global ~= nil and ai_soldier_name[e] == "KillToFinish" then
what I did:
1. The script count the Counter up if the AI dies
2. Add a new local array to the context(
3. We get the name of the entity with _init_name(e,name) and save it in an array at the position e (e is the entity number)
If you want more than 3 enemies should die to finish the game change the line with the 3 in win.lua:
if End_Game_Global >= 3 then
Edit:
Seems like I am too late
My dream is to develope games, which makes fun when I create it and fun when other people play it.