Author Sticky: Post Working Scripts Here
Ayrizale Posted: Friday, 21 June 07:40PM
I'm a scripting newbie, but I'm trying to learn. Thanks for the scripts above and any more that are posted below, I'm sure that the examples that are posted will be helpful to me and to others in learning to script.

I've made a couple of scripts so far, but the only one that I know to be a working success is:

Script Name: Give_Special

What it Does: This script gives a creature item to a PC and then equips it into one of the Creature Item Inventory Slots so that the PC gains the benefits of the Item without it taking up one of their normal slots. This is useful for giving the PC some extra powers that are either, a) Granted to them by a higher power, or b) are powers granted by their subrace. There are probably some other uses for it, but those are the two that were intended from the start.

Notes: The script relies upon you having already created the item that it will give to the PC. You will need to make the item of the proper type so that it will fit into the Inventory slot that you want to put it in, so Creature Type items go into the INVENTORY_SLOT_CARMOUR slot, while the Creature weapons go into the INVENTORY_SLOT_CWEAPON_* slots.

NWScript:
////////////////////////////

// File Name: Give_Special

////////////////////////////

////////////////////////////

// Created by: Lael Buchanan

// Date: 6/18/02

////////////////////////////

void main()

{

    // Capture the PC in a variable for later use in the AssignCommand

    object oPC = GetPCSpeaker();

    // Give the speaker the items

    object oSpecialItem = CreateItemOnObject ("Item_Tag", GetPCSpeaker(), 1);

    //Force the speaker to equip the item that was just given

    AssignCommand(oPC, ActionEquipItem (oSpecialItem, INVENTORY_SLOT_CARMOUR));

}

I am replying to my own post on page one with some more Notes that I have learned through use of the script that I posted there. The Script in question gives Rewards to PCs in the form of a Creature Item and then equips it for them so that they don't ever see the item, but still get the benefits.

First, when using the CreateItemOnObject Function, you must call the item by its BlueprintRef ID rather than its Tag or Name. Might be something simple to the people that have a bit more experience with scripting, but it caused me considerable frustration until I figured it out.

Second, when creating an item for one of the Creature Weapon Slots, my suggestion is to create the item as a Dagger. If you create the item as one of the creature weapons, then when it goes to equip it you will get an error saying that you do not have the right proficiencies to equip that item. I'm pretty sure that anyone can use a dagger and it won't add too much to the character's carried weight.

(Edit:)

Third, must be an oddity of the program, but when you add an item into the Creature Weapon Slots, Properties such as Attack Bonuses and Damage Bonuses do not appear in the Character window if you open it. But they *are* in effect. If you give you character Bonus Fire Damage, it will not show in the Character window, but when they attack they will deliver the bonus Fire Damage.

I think that's about it for now. If there is any way that one of the moderators could add this text into my earlier message or delete the earlier message to keep the information all in one place, I would appreciate it. For some reason I could not edit my earlier post, might just be a function of this board software.

Thanks,

Lael