Jump to content

[LE] Script issue with game's 'Favorite' and 'OnEquipped' not firing.


maxarturo

Recommended Posts

Hi to all.


I've run into an issue that when adding a weapon or armor to 'Favorite' it won't fire the 'OnEquipped' event.


Explanation of the issue:

I've 1 greatsword, 1 sword and 1 shield that are added to 'Favorite' and they all have an 'OnEquipped' script that adds/removes a Perk.

- I first press "Q" to bring up the 'favorite menu' and i equip the sword and the shield. Here everything works fine.

- Then i press again "Q" to equip the 'Greatsword'. Here also everything works fine.


NOW THE ISSUE:

- When i press once more "Q" and equip the sword the shield gets automatically equipped, and the 'OnEquipped' event does not fire on the shield.

* When equipping a weapon or armor throught "Q" the 'OnEquipped' event will only fire if the player clicks on it (or press 'E').

If it's equipped automatically it will never fire !.


* The script is as simple as it can be, 'OnEquipped' add 'Perk'. Nothing else.


* This time i really need some help because i've been working too much this last month and i'm trying to find a work around since yesterday, but... my brain is completely empty, like a dead's brain scan... flat line... i'm sitting for 2 days in front of the PC just looking at the monitor with no brain activity and doing absolutely nothing...


If someone has a workaround for this i would be most grateful !!.

Link to comment
Share on other sites

Hey, since this is only a problem for the player, instead you could make a new quest with a reference alias that points at the player. Use specific reference, cell Any, player. Then attach a reference alias script and use the OnObjectEquipped(Form akBaseObject, ObjectReference akReference) and OnObjectUnEquipped(Form akBaseObject, ObjectReference akReference) events to add/remove the perks. Use if akBaseObject == Greatsword, add/remove perk.

Link to comment
Share on other sites

Thanks dylbill for replying.

But i have too many equipments that adds perks (equipment's ability), and from the beginning of the construction of this idea i decided to not use "Dummy Quests" (that will always be running on the background).


* Plus i'm not sure that this will resolve the 'automatically equipped' issue.


* One of my priorities is to make this mod as light as possible, there is already too much going on...

And at this point the whole mod is as stable as it can possible be !, 37 cells which half of them are massive and NOT a single CTD whatsoever.


Nevertheless, thank you !.

Edited by maxarturo
Link to comment
Share on other sites

I want this part to be empty, meaning that the Player if he/she wants can make the equipments stronger by enchanting and tempering them.

That's why i didn't used my scripts on an enchantment.


Thank you again !.

Edited by maxarturo
Link to comment
Share on other sites

Ah, no problem. I would still maybe try and use a player alias, and if you have a lot of equipment you can use formlists and indexing to easily find the correct perks. Example:

 

 

 

Actor Property PlayerRef Auto
Formlist Property MyEquipment Auto 
Formlist Property MyPerks Auto 
 
Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference)
    If MyEquipment.HasForm(akBaseObject) 
        Int Index = MyEquipment.Find(akBaseObject)
        PlayerRef.AddPerk(MyPerks.GetAt(Index) as perk) 
    Endif 
EndEvent
 
Event OnObjectUnEquipped(Form akBaseObject, ObjectReference akReference)
    If MyEquipment.HasForm(akBaseObject) 
        Int Index = MyEquipment.Find(akBaseObject)
        PlayerRef.RemovePerk(MyPerks.GetAt(Index) as perk) 
    Endif 
EndEvent

 

 

 

Just make sure your Equipment and Perks are in the same positions in the lists.

Edited by dylbill
Link to comment
Share on other sites

So, I gather all the energy i could to concentrate and started experimenting on solutions.


The issue that i found is that the 'Automatic Equip' does not get register as "Object Equipped", so i think this won't either work in a 'Dummy Quest'.


Here is my last experiment (it's just a draft experiment):



Perk Property MyPerk auto

Armor Property Xshield Auto

Weapon Property Xweapon Auto


Event OnInit()
RegisterForMenu("FavoritesMenu")
EndEvent


Event OnEquipped(Actor akActor)
If ( akActor == Game.GetPlayer())
akActor.AddPerk(MyPerk)
EndIf
EndEvent


Event OnUnequipped(Actor akActor)
akActor.RemovePerk(MyPerk)
EndEvent


Event OnMenuClose(String MenuName)
Debug.Notification("MENU CLOSE")
If MenuName == "FavoritesMenu"
If (Game.GetPlayer().GetEquippedWeapon() == Xweapon)
Game.GetPlayer().AddPerk(MyPerk)
ElseIf (Game.GetPlayer().GetEquippedShield() == Xshield)
Game.GetPlayer().AddPerk(MyPerk)
endif
EndIf
EndEvent



I think i just hit a wall once again...

Edited by maxarturo
Link to comment
Share on other sites

I think that should work, although it does require SKSE. I've actually been thinking about how to implement script conditions in my own scripts by using while loops. Here's something I thought of that might work:

 

 

 

Scriptname TestWeaponEquipStates extends ObjectReference 
 
Perk Property MyPerk auto
Actor Property PlayerRef Auto
 
Event OnInit()
    GoToState("UnEquipped")
EndEvent
 
State UnEquipped
    Event OnBeginState()
        While (PlayerRef.IsEquipped(Self.GetBaseObject())) && (PlayerRef.HasPerk(MyPerk) == false)
            PlayerRef.AddPerk(MyPerk)
            GoToState("Equipped")
        EndWhile 
    EndEvent 
EndState
 
State Equipped
    Event OnBeginState()
        While (PlayerRef.IsEquipped(Self.GetBaseObject()) == false) && (PlayerRef.HasPerk(MyPerk))
            PlayerRef.RemovePerk(MyPerk)
            GoToState("UnEquipped")
        EndWhile 
    EndEvent 
EndState
 

 

 

Edited by dylbill
Link to comment
Share on other sites

The last draft script i posted also requires SKSE.

Unfortunately the 'IsEqipped' fires only for right handed equipped items and never for left handed and the shield can only be equipped on the left.


* The 'IsEquipped' is been tested to death while creating the main "Weapons Abilities" scripts.


I'll give a try one more time tomorrow after i get a good 12h sleep.


Thank you very much for your time dylbill !.

Edited by maxarturo
Link to comment
Share on other sites

No problem, I just tested the last script I posted cause I was curious, and no joy. The OnMenuClose is probably the way to go. Good luck!

 

EDIT: If you're using SKSE, you can try using the GetWornForm function to see if a weapon or shield is equipped.

Edited by dylbill
Link to comment
Share on other sites

  • Recently Browsing   0 members

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