Jump to content

TheMrDomino

Supporter
  • Posts

    18
  • Joined

  • Last visited

Nexus Mods Profile

About TheMrDomino

Profile Fields

  • Country
    United States

TheMrDomino's Achievements

Apprentice

Apprentice (3/14)

  • First Post
  • Collaborator Rare
  • Conversation Starter
  • Week One Done
  • One Month Later

Recent Badges

0

Reputation

  1. The spell this script is attached to is attached to actors. When that's the case, you can use Actor events even though it extends ActiveMagicEffect. The issue is one of syncing across multiple actors, not just one. As of right now the spell is attached to skeletons. When fighting one skeleton everything is fine. However, when a second is added, upon killing the first the OnDying() event triggers, and sets the variable back to it's initial value (let's say 1 for simplicity's sake). In the half-second it takes to update, if the player attacks the second skeleton, they will suffer from the glitch. Waiting just a moment allows the script to update and set the variable to 0. The most logical way to fix this I can think of is to add a condition that if the player is fighting any other actor with this spell, don't trigger the script in OnDying(), but I don't know how to do that. You mention quest aliases, and I initially thought of them, but I must not understand them fully, as I thought they were only populated when the quest initialized, and I'd need that list to be updating like the script I posted. Is that possible? Also, can an alias hold a reference to more than one actor? It feels like I should be able to use the Find Matching Reference option of filling the alias with the In Loaded Area checkbox, and then set a condition to only add actors that have a specific spell or keyword.
  2. I have a script that's working, but I'm only about 95% happy with its functionality right now. It's purpose is to prevent a glitch. This is it, in its entirety: Scriptname zKillmoveControlGlitchFix extends ActiveMagicEffect GlobalVariable Property KillMove Auto GlobalVariable Property killmovesInitialValue Auto import Debug Float initialValue Actor thisActor Event OnEffectStart(Actor akTarget, Actor akCaster) ;get the original killmove setting Debug.Notification("oneffectstart event triggered") initialValue = killmovesInitialValue.GetValue() thisActor = akCaster RegisterForUpdate(1) EndEvent Event OnDying(Actor akKiller) KillMove.SetValue(initialValue) Debug.Notification("actor killed, killmove reset") UnregisterForUpdate() EndEvent Event OnUpdate() ;If Game.GetPlayer().GetCombatTarget() == thisActor too precise, switched to line of sight ;If Game.GetPlayer().HasLOS(thisActor) caused issues with multiple actors deactivating/activating If thisActor.IsNearPlayer() If KillMove.GetValue() == 1 KillMove.SetValue(0) Debug.Notification("is combat target, killmoves disabled") Else Debug.Notification("killmoves already disabled") EndIf ; GoToState("targeted") ; ElseIf Game.GetPlayer().GetCombatTarget() != thisActor unneeded, too buggy ; GoToState("waiting") unneeded, too buggy Else KillMove.SetValue(initialValue) Debug.Notification("no longer target, killmoves reset") EndIf EndEvent What this does is, when the player sees whatever the script is attached to, it changes some globals around, and on death it resets their value. This code compiles and runs well, and performs admirably, doing what I need it to. It is, in fact, doing exactly what I tell it to. My dissatisfaction arises when fighting multiple actors with this script attached. What happens is when one actor dies, the ondying() event triggers and the global is restored to its original value. Because the script only updates once every second, there is a brief opportunity after killing one actor where the glitch can occur if the player kills another actor quickly. I tried decreasing the update time, even as low as .05, but that didn't help, and truth be told I'd be loathe to use that as a solution even if it did for fear of getting stacking onupdate() events. What I'd like to do is add a condition to the ondying() event so that it only runs the code if the player does not have line of sight to any similar actors. Something like 'if nearby actor has this spell' or 'if player has line of sight to an actor with this spell' or 'player has line of sight/is near actors with a certain keyword' . My problem lies in defining an Actor variable to hold that infomation. I thought perhaps trying a quest alias would work, having it populate with references to actors with a specific keyword/spell that were near the player, but from my understanding the alias only holds one reference, and it only updates when the quest starts. Is it possible for an alias to hold multiple actor references, and if so, is it possible to attach a script to the quest holding the alias that would update it at regular intervals, refreshing the references in the alias? Ultimately I'm just looking for a way to get actors nearby the player.
  3. The property is set in the CK, yes. I've been using the same save for all my testing, but it's had previous versions of the mod saved with it. I'll make a clean save and see if that makes a difference. edit: Creating a clean save did the trick. How odd it behaves that way, but I'm glad a solution was found. Thank you!
  4. I have a feeling this is something very obvious, but I've been staring at it for so long I can't see the solution This is the relevant snippet of the script that I'm working with: Message Property menuChance Auto Message Property menuEnabled Auto Message Property menuDEnabled Auto Message Property menuDChance Auto GlobalVariable Property kchance Auto GlobalVariable Property enabled Auto GlobalVariable Property enabledPermanent Auto ;activate when book is opened Event OnRead() ;wait for 1.3 seconds before showing menu while book opening animation plays WaitMenuMode(1.3) ;initialize data-holding values. First line brings up the enabled menu int enabled = menuEnabled.Show() int choice = 0 int chance = 0 ;if the user clicks enabled set the set the relevant variable to 1, display the chance menu, ;calculate the chance based on input, and use the value to set the global variable chance if enabled == 1 enabled.SetValueInt(1) enabledPermanent.SetValueInt(1) choice = menuChance.Show() chance = (choice + 1) * 10 kchance.SetValue(chance) The issue lies with the enabledPermanent.SetValueInt(1) line. Quite simply, it doesn't change the variable at all. I've gone through everything I can think of. The enabledPermanent property is tied to a new global variable (short type) I created that is NOT set to constant: in-game I can use the set command to manually change the value, verifying the change with getglobalvalue. I've tried using just SetValue instead of SetValueInt. Nowhere else in the script is enabledPermanent set to any other value. This the only script that ever attempts to set this specific custom variable, in the only other script that uses it the value is retrieved, never modified. I've recompiled the script, and there are no errors, compilation succeeds. What makes it doubly strange is the line above it works just fine, changing the global variable it's attached to just fine. The only thing I could think that's causing the issue is the fact that I'm trying to modify a newly created global variable, as all the other globals that are modified in the script are existing vanilla globals. Is there a trick to creating a new global variable beyond going to the globals section and adding a new entry? As I mentioned, I can check and set the value of the new global in the console in-game, which leads me to believe I've added it correctly. Which just leaves me back at square one.
  5. Ah! I had read that, too. Must have been before I understood the ramifications of what it was actually saying. Well, looks like my job just got even more complicated. I swear, for what was supposed to be a 'simple' mod, it's giving me no end of trouble.
  6. Adding a template to an actor wasn't the issue, I could add the dummy template just fine. My problem was that once I added the dummy to certain actors as a template, the dummy itself lost its script box. It became greyed out with no scripts displaying in it. In-game testing showed that the script wasn't activating, either.
  7. I'm having an issue with adding scripts to actors. I have a script I wrote that needs to be added to several different creature actors in the game. For simplicity's sake, I'll just use skeletons as an example. There are several skeleton actors, but most of them are based off of a handful of encounter actors that are used as templates. It seems the most efficient way to get what I want done is to attach the script to the templates and call it a day. The problem is the template actors script box is, while empty, greyed out. Every other skeleton actor has editable scripts, but not these few. I decided to get creative when I noticed that the actors used as templates didn't use any templates themselves. So, I created a dummy actor and attached the script to that, and then went to the template actors and modified them so that they in turn used a template, inheriting scripts from the dummy actor. Saved the mod and went to test it, but no dice. Upon reloading in the creation kit, I look at the dummy actor and discover that its script box is now greyed out (and empty) as well. What's going on? I need to attach this script to these actors but am now out of ideas.
  8. Well, the entire point of the script is to change that particular global, as it's what I have set up to control whether kill moves are enabled or not. As for initializing with GetValue(), I thought I had, but I was mistaken. I had actually taken the index value from a message box. That being said, is it possible to store a global value with GetValue() in a local variable? I need to hold its initial value in order to restore it at the end of the script. edit: also, thanks for the code snippet. States look like they could be immensely helpful.
  9. I've got a basic script set up, but it refuses to compile, giving me odd errors. The code: Scriptname myscript extends ObjectReference GlobalVariable Property killmoveEnabled Auto import Utility import Debug int initialValue = killmoveEnabled.GetValue() Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked) if initialValue == 1 debug.Notification("Onhit has triggered") killmoveEnabled.SetValue(0) debug.Notification("Killmove Disabled") Utility.Wait(0.1) debug.Notification("Game waited for .1 seconds") killmoveEnabled.SetValue(initialValue) debug.Notification("Killmove reset to initial value") endif EndEvent The errors: (8,19): no viable alternative at input 'KillMove' (8,27): required (...)+ loop did not match anything at input '.' (8,4): Unknown user flag KillMove No output generated, compilation failed. Batch compile of 1 files finished. 0 succeeded, 1 failed. If I replace all the instances of KillMove.GetValue()/KillMove.SetValue() and just enter in constants, the script compiles just fine. I've connected the property with a global in the CK, double-checked that. I've used this exact same syntax for other scripts editing other global variables in the same manner and they've worked splendidly. I'm sure it's something obvious, but I can't figure out what I'm doing wrong.
  10. The strange thing is, the bug only occurs on two-handed weapons (though I have some reports of H2H experiencing it as well), so the delay should be sufficient. Though the delay is longer because initially the script would have to cycle through a long list of races, so I wanted to give it sufficient time to complete. Now it shouldn't be an issue, I can set it fast enough to cover multiple attacks from any weapon. Edit: I have a question: if I'm adding this script to an actor, would the script have to extend Actor? Or could I have it extend ObjectReference? I guess the real question is can the actor be considered an object for the purpose of extending the script.
  11. Thanks for the tip SinderionsBones, that sounds promising. @nephlm: I should better explain the situation. I have a global variable that controls whether killmoves are enabled or not. What I want to happen is, when attacking certain monsters, for that variable to be changed to 0, and then after a short delay, to be changed back to its initial value. This is to overcome (what I think is) a bug that manifests when you change the killmove frequency and remove last enemy requirements. To that end, after looking through the various events, onhit seemed like the best trigger to encapsulate this code with. While I do think onAnimation would be a better solution, I don't know that it's possible. Ultimately I'm not dedicated to any particular method, and am wide open to suggestions. If I'm understanding it correctly, I like your idea of attaching the onhit event script to the creatures, as it seems that would simplify things greatly. Much simpler, much more straightforward.
  12. That certainly makes sense. Thanks for the info! I suppose that makes my last question about the OnAnimationEvent() event even more important.
  13. I'm working on a script that I'd like to run constantly in the background, monitoring for OnHit() events and performing certain actions when the player attacks certain types of enemies, and then after the event has concluded, to reset those values to their initial value. I've practically no experience with papyrus, and would greatly appreciate some help from those more talented and experienced than I. Here's what I've managed to cobble together so far: ScriptName myScript extends Quest import Actor import Game import Utility GlobalVariable Property myProperty auto int initialValue = myProperty.GetValue() int enabled = 0 Event OnHit(ObjectReference akAggressor) if akAggressor == game.getPlayer() if game.getPlayer().actor.getCombatTarget().HasKeyword(ActorTypeCreature) == 1 race targetRace = game.GetPlayer.Actor.GetCombatTarget().GetRace() if targetRace == SkeletonRace myProperty.SetValue(0) Utility.Wait(0.2) myProperty.SetValue(initialValue) endif endif EndEvent I know that's ugly and probably all very, very wrong. For instance, in the third line of the OnHit() event code chunk, I want to get the type of actor the character is attacking. How can you set which actor the getCombatTarget() function runs on? Moreso, what kind of value does the function return? I'd like to store the value in a variable, but don't know what kind to declare. Int, string, float? The same goes for the GetRace() function, because I need to use the return value in a conditional statement, but don't know how to format the second half. As you can see, for now I just have the string 'SkeletonRace'. The event GetCombatTarget(), will it not trigger if the player isn't currently in combat? Say, a stealth character is initiating combat, will that first attack still trigger the function? Right now I've got the idea to attach the script to a dummy quest in order to auto-launch it when the player loads the save. The script, though, needs to be running in the background, constantly looking for OnHit() events. How could I set that up? Finally, would it be possible to run this script off of the OnAnimationEvent() event? Specifically, the ActorRightAttack and ActorRightPowerAttack animation nodes? This script would likely be much more efficient if it instead ran only when the player attacked rather than constantly scanning for when actors are hit.
×
×
  • Create New...