spacefiddle Posted January 10, 2017 Share Posted January 10, 2017 Hallo! I am trying to avoid altering vanilla objects, and make something potentially compatible with mod-added weapons; so I'd like to be able to dynamically add a mod to a weapon when it's equipped. Alternately, if there's some way to get a couple of enchantments onto a weapon without them being on a mod attached to that weapon, that would do it too and I'd love to hear about it. Otherwise, I have my script adding the ap_ keyword to the weapon, which seems to work fine; but the mod still has nowhere to go and does not seem to be applied to the weapon, and I'm guessing it's because I still need my attach point referenced in the guns Attach Parent Slots. Except I can't see if there's any way to add one of those outside the CK. Which would lead me back to the tiresome workaround of manually doing it to every vanilla weapon, blargh. Any ideas appreciated. Full script to follow below. It's a mess, but it works .. until we get to the mod add, where it fails.It's based on the Furious legendary mod, using the mechanism of "increment a counter for every consecutive hit on the same target." Scriptname spacefiddle_Perforation_QuestScript extends Quest import Debug Actor Property playerRef Auto Perk Property spacefiddle_Perforation_Perk Auto int Property doneOnce = 0 Auto ; using this as a flag to prevent an endless onEquip loop Group WeaponsUsed Keyword Property WeaponTypeAutomatic Auto Keyword Property WeaponTypeGatlingLaser Auto Keyword Property WeaponTypeMinigun Auto Keyword Property ap_Gun_spacefiddlePerforation Auto ObjectMod Property pmod_Gun_spacefiddlePerforation Auto Form Property WeaponToMod Auto ObjectReference Property ModWeaponRef Auto EndGroup Event OnInit() playerRef.AddPerk(spacefiddle_Perforation_Perk) Debug.Trace("You are ready to perforate!") RegisterForRemoteEvent(playerRef, "OnItemEquipped") EndEvent CustomEvent spacefiddle_PerforationSendMagicEffectEvent ;used to send messages from Contact-Target enchantment effects running on things hit by automatic weapons ;to enchantment effects running on actors equipped with those automatic weapons ; > This is based on the legendary "Furious" effect and is imitating its counter mechanism < ;Event enums int Property iEventType_Starting = 1 const auto hidden int Property iEventType_Finishing = 2 const auto hidden int Property iEventType_OnHit = 3 const auto hidden Event Actor.OnItemEquipped(Actor akSender, Form akBaseObject, ObjectReference akReference) if akBaseObject as Weapon Debug.Trace(self + " Actor " + akSender + " just equipped " + akBaseObject) if akSender.WornHasKeyword(WeaponTypeAutomatic) || akSender.WornHasKeyword(WeaponTypeGatlingLaser) || akSender.WornHasKeyword(WeaponTypeMinigun) if doneOnce == 0 WeaponToMod = akBaseObject ModWeaponRef = playerRef.DropObject(WeaponToMod) Debug.Trace(self + " I just dropped " + ModWeaponRef) ModWeaponRef.AddKeyword(ap_Gun_spacefiddlePerforation) if ModWeaponRef.HasKeyword(ap_Gun_spacefiddlePerforation) Debug.Trace(self + " We've added the keyword to " + ModWeaponRef) else Debug.Trace(self + " We didn't add the keyword to " + ModWeaponRef) endIf ModWeaponRef.Enable() if ModWeaponRef.AttachMod(pmod_Gun_spacefiddlePerforation) Debug.Trace(self + " We attached the damn mod ") else Debug.Trace(self + " We did NOT attach the damn mod ") endIf ModWeaponRef.Activate(playerRef, true) Debug.Trace(self + " We picked up the " + ModWeaponRef) doneOnce = 1 playerRef.EquipItem(WeaponToMod, false, true) Utility.Wait(1) doneOnce = 0 endIf endIf endIf endEvent Function spacefiddle_PerforationSendMagicEffectFunc(Var[] kArgs) ;called by LegendaryMagicEffectEventSenderScript running on Contact-Target enchantment's magic effects debug.trace(self + "spacefiddle_PerforationSendMagicEffectFunc() kArgs:" + kArgs) SendCustomEvent("spacefiddle_PerforationSendMagicEffectEvent", kArgs) EndFunction Link to comment Share on other sites More sharing options...
kitcat81 Posted January 11, 2017 Share Posted January 11, 2017 "Event Actor.OnItemEquipped(Actor akSender, Form akBaseObject, ObjectReference akReference)" - Debug.Trace(self + " Actor " + akSender + " just equipped " + akBaseObject) - does it return you weapon reference? I think that you can`t attach mods to base objects. Link to comment Share on other sites More sharing options...
spacefiddle Posted January 12, 2017 Author Share Posted January 12, 2017 Yah, adding a keyword and adding a mod are both inventory-safe. It's silently failing because the target doesn't "know" about what I'm trying to slap on it.If I went into the CK and manually added the ap_ i made up to every weapon, it would work. So, I'm hoping to be able to add the Attach Parent to a weapon on the fly - if I can do that, then, instead of manually altering every vanilla weapon record, and having to make a patch for every mod-added weapon individually as they come up - my buffs would happily apply themselves to anything tagged as an automatic weapon, be they vanilla, DLC, mod-added, or whathaveyou. Link to comment Share on other sites More sharing options...
Recommended Posts