Jump to content

[LE] Need help getting started with Papyrus


MShoap13

Recommended Posts

I'm in the middle of making myself a minimalist Unarmed mod (affects one-handed Skill, affected by Dual Flurry, and doesn't break the Khajiit bonus or Fists of Steel or the Pugilist item effect are my goals for proof of concept and may end up being the entirety of the mod). I've tinkered with a number of the unarmed mods on the Nexus through the CK and TES5Edit and I think I have all of my records how I'd like them (they're untested though).

Now I need to make a script that adds my "Unarmed" weapon to the player and makes it quest essential so it can't be sold, dropped, or stored. Thorough advice/links appreciated.

Link to comment
Share on other sites

As a start game enabled quest, run once; you need two aliases. One to the player and on for your item to be placed onto the player. These should be in order of player then item in the alias ref list, you want the player filled first.

 

Player is a specific reference to the player. Non-optional, allows reserved.

 

The weapon should be created as the item, level easy, in the player ref. Click the "quest object" check box for this alias.

 

You should have a single stage, with start up stage checked. When the game starts, the player will fill, and then the game will create a quest item of your unarmed object into the player's inventory.

Link to comment
Share on other sites

As a start game enabled quest, run once; you need two aliases. One to the player and on for your item to be placed onto the player. These should be in order of player then item in the alias ref list, you want the player filled first.

 

Player is a specific reference to the player. Non-optional, allows reserved.

 

The weapon should be created as the item, level easy, in the player ref. Click the "quest object" check box for this alias.

 

You should have a single stage, with start up stage checked. When the game starts, the player will fill, and then the game will create a quest item of your unarmed object into the player's inventory.

I think I love you. That was a little jargon-heavy considering how little experience I have but I managed to work my way through it and I believe it's working properly. No scripting necessary.

 

Now I need to figure out how to trick the game into leveling the One Handed skill when I punch things. I have a feeling this is going to require a script that activates through an on-hit spell. Am I at least warm this time?

 

 

Edit: So I've added a script to my quest that should be adding a dummy perk to my character. I've yet to figure out how to debug and verify that said perk is actually getting added (I suppose I could make it do something really obvious like multiply damage times three now that I think of it). The perk chains a spell that adds a magical effect on hit when you have my "Unarmed" weapon equipped.

 

Underneath Magical Effects I think I've found references for directly modifying skill experience values there so if that's correct it's just a matter of tweaking the magnitude and making sure it's targeting the player I believe.

 

Either way, what I have so far isn't currently leveling the One Handed skill.

 

Here's the script:

 

 

Scriptname UnarmedQ_Script   

Perk Property UnarmedLevelsOneHanded Auto

Event OnInit()
	Game.GetPlayer().AddPerk(UnarmedLevelsOneHanded)
	Debug.Notification("Perk successfully added to player.")
EndEvent

 

 

And a link to the entire mod as-is: tinyupload.com

Edited by MShoap13
Link to comment
Share on other sites

I've verified that the Khajiit bonus and Fists of Steel are working with my weapon and I've gotten my Quest to fire it's script which gives the player a dummy perk. I'm not sure how to verify that my Spell is getting applied but I know my Magic Effect (which is barebones now because I changed to a scripted approach) is either not firing it's script or the script's event isn't triggering.

 

Scriptname UnarmedSkillAdvance extends activemagiceffect  

Event OnEffectStart(Actor akTarget, Actor akCaster)
    float CurrentLevel = akCaster.GetAV("OneHanded")
    float Modifier = 10 + CurrentLevel / 10.0
    
    Game.AdvanceSkill("OneHanded", Modifier)
    Debug.Notification("One Handed skill updated.")
EndEvent

 

 

 

I am not getting that debug notification.

I finally got the script to fire (I need conditionals in my perk and the magic effect >_>) and it is properly updating the One Handed skill's experience value EEEEXCEEEEPPPTTT...

It only fires the first time I hit a creature.

 

Adding the "Recover" flag to my Magic Effect allows my script to fire every impact. I think that covers my Proof of Concept goals.

Edited by MShoap13
Link to comment
Share on other sites

TL; DR: How do I detect whether the object I just unequipped was a shield?

 

New problem. I'm now trying to force my Unarmed weapon onto the player when has both hands unarmed. I attached a script to the referencealias tied to Player in my init quest (the one discussed previously in this thread). It fires, and I'm using the event OnObjectUneqquipped. I can just make it run my code everytime the player unequips anything (shout, key ring, hidden quest object, whatever) but I'm trying to restrict it to only run the unarmed check (which works) when a weapon, spell, OR SHIELD are unequipped. My issues are with detecting shields with the given akBaseObject and akReference parameters the event passes.

 

Scriptname UnarmedForceWeapon extends ReferenceAlias  

Function DoForceUnarmed()
    Actor Me = Game.GetPlayer()
    
    if Me.GetEquippedItemType(0) == 0
        Debug.trace("Right Unarmed")
        if Me.GetEquippedItemType(1) == 0
            Debug.Trace("Both Unarmed")
            Me.EquipItem(UnarmedWeapon, false, true)
        endIf
    endIf
endFunction

Event OnObjectUnequipped(Form akBaseObject, ObjectReference akReference)

;; I'd like to get this to only fire when unequipping a hand slot...
    if akBaseObject as Weapon || akBaseObject as Spell ||
        Debug.Trace("This actor just unequipped a weapon, spell, or shield!")
        DoForceUnarmed()
    endIf
endEvent

WEAPON Property UnarmedWeapon  Auto  

WEAPON Property Unarmed  Auto 

 

 

Edited by MShoap13
Link to comment
Share on other sites

TL; DR: How do I detect whether the object I just unequipped was a shield?

 

Two variations, neither tested for compilation or function, both should yield the same results.

;this version of the event requires SKSE for IsShield()
Event OnObjectUnequipped(Form akBaseObject, ObjectReference akReference)
	If akBaseObject as Armor
		If (akBaseObject as Armor).IsShield()
			Debug.Notication("A shield was unequipped")
		EndIf
	EndIf
EndEvent
;this version of the event does not require SKSE
Event OnObjectUnequipped(Form akBaseObject, ObjectReference akReference)
	If akBaseObject as Armor
		If (akBaseObject as Armor).HasKeywordString("ArmorShield")
			Debug.Notification("A shield was unequipped")
		EndIf
	EndIf
EndEvent
Link to comment
Share on other sites

Thank you. I went with the keyword approach to avoid the SKSE requirement (though I'm running SKSE anyways). Also, I made ArmorShield a property instead of piddling with strings; I haven't tested but if my coding experience elsewhere tells me anything it's probably an order of magnitude faster to execute than the string implementation.

Link to comment
Share on other sites

IsharaMeradin, I am always your fan and I like your very good postings.
Please keep in mind both variations you posted require SKSE.

link: http://www.creationkit.com/index.php?title=HasKeywordString_-_Form

A third variation could be like that, SKSE is not required! You posted recently HasKeyword with a keyword property

(3a) no property on top

EVENT OnObjectUnequipped(Form akBaseObject, ObjectReference akReference)
IF (akBaseObject as Armor)
ELSE
    RETURN    ; - STOP -    item is no kind of armor
ENDIF
;---------------------
    keyword kw = Game.GetForm(0x000965B2) as Keyword    ; ArmorShield [KYWD:000965B2]

IF (akBaseObject as Armor).HasKeyword(kw)
ELSE
    RETURN    ; - STOP -    armor is not a shield
ENDIF
;---------------------
    Debug.Notification("A shield was unequipped")
;;    Debug.Trace(self+" OnObjectUnequipped() - baseObj = " +akBaseObject+", itemRef = " +akReference)

    ; place here any shield specific code
ENDEVENT

(3b) assumed we have a valid keyword property declared

  Keyword PROPERTY AmorShield auto        ; ArmorShield [KYWD:000965B2]

EVENT OnObjectUnequipped(Form akBaseObject, ObjectReference akReference)
IF (akBaseObject as Armor)
ELSE
    RETURN    ; - STOP -    item is no kind of armor
ENDIF
;---------------------
IF (akBaseObject as Armor).HasKeyword(AmorShield)
ELSE
    RETURN    ; - STOP -    armor is not a shield
ENDIF
;---------------------
    Debug.Notification("A shield was unequipped")
;;    Debug.Trace(self+" OnObjectUnequipped() - baseObj = " +akBaseObject+", itemRef = " +akReference)

    ; place here any shield specific code
ENDEVENT

I wish you the best..

Link to comment
Share on other sites

  • Recently Browsing   0 members

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