Jump to content

script for an ability to turn on when not sneaking.


thelawfull

Recommended Posts

I tried to look for a more efficient way, but a quick search did not turn up anything, so maybe a simple quest script could do. Skyrim has the ability to register for animation events, but constant polling is probably the best way there is in Oblivion...

 

Here is a quick, untested example of a quest script that might do the trick. Others are free to improve it.

ScriptName YourQuestScript

float fQuestDelayTime
short iAction

Begin GameMode

    If ( GetGameLoaded )
        let fQuestDelayTime := 1.0 ; approximate check interval
    EndIf

    ; sneaking + has spell = 1 + 1 = 2
    ; sneaking + no spell  = 1 + 0 = 1
    ; standing + has spell = 0 + 1 = 1
    ; standing + no spell  = 0 + 0 = 0

    let iAction := ( PlayerRef.IsSneaking ) + ( PlayerRef.HasSpell SomeSpell )

    If ( iAction == 1 )
        Return
    ElseIf ( iAction == 2 )
        PlayerRef.RemoveSpellNS SomeSpell
    Else
        PlayerRef.AddSpellNS SomeSpell
    EndIf

End

Hopefully that helps a little. :thumbsup:

 

Edit: Waaaaaaaaaaaaaaaaaaaaait. It should work the other way round. Sorry. Just a minute... :facepalm:

 

Edit 2: Done. Sorry for the initial mistake. Now it should work the right way. :sweat:

Edited by Contrathetix
Link to comment
Share on other sites

my version (based on Contra)

 

scripting is fun :D btw ... the code below I don't know it will work or not, I can't test it because right now my LO is so messed up (building my LO from scratch)

scn yourQuestScript
float fQuestDelayTime
Begin GameMode
	if Player.IsSneaking
		;this can be repeated no need for HasSpell check, if player already have that spell this script will do nothing. will return 0
		Player.AddSpellNS SomeSpell
	else
		;this can be repeated no need for HasSpell check, if player not have the spell this script will do nothing. will return 0
		Player.RemoveSpellNS SomeSpell
	endif
End

begin MenuMode 1044
	;set this only when in main menu
	Let fQuestDelayTime := 1.0 ; approximate check interval
end
Edited by lubronbrons
Link to comment
Share on other sites

 

my version (based on Contra)

 

scripting is fun :D btw ... the code below I don't know it will work or not, I can't test it because right now my LO is so messed up (building my LO from scratch)

scn yourQuestScript
float fQuestDelayTime
Begin GameMode
	if Player.IsSneaking
		;this can be repeated no need for HasSpell check, if player already have that spell this script will do nothing. will return 0
		Player.AddSpellNS SomeSpell
	else
		;this can be repeated no need for HasSpell check, if player not have the spell this script will do nothing. will return 0
		Player.RemoveSpellNS SomeSpell
	endif
End

begin MenuMode 1044
	;set this only when in main menu
	Let fQuestDelayTime := 1.0 ; approximate check interval
end

Thankyou for your input aswell. :smile:

I was going to remake the mod I needed it for just to learn its on the hotlist right now so it will get even more downloads and views now that its done right, Before it just damaged sneaking -20 and to only enable it when your not playing a nonsneak archer. I wanted to make a mod that gives players a benefit to using a bow while not sneaking so it would become a thing something more like a militia archer. Anyways heres the link and thankyou guys!. http://www.nexusmods.com/oblivion/mods/47120/?

Edited by thelawfull
Link to comment
Share on other sites

No problem. :thumbsup:

 

As for the suggestion by L: I have no idea how much of a difference it makes to call the ones in my script (IsSneaking + HasSpell) and the ones in L's script (IsSneaking + Remove/AddSpell) every time. My suggestion was based on the idea of avoiding excess Add/RemoveSpell commands, but it still has two commands as well.

 

If you are still open for suggestions, thelawfull, you could consider moving the fQuestDelayTime variable assignment to the MenuMode 1044 block to avoid running GetGameLoaded each time the script updates. Like this:

ScriptName YourQuestScript

float fQuestDelayTime
short iAction

Begin MenuMode 1044

    let fQuestDelayTime := 1.0 ; approximate check interval

End

Begin GameMode

    let iAction := ( PlayerRef.IsSneaking ) + ( PlayerRef.HasSpell SomeSpell )

    If ( iAction == 1 )
        Return
    ElseIf ( iAction == 2 )
        PlayerRef.RemoveSpellNS SomeSpell
    Else
        PlayerRef.AddSpellNS SomeSpell
    EndIf

End

Thank you, L, for reminding me of that menumode thing. I keep forgetting it. :tongue:

Edited by Contrathetix
Link to comment
Share on other sites

me too still unsure Contra lol

 

I just try to optimize the code to have maximum performance

 

my teacher said that command ' If ' is very costly compared assignment

 

I quote this from cs wiki " This function returns 1 if the spell is successfully added to the caller, and 0 if the spell cannot be added (e.g. if they already have the spell in their spell list in the first place). "

reference >>> http://cs.elderscrolls.com/index.php?title=AddSpell

 

haha me too ... still not implement that MenuMode 1044 even though my teacher gave me detailed explanation

Edited by lubronbrons
Link to comment
Share on other sites

I have the same situation - I have learned a lot again in these past few months or more, and I would need to update my mods to reflect that. Maybe I should make a to-do list again, it helped me get stuff done last year, and it could help now, too.

 

So comparisons using if are expensive... :psyduck:

 

I wonder if using OBSE compiler override and Eval make any difference, and to which direction. As in, how expensive (overall, approximately) something like this:

Begin _GameMode
    If Eval ( PlayerRef.HasSpell )
        PlayerRef.RemoveSpellNS SomeSpell
    EndIf
End

could theoretically be based on any code available from OBSE, compared to using just

Begin _GameMode
    PlayerRef.RemoveSpellNS SomeSpell
End

because RemoveSpellNS also needs to check if player has the spell. Right? This is interesting. I have a few mods that might do with some optimisations, and variable comparisons might be one place to potentially start, assuming it makes a difference (no matter how tiny). :unsure:

 

Not a day goes by without me learning something new, or at least hearing about something potentially new that could be useful to know. It is as if little crumbs of knowledge occasionally fell from those above me for me to catch. :sweat:

Edited by Contrathetix
Link to comment
Share on other sites

Well right now it works just fine going in and out of sneak, But if your up to it a delay in when the bonus adds from sneak to not sneaking of something like 20 seconds would prevent people exploiting this bonus by sneak attacking then immediately unsneaking. Did I lose you?. lol

 

Either way im happy the way this worked out for a much needed mod, You should be able to be an archer without being forced to do a stealth class, Will also give it a short blade bonus so people dont have to play a stealth class to use daggers and the like either.

Edited by thelawfull
Link to comment
Share on other sites

  • Recently Browsing   0 members

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