Script not starting OnEquip

Post » Mon Mar 14, 2011 2:22 pm

Goal: Have a book in game which the player can click on in their inventory which runs a script that adds a perk, a weapon, armor, and a helmet.
Problem: The script does not seem to be running.
Script:

scn CP337PowerArmorSCRIPT

Begin OnEquip player

player.addperk PowerArmorTraining
player.additem FookPowerArmorT45dRaiderARMO
player.additem FookDesertHelmetAquaARMO
player.additem WeapNVBumperSword

End


I created a new book and set the 'Teaches' entry to 'NONE', set my script to load, then entered some jibberish in the 'Book Text' field. With nothing to teach, trying to use the book in game plays the equip/unequip sound. I thought that this might not trigger the OnEquip entry, so I created a bandanna that also used my script (which also failed to run the script).

Obviously I am doing something wrong here. Any help would be appreciated.
User avatar
saharen beauty
 
Posts: 3456
Joined: Wed Nov 22, 2006 12:54 am

Post » Mon Mar 14, 2011 7:16 pm

Goal: Have a book in game which the player can click on in their inventory which runs a script that adds a perk, a weapon, armor, and a helmet.
Problem: The script does not seem to be running.
Script:

scn CP337PowerArmorSCRIPT

Begin OnEquip player

player.addperk PowerArmorTraining
player.additem FookPowerArmorT45dRaiderARMO
player.additem FookDesertHelmetAquaARMO
player.additem WeapNVBumperSword

End


I created a new book and set the 'Teaches' entry to 'NONE', set my script to load, then entered some jibberish in the 'Book Text' field. With nothing to teach, trying to use the book in game plays the equip/unequip sound. I thought that this might not trigger the OnEquip entry, so I created a bandanna that also used my script (which also failed to run the script).

Obviously I am doing something wrong here. Any help would be appreciated.


What you may want to do as a bit of reverse thinking is make this an effect script. Studied the effects scripts and they allow for alot of things and this sounds right up your alley. I would change the script to this:

scn CP337PowerArmorEffectSCRIPTBEGIN ScriptEffectStart      player.addperk PowerArmorTraining      player.additem FookPowerArmorT45dRaiderARMO      player.additem FookDesertHelmetAquaARMO      player.additem WeapNVBumperSwordEnd


After that go to the Base Effects window and add in a new effect with the Effect Archetype being script *We'll call the effect InitiateArmor*. With the effect made go to the Ingestible category and select whatever skill magazine look you want. Alter it to be whatever name you want creating a new form for it so it creates a new item instead of replacing EVERY skill magazine out there of that type. Delete the current effect for your new magazine and add in the InitiateArmor effect keeping the magnitude and such blank. That should pretty much do it and now your magazine just needs to be placed in the world.
Just make sure to leave the magnitude and such alone since you just want a 1 time effect and not some weird reoccurring effect.
User avatar
Wanda Maximoff
 
Posts: 3493
Joined: Mon Jun 12, 2006 7:05 am

Post » Mon Mar 14, 2011 3:32 pm

Goal: Have a book in game which the player can click on in their inventory which runs a script that adds a perk, a weapon, armor, and a helmet.
Problem: The script does not seem to be running.
Script:

scn CP337PowerArmorSCRIPT

Begin OnEquip player

player.addperk PowerArmorTraining
player.additem FookPowerArmorT45dRaiderARMO
player.additem FookDesertHelmetAquaARMO
player.additem WeapNVBumperSword

End


I created a new book and set the 'Teaches' entry to 'NONE', set my script to load, then entered some jibberish in the 'Book Text' field. With nothing to teach, trying to use the book in game plays the equip/unequip sound. I thought that this might not trigger the OnEquip entry, so I created a bandanna that also used my script (which also failed to run the script).

Obviously I am doing something wrong here. Any help would be appreciated.


Where did you write your script? In FONVEdit or in the GECK?
The OnEquip Part should only work for equippable items (weapons/armor/cloth), so a book doesn't work. The bandana should work but your script is wrong, the additem function require more than a object id, it also needs a number to know how many items should be added, so for example "player.additem FookDesertHelmetAquaARMO 1". Without the number for the quantity the script shouldn't even save.
User avatar
Emilie M
 
Posts: 3419
Joined: Fri Mar 16, 2007 9:08 am

Post » Mon Mar 14, 2011 11:29 pm

Books are equipped - at least in FO3 they are, so an OnEquip block should work.
The thing you are missing is the quantities on the added items, as Mr J indicated.
User avatar
Conor Byrne
 
Posts: 3411
Joined: Wed Jul 11, 2007 3:37 pm

Post » Mon Mar 14, 2011 9:47 pm

*woops, never mind
User avatar
lucile
 
Posts: 3371
Joined: Thu Mar 22, 2007 4:37 pm

Post » Mon Mar 14, 2011 2:03 pm

I took PredatorX's advice, but I have no idea if the script works now. Everytime I pickup the book in game and mouse over it, the game crashes.
User avatar
OnlyDumazzapplyhere
 
Posts: 3445
Joined: Wed Jan 24, 2007 12:43 am

Post » Tue Mar 15, 2011 4:56 am

Did you give the new base effect a name? If so, how long was it? Descriptions that are too long or 0 can crash the menus.
User avatar
Alina loves Alexandra
 
Posts: 3456
Joined: Mon Jan 01, 2007 7:55 pm

Post » Mon Mar 14, 2011 8:06 pm

I took PredatorX's advice, but I have no idea if the script works now. Everytime I pickup the book in game and mouse over it, the game crashes.


Sorry this might fix the problem

scn CP337PowerArmorEffectSCRIPTBEGIN ScriptEffectStart      player.addperk PowerArmorTraining      player.additem FookPowerArmorT45dRaiderARMO 1 1      player.additem FookDesertHelmetAquaARMO 1 1      player.additem WeapNVBumperSword 1 1End


The first 1 is the amount of the item that you are giving to the player while the second 1 is to hide the message displaying to the player that they received X item. As to why it is crashing did you set the script to Effect from the Archetype window?

*note:*

Did some poking around and that addperk looked interesting to me, but found this bit of information on the GECK wiki:

* With Fallout 3 version 1.4 or older: Loading a savegame in which the player has a mod-created perk, when the mod that created it is no longer installed, may crash the game. That issue was fixed in Fallout v1.5. If you know the FormId of the Perk, you can remove it from yourself using the console. Modders are also advised to provide an in-game means for players to remove perks, should they wish to uninstall while keeping older versions of FO3, or at least provide instructions on how to remove the perks.

* One simple way is to provide an "uninstaller" esm file, that the user must install, load their game, and save it, before they remove the mod. The esm will do nothing but remove the perks, and contains one quest, called something like "MyPerkRemovalQuest", set to "start game enabled", with a Quest-type script:

Interesting thing is the PowerArmorTraining shouldn't be a player created perk since it is already in new vegas for when you help out the Enclave or Brotherhood *Whatever comes first*.

As Toaster mentioned you will need to give the item a short concise name like "ArmMagEffect" or "SPArmorEffect" . I usually keep the name between 7 and 14 characters in length then add the Effect to it. Though the mousing over part is kind of confusing to me never heard of that problem before.
User avatar
TWITTER.COM
 
Posts: 3355
Joined: Tue Nov 27, 2007 3:15 pm

Post » Mon Mar 14, 2011 4:10 pm

PredatorX, I was referring to the displayed name, the one that actually shows up in the menus. Not the editor name. The XML can only display a certain number of characters, if there are too many it crashes- this was a problem in early power armour editing mods for FO3 that added lots of effects, and why most FO3 overhauls abbreviate all the effect names (like energy resistance -> E. Res).
User avatar
Joe Alvarado
 
Posts: 3467
Joined: Sat Nov 24, 2007 11:13 pm

Post » Mon Mar 14, 2011 8:48 pm

I scrapped my old plugin and started from scratch.

I created a script called 'CP337PowerArmorEffectSCRIPT' using PredatorX's code and set the Script Type to 'Effect'.

I created a base effect, ID: CP337PABE
Name: Fiend Power
Archetype: Script
Assoc. Item: CP337PowerArmorEffectSCRIPT
Flags: Self

I created a new Ingestible based on MagazineNVCritical
New ID: CP337Mag1
Name: Book of Fiends
Script: None
Use Sound: NPCHumanUsingComic
Addiction: None
Equip Type: Food
I deleted the old effects and added : CP337PABE (Range:Self. Duration:0, Magnitude:0)

Now it works! I must have screwed something up in the first plugin without noticing.

Thanks for the help everyone!
User avatar
Devin Sluis
 
Posts: 3389
Joined: Wed Oct 24, 2007 4:22 am


Return to Fallout: New Vegas