From d3945f4b65417d154492e28831b5fbd230416118 Mon Sep 17 00:00:00 2001 From: F1F7Y <64418963+F1F7Y@users.noreply.github.com> Date: Fri, 29 Apr 2022 23:05:09 +0200 Subject: Add Attrition (#321) * Skyshow * Attrition score stuff * DropShip and DropPod spawn funcs * Attrition intro * Reaper spawn func * Attrition assault point logic * Cleanup * Match logic + basic spawn algo * Fix crash * Improve ai ? * Add AI weapon setter funcs * Bounty hunt score basics * code cleanup * add cleanup for bored ai * fix issue with failedChecks not being reset properly in cleanup * more cleanup * stop ai spawns on epilogue * don't run aitdm spawning code if we don't have ains/nms * Fix missing nodes crash * initial bounty hunt stuff * oops forgot to push this * me when i'm a competent developer * formatting and such * cap score + proper mp_rise spawns fix * Better squad handler * comment reaper out; needs to be checked out * Fix crash site crash * reapers * minor visual change is what Id call this * bh basic damage scoring * going to push this so there's a base to work with, still doesn't work * fix funny suicide bug :) * I hate crash site + score funnies * comlpex skill issue * final score fix, lets hope so * Hacked spectre fix * 1p npc executions fix * stalkers * Archer Grunts :) * minor fixing * Skyshow * Attrition score stuff * DropShip and DropPod spawn funcs * Attrition intro * Reaper spawn func * Attrition assault point logic * Cleanup * Match logic + basic spawn algo * Fix crash * Improve ai ? * Add AI weapon setter funcs * Bounty hunt score basics * code cleanup * add cleanup for bored ai * fix issue with failedChecks not being reset properly in cleanup * more cleanup * stop ai spawns on epilogue * don't run aitdm spawning code if we don't have ains/nms * Fix missing nodes crash * initial bounty hunt stuff * oops forgot to push this * me when i'm a competent developer * formatting and such * cap score + proper mp_rise spawns fix * Better squad handler * comment reaper out; needs to be checked out * Fix crash site crash * reapers * minor visual change is what Id call this * bh basic damage scoring * going to push this so there's a base to work with, still doesn't work * fix funny suicide bug :) * I hate crash site + score funnies * comlpex skill issue * final score fix, lets hope so * Hacked spectre fix * 1p npc executions fix * stalkers * Archer Grunts :) * minor fixing * Unlock attrition in mode select menu * move archer grunts settings Co-authored-by: BobTheBob <32057864+BobTheBob9@users.noreply.github.com> --- .../scripts/vscripts/gamemodes/_ai_gamemodes.gnut | 164 +++++++++++++++++++++ 1 file changed, 164 insertions(+) (limited to 'Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_ai_gamemodes.gnut') diff --git a/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_ai_gamemodes.gnut b/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_ai_gamemodes.gnut index cf7f7e150..d6d578bb7 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_ai_gamemodes.gnut +++ b/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_ai_gamemodes.gnut @@ -1,6 +1,170 @@ global function AiGameModes_Init +global function AiGameModes_SetGruntWeapons +global function AiGameModes_SetSpectreWeapons + +global function AiGameModes_SpawnDropShip +global function AiGameModes_SpawnDropPod +global function AiGameModes_SpawnReaper +global function AiGameModes_SpawnTitan + +global function GetValidIntroDropShipSpawn + + +const INTRO_DROPSHIP_CUTOFF = 2000 + +struct +{ + array< string > gruntWeapons = [ "mp_weapon_rspn101" ] + array< string > spectreWeapons = [ "mp_weapon_hemlok_smg" ] +} file + void function AiGameModes_Init() { +} + +//------------------------------------------------------ + +void function AiGameModes_SetGruntWeapons( array< string > weapons ) +{ + file.gruntWeapons = weapons +} + +void function AiGameModes_SetSpectreWeapons( array< string > weapons ) +{ + file.spectreWeapons = weapons +} + +//------------------------------------------------------ + +void function AiGameModes_SpawnDropShip( vector pos, vector rot, int team, int count, void functionref( array guys ) squadHandler = null ) +{ + string squadName = MakeSquadName( team, UniqueString( "" ) ) + + CallinData drop + drop.origin = pos + drop.yaw = rot.y + drop.dist = 768 + drop.team = team + drop.squadname = squadName + SetDropTableSpawnFuncs( drop, CreateSoldier, count ) + SetCallinStyle( drop, eDropStyle.ZIPLINE_NPC ) + + thread RunDropshipDropoff( drop ) + + WaitSignal( drop, "OnDropoff" ) + + array< entity > guys = GetNPCArrayBySquad( squadName ) + + foreach ( guy in guys ) + { + ReplaceWeapon( guy, file.gruntWeapons[ RandomInt( file.gruntWeapons.len() ) ], [] ) + guy.EnableNPCFlag( NPC_ALLOW_PATROL | NPC_ALLOW_INVESTIGATE | NPC_ALLOW_HAND_SIGNALS | NPC_ALLOW_FLEE ) + } + + if ( squadHandler != null ) + thread squadHandler( guys ) +} + + +void function AiGameModes_SpawnDropPod( vector pos, vector rot, int team, string content /*( ͡° ͜ʖ ͡°)*/, void functionref( array guys ) squadHandler = null ) +{ + string squadName = MakeSquadName( team, UniqueString( "" ) ) + array guys + + entity pod = CreateDropPod( pos, <0,0,0> ) + + InitFireteamDropPod( pod ) + + for ( int i = 0; i < 4 ;i++ ) + { + entity npc = CreateNPC( content, team, pos,<0,0,0> ) + DispatchSpawn( npc ) + SetSquad( npc, squadName ) + + switch ( content ) + { + case "npc_soldier": + ReplaceWeapon( npc, file.gruntWeapons[ RandomInt( file.gruntWeapons.len() ) ], [] ) + break + + case "npc_spectre": + ReplaceWeapon( npc, file.spectreWeapons[ RandomInt( file.spectreWeapons.len() ) ], [] ) + break + } + + npc.SetParent( pod, "ATTACH", true ) + + npc.EnableNPCFlag( NPC_ALLOW_PATROL | NPC_ALLOW_INVESTIGATE | NPC_ALLOW_HAND_SIGNALS | NPC_ALLOW_FLEE ) + guys.append( npc ) + } + + // The order here is different so we can show on minimap while were still falling + if ( squadHandler != null ) + thread squadHandler( guys ) + + waitthread LaunchAnimDropPod( pod, "pod_testpath", pos, rot ) + + ActivateFireteamDropPod( pod, guys ) +} + +void function AiGameModes_SpawnReaper( vector pos, vector rot, int team, string aiSettings = "", void functionref( entity reaper ) reaperHandler = null ) +{ + entity reaper = CreateSuperSpectre( team, pos, rot ) + SetSpawnOption_Titanfall( reaper ) + SetSpawnOption_Warpfall( reaper ) + + if ( aiSettings != "" ) + SetSpawnOption_AISettings( reaper, aiSettings ) + + DispatchSpawn( reaper ) + + + if ( reaperHandler != null ) + thread reaperHandler( reaper ) +} + +// including aisettings stuff specifically for at bounty titans +void function AiGameModes_SpawnTitan( vector pos, vector rot, int team, string setFile, string aiSettings = "", void functionref( entity titan ) titanHandler = null ) +{ + entity titan = CreateNPCTitan( setFile, TEAM_BOTH, pos, rot ) + SetSpawnOption_Titanfall( titan ) + SetSpawnOption_Warpfall( titan ) + + if ( aiSettings != "" ) + SetSpawnOption_AISettings( titan, aiSettings ) + + DispatchSpawn( titan ) + + if ( titanHandler != null ) + thread titanHandler( titan ) +} + +// entity.ReplaceActiveWeapon gave grunts archers sometimes, this is my replacement for it +void function ReplaceWeapon( entity guy, string weapon, array mods ) +{ + guy.TakeActiveWeapon() + guy.GiveWeapon( weapon, mods ) + guy.SetActiveWeaponByName( weapon ) +} + +// Checks if we can spawn a dropship at a node, this should guarantee dropship ziplines +array function GetValidIntroDropShipSpawn( array introNodes ) +{ + array introShipSpawns + + if ( GetZiplineDropshipSpawns().len() == 0 ) + return [] + + foreach ( node in introNodes ) + { + entity closestNode = GetClosest( GetZiplineDropshipSpawns(), node.GetOrigin() ) + SetTeam( closestNode, node.GetTeam() ) + + if ( Distance( closestNode.GetOrigin(), node.GetOrigin() ) < INTRO_DROPSHIP_CUTOFF ) + introShipSpawns.append( closestNode ) + } + + return introShipSpawns } \ No newline at end of file -- cgit v1.2.3