Aller au contenu

Photo

2 hander AC


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

#1
0pie

0pie
  • Members
  • 37 messages
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.

#2
Shadooow

Shadooow
  • Members
  • 4 470 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(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 .


#3
0pie

0pie
  • Members
  • 37 messages
Thanks ShaDoOoW , I will try this out :)

#4
0pie

0pie
  • Members
  • 37 messages
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.

#5
0pie

0pie
  • Members
  • 37 messages
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 ?

#6
Shadooow

Shadooow
  • Members
  • 4 470 messages
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 .


#7
Shadooow

Shadooow
  • Members
  • 4 470 messages

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 .


#8
0pie

0pie
  • Members
  • 37 messages
Thank you SOOO much ShaDoOoW :) , my only problem now is Small races do not get AC from a shortbow.

#9
Shadooow

Shadooow
  • Members
  • 4 470 messages
really? they should if you updated the function with the one above...

#10
0pie

0pie
  • Members
  • 37 messages
lol ... your right ShaDoOoW , i'm sorry. But thanks for helping me with this it all works perfectly !

#11
Shadooow

Shadooow
  • Members
  • 4 470 messages
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:

#12
0pie

0pie
  • Members
  • 37 messages
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)

#13
Shadooow

Shadooow
  • Members
  • 4 470 messages
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

#14
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
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 ;
}
 

#15
Terrorble

Terrorble
  • Members
  • 194 messages

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.

#16
BCH

BCH
  • Members
  • 86 messages
Is there a way to make these methods work for NPCs?

I'm assuming that these scripts will go in OnPlayerEquipItem or a tag-based script, and that those don't work for NPCs.

#17
Shadooow

Shadooow
  • Members
  • 4 470 messages
Only if you would change AC type of weapons to shield and then you would add the armor bonus on weapon in their inventory

#18
BCH

BCH
  • Members
  • 86 messages
Thanks!

If you were going to do that for NPCs by script, would you put in their OnSpawn event, or somewhere else?

#19
Shadooow

Shadooow
  • Members
  • 4 470 messages
Well I don't know where you are getting those weapons for your creatures.

For example I have a script which makes a random weapon with random boosts in OnSpawn, so the weapon is not present in inventory in time the OnSpawn is fired and I would have to do it in my script or Acquire.

If they are already present in inventory, then you can use OnSpawn.

But this has very little sense if your creature is using one weapon all the time since you could "fake" that bonus via natural armor. Of course if the creature would have ranged weapon + dagger or if she would be disarmable there would be a reason to do it the way you want...

#20
BCH

BCH
  • Members
  • 86 messages
Part of the situation that I should have explained is that I also make this want to work for henchmen, who might have their equipment changed regularly by their PC masters.

(I'm running a virtual tabletop game that uses a lot of henchmen.)

I could handle PCs, henchmen, and town guards / monsters in three different ways, but I'd rather keep the scripts as few as possible.

I'm afraid I'll have to use the heartbeat event for NPCs, but people here often have extremely clever ways of doing things that I've never thought of. :D

#21
Shadooow

Shadooow
  • Members
  • 4 470 messages
I see. Then OnAcquire with conjuction with UnAcquire should work.

If henchman acquire a 2hand weapon then apply a temporary ac bonus on it (which would need to change the weapon ac type do shield or dodge if you want to count it into +20 cap) if this weapon is unacquire remove it.

This way would work also for players.

Modifié par ShaDoOoW, 10 avril 2011 - 08:05 .


#22
HUNTER_of_Wisdom

HUNTER_of_Wisdom
  • Members
  • 9 messages
Hello Gentlemen,
I'd like to make a SCRIPT similar to this, but my I'd like to maybe put in OnPlayerEquipItem, so that when the PC is using the SET full ARMOR001 + HELMT001, he will gain an AC bonus (DODGE) + 2, for example , could someone help me with this?