Aller au contenu

Photo

On Item Aquire Script Request


  • Veuillez vous connecter pour répondre
4 réponses à ce sujet

#1
Masiquer

Masiquer
  • Members
  • 7 messages
I've spent a good deal of time self learning basic scripting stuffs and on occasion I get something working, but I'm struggling with this one.  I imagine it'd be easy for someone who knows a lot more than I do about scripting.

What I am requesting is a module On Acquire Item script that fires every time a PC acquires a 'magic' item. 

Check to see if the magic item has variable 'v_itemvariable'. 
If the magic item does not have the variable, then apply the variable'v_itemvariable' to it AND apply 1 of 11 item property sets to it with the name of the set put in the description of the item.

i.e. Player acquires Longsword +1.  Once the player picks up the item, the item recieves v_variable and added property set 4 (random of 1 out of 11 rolled a 4).  Set 4 is named: Ice & Fire and is +1 save vs. cold/fire.  So the Longsword +1, once acquired, becomes Longsword +1 with the item properties of +1 save vs. cold, +1 save vs. fire and it's description simply says 'Ice & Fire'.

I don't need a full 11 sets typed out, just 3 will be fine, I can expand it myself. 

#2
bealzebub

bealzebub
  • Members
  • 352 messages
If you check the script assist in the toolset, there is an item aquire template that is pretty self explanatory.

#3
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 603 messages
If you want to have multiple items with different tags use the same script, then you should probably use a module on acquire script rather than using tag-based scripting. The templates are for tag based scripting, which is item specific. Using a module on acquire script is the way this was done in NWN. You'll need to have the script check for your variable and if found then figure out the properties you want to apply and apply them and then remove the variable (otherwise it will happen again when the item is dropped and picked up again). My Nasher's Set scripts in the vault apply properties to objects if you want to see how that is done.

Regards

#4
Masiquer

Masiquer
  • Members
  • 7 messages
Thanks for the replies guys! Definely pointing me in the right direction.

It's one of my next big 'to dos'. Amazing how fast that list grows and then shrinks each night. I'll probably take a look at your scripts, Kaldor, thanks!

I'm actually wanting the variable to be 'not found' and then applied it and stick to the item so each time the item is acquired, it sees that the variable is already there and doesn't apply the IPs again, but I can probably juggle the script some.  Isn't that what we do when we are low lvl scripters? Chop, juggle and paste!!

Modifié par Masiquer, 08 novembre 2012 - 11:13 .


#5
Darin

Darin
  • Members
  • 282 messages

Masiquer wrote...

I've spent a good deal of time self learning basic scripting stuffs and on occasion I get something working, but I'm struggling with this one.  I imagine it'd be easy for someone who knows a lot more than I do about scripting.

What I am requesting is a module On Acquire Item script that fires every time a PC acquires a 'magic' item. 

Check to see if the magic item has variable 'v_itemvariable'. 
If the magic item does not have the variable, then apply the variable'v_itemvariable' to it AND apply 1 of 11 item property sets to it with the name of the set put in the description of the item.

i.e. Player acquires Longsword +1.  Once the player picks up the item, the item recieves v_variable and added property set 4 (random of 1 out of 11 rolled a 4).  Set 4 is named: Ice & Fire and is +1 save vs. cold/fire.  So the Longsword +1, once acquired, becomes Longsword +1 with the item properties of +1 save vs. cold, +1 save vs. fire and it's description simply says 'Ice & Fire'.

I don't need a full 11 sets typed out, just 3 will be fine, I can expand it myself. 


Well, here's 1.  Have fun!


// x2_mod_def_aqu
/*
Description
This script will replace your "on aquire" script
it lists below the added-in stuff to allow for your
edits
*/




// Edited by Darin LaSota, 12/27/2012




//::///////////////////////////////////////////////
//:: Example XP2 OnItemAcquireScript
//:: x2_mod_def_aqu
//:: © 2003 Bioware Corp.
//:://////////////////////////////////////////////
/*
    Put into: OnItemAcquire Event




*/
//:://////////////////////////////////////////////
//:: Created By: Georg Zoeller
//:: Created On: 2003-07-16
//:://////////////////////////////////////////////




#include "x2_inc_switches"
void main()
{
     object oItem = GetModuleItemAcquired();
 
//  ***  Begin Item Property Stuff ***
 
// only apply if it hasn't been applied yet (first set) and if it has an item property (second set)
if( (GetLocalInt(oItem,"v_itemvariable")==0) && (GetIsItemPropertyValid(GetFirstItemProperty(oItem))) ) 
{
//this is a reserved area, in case you want
//to check for a specific item property
int nCheck;
// run whatever check you'd like, with the following in it:
nCheck == 1;


if(nCheck==1)
{
int nVar = Random(11)+1; //Random allows 0, max is 1 higher
switch (nVar)
{
case 1: //blank for you, see case 4)
break;
case 2:
break;
case 3:
break;
case 4: //your example
//Save Bonuses:
AddItemProperty(DURATION_TYPE_PERMANENT, ItemPropertyBonusSavingThrowVsX(IP_CONST_SAVEVS_FIRE,1),oItem);
AddItemProperty(DURATION_TYPE_PERMANENT, ItemPropertyBonusSavingThrowVsX(IP_CONST_SAVEVS_COLD,1),oItem);
//Rename and redescribe.  You can use get functions to include the original desc, etc.
SetFirstName(oItem,"Fire & Ice");
SetDescription(oItem,"Fire & Ice");
break;
case 5:
break;
case 6:
break;
case 7:
break;
case 8:
break;
case 9:
break;
case 10:
break;
case 11:
break;




}

SetLocalInt(oItem,"v_itemvariable",nVar); //sets the variable on the item so we know

}
}
//  ** End Item Property Stuff  ***

Modifié par EpicFetus, 27 décembre 2012 - 08:14 .