Jump to content

[LE] Why is the script not working?


Masterofnet

Recommended Posts

The CK wiki was completely wrong in regards to DropObject. It claimed you can not get the object reference of the item from it. That is totally false.

PoisonDagger.ForceRefTo(PlayerRef.DropObject(PlayerRef.GetEquippedWeapon(), 1))
WeaponRef = PoisonDagger.GetReference()
PlayerRef.AddItem(WeaponRef)
Utility.Wait(1)
PlayerRef.EquipItem(WeaponRef.GetBaseObject())

 

Edited by Masterofnet
Link to comment
Share on other sites

The wiki says you cannot get the object reference of persistent objects from dropObject(). Are you saying that is false? That would be an important discovery. The whole reason that the Unofficial Patch uses a workaround for weapon racks is exactly this kind of situation. You can test it by trying it with the Bloodskal Blade or the Ebony Blade.

 

This note might also be relevant to your interests:

 

 

If akObject is equipped, the game will first search for unequipped items in inventory to drop. Only when there are no more unequipped items will it drop the equipped items.

 

 

So if the player has a glass dagger in their inventory that is untempered and unenchanted they are trying to poison the +6 glass dagger with a 35 point fire enchantment in their hand, they'll end up poisoning the weaker one instead.

Edited by lofgren
Link to comment
Share on other sites

Ya, This was a colossal failure. I am just getting back to the post. All I can get is the potion has been applied to a weapon and that is where I am leaving it. As far as what it says on the Wiki. I don't know, I was able to get the object reference from the item I dropped and it was a quest item so should be persistent. However I am not going to be doing any further testing as I have wasted enough time on this.

 

You would have to do it like this

ObjectReference Dagger = PlayerRef.DropObject(PlayerRef.GetEquippedWeapon(), 1)

Does this wiki quote actually mean if someone put an object reference where the base object should be the script will not work??

 

"If akObject is an ObjectReference, even one which was just received by i.e. OnItemAdded(), DropObject() will fail with an error in the script log: "cannot be dropped, it has no 3d." You can instead use itemRef.MoveTo(containerRef) to pull a specific reference out of inventory, but note that if itemRef is a weapon and containerRef is an actor (such as the player), the actor may be wounded unless you give MoveTo() a sufficient offset."

Edited by Masterofnet
Link to comment
Share on other sites

I think its about the note above the one you quoted, i.e. "If akObject is a permanently-persistent reference, DropObject will not return a Form ID value for the ObjectReference, even though it still physically drops the object from the inventory. If you need to run further ObjectReference Functions onto the dropped object, you will need to refer to that object's reference ID directly."

 

Meaning that with:

ObjectReference Dagger = PlayerRef.DropObject(PlayerRef.GetEquippedWeapon(), 1)

The equipped weapon should be dropped but the reference passed into the Dagger ref would be invalid and anything below it using Dagger shouldn't work properly, asuming the equiped weapon is permanently-persistent (what does that include exactly? Being in an alias and being referenced in a property in ck?), at least that's i what understand from what's on the wiki.

Link to comment
Share on other sites

It works just fine and the weapon should be persistent.

 

Has no one ever tested this with a persistent item? It would be very easy to test.

 

I was thinking about how this idea might actually work. When you poison the weapon and drop the equipped weapon you could do while.

 

While the number of weapons is greater than 1 drop them, count them and disable them. Then when you get to the last weapon drop it and force it to a ref alias, put it back on the player and equip it. Then put the other weapons back in the players inventory.

 

It would not be practical to do every time you poison a weapon but for a couple of quests it might work.

Link to comment
Share on other sites

lofgren wrote here:

The wiki says you cannot get the object reference of persistent objects from dropObject(). Are you saying that is false? That would be an important discovery.

The whole reason that the Unofficial Patch uses a workaround for weapon racks is exactly this kind of situation. You can test it by trying it with the Bloodskal Blade or the Ebony Blade.

 

Bethesda wiki contains the following page to explain weaponrack scripts.
http://www.creationkit.com/index.php?title=Dissecting_the_Scripts_for_Weapon_Racks

The first one ever who provided a solution for the weaponrack bug was this mod.
"Weapon Display FIX" by LukeH http://www.nexusmods.com/skyrim/mods/27374/?

The issue with DropObject() and weaponracks has been described by Taleden in 2014.
http://www.creationkit.com/index.php?title=ObjectReference_Broken_Pointer_Bug

What is the culprit with method DropObject?
If a shield or weapon has attached a script (special kind of persistence),
the return value of itemRef goes crazy by method DropObject().

 

the ReferenceAlias script could look as follow:

 

Scriptname WeaponRackPlayerAlias extends ReferenceAlias

  ObjectReference lastDrop        ; see also "WeaponRackActivateSCRIPT.psc"

;-----------------------------------------
 ObjectReference FUNCTION myF_GetItemRef()    ; only called by "WeaponRackDbg.psc" as a single task
;-----------------------------------------
int i = 10
WHILE (!lastDrop) && (i > 0)
    Utility.Wait(0.03)                            ; 0.03 * 10 = 0.30 sec
    i = i - 1
ENDWHILE

    objectReference oRef = lastDrop                ; move RefID to return value
    lastDrop = None                                ; nope out this objRef
    RETURN oRef                                    ; give back the valid RefID or <None>, if while loop runs out of time
ENDFUNCTION

;==============================
state ItemDrop    ; set by "WeaponRackActivateSCRIPT.psc" if player drops an item for weapon rack
;=============
EVENT OnItemRemoved(Form akBaseItem, Int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer)
IF ( akDestContainer )
ELSE
    gotoState("")                    ; ### STATE ###
    lastDrop = akItemReference                    ; store the dropped ItemRef for the function above
ENDIF
;#########
;;    Debug.Trace("WRPA: OnItemRemoved() - called for " +akBaseItem+ " with itemRef " +akItemReference)
;#########
ENDEVENT
;=======
endState

 

 


To get a valid Reference, we have to use a quest with a playeralias.
The playeralias has attached a ReferenceAlias script which is using event OnItemRemoved().

Edited by ReDragon2013
Link to comment
Share on other sites

The item I was working on had no script attached. It was as far as I know persistent, and I was able to get the objectreference.

 

Redragon - Do you have any thoughts on a script to get the exact weapon that a person poisoned, force it to ref and then re - equip it.

This is what I have so far.

Int Count
Int NoPoison

ReferenceAlias Property PoisonedWeapon Auto

Event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer)
AddInventoryEventFilter(Potion) ; The exact posoin you are using on the weapon.

Count += 1

Utility.Wait(0.7)

If Count = 2
Weapon Poisoned = (PlayerRef.GetEquippedWeapon())

Int WeaponCount = PlayerRef.GetItemCount(Poisoned)

While WeaponCount > 1
NoPoison += 1
(PlayerRef.DropObject(Poisoned)).Disable()
EndWhile

PoisonedWeapon.ForceRefTo(PlayerRef.DropObject(Poisoned))
ObjectReference PWeaponRef = PoisonedWeapon.GetReference()

PlayerRef.AddItem(PWeaponRef, 1, True)
Utility.Wait(1)
PlayerRef.EquipItem(PWeaponRef.GetBaseObject(), False, True)

PlayerRef.AddItem(Poisoned,NoPoison,True) 
EndIf
endEvent

There is more to it. You have to use an if count == 1 to make sure the potion was not dropped. If so you must put it back in the players inventory.

 

Also with this information about Persistent Weapons with scripts you will need to detect that. You might be able to force them to Alias without dropping them. Most likely there would only be a limited # in the game.

Edited by Masterofnet
Link to comment
Share on other sites

  • Recently Browsing   0 members

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