fallwish Posted August 16, 2024 Posted August 16, 2024 I want to have a follower can use resurrect spell similar like this when he/she detect near companion/target is dead, but I cant find any information on internet, anyone have idea? I ask copilot ai it give me the script is not work. Scriptname FollowerCastSpellOnNearDeadTarget extends Actor Spell Property SpellToCast Auto Actor Property FollowerRef Auto Event OnUpdate() Actor TargetActor = FindNearDeadTarget() If TargetActor != None FollowerRef.Cast(SpellToCast, TargetActor) EndIf RegisterForSingleUpdate(1.0) ; Check every second EndEvent Function FindNearDeadTarget() As Actor Actor ClosestNearDead = None Float ClosestDistance = 999999.0 Float HealthThreshold = 20.0 ; Define near-dead as having less than 20 health ; Iterate through all actors in the vicinity Actor[] NearbyActors = FindAllActorsInVicinity() For Each Actor CurrentActor In NearbyActors If CurrentActor.GetActorValue("Health") < HealthThreshold Float Distance = FollowerRef.GetDistance(CurrentActor) If Distance < ClosestDistance ClosestDistance = Distance ClosestNearDead = CurrentActor EndIf EndIf EndFor Return ClosestNearDead EndFunction Function FindAllActorsInVicinity() As Actor[] ; Implement logic to find all actors in the vicinity ; This is a placeholder function and needs to be filled in Return new Actor[0] EndFunction
Qviddhartha Posted August 16, 2024 Posted August 16, 2024 Seems pretty clear to me this will not compile. Unlike most answers from MS, this one is technically wrong, in addition to the usual unhelpfulness we have learned to expect (and incomplete, and ungrammatical, and...). I doubt anyone can really help you if you cannot get it at least to the point where it compiles, or if you are not interested in learning enough about programming and scripting to attempt it and come back with more specific questions. If you want to learn about programming, PM me and I will do what I can to help you along.
Miauzi Posted August 16, 2024 Posted August 16, 2024 9 hours ago, fallwish said: Wiederbelebungszauber verwenden kann, Ich möchte, dass ein Anhänger einen ähnlichen wenn er/sie erkennt, dass ein naher Begleiter/Ziel tot ist, aber ich kann keine Informationen im Internet finden. Hat jemand eine Idee? Ich bitte Copilot Ai, mir das Skript zu geben, es funktioniert nicht. Skriptname FollowerCastSpellOnNearDeadTarget erweitert Actor Spell-Eigenschaft SpellToCast Auto Actor-Eigenschaft FollowerRef Auto Ereignis OnUpdate() Akteur TargetActor = FindNearDeadTarget() Wenn TargetActor != None FollowerRef.Cast(SpellToCast, TargetActor) EndIf RegisterForSingleUpdate(1.0) ; Überprüfen Sie jede Sekunde EndEvent Funktion FindNearDeadTarget() als Akteur Akteur ClosestNearDead = Keine Float ClosestDistance = 999999,0 Float HealthThreshold = 20.0 ; Definieren Sie einen Beinahe-Toten mit weniger als 20 Lebenspunkten ; Durchlaufen Sie alle Akteure in der Nähe Actor[] NearbyActors = FindAllActorsInVicinity() Für jeden Akteur CurrentActor in NearbyActors Wenn CurrentActor.GetActorValue("Health") < HealthThreshold Float Distance = FollowerRef.GetDistance(CurrentActor) Wenn Distanz < ClosestDistance ClosestDistance = Entfernung ClosestNearDead = CurrentActor EndIf EndIf EndFor Gibt ClosestNearDead zurück EndFunction Funktion FindAllActorsInVicinity() als Akteur[] ; Implementieren Sie eine Logik, um alle Akteure in der Nähe zu finden ; Dies ist eine Platzhalterfunktion und muss ausgefüllt werden Neuen Schauspieler zurückgeben[0] EndFunction And which companion framework is this supposed to work with? Have you ever thought about the fact that in Vanilla Skyrim there is only ONE "human" companion for the player... nothing more was planned - a second companion is an animal The only exception is Serana - when the player brings her back to the castle from her stone coffin... but then she is not a companion in the sense of "You now do what I tell you as a dragonborn" - she simply travels with the player and their companion Only the multi-companion systems (such as NFF) allow a second (or more) companion... and only then would it make sense to think about resurrection as a possible action between two companions So my question again: "Which multi-companion system were you thinking of?
DarkBlade13 Posted August 23, 2024 Posted August 23, 2024 (edited) On 8/16/2024 at 1:31 PM, fallwish said: I want to have a follower can use resurrect spell similar like this when he/she detect near companion/target is dead, but I cant find any information on internet, anyone have idea? I ask copilot ai it give me the script is not work. Scriptname FollowerCastSpellOnNearDeadTarget extends Actor Spell Property SpellToCast Auto Actor Property FollowerRef Auto Event OnUpdate() Actor TargetActor = FindNearDeadTarget() If TargetActor != None FollowerRef.Cast(SpellToCast, TargetActor) EndIf RegisterForSingleUpdate(1.0) ; Check every second EndEvent Function FindNearDeadTarget() As Actor Actor ClosestNearDead = None Float ClosestDistance = 999999.0 Float HealthThreshold = 20.0 ; Define near-dead as having less than 20 health ; Iterate through all actors in the vicinity Actor[] NearbyActors = FindAllActorsInVicinity() For Each Actor CurrentActor In NearbyActors If CurrentActor.GetActorValue("Health") < HealthThreshold Float Distance = FollowerRef.GetDistance(CurrentActor) If Distance < ClosestDistance ClosestDistance = Distance ClosestNearDead = CurrentActor EndIf EndIf EndFor Return ClosestNearDead EndFunction Function FindAllActorsInVicinity() As Actor[] ; Implement logic to find all actors in the vicinity ; This is a placeholder function and needs to be filled in Return new Actor[0] EndFunction Your biggest problem is the detect dead companion part. How exactly did you intend to find the dead companion? For every script you need a trigger and there are only a limited amounth of triggers to start a script. For example a trigger box (start a script when run through). Events can start a script. Spells can start a script. So far there is no on finding a death companion event. Check these events https://ck.uesp.net/wiki/Category:Events. Either you need to scan and run a script every x seconds for the whole game wich will cause lag (this is a very bad idea). You can also scan every time the npc sees another actor wich will cause lag (also a bad idea). Problem number two is that the findclosestactor from an actor will always return that same actor (it's pretty dumb). You can solve this by using findrandomactor from an actor that matches certain criteria and if not repeat the findrandomactor untill the actor matches the criteria. or You should porbably also set a max number of attempts if you don't want to lag the game. If you need information you can read my blog, or dowload my mod and read the code. Some of the assets in it aren't mine but the cody is entirely copy right free so grab what you like. Just change the names of functions and objectreferences so it doesn't interfere with my mod. Edited August 23, 2024 by DarkBlade13
fallwish Posted August 24, 2024 Author Posted August 24, 2024 I will see what I can do, thanks for you guys trying to answer me.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now