Imrinfected Posted April 21, 2010 Share Posted April 21, 2010 I'm trying to figure out how to get the reference that has the effect on it that this script is running in. I thought I could use getcontainer in the script to find the reference that has said magic script effect on it, but it doesn't seem to be working. I'm not sure if it's because of this, or some other part of the script. The only other issue I can think of is it isn't running every frame like it should. It's running on gamemode, but since it's a magic effect, and an Ability, it would probably work differently. So basically, how would a person get the reference that has an ability in a script on that ability? Link to comment Share on other sites More sharing options...
Vagrant0 Posted April 21, 2010 Share Posted April 21, 2010 I'm trying to figure out how to get the reference that has the effect on it that this script is running in. I thought I could use getcontainer in the script to find the reference that has said magic script effect on it, but it doesn't seem to be working. I'm not sure if it's because of this, or some other part of the script. The only other issue I can think of is it isn't running every frame like it should. It's running on gamemode, but since it's a magic effect, and an Ability, it would probably work differently. So basically, how would a person get the reference that has an ability in a script on that ability?getself within a scripteffectstart/update/finish block? Link to comment Share on other sites More sharing options...
Imrinfected Posted April 21, 2010 Author Share Posted April 21, 2010 I'm trying to figure out how to get the reference that has the effect on it that this script is running in. I thought I could use getcontainer in the script to find the reference that has said magic script effect on it, but it doesn't seem to be working. I'm not sure if it's because of this, or some other part of the script. The only other issue I can think of is it isn't running every frame like it should. It's running on gamemode, but since it's a magic effect, and an Ability, it would probably work differently. So basically, how would a person get the reference that has an ability in a script on that ability?getself within a scripteffectstart/update/finish block?I tried that, but it didn't seem to work. It convinced me that it was returning the ability instead of the npc reference. Maybe it's not working because it's not running every frame. I'm not sure how to get a script that's part of an ability to run every frame. Might you or anyone else be able to help with that? EDIT: Here's my dilemma. NPCs won't get back up. Here's the quest script that finds the npc and adds the ability:scn EnemiesFallDown float fQuestDelayTime ref npc ref firstref begin gamemode set fQuestDelayTime to 0.01 set npc to getfirstref 69 1 set firstref to npc label 1 if npc.getactorvalue health < 50 npc.addspellns EnemiesFallDownSpell set npc to getnextref if npc == firstref return else goto 1 else set npc to getnextref if npc == firstref return else goto 1 endif endif endif end And the script that handles removing that ability when the npc is above 50 health: scn EnemiesFallDownRemovalScript ref self short added begin scripteffectupdate set self to getself if self.getav health > 50 self.removespellns EnemiesFallDownSpell return endif end Originally it was 10 HP, but for some reason it wouldn't even add the ability. Raised it to 50, and for some reason it worked. Very strange. No idea what I'm doing wrong. Link to comment Share on other sites More sharing options...
Vagrant0 Posted April 21, 2010 Share Posted April 21, 2010 Try using the normal add/removespell function instead of the OBSE one. You don't need the message blocking feature on NPCs anyway. Wihin your spell script, you might want to have it like; scn EnemiesFallDownRemovalScript begin scripteffectupdate if getav health > 50 removespell EnemiesFallDownSpell endif end or if that doesn't work scn EnemiesFallDownRemovalScript ref self begin scripteffectstart set self to getself end begin scripteffectupdate if self.getav health > 50 self.removespell EnemiesFallDownSpell endif end The success of this will also depend on what the other effects of that script is. Additionally, many lower level things never have more than 50 health, so this may not be a particularly viable effect here. Link to comment Share on other sites More sharing options...
Imrinfected Posted April 22, 2010 Author Share Posted April 22, 2010 Neither of those work. When I get this to work, I'll set the health value much lower, to 10 or 5 or something like that, but for testing purposes, 50 is fine. I'm thinking of two reasons why this wouldn't work: getself is returning the ability instead of the npc, so it's trying to remove the ability from the ability, which obviously doesn't work.Scripts trying to remove the ability that they're active in don't work, for whatever reason. Maybe it would cause the script to stop working in the middle, causing a crash or something, and this is one of the few precautions bethesda took. I believe it's the former rather than the latter, so I'll have to use some other method of getting the npc. I'm sure there's some way to find the npc that has the ability without using anything complicated. I could use the obse getfirstref and getnextref, but that only works with the player around, and I need this to remove the ability even when the player is not around. I could use an aoe spell, but I've never done that before, and I'm not sure if that would accomplish what I'm trying to. I don't want to use tokens, but I tried it anyway to see if it would work.I tried using an object script using getcontainer instead of getself, but it seems to not get the right npc either. scn EnemiesFallDownRemovalScript ref self begin gamemode set self to getcontainer if self.getav health > 50 self.removespell EnemiesFallDownSpell messagebox "Spell removed" self.removeitem FallDownToken 1 endif end I have never gotten the messagebox, so clearly it doesn't work for some reason, and the only reason that makes any sense is that it's not getting the npc. EDIT: I changed the script around to work differently. Instead of having it as an ability, it's a spell instead. An activator is moved to the npc, and the spell is cast, so the npc has their fatigue damaged by around 1000000. It's fairly obvious when it happens, because of the visuals. On the spell, there's another effect script that dispels the whole thing if their health is above 50, and again it's very easy to see when this happens, as the visuals change. I found that everything works like it should. The activator is moved, the spell is cast, the npc is affect, and falls down. If their health goes above 50, it's dispelled. BUT they don't get back up. This is interesting, and leads me to believe that the other scripts DID work as intended, but the NPC just wouldn't get back up for some reason. I have no idea why, though, so I have no idea how to fix it. New quest script:scn EnemiesFallDown float fQuestDelayTime ref npc ref firstref begin gamemode set fQuestDelayTime to 0.01 set npc to getfirstref 69 1 set firstref to npc label 1 if npc.getactorvalue health <= 50 EnemiesFallDownActiRef.moveto npc EnemiesFallDownActiRef.cast EnemiesFallDownSpell npc EnemiesFallDownActiRef.moveto EnemiesFallDownMoveToDummyRef set npc to getnextref if npc == firstref return else goto 1 else set npc to getnextref if npc == firstref return else goto 1 endif endif endif end New effect script: scn EnemiesFallDownRemovalScript ref self begin scripteffectstart set self to getself end begin scripteffectupdate if self.getactorvalue health > 50 self.dispel EnemiesFallDownSpell endif end EDIT: I got it to work! Turns out, I had to increase the actor's fatigue for them to get up. So, the spell was really unnecessary. I'm doing it all through one script in one ability, and working quite well, and reliably. One thing though, actors on the ground still detect the player. They're supposed to be unconscious, thus they shouldn't do that. I could use setunconscious, but that causes quite a few problems, more than it solves. So, one final question, how might I make an actor not detect anything? Thanks for all of the help. Link to comment Share on other sites More sharing options...
Recommended Posts