Sqwince 1 Posted July 31, 2022 I'm working on a script based gamemode and I have worked out how to spawn a prefab entity using this code. IEntity hostile = IEntity.Cast(GetGame().SpawnEntityPrefab(resource, GetGame().GetWorld(), params)); I also have a HUD that will show a total score for the player. I'm trying to collect the current score of the player using this code: m_iKillPoints = m_pScoringSystem.GetPlayerScore(m_iAffiliatedPlayerID); It appears the scoring system is not tracking AI kills. I also tried committing suicide and the score isn't affected either. I'm not quite sure how to invoke the scoring system properly. are there any pointers out there on how to track AI kills for score? eventually I would like to use the "killpoints" as a form of currency. I'm not sure the SCR_ScoringSystemComponent will do what I need, or if I need to rewrite an entire scoring system or not. I have no idea how to set an event handler to the AI entity I spawned similar to Arma3 OnKilled. Share this post Link to post Share on other sites
sarogahtyp 1109 Posted August 1, 2022 Idk if it helps but this article has some words bout scoring: https://community.bistudio.com/wiki/Arma_Reforger:Scripting_Modding Share this post Link to post Share on other sites
Sqwince 1 Posted August 2, 2022 Thanks for the link. I've read through that a number of times, but my biggest issue is that the game doesn't "SEE" killing a spawned AI entity as a player therfore it doesn't trigger any of the scoring. I tried using the following method in the SCR_BaseGameModeComponent. WHen I kill the AI it definitely triggers this method, but the two params are not set properly. The entity is the AI I kill, but the instigator registers as "NULL" so i can't really do anything with that. it seems broken to me. void OnControllableDestroyed(IEntity entity, IEntity instigator) Share this post Link to post Share on other sites
Sqwince 1 Posted August 10, 2022 I found that I missed setting the AIent.SetFlags(EntityFlags.ACTIVE, false); now I get score when I kill the AI with a headshot (1shot & 1kill). A one shot heart damage/kill doesn't register with the scoring system though. Very strange. Seems to only trigger if it's a headshot only hit/kill. This is the AI Hostile Spawn script I'm using: //------------------------------------------------------------------------------------------------ /*! \brief Spawns the given resource @return SCR_AIGroup of entity spawned. */ IEntity SpawnHostileAI() { //Spawn AI (Credit: HunterKiller) EntitySpawnParams params = EntitySpawnParams(); bool foundpos = GetSpawnPointForAI(params); string hostilePreFab = GetHostileToSpawn(); Resource resource = Resource.Load(hostilePreFab); //SCR_AIGroup group = SCR_AIGroup.Cast(GetGame().SpawnEntityPrefab(resource, GetGame().GetWorld(), params)); IEntity hostile = IEntity.Cast(GetGame().SpawnEntityPrefab(resource, GetGame().GetWorld(), params)); if (!hostile) { Print("[SpawnHostileAI] Unable to spawn hostile!", LogLevel.ERROR); return null; } // Manage the life cycle for the spawned group GetGame().GetCallqueue().CallLater(ManageHostileLifeCycle, 1000, false, hostile); return hostile; //SetEventMask(EntityEvent.FRAME); hostile.SetFlags(EntityFlags.ACTIVE, false); //Adding this line allowed for headshot kills to register. Damaged to death AI still does not register though. } Here is what I did to the scoring system component: //------------------------------------------------------------------------------------------------ /*! Handle and dispatch scoring logic for this event. */ protected override void OnControllableDestroyed(IEntity entity, IEntity instigator) { super.OnControllableDestroyed(entity, instigator); Print("AI Destroyed!"); //debug int killerId = GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(instigator); //check if ID is a player: array<int> allPlayers = {}; int count = GetGame().GetPlayerManager().GetAllPlayers(allPlayers); if(allPlayers.Contains(killerId)) { super.AddKill(killerId); } Share this post Link to post Share on other sites
firefall70 10 Posted September 19, 2022 The scoring component only works on players not on AI. If you want AI kills to count you have to listen to the death Event of the AI and inject your callback function that updates the score. Share this post Link to post Share on other sites