Jump to content

DOWNLOAD MODS

Are you looking for something shiny for your load order? We have many exclusive mods and resources you won't find anywhere else. Start your search now...

LEARN MODDING

Ready to try your hand at making your own mod creations? Visit the Enclave, the original ES/FO modding school, and learn the tricks of the trade from veteran modders...

JOIN THE ALLIANCE

Membership is free and registering unlocks image galleries, project hosting, live chat, unlimited downloads, & more...

Script Requests


Tonycubed2
 Share

Recommended Posts

Greetings everyone.

 

I'm trying to create a script that will deposit 20 gold coins into a non-respawning container once every hour in game time. The script i have so far compiles correctly yet when I check the container in game the money fails to appear. Here is what I have so far:

 

Scriptname CompanyProfits extends ObjectReference

 

MiscObject Property Gold001 Auto

 

Event OnInit ()

 

          RegisterForUpdateGameTime(1.0)

 

endevent

 

Event OnUpdateGameTime()

 

          Additem(gold001, 20, true)

 

endevent

Link to comment
Share on other sites

Have you added debug statements and checked the log to see if your script is actually being triggered? Or if it is producing any Papyrus run-time errors?

 

Is your Gold001 property set to the base ID of the gold coin?

 

Are you sleeping, fast-traveling, or using Wait to make time pass more quickly before checking the container? If so, the event may not be getting triggered when you expect, since it won't happen while you're doing any of those things.

Link to comment
Share on other sites

  • 3 weeks later...

I've been searching for a few days on how to make a script that will add a set of arrows I've made when I equip a ring I've made. Basically what I want it to do is when I equip the ring it will add a set amount of arrows to my inventory and then unequip the ring afterwards. If the last part isn't possible that's cool I just want it to add the arrows on equip.

Link to comment
Share on other sites

I've been searching for a few days on how to make a script that will add a set of arrows I've made when I equip a ring I've made. Basically what I want it to do is when I equip the ring it will add a set amount of arrows to my inventory and then unequip the ring afterwards. If the last part isn't possible that's cool I just want it to add the arrows on equip.

 

 

Event OnEquipped(Item akActor)

  if akActor == Game.GetPlayer()

    Game.GetPlayer().AddItem(Diamond, 2, true)

    ; Add a two diamonds to the player's inventory, silently

  endIf

endEvent

 

I THINK this is how you'd do that.

Link to comment
Share on other sites

I've been searching for a few days on how to make a script that will add a set of arrows I've made when I equip a ring I've made. Basically what I want it to do is when I equip the ring it will add a set amount of arrows to my inventory and then unequip the ring afterwards. If the last part isn't possible that's cool I just want it to add the arrows on equip.

 

This should be a pretty simple script. Add a script with the OnEquipped event to the ring. The script will need a property that contains the base form ID for the arrows, and you can place the quantity you like into your inventory with the AddItem function in the event. Then just call the UnequipItem function to remove the ring again.

 

Edit: Van was a little ahead of me. First line of the script, though, has a typo. Should be

Event OnEquipped(Actor akActor)
Edited by BrettM
Link to comment
Share on other sites

I've been searching for a few days on how to make a script that will add a set of arrows I've made when I equip a ring I've made. Basically what I want it to do is when I equip the ring it will add a set amount of arrows to my inventory and then unequip the ring afterwards. If the last part isn't possible that's cool I just want it to add the arrows on equip.

Sorry, got thet WAY wrong. This is how it should be:

 

Scriptname "      " extends ObjectReference  

;delete all quotations in script, only used for examples

"ItemType" Property "item"  Auto  

EVENT OnEquipped(Actor akActor)

    akActor.additem("item", 1000, TRUE)

    akActor.equipItem("item", TRUE, TRUE)

          ;this way your arrows are automatically equipped for you

endEVENT

EVENT OnUnequipped(Actor akActor)

    akActor.removeitem("item", akActor.getItemCount("item"), TRUE)

           ;this is what you'd use if you want your arrows unequipped after you take off the ring

endEVENT

 

Edited by VanScythe
Link to comment
Share on other sites

I think OP wants to remove the ring, not the arrows. I would use something like:

Scriptname MagicRingScript extends ObjectReference
{Adds arrows to inventory when equipped.}

; ---------------------------------------------------------------
; Properties
; ---------------------------------------------------------------

Actor Property PlayerREF Auto
{Efficient reference to player}

Ammo Property ArrowREF Auto
{Type of arrow to be added.}

; ---------------------------------------------------------------

Event OnEquipped(Actor akActor)

    if akActor == PlayerREF
        PlayerREF.AddItem(ArrowREF,10,true) ; Add 10 arrows silently
        PlayerREF.UnequipItem(Self)         ; Remove ring
    endif

EndEvent
Link to comment
Share on other sites

 

I think OP wants to remove the ring, not the arrows. I would use something like:

Scriptname MagicRingScript extends ObjectReference
{Adds arrows to inventory when equipped.}

; ---------------------------------------------------------------
; Properties
; ---------------------------------------------------------------

Actor Property PlayerREF Auto
{Efficient reference to player}

Ammo Property ArrowREF Auto
{Type of arrow to be added.}

; ---------------------------------------------------------------

Event OnEquipped(Actor akActor)

    if akActor == PlayerREF
        PlayerREF.AddItem(ArrowREF,10,true) ; Add 10 arrows silently
        PlayerREF.UnequipItem(Self)         ; Remove ring
    endif

EndEvent

ok now i'm just confused on what parts of that do i change to the names of my items. i thought i could change the arrowREF in the properties to match the arrow i'm using but still no luck getting it to do any of it :( if it helps any the items i'm using are "_RagnarArrow" and "_RagnarRing"

Edited by Grimrage
Link to comment
Share on other sites

ok now i'm just confused on what parts of that do i change to the names of my items. i thought i could change the arrowREF in the properties to match the arrow i'm using but still no luck getting it to do any of it :( if it helps any the items i'm using are "_RagnarArrow" and "_RagnarRing"

I've never seen a script use underscores before, that might be your problem. Try changing the names of the items in the object window of the CK so they don't have the underscores. Then try this script (copied from BrettM).

Scriptname MagicRingScript extends ObjectReference
{Adds arrows to inventory when equipped.}

; ---------------------------------------------------------------
; Properties
; ---------------------------------------------------------------

Actor Property RagnarRing Auto
{Efficient reference to player}

Ammo Property RagnarArrow Auto
{Type of arrow to be added.}

; ---------------------------------------------------------------

Event OnEquipped(Actor akActor)

    if akActor == RagnarRing
        akActor.AddItem(RagnarArrow,10,true) ; Add 10 arrows silently
        akActor.UnequipItem(Self)         ; Remove ring
    endif

EndEvent
Edited by VanScythe
Link to comment
Share on other sites

i tried copying that script in and it still doesn't work. i had to change the actor reference back to playerREF because the ring is an armor and that doesn't work as far as i know(unless i'm missing something in the properties?). i removed the underscores from the itemID names on both items but when i log into the game with it and put the ring on nothing happens. i'm completely new to using papyrus so maybe i'm missing something. i wrote a script in oblivion that did this and it wasn't anywhere near as hard as this is for me so maybe its just because i'm a complete novice and over looking something that i'm not aware of. i greatly appreciate all the help i've gotten so far and feel bad still asking for help but this has been bugging me for a few days now lol

Scriptname ArrowRing extends ObjectReference
{Adds arrows to inventory when equipped.}

; ---------------------------------------------------------------
; Properties
; ---------------------------------------------------------------

Actor Property PlayerREF Auto
{Efficient reference to player}

Ammo Property RagnarArrow Auto
{Type of arrow to be added.}

; ---------------------------------------------------------------

Event OnEquipped(Actor akActor)

    if akActor == PlayerREF
        akActor.AddItem(RagnarArrow,100,true) ; Add 100 arrows silently
        akActor.UnequipItem(Self)         ; Remove ring
    endif

EndEvent

thats what i have so far from what brettm and vanscythe have helped me with so far.

Edited by Grimrage
Link to comment
Share on other sites

Use this:

Scriptname MagicRingScript extends ObjectReference
{Adds arrows to inventory when equipped.}

; ---------------------------------------------------------------
; Properties
; ---------------------------------------------------------------

Actor Property RagnarRing Auto
{Efficient reference to Item}
         ;if Actor not working use Armor

Ammo Property RagnarArrow Auto
{Type of arrow to be added.}

; ---------------------------------------------------------------

Event OnEquipped(Actor akActor)
             ;if Actor not working use Armor
    if akActor == Game.GetPlayer()
        akActor.AddItem(RagnarArrow, 10, True) ; Add 10 arrows silently
        akActor.UnequipItem(Self)         ; Remove ring
    endif

EndEvent
Edited by VanScythe
Link to comment
Share on other sites

i tried copying that script in and it still doesn't work. i had to change the actor reference back to playerREF because the ring is an armor and that doesn't work as far as i know(unless i'm missing something in the properties?). i removed the underscores from the itemID names on both items but when i log into the game with it and put the ring on nothing happens. i'm completely new to using papyrus so maybe i'm missing something. i wrote a script in oblivion that did this and it wasn't anywhere near as hard as this is for me so maybe its just because i'm a complete novice and over looking something that i'm not aware of. i greatly appreciate all the help i've gotten so far and feel bad still asking for help but this has been bugging me for a few days now lol

Scriptname ArrowRing extends ObjectReference
{Adds arrows to inventory when equipped.}

; ---------------------------------------------------------------
; Properties
; ---------------------------------------------------------------

Actor Property PlayerREF Auto
{Efficient reference to player}

Ammo Property RagnarArrow Auto
{Type of arrow to be added.}

; ---------------------------------------------------------------

Event OnEquipped(Actor akActor)

    if akActor == PlayerREF
        akActor.AddItem(RagnarArrow,100,true) ; Add 100 arrows silently
        akActor.UnequipItem(Self)         ; Remove ring
    endif

EndEvent

thats what i have so far from what brettm and vanscythe have helped me with so far.

That script should be fine, and you are correct not to change the PlayerREF.

 

When a character -- whether yours or an NPC -- puts on the ring, the system calls the event and passes in the akActor to tell it who equipped the ring. The event is checking to make sure that the arrows are added only if that character is the player. It's a little belt-and-suspenders in this case, since only the player will have the ring, but there are many scripts where you want to be sure that the action is only carried out for the player. Having the ID of the player already defined as a property is much more efficient than continually calling "Game.GetPlayer()". For the other statements, you can use either akActor or PlayerREF, since you have verified that they are equivalent.

 

The name given to the Ammo property doesn't really matter. You can call it LateForDinner if you want. What matters is the item assigned to that name in the property settings after the script is compiled. It needs to be the base form ID for the arrow you want as shown in the Object Window.

 

You add this script to the ring itself. Open the edit window for the ring in the Object Window. Click the Add button next to the scripts window for the ring, select [New Script], and enter the name of the script. After the script is added, right click on the script name and edit the source code to add the rest of the script, then compile and save.

 

Because the script is attached to the ring, a reference to "Self" is a reference to the ring. You don't need any other property to identify the ring by its actual name. If the same script were added to, say, some amulet, the amulet would be "Self" and putting on the amulet would add arrows to your inventory. No script changes would be needed at all to use this script with any kind of item that you can equip.

 

After the script is compiled, select it and hit the Properties button. Click the Auto-Fill All button to automatically fill in the PlayerREF. Then click the RagnarArrow property (or ArrowREF or LateForDinner or whatever you named it), click the Edit Value button, and choose the arrow you want from the drop-down list of arrow types that is shown in the "Pick Object" box that appears.

 

That's all there is to it.

Edited by BrettM
  • Upvote 1
Link to comment
Share on other sites

well i followed your advice step by step and still nothing. from my limitied knowledge of scripting it makes sense that it should work but for whatever reason everytime i put the ring on it just acts as if i put on any normal ring. i guess i'm just not allowed to have this work right for me lol. thanks for all the help though BrettM and VanScythe you were both a great deal of help in figuring that out(even though it still doesn't work for me lol).

Link to comment
Share on other sites

There has to be something we don't know about the situation, then. Something different about the ring or the arrows or some other piece of the puzzle, assuming that you did follow the procedure exactly.

 

I just opened the CK and made a copy of a silver ring that I named ArrowRing. I then followed the steps I outlined to add a script, using the code you posted and presumably used yourself. It compiled without error, and I set the properties as I described, choosing iron arrows from the list. I added the ring to my test cell by dragging it onto a handy table, started the game, and had my character go pick up the ring. Putting on the ring put 100 iron arrows into his inventory. So I'm confident that everything (almost) works correctly with an ordinary ring and arrows.

 

I say "almost" because the script did not unequip the ring afterwards. I made a mistake in coding that statement. It needs to be:

akActor.UnequipItem(Self.GetBaseID())

The reason for that change is that "Self" is an ObjectReference in this case, referring to the ring in the player's inventory. But the UnequipItem function requires the Object Window FormID of the ring, like the AddItem requires the FormID of the arrows. The GetBaseID() function gets the FormID that corresponds to an ObjectReference.

 

After making that change, the ring is now properly removed from my character after the arrows are added.

Link to comment
Share on other sites

ok now i got it to work and i feel kind of stupid. i tried using a different save that had never touched the chest that had the ring and it worked perfectly. thank you so much BrettM for all your help, you've been amazingly patient with me and i really appreciate it :) when i tried to add the section of code you mentioned and tried to compile it i would get an error saying "GetBaseID" was an unknown function or did not exist. not a big deal as long as it adds the arrows i'm happy 

akActor.UnequipItem(Self.GetBaseID())
Edited by Grimrage
Link to comment
Share on other sites

Ah, crud. Seems this is my day for errors. I'm sorry. It should have been "Self.GetBaseObject()" rather than "GetBaseID()". Sometimes I wonder if my brain is entirely connected to my fingers. :)

 

Anyway, I'm glad it's working for you. I get caught out on that problem myself, forgetting to go back to an earlier save after adding or changing a script.

Edited by BrettM
Link to comment
Share on other sites

I was going to mention using a clean save game, (had it all typed out in a response and everything) but it seems to be the number one response from me, and I hate sounding like a broken record about it.

Scripts are saved with your save game, so it is a big issue when you change the script.

Link to comment
Share on other sites

Hey, I was just wondering if there was any way to get the amount of stamina an actor has (in percentage form). I'd like to have a script which increases magicka regeneration depending on how full the stamina bar is. I'm guessing that it'd include use of a few spells that change magicka regeneration depending on, for example, if the actor is above or below half stamina.

 

My end goal is to have stamina regeneration dependent on health percentage, and magicka regeneration dependent on stamina percentage.

Link to comment
Share on other sites

Your search needs to begin with the Actor Script, which has a handy function for GetActorValuePercentage that would seem to be what you're looking for. (The Papyrus reference information on the CK Wiki is invaluable, since it is the only reference we have. I often find solutions by browsing through the list of functions and events for whichever native scripts seem relevant to my problem, or by using the search function when I'm too clueless to figure out which script would cover the situation.)

Link to comment
Share on other sites

I would like to request some scripting help. I need to know how to turn the player character invisible while they are sneaking. I would also like some help with how to apply a mage armor spell to the player when they enter combat, or unsheathe their weapon/spell. Any help would be greatly appreciated, and anyone that does help will be credited for doing so in the mod I am using them for.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...