Jump to content

Need some help with script


Sithrazer

Recommended Posts

===

EDIT:

I've got a hack-y workaround that sorta works, simply removing the item to be repaired and giving the player a new one, but I'd still like to hear if anyone knows why my script below doesn't work.

===

EDIT 2:

The setHealth function does -not- do what I thought it did. I think I've got this figured out now, though. It might not be exactly what I was hoping to accomplish, but should be a lot better than the workaround in my first edit.

===

 

Started playing FO3 again and revisited my repair anvil mod, trying to work out a custom script beyond just calling player.srm. I'm not sure if the functions I'm using just don't do what I think they do or if I'm overlooking something stupid.

 

Anyway, here's the code I have.

scn srRepairAnvilScript

ref rEqArmor
ref rEqWeapon
int iTemp

begin onActivate
    if player.getItemCount SpareParts == 0
        showmessage srNoScrap
    else
        set rEqArmor to player.getEquippedObject 2
        set rEqWeapon to player.getEquippedObject 5
        set iTemp to rEqArmor.getHealth
        player.addItem caps001 iTemp ; debug attempt, gives number of caps equal to max health of [armor]
        rEqArmor.setHealth iTemp
        set iTemp to rEqWeapon.getHealth
        player.addItem caps001 iTemp ; debug attempt, gives number of caps equal to max health of [weapon]
        rEqWeapon.setHealth iTemp
        player.removeItem SpareParts 1
    endif
end

It's supposed to get the max possible health for the current equipped armor and weapon and set it to those values, and take scrap metal from the player in return. Currently all it does is take scrap metal away, and judging from my debug attempts it's not getting the max possible health for the equipped armor/weapon. It also won't set the health of the equipped items even using hard coded values.

 

I have FOSE installed, it's compiling fine in GECK, and it runs in game, but the get/set health functions just don't seem to be doing anything and I don't understand why. Any help anyone can offer would be greatly appreciated.

Edited by Sithrazer
Link to comment
Share on other sites

Speaking strictly to the code example you have posted and not getting into exactly what you are trying to accomplish overall.

When you say: set iTemp to rEqArmor.getHealth

The correct syntax is really: set iTemp to GetHealth rEqArmor

Same with the weapon line. It should be: set iTemp to getHealth rEqWeapon

I know examples show it the way you have it in your script, but I believe that is only if you are calling it on a specific Reference in the game and not a Reference Variable in a script.

Link to comment
Share on other sites

Huh. I don't think I've seen that syntax anywhere, but I haven't gone out of my way to read vanilla scripts unless I'm looking to alter one. I'll have to give that a try.

 

Thanks!

 

Edit: Worked as advertised, thanks so much!

Edited by Sithrazer
Link to comment
Share on other sites

  • Recently Browsing   0 members

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