Plarux Posted August 16, 2019 Posted August 16, 2019 I hope everyone reading this is doing well. The reason for making this post is simple - I'd like a script that gives the player "Empty Fusion Cells" when they fire a weapon, such as the Laser Rifle. My research on the Creation Kit Forum lead me to this page here. I would assume the script would use this event function and then use a leveled list with various chances to give the player Empty Fusion Cells, which could be used at the Chemistry Station to make Fusion Cells. Any input on how to do this would be greatly appreciated, as this is something I've been craving in Fallout 4 for a long time. Plarux
DieFeM Posted August 16, 2019 Posted August 16, 2019 (edited) Since OnPlayerFireWeapon is sent to the player, to listen for this event you could add a script to the base actor of the player, that is not convenient, so you should use an alias script, or use a quest script with RegisterForRemoteEvent to listen for OnPlayerFireWeapon. Reference Alias pointing to Player: LeveledItem Property LL_EmptyFusionCell Auto Ammo Property AmmoFusionCell Auto Event OnPlayerFireWeapon(Form akBaseObject) If akBaseObject.GetAmmo() == AmmoFusionCell GetActorReference().AddItem(LL_EmptyFusionCell) EndIf EndEvent or Quest script: LeveledItem Property LL_EmptyFusionCell Auto Ammo Property AmmoFusionCell Auto Event OnQuestInit() RegisterForRemoteEvent(Game.GetPlayer(), "OnPlayerFireWeapon") EndEvent Event Actor.OnPlayerFireWeapon(Actor akSender, Form akBaseObject) If akBaseObject.GetAmmo() == AmmoFusionCell akSender.AddItem(LL_EmptyFusionCell) EndIf EndEvent Edited August 16, 2019 by DieFeM
Plarux Posted August 19, 2019 Author Posted August 19, 2019 (edited) Since OnPlayerFireWeapon is sent to the player, to listen for this event you could add a script to the base actor of the player, that is not convenient, so you should use an alias script, or use a quest script with RegisterForRemoteEvent to listen for OnPlayerFireWeapon. Reference Alias pointing to Player: LeveledItem Property LL_EmptyFusionCell Auto Ammo Property AmmoFusionCell Auto Event OnPlayerFireWeapon(Form akBaseObject) If akBaseObject.GetAmmo() == AmmoFusionCell GetActorReference().AddItem(LL_EmptyFusionCell) EndIf EndEvent or Quest script: LeveledItem Property LL_EmptyFusionCell Auto Ammo Property AmmoFusionCell Auto Event OnQuestInit() RegisterForRemoteEvent(Game.GetPlayer(), "OnPlayerFireWeapon") EndEvent Event Actor.OnPlayerFireWeapon(Actor akSender, Form akBaseObject) If akBaseObject.GetAmmo() == AmmoFusionCell akSender.AddItem(LL_EmptyFusionCell) EndIf EndEvent Here is the script error that I received when compiling the Quest Script that you suggested: C:\Users\Plaru\AppData\Local\Temp\PapyrusTemp\FCRScript_DieFeM.psc(11,17): GetAmmo is not a function or does not exist C:\Users\Plaru\AppData\Local\Temp\PapyrusTemp\FCRScript_DieFeM.psc(11,27): cannot compare a void to a ammo (cast missing or types unrelated) I'd assume the other script would give a similar error? Also, should the quest have a conditional or constant flag? Thank You for the Help! Plarux Edited August 19, 2019 by Plarux
hereami Posted August 19, 2019 Posted August 19, 2019 (edited) Probably, wants type casting (akBaseObject As Weapon). Wondering, "Received when player fires a weapon out of combat and based on timer" - pretty useless... PS. ??OnItemEquipped ... RegisterForAnimationEvent(game.getPlayer(), "weaponFire") PPS.Or would be more natural, to obtain some (or all) empty shells upon reload, assuming that energy weapons don't throw casings. But i don't know exact event name string ("weaponReload"??). Fire event processing may be required still to track ammo usage.Could be great to have it for db shotguns as well. Edited August 20, 2019 by hereami
Plarux Posted September 13, 2019 Author Posted September 13, 2019 Probably, wants type casting (akBaseObject As Weapon). Wondering, "Received when player fires a weapon out of combat and based on timer" - pretty useless... PS. ??OnItemEquipped ... RegisterForAnimationEvent(game.getPlayer(), "weaponFire") PPS.Or would be more natural, to obtain some (or all) empty shells upon reload, assuming that energy weapons don't throw casings. But i don't know exact event name string ("weaponReload"??). Fire event processing may be required still to track ammo usage.Could be great to have it for db shotguns as well. I know this reply is late, but I don't know much about what you've suggested.When I have some time, I will do some research on what you've mentioned.
DieFeM Posted September 14, 2019 Posted September 14, 2019 (edited) In the comparsion, use a casting as hereami suggested, instead of: akBaseObject.GetAmmo()use: (akBaseObject As Weapon).GetAmmo() Edited September 14, 2019 by DieFeM
Recommended Posts