Deleted56253002User Posted June 19, 2021 Author Share Posted June 19, 2021 (edited) As promised here's the function I have developed to detect the correct speed at which to rotate. I simply plug this function into the afOffsetAngleZ parameter of KeepOffsetFromActor and it requires a constant update check to see if the soldier is in position or not. It determines if the actor's current Z angle is within a certain range and if so, it may rotate if they aren't matching similar Z angles. Float Function GetRotationSpeed(actor Commander, actor SoldierToObtainRotationSpeed) float CommanderAngleZ = 0.0float LeftBound = 0.0float RightBound = 0.0float CommanderAngleZHalfway = 0.0float ViewConeHalved = 90.0float SpeedToRotate = 5.0 CommanderAngleZ = Commander.GetAngleZ()LeftBound = CommanderAngleZ - ViewConeHalved ;Set Initial LeftBoundRightBound = CommanderAngleZ + ViewConeHalved ;Set Initial RightBoundCommanderAngleZHalfway= CommanderAngleZ + 180 if LeftBound < 0LeftBound = LeftBound + 360endIf if RightBound >= 360RightBound = RightBound - 360endIf if CommanderAngleZHalfway>= 360CommanderAngleZHalfway = CommanderAngleZHalfway - 360endIf if (LeftBound > RightBound)if (SoldierToObtainRotationSpeed.GetAngleZ()> RightBound)&&(SoldierToObtainRotationSpeed.GetAngleZ()< LeftBound)if (SoldierToObtainRotationSpeed.GetAngleZ()>CommanderAngleZHalfway)&&(SoldierToObtainRotationSpeed.GetAngleZ()< LeftBound) return 1.0 * SpeedToRotateelsereturn -1.0 * SpeedToRotateendIfelsereturn 0.0endIfelse ;(RightBound > LeftBound)if (SoldierToObtainRotationSpeed.GetAngleZ()< LeftBound)||(SoldierToObtainRotationSpeed.GetAngleZ()> RightBound)if (SoldierToObtainRotationSpeed.GetAngleZ()> RightBound)&&(SoldierToObtainRotationSpeed.GetAngleZ()< CommanderAngleZHalfway)return -1.0 * SpeedToRotateelsereturn 1.0 * SpeedToRotateendIfelsereturn 0.0endIfendIf EndFunction Edited June 20, 2021 by Guest Link to comment Share on other sites More sharing options...
IsharaMeradin Posted June 19, 2021 Share Posted June 19, 2021 You constantly run an update to check this? Wouldn't that be taxing on the system with a lot of NPCs in the formation needing to be checked? How often do you run this update? Link to comment Share on other sites More sharing options...
Deleted56253002User Posted June 20, 2021 Author Share Posted June 20, 2021 It runs every second. Surprisingly it works fine in game and I haven't noticed any drop in FPS or increase in save game file size with this active, even when 40+ actors are running this. I usually set this script only to run on actors that are loaded. Link to comment Share on other sites More sharing options...
IsharaMeradin Posted June 20, 2021 Share Posted June 20, 2021 I might give it a shot with Followers As Companions to see if it helps out there. Do you mind if I incorporate the function into a release if it does work? Link to comment Share on other sites More sharing options...
Deleted56253002User Posted June 20, 2021 Author Share Posted June 20, 2021 No problem! Link to comment Share on other sites More sharing options...
Deleted56253002User Posted July 7, 2021 Author Share Posted July 7, 2021 (edited) Probably do need to use reference aliases. I'm wondering if it would be possible to have something like LeadA, LeadB, LeadD and LeadE each at an offset from the player / commander (who would be LeadC). For those that follow, give them a modified variation of the follower package and have them follow a specific lead. Thus any gaps in the following ranks would auto-fill as replacements are added. Only the leads would then need to be specifically replaced.I had the idea where a script could check whether if a soldier in the first column first row is dead, then a new soldier in the next row would replace that actor variable. However, I am having some trouble figuring out how trying to register an NPC death event since I don't want these if statements to run regularly on an update but when an NPC dies for performance issues. In the script I have experimented with these events: "Event OnDeath(Actor akKiller)""Event OnDeath(Actor akKiller)""Event OnStoryKillActor(ObjectReference akVictim, ObjectReference akKiller, Location akLocation, int aiCrimeStatus, int aiRelationshipRank)" On a new test mod to figure out how these events worked, I created a new quest, added a new script to that quest, and filled them out as follows. For testing purposes to see if the script was working correctly, it was setup so that if a certain actor property died, the player would die: Scriptname testingDeathEvents extends Quest Actor Property PlayerRef Auto Actor Property AlvorREF Auto Actor Property GerdurREF Auto Event OnStoryKillActor(ObjectReference akVictim, ObjectReference akKiller, Location akLocation, int aiCrimeStatus, int aiRelationshipRank) if akVictim == GerdurREF PlayerRef.Kill() elseif akVictim == AlvorREF PlayerRef.Kill() endIf endEvent Went to Riverwood, killed Gerdur and Alvor hoping to see the player die and the script to function correctly, but it didn't work. Do death events need to run on individual actor references and/or alias references to function correctly or is there a way for them to work within the quest script? Edited July 7, 2021 by Guest Link to comment Share on other sites More sharing options...
IsharaMeradin Posted July 7, 2021 Share Posted July 7, 2021 The OnDeath event needs to run on the actor or alias pointing to the actor. Link to comment Share on other sites More sharing options...
Recommended Posts