Aller au contenu

Photo

Need a couple functions


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

#1
ShadowM

ShadowM
  • Members
  • 768 messages
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 :). thanks in advance.

#2
Shadooow

Shadooow
  • Members
  • 4 474 messages

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;
}



#3
WhiZard

WhiZard
  • Members
  • 1 204 messages
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.

#4
FunkySwerve

FunkySwerve
  • Members
  • 1 308 messages
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 .


#5
Shadooow

Shadooow
  • Members
  • 4 474 messages

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 .


#6
WhiZard

WhiZard
  • Members
  • 1 204 messages

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.

#7
ShadowM

ShadowM
  • Members
  • 768 messages
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. :)

#8
ffbj

ffbj
  • Members
  • 593 messages
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 .


#9
ShadowM

ShadowM
  • Members
  • 768 messages
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. :)