Author Topic: Need a couple functions  (Read 269 times)

Legacy_ShadowM

  • Hero Member
  • *****
  • Posts: 1373
  • Karma: +0/-0
Need a couple functions
« on: December 08, 2011, 04:55:38 am »


               I need two functions, one that returns if oCreature is holding a two handed weapon
and one if oCreature is holding a light weapon. I could prob. make these myself, but it take awhile and I prob. miss something so I figured I ask the scripting gods '<img'>. thanks in advance.
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Need a couple functions
« Reply #1 on: December 08, 2011, 05:10:41 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(CORE_GetRacialType(GetItemPossessor(oWeapon)))
  {
  case RACIAL_TYPE_GNOME:
  case RACIAL_TYPE_HALFLING:
  return TRUE;
  }
  /*if(!GetIsObjectValid(GetItemInSlot(INVENTORY_SLOT_LEFTHAND,GetItemPossessor(oWeapon))))
  {//SPECIAL: one handed weapon holded in two hands
  return TRUE;
  }*///guess this wont fit you
 }
return FALSE;
}


int GetIsLightWeapon(object oWeapon)
{
object oPC = GetItemPossessor(oWeapon);
object oRightWeapon = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND,oPC);
 if(oRightWeapon == oWeapon)
 return FALSE;
 if(StringToInt(Get2DAString("baseitems","WeaponSize",GetBaseItemType(oWeapon))) < GetCreatureSize(oPC))
 return TRUE;
return FALSE;
}


               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Need a couple functions
« Reply #2 on: December 08, 2011, 06:46:23 am »


               The first script looks good, though it doesn't consider epic minotaur shape and drider shape (large creature with large weapon) what I am posting below should be more robust.

int GetIsTwoHandedWeapon(object oWeapon)
{
if(oWeapon == OBJECT_INVALID)
 return FALSE;
object oCreature = GetItemPossessor(oWeapon);
int nWeaponSize = StringToInt(Get2DAString("baseitems", "WeaponSize",GetBaseItemType(oWeapon)));
if(GetWeaponRanged(oWeapon))
 return FALSE;
//Rules out base item type torch, and possible custom modifications to baseitems.2da
if(!StringToInt(Get2DAString("baseitems", "WeaponType", GetBaseItemType(oWeapon))))
 return FALSE;
int nCreatureSize = GetCreatureSize(oCreature);
if(nCreatureSize + 1 == nWeaponSize)
 return TRUE;
return FALSE;
}

For the second script torches could return as light weapons. A simple base item check should fix this easily.
               
               

               
            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Need a couple functions
« Reply #3 on: December 08, 2011, 06:48:29 am »


               Here's our item type functions, in case you're using CEP. Unfortunately they don't include a GetIsLightWeapon, since we use NWNX to alter that (our katanas are finesseable, by way of example):
[Edit] *Snip* Just realized both rely on NWNX, sorry.

Funky
               
               

               


                     Modifié par FunkySwerve, 08 décembre 2011 - 06:50 .
                     
                  


            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Need a couple functions
« Reply #4 on: December 08, 2011, 07:39:22 am »


               

WhiZard wrote...

The first script looks good, though it doesn't consider epic minotaur shape and drider shape (large creature with large weapon)

Does work.

For the second script torches could return as light weapons. A simple base item check should fix this easily.

yea right. Im using it after I find out its a weapon so I havent think of that so check whether baseitem matches shields/torch and if so return FALSE
               
               

               


                     Modifié par ShaDoOoW, 08 décembre 2011 - 07:42 .
                     
                  


            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Need a couple functions
« Reply #5 on: December 08, 2011, 07:25:03 pm »


               

ShaDoOoW wrote...

WhiZard wrote...

The first script looks good, though it doesn't consider epic minotaur shape and drider shape (large creature with large weapon)

Does work.


What I meant is epic minotaur and drider don't get the 2 handed strength bonus, but your script acknowledges them as two-handing a weapon.
               
               

               
            

Legacy_ShadowM

  • Hero Member
  • *****
  • Posts: 1373
  • Karma: +0/-0
Need a couple functions
« Reply #6 on: December 08, 2011, 10:17:11 pm »


               Thanks everyone, sorry it was so late to respond. I went to bed after posting the topic. I look over the functions and make some modifications. Thanks for making them for me. '<img'>
               
               

               
            

Legacy_ffbj

  • Hero Member
  • *****
  • Posts: 1097
  • Karma: +0/-0
Need a couple functions
« Reply #7 on: December 10, 2011, 06:12:30 pm »


               You do not differentiate between bows, which are 2-handed weapons.  The question is bit fuzzy for this reason.  If you only want to consider melee weapons then please so state.  If that is the case an easy way to do it would be to check the weight of the of the weapon by using:

 if (GetWeight(oItem) >12)
Or whatever the weight for the lightest 2-hander is. Of course if you have extremely light 2-handed weapons, by using weight reduction, this will not work, but if you do then what is the point of this script?
Simpler than listing all the weapons.
And the function to check if it's ranged:
if (GetWeaponRanged(oItem))
Unneeded if you are just interested in how much the thing weighs, which is what I'm guessing.
               
               

               


                     Modifié par ffbj, 10 décembre 2011 - 06:16 .
                     
                  


            

Legacy_ShadowM

  • Hero Member
  • *****
  • Posts: 1373
  • Karma: +0/-0
Need a couple functions
« Reply #8 on: December 10, 2011, 08:55:02 pm »


               I adjusted their functions to include bows, x-bows, custom base items etc.. and made them check the creature not just the weapon. Nope not interested in the weights. Many feats have call for checks of weapons they are wielding for there calculations. That what these functions are used for. '<img'>