Jump to content

Need a simple script


mechatech

Recommended Posts

Can someone show me a simple script that does the following.

 

Item with script attached is unequipped but is in inventory, character is visible sneaking or not

Item is equipped and character is visible when not sneaking and invisible when sneaking.

 

I want to make a cloak that when worn applies chameleon to the character when sneaking only.

The cloak already as an enchantment of protection and I want that to stay permanently.

 

I tried something but I really don't have a clue with scripting. Maybe I'm asking too much but I don't know that or not either.

 

Thanks in advance.

Link to comment
Share on other sites

Hi mecha !

you already created some mods, Good ! then you can use CSE

I will assume your cloak is equipped at slot 2 (Upper Body), Change if you use other slot you can see for slot info in cs wiki GetEquippedObject

use this script and attach it to your invis Cloak



scn InvisCLoakObjectScript
ref me
begin OnEquip
Let me := GetContainer
end
begin GameMode
if me == 0
return ;prevent script running on non actor
endif
if me.HasSpell Mg06JskarInvis ;we can use Jskar Chameleon (from Bruma Mages Guild), or you can make custom chameleon spell by yourself
if me.IsSneaking == 0 || InvisCloakEditorID == me.GetEquippedObject 2 ;-----------------> Change this slot if not upper body
me.RemoveSpellNS Mg06JskarInvis
endif
elseif me.IsSneaking
if InvisCloakEditorID == me.GetEquippedObject 2 ;-----------------> Change this slot if not upper body
me.AddSpellNS Mg06JskarInvis
endif
endif
end

Link to comment
Share on other sites

What a quick response! Thanks!

 

Anyway never used the CSE before. Put it in. What a difference in scripting it makes.

 

Anyway after some mind numbing stupidity on my part. I'm still working on it. Will post results soon.

Link to comment
Share on other sites

hmm ... I see that you are still learning :)

 

you know, you should change that ' InvisCloakEditorID ' with your Invisible Cloak Editor ID

 

editor ID is the unique ID every reference have, example remember Martin? the Emperor's child

 

if you want to do something with martin you should use MartinRef. So .... just replace that 'InvisCloakEditorID' with your invisible cloak which item I-don't-know-whats-that-Editor-ID is

Link to comment
Share on other sites

The script works, sort of. I made a custom chameleon spell. If I apply it using the console it works. But if it is applied by the script my character flickers and is detected. I tried using Mg06JskarInvis with the same result. Strange thing is if I apply Mg06JskarInvis manually it doesn't work at all and if I remove it I get the message not found on my character. What's really weird is Mg06JskarInvis worked last night.

 

It seems the script works but the game engine is not applying it properly.

Link to comment
Share on other sites

Great !

happy to hear the script is working well

 

hmm.... I don't know about that, but maybe mod conflict ?

mod such as SDR by Saebel can detect Player even in Chameleon 100% right? I don't see any other reasons that that

this is probably conflict with mod that modify detection setting or the Game Setting itself

 

EDIT :

 

ahh I am sorry the code is wrong ! There's little terrible mistake

 

this line is wrong !! this what's causing flicker

if me.IsSneaking == 0 || InvisCloakEditorID == me.GetEquippedObject 2 ;-----------------> Change this slot if not upper body

it should be like this, notice there is different in == (script above) and != (script below)

if me.IsSneaking == 0 || InvisCloakEditorID != me.GetEquippedObject 2 ;-----------------> Change this slot if not upper body

and here's the new revision.

This will work much better than the previous code,

can be applied to any equipment you wants :D no need to replace the obj with you invis Cloak EDID !!!

Try it, and tell me what you think

scn InvisCLoakObjectScript
ref me
ref obj
begin OnEquip
	Let me := GetContainer
	Let obj := GetSelf
end
begin GameMode
	if me == 0
		return
	endif
	if me.HasSpell Mg06JskarInvis
		if me.IsSneaking == 0 || obj != me.GetEquippedObject 2 ;-----------------> Change this slot if not upper body
			me.RemoveSpellNS Mg06JskarInvis
		endif
	elseif me.IsSneaking
		if obj == me.GetEquippedObject 2 ;-----------------> Change this slot if not upper body
			me.AddSpellNS Mg06JskarInvis
		endif
	endif
end
Edited by lubronbrons
Link to comment
Share on other sites

It doesn't work. I started with just the base game and the latest version of OBSE, plus only this mod containing this script and nothing else. I tried this experiment with Mg06JskarInvis and a custom spell. This is what happens.

 

Using the console I add the spell and my character disappears. I remove the spell and my character reappears. Using the console I add the scripted item (at present it has no enchantments). I then equip the item. I use the console again to add and remove the spell and the spell works as expected. I go into sneak and nothing happens. If I add the spell, that spell doesn't work anymore, sneaking or not. i unequip the item, the spell still doesn't work using console. Removing the spell gives the message that the spell is not on the character. The spell will only work if I remove the item from inventory. Somehow the script, once running, stops the spell from being applied.

 

 

edit - I'm wondering if the flickering with the first script was the script fighting with itself. Applying and removing the spell repeatedly.

Link to comment
Share on other sites

Yess ! the frist script I've given to you made that happen

you see....

 

this line >>> if me.HasSpell Mg06JskarInvis

means : current host already Jskar invis or not

 

this line >>> if me.IsSneaking == 0 || InvisCloakEditorID == me.GetEquippedObject 2

me.RemoveSpellNS Mg06JskarInvis

means : current host is currently sneaking or equipped the invis cloak then the condition meet, TRUE

evaluation : This is my first mistake ! The correct one should be like this ---> InvisCloakEditorID != me.GetEquippedObject 2 (notice the different in != )

that is why you have flicker effect bug since the condition is always TRUE in my first script, the Second script I think should be fine

or you can use the better version, the second script will have it running by itself you DON'T have to write EDID for Invis cloak manually like in the first script

begin OnEquip
Let me := GetContainer
Let obj := GetSelf
end
...
if me.IsSneaking == 0 || obj != me.GetEquippedObject 2
...
Edited by lubronbrons
Link to comment
Share on other sites

Out of curiosity I made my custom spell using both chameleon and then invisibility into a power than a less power and a spell and that doesn't work either.

I don't get it. I'm doing everything right and it just won't work.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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