Author Topic: Restrict armor  (Read 398 times)

Legacy_Surek

  • Full Member
  • ***
  • Posts: 169
  • Karma: +0/-0
Restrict armor
« on: March 19, 2015, 05:15:59 am »


               

I have a question about armor.

Is there any way to restrict a certain armor type from being worn by the PC through scripting?

Example, restricting the PC from wearing any type of heavy armor. Any ideas on how to do this would be greatly appreciated.



               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
Restrict armor
« Reply #1 on: March 19, 2015, 07:03:48 am »


               

The usual way to do this is in the module OnPlayerEquipItem event. For example, here is the CEP script which prevents wearing items if the custom gender restriction applies:


 



   Spoiler
   


 


In your example of heavy armour, you could check GetBaseItemType instead.



               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
Restrict armor
« Reply #2 on: March 19, 2015, 12:40:11 pm »


               

The armors will all have the same baseitem type so it gets a little more complicated. The type of the armor is based on the chest part's ACBONUS value, which in turn determines if it's light, medium or heavy.



   int nTorso = GetItemAppearance( oItem, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_TORSO);
   // Read 2DA for base AC
   string sACBase = Get2DAString( "parts_chest","ACBONUS", nTorso);
   int nAC = StringToInt(sACBase);

Then use nAC to determine if you consider this heavy armor or not. I think the game uses >= 6 for heavy.  Of course you'll want to check the base item type is armor before using the above or won't mean much.


               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
Restrict armor
« Reply #3 on: March 19, 2015, 05:52:08 pm »


               

The armors will all have the same baseitem type so it gets a little more complicated....

lol I remembered that shortly after posting - thanks for the correction.
               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
Restrict armor
« Reply #4 on: March 19, 2015, 08:33:50 pm »


               

I thought you probably knew that '<img'>  I was just giving a more complete soultion rather than trying to correct you.  



               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
Restrict armor
« Reply #5 on: March 19, 2015, 11:03:25 pm »


               No worries - it's just that I was driving around all day thinking "actually what I said was bollox" so glad you put it straight.