Author Topic: 2 hander AC  (Read 1665 times)

Legacy_0pie

  • Jr. Member
  • **
  • Posts: 74
  • Karma: +0/-0
2 hander AC
« on: March 25, 2011, 12:33:53 am »


               I'm trying to script something that will give people using 2 handed weapons or duel wielding +8 shield ac. Any ideas on how I can do this ? I was thinking maybe give the ac if the player has weapon focus in a 2 handed weapon , but then what if the player is a small race and 2handing a scimitar perhaps.  I'm stuck.
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
2 hander AC
« Reply #1 on: March 25, 2011, 01:40:48 am »


               

int GetIsTwoHandedWeapon(object oWeapon)
{
 switch(GetBaseItemType(oWeapon))
 {
 case BASE_ITEM_GREATAXE:
 case BASE_ITEM_SHORTSPEAR:
 case BASE_ITEM_TRIDENT:
 case BASE_ITEM_GREATSWORD:
 case BASE_ITEM_HALBERD:
 case BASE_ITEM_SCYTHE:
 case BASE_ITEM_HEAVYFLAIL:
 case BASE_ITEM_QUARTERSTAFF:
 return TRUE;
 case BASE_ITEM_SCIMITAR:
 case BASE_ITEM_CLUB:
 case BASE_ITEM_MORNINGSTAR:
 case BASE_ITEM_LIGHTFLAIL:
 case BASE_ITEM_WARHAMMER:
 case BASE_ITEM_BATTLEAXE:
 case BASE_ITEM_BASTARDSWORD:
 case BASE_ITEM_LONGSWORD:
 case BASE_ITEM_RAPIER:
 case BASE_ITEM_DWARVENWARAXE:
  switch(GetRacialType(GetItemPossessor(oWeapon)))
  {
  case RACIAL_TYPE_GNOME:
  case RACIAL_TYPE_HALFLING:
  return TRUE;
  }
 }
return FALSE;
}

hope I didn't forget any, check it with NWN Wiki please
               
               

               


                     Modifié par ShaDoOoW, 25 mars 2011 - 01:42 .
                     
                  


            

Legacy_0pie

  • Jr. Member
  • **
  • Posts: 74
  • Karma: +0/-0
2 hander AC
« Reply #2 on: March 25, 2011, 01:49:30 am »


               Thanks ShaDoOoW , I will try this out '<img'>
               
               

               
            

Legacy_0pie

  • Jr. Member
  • **
  • Posts: 74
  • Karma: +0/-0
2 hander AC
« Reply #3 on: March 25, 2011, 03:53:05 am »


               Yay that worked. I have one problem  though. In my OnPlayerUnequip script for this is there a way to remove only shield ac ? Right now I have RemoveSpecificEffect( EFFECT_TYPE_AC_INCREASE,oPC); but that removes all ac.
               
               

               
            

Legacy_0pie

  • Jr. Member
  • **
  • Posts: 74
  • Karma: +0/-0
2 hander AC
« Reply #4 on: March 25, 2011, 10:41:50 am »


               Also I added bows to the include you made me. But it wont let me put 2 instances of shortbow ( because it is 2 handed for both medium and small races ) in it. Any way to fix this so that both medium and small races get the ac ?
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
2 hander AC
« Reply #5 on: March 25, 2011, 10:44:23 am »


               First you need to create a special placeable (non static, non useable, no scripts) with unique tag.Eg. EC_TWOHANDED.

then you need to apply the effect in OnEquip this way

AssignCommand(GetObjectByTag("EC_TWOHANDED"), ApplyEffectToObject(DURATION_TYPE_PERMANENT, SupernaturalEffect(EffectACIncrease(8,AC_SHIELD_ENCHANTMENT_BONUS)),oPC));


then in OnUnEquip you need to remove it this way


  oPC = GetPCItemLastUnequippedBy();
effect e = GetFirstEffect(oPC);
  while(GetIsEffectValid(e))
  {
   if(GetTag(GetEffectCreator(e)) == "EC_TWOHANDED")
   {
   RemoveEffect(oPC,e);
   }
  e = GetNextEffect(oPC);
  }


               
               

               


                     Modifié par ShaDoOoW, 25 mars 2011 - 10:45 .
                     
                  


            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
2 hander AC
« Reply #6 on: March 25, 2011, 10:48:29 am »


               

0pie wrote...

Also I added bows to the include you made me. But it wont let me put 2 instances of shortbow ( because it is 2 handed for both medium and small races ) in it. Any way to fix this so that both medium and small races get the ac ?

Ok added bows and crossbows.

int GetIsTwoHandedWeapon(object oWeapon)
{
 switch(GetBaseItemType(oWeapon))
 {
 case BASE_ITEM_GREATAXE:
 case BASE_ITEM_SHORTSPEAR:
 case BASE_ITEM_TRIDENT:
 case BASE_ITEM_GREATSWORD:
 case BASE_ITEM_HALBERD:
 case BASE_ITEM_SCYTHE:
 case BASE_ITEM_HEAVYFLAIL:
 case BASE_ITEM_QUARTERSTAFF:
 case BASE_ITEM_LONGBOW:
 case BASE_ITEM_SHORTBOW:
 case BASE_ITEM_HEAVYCROSSBOW:
 case BASE_ITEM_LIGHTCROSSBOW:
 return TRUE;
 case BASE_ITEM_SCIMITAR:
 case BASE_ITEM_CLUB:
 case BASE_ITEM_MORNINGSTAR:
 case BASE_ITEM_LIGHTFLAIL:
 case BASE_ITEM_WARHAMMER:
 case BASE_ITEM_BATTLEAXE:
 case BASE_ITEM_BASTARDSWORD:
 case BASE_ITEM_LONGSWORD:
 case BASE_ITEM_RAPIER:
 case BASE_ITEM_DWARVENWARAXE:
  switch(GetRacialType(GetItemPossessor(oWeapon)))
  {
  case RACIAL_TYPE_GNOME:
  case RACIAL_TYPE_HALFLING:
  return TRUE;
  }
 }
return FALSE;
}


               
               

               


                     Modifié par ShaDoOoW, 25 mars 2011 - 10:49 .
                     
                  


            

Legacy_0pie

  • Jr. Member
  • **
  • Posts: 74
  • Karma: +0/-0
2 hander AC
« Reply #7 on: March 25, 2011, 11:06:19 am »


               Thank you SOOO much ShaDoOoW '<img'> , my only problem now is Small races do not get AC from a shortbow.
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
2 hander AC
« Reply #8 on: March 25, 2011, 12:27:25 pm »


               really? they should if you updated the function with the one above...
               
               

               
            

Legacy_0pie

  • Jr. Member
  • **
  • Posts: 74
  • Karma: +0/-0
2 hander AC
« Reply #9 on: March 25, 2011, 12:50:39 pm »


               lol ... your right ShaDoOoW , i'm sorry. But thanks for helping me with this it all works perfectly !
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
2 hander AC
« Reply #10 on: March 25, 2011, 12:56:06 pm »


               well just noticed that currently everyone will get 2handed bonus with shortbow, if you intended it *only* for gnome/halfling you need to move it under first return TRUE like this:


case BASE_ITEM_HEAVYCROSSBOW:
case BASE_ITEM_LIGHTCROSSBOW:
return TRUE;
case BASE_ITEM_SHORTBOW:
               
               

               
            

Legacy_0pie

  • Jr. Member
  • **
  • Posts: 74
  • Karma: +0/-0
2 hander AC
« Reply #11 on: March 25, 2011, 01:07:33 pm »


               No I wanted them all to get the ac I just thought it had to be under the "return TRUE;" part in order for the small races to get the ac.

I have another question though. If I wanted to setup the same thing for duel wielders would I do it this same way ?

Once again thank you so much 8)
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
2 hander AC
« Reply #12 on: March 25, 2011, 01:24:30 pm »


               well you need a new function to check "does dual wield", but rest is the same since you cant have twohanded and dualwield ac bonsu at the same time
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
2 hander AC
« Reply #13 on: March 25, 2011, 10:51:55 pm »


               Here is my version for your TwoHanded weapon function.
The only real differance is that it will not return true  for the short bow in the hands of a human. but it will return true for the short bow in the hands on a smal creature.  I assume you are shooting for the weapon being as large as the creature to explain the AC increase.  


int GetIsWeaponACWorthy(object oWeapon, object oWielder=OBJECT_SELF)
{
   int nWeaponType = GetBaseItemType(oWeapon);
   int nWeaponSize = StringToInt(Get2DAString("baseitems","WeaponSize",nWeaponType));
   return GetCreatureSize(oWielder)< nWeaponSize ;
}
 
               
               

               
            

Legacy_Terrorble

  • Sr. Member
  • ****
  • Posts: 370
  • Karma: +0/-0
2 hander AC
« Reply #14 on: April 02, 2011, 06:25:49 am »


               

ShaDoOoW wrote...

First you need to create a special placeable (non static, non useable, no scripts) with unique tag.Eg. EC_TWOHANDED.

then you need to apply the effect in OnEquip this way


AssignCommand(GetObjectByTag("EC_TWOHANDED"), ApplyEffectToObject(DURATION_TYPE_PERMANENT, SupernaturalEffect(EffectACIncrease(8,AC_SHIELD_ENCHANTMENT_BONUS)),oPC));


then in OnUnEquip you need to remove it this way


  oPC = GetPCItemLastUnequippedBy();
effect e = GetFirstEffect(oPC);
  while(GetIsEffectValid(e))
  {
   if(GetTag(GetEffectCreator(e)) == "EC_TWOHANDED")
   {
   RemoveEffect(oPC,e);
   }
  e = GetNextEffect(oPC);
  }



Ooo, this is great!.  It is the perfect answer to a couple things I've both done and want to do.