Author Topic: Looking for some help adding a variable to on equip and unequip events...  (Read 448 times)

Legacy_Lazarus Magni

  • Hero Member
  • *****
  • Posts: 1837
  • Karma: +0/-0


               We have a modification for our world pending (it is already in place), but yet I don't have the skills personally to implement it. Could use some help here.

From what I understand we need to add:

> in OnModuleEquip and OnModuleUnEquip all yo have to do is:
>
> equip:
> check if the item is armor and if so, set an integer variable "MaxAC" on
> a PC that holds maximum dexterity bonus for given armor type (as you
> described me the table before)
>
> unequip:
> check if the item is armor and if so, sets the variable to 100 (since
> you dont want to allow unlimited AC for naked characters right? if you
> want allow infinite then set 0 instead)
> "

If anyone could help I would appreciate it


The concept is there, using Int for Assisns for AC (we already have them set up to use Int for ab), and the framework is there, just need some help adjusting the above said events.

Any help would be appreciated.


Our max dex bonuses on armors are currently set to:

Full plate 12
Half 14
Branded/splint mail 16
Breastplate and chainmail 18
Chain shirt and scale mait 20
Hide and studded leather 22
Leather 24
Padded 26
and cloth 100
               
               

               


                     Modifié par Lazarus Magni, 05 novembre 2013 - 03:19 .
                     
                  


            

Legacy_Vicar 77

  • Newbie
  • *
  • Posts: 23
  • Karma: +0/-0
Looking for some help adding a variable to on equip and unequip events...
« Reply #1 on: November 05, 2013, 03:28:56 am »


               What are you trying to do Laz?
               
               

               
            

Legacy_Lazarus Magni

  • Hero Member
  • *****
  • Posts: 1837
  • Karma: +0/-0
Looking for some help adding a variable to on equip and unequip events...
« Reply #2 on: November 05, 2013, 03:37:34 am »


               Well essentially, we already have a modification in place to allow assassins to use Int for their AB (similar to dexers with finess, only it requires a different feat, and 10+ assassin lvls.) We would also like them to be able to use their InT for AC (again similar to dexers), however restricted to the same constraints as dexers in terms of MDB/.

Although untested, we have a plugin that supposedly allows us to do this, provided we add these variables to the above said events (on equip, and unequip.)

Comprende mi amigo Vic?


Just need some help doing that.
               
               

               
            

Legacy_Vicar 77

  • Newbie
  • *
  • Posts: 23
  • Karma: +0/-0
Looking for some help adding a variable to on equip and unequip events...
« Reply #3 on: November 05, 2013, 03:43:08 am »


               Si, Siempre. Viva La Revoloution Compadre.
               
               

               
            

Legacy_MagicalMaster

  • Hero Member
  • *****
  • Posts: 2712
  • Karma: +0/-0
Looking for some help adding a variable to on equip and unequip events...
« Reply #4 on: November 05, 2013, 05:47:00 am »


               Exactly what variables do you need to add?  An int with the exact AC bonus the Assassin is supposed to get once you factor in the armor, max dex bonus, and the AC already given from dex?

For example, what happens if a person takes off all dex gear and has 2 dex modifier with padded armor, meaning the game says he has 2 dex AC and should be able to get 6 more from int.  He gets the bonus...and then throws on his dex gear again to get a free 6 AC?

You'd need to be able to remove the int bonus and recalculate it, in other words.

What if they buff their AC with a maximized Cat's Grace and Aura of Vitality instead?  That's +4 AC and won't fire the (un)equip scripts?  How are you handling that?
               
               

               
            

Legacy_Lazarus Magni

  • Hero Member
  • *****
  • Posts: 1837
  • Karma: +0/-0
Looking for some help adding a variable to on equip and unequip events...
« Reply #5 on: November 06, 2013, 12:05:01 am »


               From my understanding it needs to be an integer variable holding the MDB of the armor. E.G. if padded it's 26 on our world.

I don't think dexterity will be an issue for us. Assassins also already use INT for their AB, so not much point in going dex/INT hybrid (other than for BS, which relates to another one of our customizations.) Long story short I don't think it will be a problem if it stacks.
               
               

               
            

Legacy_Lazarus Magni

  • Hero Member
  • *****
  • Posts: 1837
  • Karma: +0/-0
Looking for some help adding a variable to on equip and unequip events...
« Reply #6 on: November 06, 2013, 12:07:03 am »


               Just need a lil help from a competent scripter to provide some code I can add to our un-equip, and equip events. Any help would be greatly appreciated.
               
               

               
            

Legacy_MagicalMaster

  • Hero Member
  • *****
  • Posts: 2712
  • Karma: +0/-0
Looking for some help adding a variable to on equip and unequip events...
« Reply #7 on: November 06, 2013, 01:02:34 am »


               So you just need code that will find the maximum dexterity bonus of the armor currently equipped and that's all you care about?

If you're altered the defaults then you'll need to post your changes -- I can determine what TYPE of armor it is but I don't know a way of simply obtained the max dexterity bonus other than simply using constants once I determine the type of armor
               
               

               
            

Legacy_Lazarus Magni

  • Hero Member
  • *****
  • Posts: 1837
  • Karma: +0/-0
Looking for some help adding a variable to on equip and unequip events...
« Reply #8 on: November 07, 2013, 01:09:22 am »


               As described above, I quoted directly from the plugin author, and your guess what that means is as good as mine (if not better.) I could not get the person to elaborate.

P.S. See the OP for what was quoted, in addition to our custom MDB.
               
               

               


                     Modifié par Lazarus Magni, 07 novembre 2013 - 01:11 .
                     
                  


            

Legacy_Lazarus Magni

  • Hero Member
  • *****
  • Posts: 1837
  • Karma: +0/-0
Looking for some help adding a variable to on equip and unequip events...
« Reply #9 on: November 07, 2013, 01:21:08 am »


               The way I read it is:

On equip, check if is an "armor", and if so, set a variable on the PC, which is an interger named MaxAC, and corresponds in value, as described here depending on which armor type it is:

Full plate 12
Half 14
Branded/splint mail 16
Breastplate and chainmail 18
Chain shirt and scale mait 20
Hide and studded leather 22
Leather 24
Padded 26
and cloth 100


And on unequip:
A check if it is an armor (being unequipped), and if so setting the variable to 100.
               
               

               


                     Modifié par Lazarus Magni, 07 novembre 2013 - 01:21 .
                     
                  


            

Legacy_MagicalMaster

  • Hero Member
  • *****
  • Posts: 2712
  • Karma: +0/-0
Looking for some help adding a variable to on equip and unequip events...
« Reply #10 on: November 07, 2013, 02:53:22 am »


               Er...let me clarify something.

The MDB has traditionally referred to the MODIFIER, meaning padded armor had a MDB of 8 (which was 26 dexterity score).  Is that the same for you or are you allowing MDB for Padded armor to be 52 dexterity score?
               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Looking for some help adding a variable to on equip and unequip events...
« Reply #11 on: November 07, 2013, 02:55:16 am »


               Here is a function with the values you have set above.

// Returns the highest value of base armor AC plus dex for a custom system
// Returns -1 on an error and 100 if the maximum is uncapped
int GetArmorMaxAC()
{
// Armor is selected from the chest of OBJECT_SELF
object oArmor = GetItemInSlot(INVENTORY_SLOT_CHEST);
int nArmorAppear = GetItemAppearance(oArmor, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_TORSO);
string sArmorBase = Get2DAString("des_crft_appear", "BaseAC", nArmorAppear);
// If the 2DA string does not return appropriately something is wrong
if(sArmorBase == "" || sArmorBase == "****") return -1;
switch (StringToInt(sArmorBase))
 {
 //Clothing has no max
 case 0: return 100;
 case 1: return 26;
 case 2: return 24;
 case 3: return 22;
 case 4: return 20;
 case 5: return 18;
 case 6: return 16;
 case 7: return 14;
 case 8: return 12;
 }
//Everything else is an error
return -1;
}
               
               

               
            

Legacy_Lazarus Magni

  • Hero Member
  • *****
  • Posts: 1837
  • Karma: +0/-0
Looking for some help adding a variable to on equip and unequip events...
« Reply #12 on: November 07, 2013, 03:23:16 am »


               MM, correct, the bonus is typically based off the modifier, and that is what we are looking for as well.

Whiz, thank you. I will give this a shot next chance I get,

P.S. I don't see any variables being set here? I am not a scripter, but I can read them a bit (just from having to look at them so much in the past few years.) I don't see any variables being set which is what the plugin author specified was needed to make this work using their version of the nwnx_cool dll.
               
               

               


                     Modifié par Lazarus Magni, 07 novembre 2013 - 03:24 .
                     
                  


            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Looking for some help adding a variable to on equip and unequip events...
« Reply #13 on: November 07, 2013, 04:07:46 am »


               Right,  I was just doing the calculation and returning a number.  I have flopped it into the equip and unequip scripts (since these are run by the module I decided to adjust the function to take the armor as an argument rather than having to rely on an assign command.)  Though I have tested the value calculated in the function, I have not tested these scripts yet, but I am pretty sure that getting an item in a slot during these scripts gets the status of the slot after the item has been equipped/unequipped.


// Returns the highest value of base armor AC plus dex for a custom system
// Returns -1 on an error and 100 if the maximum is uncapped
int GetArmorMaxAC(object oArmor)
{
int nArmorAppear = GetItemAppearance(oArmor, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_TORSO);
string sArmorBase = Get2DAString("des_crft_appear", "BaseAC", nArmorAppear);
// If the 2DA string does not return appropriately something is wrong
if(sArmorBase == "" || sArmorBase == "****") return -1;
switch (StringToInt(sArmorBase))
{
//Clothing has no max
case 0: return 100;
case 1: return 26;
case 2: return 24;
case 3: return 22;
case 4: return 20;
case 5: return 18;
case 6: return 16;
case 7: return 14;
case 8: return 12;
}
//Everything else is an error
return -1;
}

// Main script of OnEquip/OnUnequip
On Equip Event

void main()
{
object oPC = GetPCItemLastEquippedBy();
object oArmor = GetItemInSlot(INVENTORY_SLOT_CHEST, oPC);
int nAC;
if(oArmor == OBJECT_INVALID) nAC = 100;
else nAC = GetArmorMaxAC(oArmor);
SetLocalInt(oPC, "MaxAC", nAC);
}

On Unequip Event

void main()
{
object oPC = GetPCItemLastUnequippedBy();
object oArmor = GetItemInSlot(INVENTORY_SLOT_CHEST, oPC);
int nAC;
if(oArmor == OBJECT_INVALID) nAC = 100;
else nAC = GetArmorMaxAC(oArmor);
SetLocalInt(oPC, "MaxAC", nAC);
}
               
               

               
            

Legacy_Lazarus Magni

  • Hero Member
  • *****
  • Posts: 1837
  • Karma: +0/-0
Looking for some help adding a variable to on equip and unequip events...
« Reply #14 on: November 07, 2013, 04:38:24 am »


               As far as your "include" Whiz, where to I put this?

I am probably breaking all know scripter terms here, but where (and on what script) do I put this portion of the code?

"// Returns the highest value of base armor AC plus dex for a custom system
// Returns -1 on an error and 100 if the maximum is uncapped
int GetArmorMaxAC(object oArmor)
{
int nArmorAppear = GetItemAppearance(oArmor, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_TORSO);
string sArmorBase = Get2DAString("des_crft_appear", "BaseAC", nArmorAppear);
// If the 2DA string does not return appropriately something is wrong
if(sArmorBase == "" || sArmorBase == "****") return -1;
switch (StringToInt(sArmorBase))
{
//Clothing has no max
case 0: return 100;
case 1: return 26;
case 2: return 24;
case 3: return 22;
case 4: return 20;
case 5: return 18;
case 6: return 16;
case 7: return 14;
case 8: return 12;
}
//Everything else is an error
return -1;
}
"

And assuming I am adding this to a different script, OR making a new include, I assume I need to include it in the on equip and unequip events?