Jump to content

[LE] I'd like to instantly converting objects into others using a variable


Recommended Posts

Hello everybody!

 

I would like to instantly convert some objects into others, for example to turn all the iron ore into iron ingots at once preferably through spells like I do with some of my mods in Oblivion.

 

Unfortunately Papyrus scripting seems much more complicated than scripting in Oblivion.

 

Can anyone among you show me an example script so I can easily create mine?

 

I would be very grateful.

Link to comment
Share on other sites

You basically would use RemoveItem() and AddItem()

 

If I had a full example laying around id happily share, or if I had some downtime at work would write an example up etc. Thankfully for you this is def an easy one to do. You shouldnt hesitate to peek at some existing scripts in the game and copy one to adapt for your use

 

I'll peek later if you dont have any bites. Good luck

Link to comment
Share on other sites

An example would be the transmute spell that changes iron into silver and silver into gold.

 

 

Scriptname transmuteMineralScript extends ActiveMagicEffect  
{script for spell to allow transmutation of ores}
 
import game
 
MiscObject Property Ore01  Auto  
{Lowest value ore}
MiscObject Property Ore02  Auto  
{Middle value ore}
MiscObject Property Ore03  Auto  
{Highest value ore}
Sound Property FailureSFX  Auto  
float property skillAdvancement = 15.0 auto
{How much to advance the skill?  Only works when spell actually transmutes something}
message property failureMSG auto
 
 
EVENT OnEffectStart(Actor akTarget, Actor akCaster)
objectReference caster = akCaster
if caster.getItemCount(Ore02) >= 1
; favor the more valuable ore first
caster.removeItem(Ore02, 1, TRUE)
caster.addItem(Ore03, 1, FALSE)
advanceSkill("alteration",skillAdvancement)
elseif caster.getItemCount(Ore01) >= 1
; if none of that, look for the base ore to upgrade
caster.removeItem(Ore01, 1, TRUE)
caster.addItem(Ore02, 1, FALSE)
advanceSkill("alteration",skillAdvancement)
else
; caster must have had no valid ore
FailureSFX.play(caster)
failureMSG.show()
endif
endEVENT

Link to comment
Share on other sites

Doesn't mean you cannot adapt the base code into one that converts X amount.

 

Change the condition check to ensure the player has the correct amount (i.e. instead of >= 1 use >= 100 or something like that). Then adjust the amount removed and added accordingly.

 

If you are wanting something that is dynamic and will convert everything that the player might have on hand, that would be possible too. Just store the amount that the player has in a local variable rather than using it as a condition check and use that variable in the remove and add portions.

Link to comment
Share on other sites

Both examples are for use on a magic effect much like the transmute spell script. Please note that neither example has actually been tested for compilation or proper function.

 

For one that requires a specific amount and converts on a one to one basis:

 

 

Scriptname ConvertStuffScript extends ActiveMagicEffect  
{script for spell to convert one item to another at a 1 to 1 ratio}
 
MiscObject Property StartItem  Auto  
MiscObject Property EndItem  Auto  
Int Property ConvertAmount = 1 Auto
{How many of the StartItem are needed to convert}

float property SkillAdvancement = 15.0 auto
{How much to advance the skill? Only works when spell actually converts something}
Sound Property FailureSFX Auto
{Sound to play when spell fails}
message property FailureMSG auto
{Message to display when spell fails}
 
Event OnEffectStart(Actor akTarget, Actor akCaster)
  If akCaster.getItemCount(StartItem) >= ConvertAmount
    akCaster.removeItem(StartItem, ConvertAmount, TRUE)
    akCaster.addItem(EndItem, ConvertAmount, FALSE)
    Game.AdvanceSkill("alteration",SkillAdvancement)
  Else
    ; caster must have had no valid item
    FailureSFX.play(akCaster)
    FailureMSG.show()
  EndIf
EndEvent 

 

 

 

For one that will convert whatever amount the player has on a one to one basis:

 

 

Scriptname ConvertStuffScript extends ActiveMagicEffect  
{script for spell to convert one item to another at a 1 to 1 ratio}
 
MiscObject Property StartItem  Auto  
MiscObject Property EndItem  Auto  

float property SkillAdvancement = 15.0 auto
{How much to advance the skill?  Only works when spell actually converts something}
Sound Property FailureSFX  Auto  
{Sound to play when spell fails}
message property FailureMSG auto
{Message to display when spell fails}
 
Event OnEffectStart(Actor akTarget, Actor akCaster)
  Int ConvertAmount = akCaster.getItemCount(StartItem)
  If ConvertAmount >= 1
    akCaster.removeItem(StartItem, ConvertAmount, TRUE)
    akCaster.addItem(EndItem, ConvertAmount, FALSE)
    Game.AdvanceSkill("alteration",SkillAdvancement)
  Else
    ; caster must have had no valid item
    FailureSFX.play(akCaster)
    FailureMSG.show()
  EndIf
EndEvent 

 

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

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