Jump to content

[LE] Why is the script not working?


Masterofnet

Recommended Posts

  On 1/16/2017 at 12:56 AM, cdcooley said:

 

Your code is also not putting back the actual items taken from the player for the unpoisoned ones. In 99.9% of the cases that's fine, but if you're going for absolute safety you need return the items that were dropped UnpoisonedStackRef instead of Poisoned as the first parameter. (And the Disable call has to be done on a separate line.)

 

Agreed The exact same weapons need to be put back, but when I put the stack back in inventory and dropped the weapons one at a time they all disappeared until only one was left because they all had the same object reference. The new version solved both of these issues.

 

For some reason most of my post was just deleted. So here is the short version.

 

Check out this new script. It uses remove item and a chest.

 

lofgren - Yes and it works well.

 

A couple of updates. The weapon issue with drop has nothing to do with persistence. I was also able to use Silver Swords so it is more that just the script.

 

As far as quest items, which are all persistent while the quest is running, it works fine with all I have attempted other than the Ebony Blade.

 

However, Drop does not work with the Ebony Blade so I have updated the script and it works fine. Just the Weapon Ebony Blade also works fine, but the quest object does not.

 

If anyone knows about weapons other than the Ebony or Bloodskal Blade that do not work with weapon racks please let me know.

Scriptname PlayerAliasPotion extends ReferenceAlias  

Potion Property ThePotion Auto
ObjectReference UnpoisonedStackRef
ObjectReference PWeaponRef 
ObjectReference PotionRef 
ObjectReference Property chest  Auto  
ObjectReference Property DA08EbonyBladeREF Auto 
ReferenceAlias Property PotionAlias Auto
ReferenceAlias Property PoisonedWeaponRef Auto
Int Distance
Int  UnpoisonedCount
Weapon Poisoned
Actor PlayerRef

Event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer)
AddInventoryEventFilter(ThePotion) 
PlayerRef = Self.GetReference() As Actor
PotionRef = PotionAlias.GetReference()

If PlayerRef.GetItemCount(ThePotion)
Else 
Distance = PlayerRef.GetDistance(PotionRef) as Int
  If akDestContainer 
    akDestContainer.RemoveItem(PotionRef, 1 , False, PlayerRef )
    Debug.Notification("You can not drop this!")
  Else  
    If Distance <  4000
      PlayerRef.AddItem(PotionRef,1,True)
      Debug.Notification("You can not drop this!")
    Else
      WeaponPoisoned()
    EndIf
  EndIf
EndIf
EndEvent  

Function WeaponPoisoned()

Poisoned = (PlayerRef.GetEquippedWeapon())

If Poisoned == DA08EbonyBladeREF.GetBaseObject() As Weapon
PoisonedWeaponRef.ForceRefTo(DA08EbonyBladeREF)
Else
UnpoisonedCount = PlayerRef.GetItemCount(Poisoned) - 1

PlayerRef.RemoveItem(Poisoned, 1, True, Chest)
PoisonedWeaponRef.ForceRefTo(Chest.DropObject(Poisoned))

  If UnpoisonedCount > 0
    PlayerRef.RemoveItem(Poisoned, UnpoisonedCount, True, Chest)
  EndIf

PWeaponRef = PoisonedWeaponRef.GetReference()

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

  If UnpoisonedCount > 0
    Chest.RemoveItem(Poisoned, UnpoisonedCount, True, PlayerRef)
  EndIf

EndIf
EndFunction
Edited by Masterofnet
Link to comment
Share on other sites

I was reading up on this and there may some other weapons that can have a problem with drop based on weapon rack reports. So I came up with this and believe it or not it works perfectly.

When testing this script I made a very interesting discovery. I can not get a weapon to not be a objectreference when it is dropped from the player.

 

The purpose of this script is to get.

1. When the potion is applied to a Weapon

2. When the target is poisoned and who they are.

3. The exact weapon and type of weapon that was poisoned.

4. If the potion was lost - Not used on a target and not able to be reapplied. For example the potion was put on a bow and the shot missed.

 

Here is the final version of the script.

 

This script goes on a playerAlias

 

 

  Reveal hidden contents

 

 

This Script goes on the Potion's Magic Effect

 

 

  Reveal hidden contents

 

 

This Script goes on the Poisoned Weapons Alias

 

 

 

Edited by Masterofnet
Link to comment
Share on other sites

what does it mean: "B2C" infront of your script names?

Nothing I actually use something else but I want to keep it secret for now. It would be the 3 letters I identify my mod with.

 

1 "B2CquWildMan" I guess, you forgot the quest script

That quest script is not the quest script for this quest. It is a quest that I use to manage all my other quests. VM quest variables and other things. Like reducing the properties I have on a script. By simply adding that Quest Script I have access to all kinds of things so I can significantly modify a large # of scripts without having to refill any properties.

 

2) What formID have the chests, what is the container object?

I have a cell I made that I keep the things for my quests in. That is where the chests are. They are empty small draugr chests.

 

3) I found script code issue!

Yes, I made a couple of small changes to the scripts today and found that. It is just = now.

 

4) Scriptname B2CameKrosisPotion extends activemagiceffect

All it does is make an invulnerable NPC vulnerable for a set amount of time. It is the effect for the Potion.

 

5) You wrote: "I can not get a weapon to not be a objectreference when it is dropped from the player."

No matter how I add an item to the players inventory, when I drop it and use OnItemRemoved to get the form or object reference, the item always has an object reference.

Edited by Masterofnet
Link to comment
Share on other sites

A couple of things.

 

Remove item will always remove the equipped weapon first. That is why you must remove it and then the other weapons.

 

Also the potion being < 4000) from the player is a way of determining if it has been dropped or used on a weapon. If there is no new container and the distance is > 4000 the potion has been applied to a weapon.

 

This is done because if you attempt to poison a weapon and decide not to, or you attempt to use a potion and do not have a weapon equipped, the on item removed event will fire but the potion will still be in the players inventory.

IF (selfRef.GetItemCount(akBaseItem) > 0)
    RETURN    ; - STOP - /1    player has still left one potion
ENDIF

Some interesting work as usual. I will need time to go over it all.

 

 

 

Redragon , Here is my update of the Player Alias Script. I don't change the names to much because it effects auto filling of the properties.

 

This is in my option a huge improvement. Thanks

 

 

The first script is another script needed on the player alias.

 

 

  Reveal hidden contents

 

 

Player Alias

 

 

  Reveal hidden contents

 

 

The Potion Alias

 

 

  Reveal hidden contents

 

 

The Weapon Alias

 

 

  Reveal hidden contents

 

 

If you had two scripts on one alias and both had add and remove item events. Would an inventory event filter you put on one script also effect the events on the other script?

 

I have read some conflicting information about this. However the answer is Yes, It will effect other on item add or remove events on that reference alias.

Edited by Masterofnet
Link to comment
Share on other sites

  • Recently Browsing   0 members

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