Last active
September 10, 2018 23:47
-
-
Save Calrissian97/905d9399f86567a21fcbe3f464b7722b to your computer and use it in GitHub Desktop.
Couple Hero-Spawner functions that allow enemy AI to spawn as heroes once the player has spawned as a hero- Battlefront II
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local Hero = "ClassNameHere" | |
| local Villain = "ClassNameHere" | |
| local HeroCounter = 1 -- Number of heroes on the field | |
| local PorgTeam = 0 -- PlayerTeam | |
| local HeroIndex = 0 -- Character Index to spawn hero | |
| -- These functions make sure enemy hero only spawns after you've become a hero | |
| HeroWaitingALL = OnCharacterSpawnClass( | |
| function(character) | |
| if IsCharacterHuman(character) then | |
| HeroCounter = HeroCounter - 1 | |
| PorgTeam = GetCharacterTeam(character) | |
| print("ANF:HeroWaiting: Enemy AI Villain is Enabled!") | |
| BroadcastVoiceOver("team_bonus_leader_us_all", ALL) | |
| BroadcastVoiceOver("team_bonus_leader_them_all", ALL) | |
| ReleaseCharacterSpawn(HeroWaitingALL) | |
| HeroWaitingALL = nil | |
| end | |
| end, | |
| Hero | |
| ) | |
| HeroWaitingIMP = OnCharacterSpawnClass( | |
| function(character) | |
| if IsCharacterHuman(character) then | |
| HeroCounter = HeroCounter - 1 | |
| PorgTeam = GetCharacterTeam(character) | |
| print("ANF:HeroWaiting: Enemy AI Hero is Enabled!") | |
| BroadcastVoiceOver("team_bonus_leader_us_imp", IMP) | |
| BroadcastVoiceOver("team_bonus_leader_them_imp", IMP) | |
| ReleaseCharacterSpawn(HeroWaitingIMP) | |
| HeroWaitingIMP = nil | |
| end | |
| end, | |
| Villain | |
| ) | |
| -- This does the magic that spawns in an enemy hero based off the position of an enemy ai | |
| HeroSpawner = OnCharacterSpawn( | |
| function(character) | |
| if HeroCounter < 1 then | |
| local CharTeam = GetCharacterTeam(character) | |
| local HeroClass = (GetTeamClassCount(CharTeam) - 1) | |
| if IsCharacterHuman(character) then | |
| PorgTeam = GetCharacterTeam(character) | |
| else | |
| if CharTeam ~= PorgTeam then | |
| UnlockHeroForTeam(CharTeam) | |
| local TeamSize = GetTeamSize(CharTeam) | |
| local spawnpoint = GetEntityMatrix(GetCharacterUnit(character)) | |
| local C = TeamSize - 1 | |
| local CharIndex = GetTeamMember(CharTeam, C) | |
| if CharIndex then | |
| local CharUnit = GetCharacterUnit(CharIndex) | |
| if not CharUnit then | |
| HeroIndex = CharIndex | |
| print("ANF:HeroSpawner: Unspawned bot found!") | |
| else | |
| AddReinforcements(CharTeam, 1) | |
| KillObject(CharUnit) | |
| HeroIndex = CharIndex | |
| print("ANF:HeroSpawner: Unspawned bot *made* >:)") | |
| end | |
| HeroCounter = HeroCounter + 1 | |
| print("ANF:HeroSpawner: HeroCounter: ", HeroCounter) | |
| SelectCharacterClass(HeroIndex, HeroClass) | |
| SpawnCharacter(HeroIndex,spawnpoint) | |
| print("ANF:HeroSpawner: Hero Spawned!") | |
| end | |
| end | |
| end | |
| end | |
| end | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment