Jump to content

Beginner moder noob question on adding functionality to an item


ReelBigFan

Recommended Posts

I've recently been dabbling with creating my own mods for Oblivion with the CSE, starting with real simple things like adding objects to the game words and fixing minor conflicts with my installed mods. I've done some coding (mostly Python) and built some decently complex stuff on my own so I figured I'd try my hand at some scripting and create a more functional mod. Unfortunately I'm running into a major road block with the mod I'm looking to create.

 

Before I explain the problem, the basic idea behind the mod is to add an item that when activated from the inventory will take the players equipped weapon, make a copy of it, add some amount to the base damage of the copy, remove some amount of gold from the player, remove and replace the original weapon with the copy. I know that this will likely cause some issues with quest items if I can get this to even work, but thats all fine for now. I'm not worried about making the mod perfectly functional, just functional enough for now lol.

 

At this point I can get this intended item to spawn in my inventory with a simple quest script, but I'm at a loss how to get my object script to work when I click the item in my menu. I know from other mods that there is definitely a way to add functionality to misc items, but even digging through mods I know do this and using google I can't seem to find anything that points me in the right direction. Any advice on how this is done would be greatly appreciated!

 

Here is my object script incase this helps

 

scriptName MithasHammerTest
Ref equippedWeapon
Ref upgradedWeapon
int currentDamage
int upgradeDamage
Begin onActivate
let equippedWeapon := PlayerRef.GetEquippedObject 16
set equippedWeapon to CloneForm upgradedWeapon
set currentDamage to upgradedWeapon.GetAttackDamage
upgradedWeapon.SetAttackDamage currentDamage+1
player.UnequipItemSilent equippedWeapon
player.removeitem equippedWeapon 1
player.additem upgradedWeapon 1
player.EquipItemSilent upgradedWeapon
Message "Test:Activated", 5
end
Link to comment
Share on other sites

I appreciate the advice! I figured out why onEquip wasn't working for me (embarrassing to say I had spent a whole day looking for solutions when all it was just some mixed up some variables that broke the whole code lol). I had not considered how making so many clones would be bloating the save though so thanks for the heads up on that RomanR! Now I've got most of the mod working in a way I'm pretty happy with. There's just two things I'm having trouble with figuring out;

 

1st is figuring out how to check that the player actually has a weapon equipped and isn't bare-fisted. Right now the misc item i have set will just be duplicated when you try to upgrade without a weapon in hand.

 

2nd is getting the isQuesttem function to work. For whatever reason I cannot get it to properly see if a weapon is a quest item or not to reject for upgrading.

 

I appreciate any additional advice on how I might solve these two issues. If I can get these solved I think I'll have everything pretty solid.

Link to comment
Share on other sites

In this case the GetEquippedObject function will return zero. So you can test against it. This function returns base object too, so for testing both you can use these conditions for example:

let equippedWeapon:= PlayerRef.GetEquippedObject 16
if equippedWeapon != 0
   if IsQuestObject equippedWeapon == 0
      .....
   endif
endif
Link to comment
Share on other sites

Actually figured it all out last night just a little after posting my comment. Turns out it was another simple error caused by my own carelessness. I needed to restructure my if/elseif order to make the checks. Its very inelegant right now, and I'll probably try to tweak it, but as of now I can say I have a fully functional mod!

 

Working on a second version now to expand on it and integrate it into the game a little better. Trying to have the full version done in a few days and I'll share that and the simple versions together, hopefully can get some feedback then. Again, thanks for all the suggestions!

Link to comment
Share on other sites

  • Recently Browsing   0 members

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