Jump to content

Object script issue


Nephenee13

Recommended Posts

Alright, I'm adding a leveled item to the game, and I want it to update as the player advances in level. I figured the simplest way to do this would be to put a script on each version, so that when the player equips it, it checks the player's level. If the player has advanced to the next level tier, it will remove the current one and re-add the leveled list, so the player gets the appropriate one for their level. Additionally, whether the player received the Light or Heavy version depended on their level in those skills, and I want them to get the appropriate version if they've decided to pursue the other skill. Anyway, my code isn't working.

 

 

Scriptname NephRoseKvatchHeavy01Script



begin OnEquip player

    if player.getlevel > 4

        player.removeitem NephRoseKvatchHeavy01 1

            if player.getav LightArmor > player.getav HeavyArmor

                player.EquipItem NephRoseofKvatchLightList 1

            else

                player.EquipItem NephRoseofKvatchHeavyList 1

            endif

    endif

end


However...it doesn't work. It doesn't even remove the item properly. It doesn't seem to do anything.
Link to comment
Share on other sites

Ok, it seems I can't use an OnEquip block, so here's my shot at a GameMode block

 

 

Scriptname NephRoseKvatchHeavy01Script

Short DoOnce

begin GameMode
    if DoOnce == 0
        if player.GetLevel &--#62; 4

            Player.RemoveItem NephRoseKvatchHeavy01 1
            if Player.GetAV LightArmor &--#62; Player.GetAV HeavyArmor
                Player.AddItem NephRoseofKvatchLightList 1
            else
                Player.AddItem NephRoseofKvatchHeavyList 1
            endif
        endif
        Set DoOnce to 1
    endif
end

 

Still not working.

Link to comment
Share on other sites

Let me get this straight. You're trying to remove an item via a script that is attached to that item?

 

Again, my experience is Morrowind, so Oblivion may work differently, but in Morrowind, you need the item to be available to run the script on. Remove the item, you remove the script. Again, in Morrowind, this would crash the game as it is trying to access a script that is no longer there.

 

You may need to start a "quest" which would run a script for the actual swap. Once the swap is done, you simply stop the quest.

Edited by KenJackson
Link to comment
Share on other sites

Yes, KenJackson is right on this. While it certainly won't 'crash' Oblivion (it actually could, as the game is very touchy and always unpredictable even), removing the item the script is running on will terminate the script at the point of the removal.

 

So you at least have to reorder things a little for this to ever have a chance to work:

 

Scriptname NephRoseKvatchHeavy01Script



begin OnEquip player

    if player.getlevel > 4

            if player.getav LightArmor > player.getav HeavyArmor

                player.AddItem NephRoseofKvatchLightList 1
                player.EquipItem NephRoseofKvatchLightList

            else

                player.AddItem NephRoseofKvatchHeavyList 1
                player.EquipItem NephRoseofKvatchHeavyList

            endif

    endif
 
    removeMe ;should do here. if not, use your line instead. could be requiring OBSE in any case.

end

I'm not exactly sure you can 'equip' a 'list' though.

Dusk/Dawnfang wasn't scripted with every instance of its advancement hardcoded into the script for no reason.

Link to comment
Share on other sites

Uah! Man, it's making a total mess of my code, if I try to edit it now! By all means, the "removeMe" line must not be outside of the "if" block! It will remove itself every time you equip it!

 

Ahem. And coming to think of it, it will do so still even if it is placed correctly. You need to add some "do once" condition into this for sure, as the player's level will remain > 4 for quite a while and as such the script will run every time you equip this item again and again!

Link to comment
Share on other sites

  • 1 month later...

.esp - How it http://www.sendspace.com/file/z2vgju


Two scripts on the objects can not work simultaneously.


This is easier to do as a quest script

 

Scriptname NephRoseKvatchHeavy01Script

Short DoOnce

Short DoOnce2


short ic

;MUST BE QUEST SCRIPTTTTT
;You can add control variables for the quest script into clothing scripts
;Exmp. - Begin OnEquip
; NameQuest.DoOnce to 0 ;
; to start controll this cloth
begin GameMode


if DoOnce == 0 ; with Begin OnEquip controll must be not 0

if player.GetLevel >0 ;>4, for test >0

if Player.GetAV HeavyArmor< Player.GetAV LightArmor
set ic to Player.getitemcount JailShirt ;NephRoseKvatchHeavy01 1;+it must be CALLfunc of course
if ic>0 ;+
Player.removeitem JailShirt ic ;+NephRoseKvatchHeavy01 1
endif ;+
Player.AddItem JailShirt 1 ;NephRoseKvatchHeavy01 1
Set DoOnce to 1 ;!!!!!!!!!! added


else
set ic to Player.getitemcount JailPants ;NephRoseofKvatchLightList 1
if ic>0
Player.removeitem JailPants ic ;NephRoseofKvatchLightList 1
endif
Player.AddItem JailPants 1 ;NephRoseofKvatchLightList 1
Set DoOnce to 1 ;!!!!!!!!!! added
endif
endif
endif



;========================
; if DoOnce2 == 0 ; with Begin OnEquip controll must be not 0
;
; if player.GetLevel >0 ;>4, for test >0
;
; if Player.GetAV HeavyArmor> Player.GetAV LightArmor
; set ic to Player.getitemcount JailShirt2 ;NephRoseKvatchHeavy02 1;+it must be CALLfunc of course
; if ic>0 ;+
; Player.removeitem JailShirt2 ic ;+NephRoseKvatchHeavy02 1
; endif ;+
; Player.AddItem JailShirt 1 ;NephRoseKvatchHeavy02 1
; Set DoOnce to 1 ;!!!!!!!!!! added
;
;.........................etc

end

Edited by DKZZ2
Link to comment
Share on other sites

if you use OBSE is easier to get rid of the oldrosequirass and add the new (but still no equip)

example without Quest

--------------------------------------------------------------

 

  Reveal hidden contents

 


=============================================================

example with quest

----------------------------

 

  Reveal hidden contents

 

Edited by kastano
Link to comment
Share on other sites

  On 5/11/2013 at 5:04 PM, kastano said:

if you use OBSE is easier to get rid of the oldrosequirass and add the new (but still no equip)

example without Quest

--------------------------------------------------------------

 

  Reveal hidden contents

 

 

=============================================================

example with quest

----------------------------

 

  Reveal hidden contents

 

i found sth on nexus ,i think it works(for equip)

 

Scriptname NephRoseKvatchScript

 

ref pinvobj

ref pcont

ref freshRose

short neednewdress

short invpos

 

Begin gamemode

 

if neednewdress == 1

set neednewdress to 0

set freshRose to player.GetEquippedObject 2

player.removeitem freshRose 1

 

if player.getav LightArmor < player.getav HeavyArmor

 

set freshRose to NephRoseofKvatchHeavyList

else

set freshRose to NephRoseofKvatchLightList

endif

 

player.additem freshRose 1

set pCont to Player;Sets the inventory ref to the player

set InvPos to pCont.GetNumItems;sets the position of the checker to the last item spot in the inventory

 

if InvPos

set InvPos to (InvPos - 1)

set pInvObj to (pCont.GetInventoryObject InvPos)

 

Player.EquipItem pinvobj

endif

 

endif

 

end

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

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