Jump to content

Outfit "Perk" Script


Recommended Posts

This is my first attempt at some scripting with a modicum amount of success. The aim is to have an outfit that uses the Upper and Lower slots add a spell to the player (maybe any actor later). Works so far, but I also want it to check that the equipped item is also considered clothing and not armor. GetObjectType or IsClothing seem relevant, but my experimentation was fruitless. Not really sure where to go from here...

scn MEHClothingULQuestScript

float fQuestDelayTime

Begin Gamemode
	set fQuestDelayTime to 1
If Player.GetEquippedObject 18
		Player.AddSpellNS MEHClothingULeffect
	endif
	If Player.GetEquippedObject 18 == 0
		Player.RemoveSpellNS MEHClothingULeffect
		endif
end

 

Link to comment
Share on other sites

I think you are using GetEquippedObject wrong. The function is not a boolean yes/no (1/0), but it gets the equipped item, which you need to store in a variable. After you stored it, you can run further checks on it.

For example (but without testing), this should work:

scn MEHClothingULQuestScript

float fQuestDelayTime

ref Clothing

Begin Gamemode
	set fQuestDelayTime to 1

	set Clothing to Player.GetEquippedObject 18

	If Clothing.getisid != 0 && Clothing.IsClothing == 1
		Player.AddSpellNS MEHClothingULeffect
	else
		Player.RemoveSpellNS MEHClothingULeffect
	endif
end

Clothing.getisid != 0 makes sure there is any object equipped (0 would be none).

 

&& makes sure that both conditions need to be true to apply the spell, if both or either is wrong, then the spell is removed (the stuff after "else").

 

Clothing.IsClothing == 1 makes sure it is clothing and not armor.

 

 

Don't forget to create a new quest in the quest menu to which you apply the script and make sure to check the "Start Game Enabled" checkbox in the quest's menu.

Link to comment
Share on other sites

If it is only a specific outfit you want this to apply to, then you can just assing a script directly to the outfit without the need of a questscript running checks in the background constantly:

scn ScriptDirectlyForOutfit

Begin OnEquip
	AddSpellNS MEHClothingULeffect
end

begin OnUnequip
	RemoveSpellNS MEHClothingULeffect
end
Edited by mixxa77
Link to comment
Share on other sites

After reading up on how IsClothing works, it turns out we both used it wrong. It is highly important to use the TES CS wiki to read up on how functions work when you are writing scripts (Because guessing how they work, as we did, often doesn't work). The wiki often provides an example syntax for how to use the function, which is how I saw that we both used IsClothing it wrong.

So, this should work:

scn MEHClothingULQuestScript

float fQuestDelayTime

ref Clothing

Begin Gamemode
	set fQuestDelayTime to 1

	set Clothing to Player.GetEquippedObject 18

	if IsClothing Clothing
		Player.AddSpellNS MEHClothingULeffect
	else
		Player.RemoveSpellNS MEHClothingULeffect
	endif
end
Edited by mixxa77
Link to comment
Share on other sites

The difference is between references and base objects. For references the "<ref>.IsClothing" notation can be used, for base objects the "IsClothing <base>" notation has to be used instead. And GetEquippedObject just so happens to return the base object.

 

(Sorry for intruding.)

Link to comment
Share on other sites

  • Recently Browsing   0 members

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