Jump to content

[LE] Help with Troop Formations


Recommended Posts

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.0
float LeftBound = 0.0
float RightBound = 0.0
float CommanderAngleZHalfway = 0.0
float ViewConeHalved = 90.0
float SpeedToRotate = 5.0
CommanderAngleZ = Commander.GetAngleZ()
LeftBound = CommanderAngleZ - ViewConeHalved ;Set Initial LeftBound
RightBound = CommanderAngleZ + ViewConeHalved ;Set Initial RightBound
CommanderAngleZHalfway= CommanderAngleZ + 180
if LeftBound < 0
LeftBound = LeftBound + 360
endIf
if RightBound >= 360
RightBound = RightBound - 360
endIf
if CommanderAngleZHalfway>= 360
CommanderAngleZHalfway = CommanderAngleZHalfway - 360
endIf
if (LeftBound > RightBound)
if (SoldierToObtainRotationSpeed.GetAngleZ()> RightBound)&&(SoldierToObtainRotationSpeed.GetAngleZ()< LeftBound)
if (SoldierToObtainRotationSpeed.GetAngleZ()>CommanderAngleZHalfway)&&(SoldierToObtainRotationSpeed.GetAngleZ()< LeftBound)
return 1.0 * SpeedToRotate
else
return -1.0 * SpeedToRotate
endIf
else
return 0.0
endIf
else ;(RightBound > LeftBound)
if (SoldierToObtainRotationSpeed.GetAngleZ()< LeftBound)||(SoldierToObtainRotationSpeed.GetAngleZ()> RightBound)
if (SoldierToObtainRotationSpeed.GetAngleZ()> RightBound)&&(SoldierToObtainRotationSpeed.GetAngleZ()< CommanderAngleZHalfway)
return -1.0 * SpeedToRotate
else
return 1.0 * SpeedToRotate
endIf
else
return 0.0
endIf
endIf
EndFunction
Edited by Guest
Link to comment
Share on other sites

  • 3 weeks later...

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 by Guest
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...