Advertisement
Guest User

syntax error, unexpected TOKEN_IF, expecting TOKEN_FUNCTION,

a guest
Oct 23rd, 2018
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 122.88 KB | None | 0 0
  1. /*
  2. Copyright © CD Projekt RED 2015
  3. */
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11. class IInventoryScriptedListener
  12. {
  13. event OnInventoryScriptedEvent( eventType : EInventoryEventType, itemId : SItemUniqueId, quantity : int, fromAssociatedInventory : bool ) {}
  14. }
  15.  
  16. import struct SItemNameProperty
  17. {
  18. import editable var itemName : name;
  19. };
  20.  
  21. import struct SR4LootNameProperty
  22. {
  23. import editable var lootName : name;
  24. };
  25.  
  26. struct SItemExt
  27. {
  28. editable var itemName : SItemNameProperty;
  29. editable var quantity : int;
  30. default quantity = 1;
  31. };
  32.  
  33.  
  34. import struct SItemChangedData
  35. {
  36. import const var itemName : name;
  37. import const var quantity : int;
  38. import const var informGui : bool;
  39. import const var ids : array< SItemUniqueId >;
  40. };
  41.  
  42. import class CInventoryComponent extends CComponent
  43. {
  44. editable var priceMult : float;
  45. editable var priceRepairMult : float;
  46. editable var priceRepair : float;
  47. editable var fundsType : EInventoryFundsType;
  48.  
  49. private var recentlyAddedItems : array<SItemUniqueId>;
  50. private var fundsMax : int;
  51. private var daysToIncreaseFunds : int;
  52.  
  53. default priceMult = 1.0;
  54. default priceRepairMult = 1.0;
  55. default priceRepair = 10.0;
  56. default fundsType = EInventoryFunds_Avg;
  57. default daysToIncreaseFunds = 5;
  58.  
  59.  
  60.  
  61.  
  62. public function GetFundsType() : EInventoryFundsType
  63. {
  64. return fundsType;
  65. }
  66.  
  67. public function GetDaysToIncreaseFunds() : int
  68. {
  69. return daysToIncreaseFunds;
  70. }
  71.  
  72. public function GetFundsMax() : float
  73. {
  74. if ( EInventoryFunds_Avg == fundsType )
  75. {
  76. return 5000;
  77. }
  78. else if ( EInventoryFunds_Poor == fundsType )
  79. {
  80. return 2500;
  81. }
  82. else if ( EInventoryFunds_Rich == fundsType )
  83. {
  84. return 7500;
  85. }
  86. return -1;
  87. }
  88.  
  89. public function SetupFunds()
  90. {
  91. if ( EInventoryFunds_Avg == fundsType )
  92. {
  93. AddMoney( (int)( 500 * GetFundsModifier() ) );
  94. }
  95. else if ( EInventoryFunds_Rich == fundsType )
  96. {
  97. AddMoney( (int)( 1000 * GetFundsModifier() ) );
  98. }
  99. else if ( EInventoryFunds_Poor == fundsType )
  100. {
  101. AddMoney( (int)( 200 * GetFundsModifier() ) );
  102. }
  103. }
  104.  
  105. public function IncreaseFunds()
  106. {
  107. if ( GetMoney() < GetFundsMax() )
  108. {
  109. if ( EInventoryFunds_Avg == fundsType )
  110. {
  111. AddMoney( (int)( 125 * GetFundsModifier()) );
  112. }
  113. else if ( EInventoryFunds_Poor == fundsType )
  114. {
  115. AddMoney( (int)( 100 * GetFundsModifier() ) );
  116. }
  117. else if ( EInventoryFunds_Rich == fundsType )
  118. {
  119. AddMoney( (int)( 500 * GetFundsModifier() ) );
  120. }
  121. }
  122. }
  123.  
  124. public function GetMoney() : int
  125. {
  126. return GetItemQuantityByName( 'Crowns' );
  127. }
  128.  
  129. public function AddMoney( amount : int )
  130. {
  131. if ( amount > 0 )
  132. {
  133. AddAnItem( 'Crowns', amount );
  134.  
  135. if ( thePlayer == GetEntity() )
  136. {
  137. theTelemetry.LogWithValue( TE_HERO_CASH_CHANGED, amount );
  138. }
  139. }
  140. }
  141.  
  142. public function RemoveMoney( amount : int )
  143. {
  144. if ( amount > 0 )
  145. {
  146. RemoveItemByName( 'Crowns', amount );
  147.  
  148. if ( thePlayer == GetEntity() )
  149. {
  150. theTelemetry.LogWithValue( TE_HERO_CASH_CHANGED, -amount );
  151. }
  152. }
  153. }
  154.  
  155.  
  156.  
  157.  
  158.  
  159. import final function GetItemAbilityAttributeValue( itemId : SItemUniqueId, attributeName : name, abilityName : name) : SAbilityAttributeValue;
  160.  
  161. import final function GetItemFromSlot( slotName : name ) : SItemUniqueId;
  162.  
  163.  
  164. import final function IsIdValid( itemId : SItemUniqueId ) : bool;
  165.  
  166.  
  167. import final function GetItemCount( optional useAssociatedInventory : bool ) : int;
  168.  
  169.  
  170. import final function GetItemsNames() : array< name >;
  171.  
  172.  
  173. import final function GetAllItems( out items : array< SItemUniqueId > );
  174.  
  175.  
  176. import final function GetItemsByTag( tag : name ) : array< SItemUniqueId >;
  177.  
  178.  
  179. import final function GetItemsByCategory( category : name ) : array< SItemUniqueId >;
  180.  
  181.  
  182. import final function GetSchematicIngredients(itemName : SItemUniqueId, out quantity : array<int>, out names : array<name>);
  183.  
  184.  
  185. import final function GetSchematicRequiredCraftsmanType(craftName : SItemUniqueId) : name;
  186.  
  187.  
  188. import final function GetSchematicRequiredCraftsmanLevel(craftName : SItemUniqueId) : name;
  189.  
  190.  
  191. import final function GetNumOfStackedItems( itemUniqueId: SItemUniqueId ) : int;
  192.  
  193. import final function InitInvFromTemplate( resource : CEntityTemplate );
  194.  
  195.  
  196.  
  197.  
  198.  
  199. import final function GetItemLocalizedNameByName( itemName : CName ) : string;
  200.  
  201.  
  202. import final function GetItemLocalizedDescriptionByName( itemName : CName ) : string;
  203.  
  204.  
  205. import final function GetItemLocalizedNameByUniqueID( itemUniqueId : SItemUniqueId ) : string;
  206.  
  207.  
  208. import final function GetItemLocalizedDescriptionByUniqueID( itemUniqueId : SItemUniqueId ) : string;
  209.  
  210.  
  211. import final function GetItemIconPathByUniqueID( itemUniqueId : SItemUniqueId ) : string;
  212.  
  213.  
  214. import final function GetItemIconPathByName( itemName : CName ) : string;
  215.  
  216.  
  217. import private final function BalanceItemsWithPlayerLevel( playerLevel : int );
  218.  
  219. public function ForceSpawnItemOnStart( itemId : SItemUniqueId ) : bool
  220. {
  221. return ItemHasTag(itemId, 'MutagenIngredient');
  222. }
  223.  
  224.  
  225. public final function GetItemArmorTotal(item : SItemUniqueId) : SAbilityAttributeValue
  226. {
  227. var armor, armorBonus : SAbilityAttributeValue;
  228. var durMult : float;
  229.  
  230. armor = GetItemAttributeValue(item, theGame.params.ARMOR_VALUE_NAME);
  231. armorBonus = GetRepairObjectBonusValueForArmor(item);
  232. durMult = theGame.params.GetDurabilityMultiplier( GetItemDurabilityRatio(item), false);
  233.  
  234. return armor * durMult + armorBonus;
  235. }
  236.  
  237. public final function GetItemLevel(item : SItemUniqueId) : int
  238. {
  239. var itemCategory : name;
  240. var itemAttributes : array<SAbilityAttributeValue>;
  241. var itemName : name;
  242. var isWitcherGear : bool;
  243. var isRelicGear : bool;
  244. var level : int;
  245.  
  246. itemCategory = GetItemCategory(item);
  247. itemName = GetItemName(item);
  248.  
  249. isWitcherGear = false;
  250. isRelicGear = false;
  251. if ( RoundMath(CalculateAttributeValue( GetItemAttributeValue(item, 'quality' ) )) == 5 ) isWitcherGear = true;
  252. if ( RoundMath(CalculateAttributeValue( GetItemAttributeValue(item, 'quality' ) )) == 4 ) isRelicGear = true;
  253.  
  254. switch(itemCategory)
  255. {
  256. case 'armor' :
  257. case 'boots' :
  258. case 'gloves' :
  259. case 'pants' :
  260. itemAttributes.PushBack( GetItemAttributeValue(item, 'armor') );
  261. break;
  262.  
  263. case 'silversword' :
  264. itemAttributes.PushBack( GetItemAttributeValue(item, 'SilverDamage') );
  265. itemAttributes.PushBack( GetItemAttributeValue(item, 'BludgeoningDamage') );
  266. itemAttributes.PushBack( GetItemAttributeValue(item, 'RendingDamage') );
  267. itemAttributes.PushBack( GetItemAttributeValue(item, 'ElementalDamage') );
  268. itemAttributes.PushBack( GetItemAttributeValue(item, 'FireDamage') );
  269. itemAttributes.PushBack( GetItemAttributeValue(item, 'PiercingDamage') );
  270. break;
  271.  
  272. case 'steelsword' :
  273. itemAttributes.PushBack( GetItemAttributeValue(item, 'SlashingDamage') );
  274. itemAttributes.PushBack( GetItemAttributeValue(item, 'BludgeoningDamage') );
  275. itemAttributes.PushBack( GetItemAttributeValue(item, 'RendingDamage') );
  276. itemAttributes.PushBack( GetItemAttributeValue(item, 'ElementalDamage') );
  277. itemAttributes.PushBack( GetItemAttributeValue(item, 'FireDamage') );
  278. itemAttributes.PushBack( GetItemAttributeValue(item, 'SilverDamage') );
  279. itemAttributes.PushBack( GetItemAttributeValue(item, 'PiercingDamage') );
  280. break;
  281.  
  282. case 'crossbow' :
  283. itemAttributes.PushBack( GetItemAttributeValue(item, 'attack_power') );
  284. break;
  285.  
  286. default :
  287. break;
  288. }
  289.  
  290. level = theGame.params.GetItemLevel(itemCategory, itemAttributes, itemName);
  291.  
  292. if ( isWitcherGear ) level = level - 2;
  293. if ( isRelicGear ) level = level - 1;
  294. if ( level < 1 ) level = 1;
  295.  
  296. return level;
  297. }
  298.  
  299. public function GetItemLevelColorById( itemId : SItemUniqueId ) : string
  300. {
  301. var color : string;
  302.  
  303. if (thePlayer.HasRequiredLevelToEquipItem(itemId))
  304. {
  305. color = "<font color = '#A09588'>";
  306. }
  307. else
  308. {
  309. color = "<font color = '#9F1919'>";
  310. }
  311.  
  312. return color;
  313. }
  314.  
  315. public function GetItemLevelColor( lvl_item : int ) : string
  316. {
  317. var color : string;
  318.  
  319. if ( lvl_item > thePlayer.GetLevel() )
  320. {
  321. color = "<font color = '#9F1919'>";
  322. } else
  323. {
  324. color = "<font color = '#A09588'>";
  325. }
  326.  
  327. return color;
  328. }
  329.  
  330. public final function AutoBalanaceItemsWithPlayerLevel()
  331. {
  332. var playerLevel : int;
  333.  
  334. playerLevel = thePlayer.GetLevel();
  335.  
  336. if( playerLevel < 0 )
  337. {
  338. playerLevel = 0;
  339. }
  340.  
  341. BalanceItemsWithPlayerLevel( playerLevel );
  342. }
  343.  
  344. public function GetItemsByName(itemName : name) : array<SItemUniqueId>
  345. {
  346. var ret : array<SItemUniqueId>;
  347. var i : int;
  348.  
  349. if(!IsNameValid(itemName))
  350. return ret;
  351.  
  352. GetAllItems(ret);
  353.  
  354. for(i=ret.Size()-1; i>=0; i-=1)
  355. {
  356. if(GetItemName(ret[i]) != itemName)
  357. {
  358. ret.EraseFast( i );
  359. }
  360. }
  361.  
  362. return ret;
  363. }
  364.  
  365. public final function GetSingletonItems() : array<SItemUniqueId>
  366. {
  367. return GetItemsByTag(theGame.params.TAG_ITEM_SINGLETON);
  368. }
  369.  
  370.  
  371. import final function GetItemQuantityByName( itemName : name, optional useAssociatedInventory : bool ) : int;
  372.  
  373.  
  374. import final function GetItemQuantityByCategory( itemCategory : name, optional useAssociatedInventory : bool ) : int;
  375.  
  376.  
  377. import final function GetItemQuantityByTag( itemTag : name, optional useAssociatedInventory : bool ) : int;
  378.  
  379.  
  380. import final function GetAllItemsQuantity( optional useAssociatedInventory : bool ) : int;
  381.  
  382.  
  383. public function IsEmpty(optional bSkipNoDropNoShow : bool) : bool
  384. {
  385. var i : int;
  386. var itemIds : array<SItemUniqueId>;
  387.  
  388. if(bSkipNoDropNoShow)
  389. {
  390. GetAllItems( itemIds );
  391. for( i = itemIds.Size() - 1; i >= 0; i -= 1 )
  392. {
  393. if( !ItemHasTag( itemIds[ i ],theGame.params.TAG_DONT_SHOW ) && !ItemHasTag( itemIds[ i ], 'NoDrop' ) )
  394. {
  395. return false;
  396. }
  397. else if ( ItemHasTag( itemIds[ i ], 'Lootable') )
  398. {
  399. return false;
  400. }
  401. }
  402.  
  403. return true;
  404. }
  405.  
  406. return GetItemCount() <= 0;
  407. }
  408.  
  409.  
  410. public function GetAllHeldAndMountedItemsCategories( out heldItems : array<name>, optional out mountedItems : array<name> )
  411. {
  412. var allItems : array<SItemUniqueId>;
  413. var i : int;
  414.  
  415. GetAllItems(allItems);
  416. for(i=allItems.Size()-1; i >= 0; i-=1)
  417. {
  418. if ( IsItemHeld(allItems[i]) )
  419. heldItems.PushBack(GetItemCategory(allItems[i]));
  420. else if ( IsItemMounted(allItems[i]) )
  421. mountedItems.PushBack(GetItemCategory(allItems[i]));
  422. }
  423. }
  424.  
  425. public function GetAllHeldItemsNames( out heldItems : array<name> )
  426. {
  427. var allItems : array<SItemUniqueId>;
  428. var i : int;
  429.  
  430. GetAllItems(allItems);
  431. for(i=allItems.Size()-1; i >= 0; i-=1)
  432. {
  433. if ( IsItemHeld(allItems[i]) )
  434. heldItems.PushBack(GetItemName(allItems[i]));
  435. }
  436. }
  437.  
  438. public function HasMountedItemByTag(tag : name) : bool
  439. {
  440. var i : int;
  441. var allItems : array<SItemUniqueId>;
  442.  
  443. if(!IsNameValid(tag))
  444. return false;
  445.  
  446. allItems = GetItemsByTag(tag);
  447. for(i=0; i<allItems.Size(); i+=1)
  448. if(IsItemMounted(allItems[i]))
  449. return true;
  450.  
  451. return false;
  452. }
  453.  
  454. public function HasHeldOrMountedItemByTag(tag : name) : bool
  455. {
  456. var i : int;
  457. var allItems : array<SItemUniqueId>;
  458.  
  459. if(!IsNameValid(tag))
  460. return false;
  461.  
  462. allItems = GetItemsByTag(tag);
  463. for(i=0; i<allItems.Size(); i+=1)
  464. if( IsItemMounted(allItems[i]) || IsItemHeld(allItems[i]) )
  465. return true;
  466.  
  467. return false;
  468. }
  469.  
  470.  
  471. public function GetItemsIds(itemName : name) : array<SItemUniqueId>
  472. {
  473. var allItems : array<SItemUniqueId>;
  474. var i : int;
  475. var localItemName : name;
  476.  
  477. GetAllItems( allItems );
  478. for(i=allItems.Size()-1; i >= 0; i-=1)
  479. {
  480. localItemName = GetItemName(allItems[i]);
  481. if(localItemName != itemName || !IsIdValid( allItems[i]) )
  482. {
  483. allItems.EraseFast( i );
  484. }
  485. }
  486.  
  487. return allItems;
  488. }
  489.  
  490.  
  491. import final function GetItem( itemId : SItemUniqueId ) : SInventoryItem;
  492.  
  493.  
  494. import final function GetItemName( itemId : SItemUniqueId ) : name;
  495.  
  496.  
  497. import final function GetItemCategory( itemId : SItemUniqueId ) : name;
  498.  
  499.  
  500. import final function GetItemClass( itemId : SItemUniqueId ) : EInventoryItemClass;
  501.  
  502.  
  503. import final function GetItemTags( itemId : SItemUniqueId, out tags : array<name> ) : bool;
  504.  
  505.  
  506. import final function GetCraftedItemName( itemId : SItemUniqueId ) : name;
  507.  
  508.  
  509. import final function TotalItemStats( invItem : SInventoryItem ) : float;
  510.  
  511. import final function GetItemPrice( itemId : SItemUniqueId ) : int;
  512.  
  513.  
  514. import final function GetItemPriceModified( itemId : SItemUniqueId, optional playerSellingItem : Bool ) : int;
  515.  
  516.  
  517. import final function GetInventoryItemPriceModified( invItem : SInventoryItem, optional playerSellingItem : Bool ) : int;
  518.  
  519.  
  520. import final function GetItemPriceRepair( invItem : SInventoryItem, out costRepairPoint : int, out costRepairTotal : int );
  521.  
  522.  
  523. import final function GetItemPriceRemoveUpgrade( invItem : SInventoryItem ) : int;
  524.  
  525.  
  526. import final function GetItemPriceDisassemble( invItem : SInventoryItem ) : int;
  527.  
  528. import final function GetFundsModifier() : float;
  529.  
  530.  
  531. import final function GetItemQuantity( itemId : SItemUniqueId ) : int;
  532.  
  533.  
  534. import final function ItemHasTag( itemId : SItemUniqueId, tag : name ) : bool;
  535.  
  536.  
  537. import final function AddItemTag( itemId : SItemUniqueId, tag : name ) : bool;
  538.  
  539.  
  540. import final function RemoveItemTag( itemId : SItemUniqueId, tag : name ) : bool;
  541.  
  542.  
  543. import final function GetItemByItemEntity( itemEntity : CItemEntity ) : SItemUniqueId;
  544.  
  545.  
  546. public function ItemHasAbility(item : SItemUniqueId, abilityName : name) : bool
  547. {
  548. var abilities : array<name>;
  549.  
  550. GetItemAbilities(item, abilities);
  551. return abilities.Contains(abilityName);
  552. }
  553.  
  554. import final function GetItemAttributeValue( itemId : SItemUniqueId, attributeName : name, optional abilityTags : array< name >, optional withoutTags : bool ) : SAbilityAttributeValue;
  555.  
  556.  
  557. import final function GetItemBaseAttributes( itemId : SItemUniqueId, out attributes : array<name> );
  558.  
  559.  
  560. import final function GetItemAttributes( itemId : SItemUniqueId, out attributes : array<name> );
  561.  
  562.  
  563. import final function GetItemAbilities( itemId : SItemUniqueId, out abilities : array<name> );
  564.  
  565.  
  566. import final function GetItemContainedAbilities( itemId : SItemUniqueId, out abilities : array<name> );
  567.  
  568.  
  569. public function GetItemAbilitiesWithAttribute(id : SItemUniqueId, attributeName : name, attributeVal : float) : array<name>
  570. {
  571. var i : int;
  572. var abs, ret : array<name>;
  573. var dm : CDefinitionsManagerAccessor;
  574. var val : float;
  575. var min, max : SAbilityAttributeValue;
  576.  
  577. GetItemAbilities(id, abs);
  578. dm = theGame.GetDefinitionsManager();
  579.  
  580. for(i=0; i<abs.Size(); i+=1)
  581. {
  582. dm.GetAbilityAttributeValue(abs[i], attributeName, min, max);
  583. val = CalculateAttributeValue(GetAttributeRandomizedValue(min, max));
  584.  
  585. if(val == attributeVal)
  586. ret.PushBack(abs[i]);
  587. }
  588.  
  589. return ret;
  590. }
  591. public function GetItemAbilitiesWithTag( itemId : SItemUniqueId, tag : name, out abilities : array<name> )
  592. {
  593. var i : int;
  594. var dm : CDefinitionsManagerAccessor;
  595. var allAbilities : array<name>;
  596.  
  597. dm = theGame.GetDefinitionsManager();
  598. GetItemAbilities(itemId, allAbilities);
  599.  
  600. for(i=0; i<allAbilities.Size(); i+=1)
  601. {
  602. if(dm.AbilityHasTag(allAbilities[i], tag))
  603. {
  604. abilities.PushBack(allAbilities[i]);
  605. }
  606. }
  607. }
  608.  
  609.  
  610.  
  611.  
  612. import private final function GiveItem( otherInventory : CInventoryComponent, itemId : SItemUniqueId, optional quantity : int ) : array<SItemUniqueId>;
  613.  
  614. public final function GiveMoneyTo(otherInventory : CInventoryComponent, optional quantity : int, optional informGUI : bool )
  615. {
  616. var moneyId : array<SItemUniqueId>;
  617.  
  618. moneyId = GetItemsByName('Crowns');
  619. GiveItemTo(otherInventory, moneyId[0], quantity, false, true, informGUI);
  620. }
  621.  
  622. public final function GiveItemTo( otherInventory : CInventoryComponent, itemId : SItemUniqueId, optional quantity : int, optional refreshNewFlag : bool, optional forceTransferNoDrops : bool, optional informGUI : bool ) : SItemUniqueId
  623. {
  624. var arr : array<SItemUniqueId>;
  625. var itemName : name;
  626. var i : int;
  627. var uiData : SInventoryItemUIData;
  628.  
  629.  
  630. if(quantity == 0)
  631. quantity = 1;
  632.  
  633. quantity = Clamp(quantity, 0, GetItemQuantity(itemId));
  634. if(quantity == 0)
  635. return GetInvalidUniqueId();
  636.  
  637. itemName = GetItemName(itemId);
  638.  
  639. if(!forceTransferNoDrops && ( ItemHasTag(itemId, 'NoDrop') && !ItemHasTag(itemId, 'Lootable') ))
  640. {
  641. LogItems("Cannot transfer item <<" + itemName + ">> as it has the NoDrop tag set!!!");
  642. return GetInvalidUniqueId();
  643. }
  644.  
  645.  
  646. if(IsItemSingletonItem(itemId))
  647. {
  648.  
  649. if(otherInventory == thePlayer.inv && otherInventory.GetItemQuantityByName(itemName) > 0)
  650. {
  651. LogAssert(false, "CInventoryComponent.GiveItemTo: cannot add singleton item as player already has this item!");
  652. return GetInvalidUniqueId();
  653. }
  654.  
  655. else
  656. {
  657. arr = GiveItem(otherInventory, itemId, quantity);
  658. }
  659. }
  660. else
  661. {
  662.  
  663. arr = GiveItem(otherInventory, itemId, quantity);
  664. }
  665.  
  666.  
  667. if(otherInventory == thePlayer.inv)
  668. {
  669. theTelemetry.LogWithLabelAndValue(TE_INV_ITEM_PICKED, itemName, quantity);
  670. if ( !theGame.AreSavesLocked() && ( this.IsItemQuest( itemId ) || this.GetItemQuality( itemId ) >= 4 ) )
  671. theGame.RequestAutoSave( "item gained", false );
  672. }
  673.  
  674. if (refreshNewFlag)
  675. {
  676. for (i = 0; i < arr.Size(); i += 1)
  677. {
  678. uiData = otherInventory.GetInventoryItemUIData( arr[i] );
  679. uiData.isNew = true;
  680. otherInventory.SetInventoryItemUIData( arr[i], uiData );
  681. }
  682. }
  683.  
  684. return arr[0];
  685. }
  686.  
  687. public final function GiveAllItemsTo(otherInventory : CInventoryComponent, optional forceTransferNoDrops : bool, optional informGUI : bool)
  688. {
  689. var items : array<SItemUniqueId>;
  690.  
  691. GetAllItems(items);
  692. GiveItemsTo(otherInventory, items, forceTransferNoDrops, informGUI);
  693. }
  694.  
  695. public final function GiveItemsTo(otherInventory : CInventoryComponent, items : array<SItemUniqueId>, optional forceTransferNoDrops : bool, optional informGUI : bool) : array<SItemUniqueId>
  696. {
  697. var i : int;
  698. var ret : array<SItemUniqueId>;
  699.  
  700. for( i = 0; i < items.Size(); i += 1 )
  701. {
  702. ret.PushBack(GiveItemTo(otherInventory, items[i], GetItemQuantity(items[i]), true, forceTransferNoDrops, informGUI));
  703. }
  704.  
  705. return ret;
  706. }
  707.  
  708.  
  709. import final function HasItem( item : name ) : bool;
  710.  
  711.  
  712.  
  713. final function HasItemById(id : SItemUniqueId) : bool
  714. {
  715. var arr : array<SItemUniqueId>;
  716.  
  717. GetAllItems(arr);
  718. return arr.Contains(id);
  719. }
  720.  
  721. public function HasItemByTag(tag : name) : bool
  722. {
  723. var temp : array<SItemUniqueId>;
  724.  
  725. temp = GetItemsByTag(tag);
  726. return temp.Size() > 0;
  727. }
  728.  
  729.  
  730. public function HasInfiniteBolts() : bool
  731. {
  732. var ids : array<SItemUniqueId>;
  733. var i : int;
  734.  
  735. ids = GetItemsByTag(theGame.params.TAG_INFINITE_AMMO);
  736. for(i=0; i<ids.Size(); i+=1)
  737. {
  738. if(IsItemBolt(ids[i]))
  739. {
  740. return true;
  741. }
  742. }
  743.  
  744. return false;
  745. }
  746.  
  747.  
  748. public function HasGroundBolts() : bool
  749. {
  750. var ids : array<SItemUniqueId>;
  751. var i : int;
  752.  
  753. ids = GetItemsByTag(theGame.params.TAG_GROUND_AMMO);
  754. for(i=0; i<ids.Size(); i+=1)
  755. {
  756. if(IsItemBolt(ids[i]))
  757. {
  758. return true;
  759. }
  760. }
  761.  
  762. return false;
  763. }
  764.  
  765.  
  766. public function HasUnderwaterBolts() : bool
  767. {
  768. var ids : array<SItemUniqueId>;
  769. var i : int;
  770.  
  771. ids = GetItemsByTag(theGame.params.TAG_UNDERWATER_AMMO);
  772. for(i=0; i<ids.Size(); i+=1)
  773. {
  774. if(IsItemBolt(ids[i]))
  775. {
  776. return true;
  777. }
  778. }
  779.  
  780. return false;
  781. }
  782.  
  783.  
  784.  
  785. import private final function AddMultiItem( item : name, optional quantity : int, optional informGui : bool , optional markAsNew : bool , optional lootable : bool ) : array<SItemUniqueId>;
  786. import private final function AddSingleItem( item : name, optional informGui : bool , optional markAsNew : bool , optional lootable : bool ) : SItemUniqueId;
  787.  
  788.  
  789. public final function AddAnItem(item : name, optional quantity : int, optional dontInformGui : bool, optional dontMarkAsNew : bool, optional showAsRewardInUI : bool) : array<SItemUniqueId>
  790. {
  791. var arr : array<SItemUniqueId>;
  792. var i : int;
  793. var isReadableItem : bool;
  794.  
  795.  
  796. if( theGame.GetDefinitionsManager().IsItemSingletonItem(item) && GetEntity() == thePlayer)
  797. {
  798. if(GetItemQuantityByName(item) > 0)
  799. {
  800. arr = GetItemsIds(item);
  801. }
  802. else
  803. {
  804. arr.PushBack(AddSingleItem(item, !dontInformGui, !dontMarkAsNew));
  805. }
  806.  
  807. quantity = 1;
  808. }
  809. else
  810. {
  811. if(quantity < 2 )
  812. {
  813. arr.PushBack(AddSingleItem(item, !dontInformGui, !dontMarkAsNew));
  814. }
  815. else
  816. {
  817. arr = AddMultiItem(item, quantity, !dontInformGui, !dontMarkAsNew);
  818. }
  819. }
  820.  
  821.  
  822. if(this == thePlayer.GetInventory())
  823. {
  824. if(ItemHasTag(arr[0],'ReadableItem'))
  825. UpdateInitialReadState(arr[0]);
  826.  
  827.  
  828. if(showAsRewardInUI || ItemHasTag(arr[0],'GwintCard'))
  829. thePlayer.DisplayItemRewardNotification(GetItemName(arr[0]), quantity );
  830. }
  831.  
  832. return arr;
  833. }
  834.  
  835.  
  836. import final function RemoveItem( itemId : SItemUniqueId, optional quantity : int ) : bool;
  837.  
  838.  
  839. private final function InternalRemoveItems(ids : array<SItemUniqueId>, quantity : int)
  840. {
  841. var i, currQuantityToTake : int;
  842.  
  843.  
  844. for(i=0; i<ids.Size(); i+=1 )
  845. {
  846.  
  847. currQuantityToTake = Min(quantity, GetItemQuantity(ids[i]) );
  848.  
  849.  
  850. if( GetEntity() == thePlayer )
  851. {
  852. GetWitcherPlayer().RemoveGwentCard( GetItemName(ids[i]) , currQuantityToTake);
  853. }
  854.  
  855.  
  856. RemoveItem(ids[i], currQuantityToTake);
  857.  
  858.  
  859. quantity -= currQuantityToTake;
  860.  
  861.  
  862. if ( quantity == 0 )
  863. {
  864. return;
  865. }
  866.  
  867.  
  868. LogAssert(quantity>0, "CInventoryComponent.InternalRemoveItems(" + GetItemName(ids[i]) + "): somehow took too many items! Should be " + (-quantity) + " less... Investigate!");
  869. }
  870. }
  871.  
  872.  
  873.  
  874. public function RemoveItemByName(itemName : name, optional quantity : int) : bool
  875. {
  876. var totalItemCount : int;
  877. var ids : array<SItemUniqueId>;
  878.  
  879.  
  880. totalItemCount = GetItemQuantityByName(itemName);
  881. if(totalItemCount < quantity || quantity == 0)
  882. {
  883. return false;
  884. }
  885.  
  886. if(quantity == 0)
  887. {
  888. quantity = 1;
  889. }
  890. else if(quantity < 0)
  891. {
  892. quantity = totalItemCount;
  893. }
  894.  
  895. ids = GetItemsIds(itemName);
  896.  
  897. if(GetEntity() == thePlayer && thePlayer.GetSelectedItemId() == ids[0] )
  898. {
  899. thePlayer.ClearSelectedItemId();
  900. }
  901.  
  902. InternalRemoveItems(ids, quantity);
  903.  
  904. return true;
  905. }
  906.  
  907.  
  908.  
  909. public function RemoveItemByCategory(itemCategory : name, optional quantity : int) : bool
  910. {
  911. var totalItemCount : int;
  912. var ids : array<SItemUniqueId>;
  913. var selectedItemId : SItemUniqueId;
  914. var i : int;
  915.  
  916.  
  917. totalItemCount = GetItemQuantityByCategory(itemCategory);
  918. if(totalItemCount < quantity)
  919. {
  920. return false;
  921. }
  922.  
  923. if(quantity == 0)
  924. {
  925. quantity = 1;
  926. }
  927. else if(quantity < 0)
  928. {
  929. quantity = totalItemCount;
  930. }
  931.  
  932. ids = GetItemsByCategory(itemCategory);
  933.  
  934. if(GetEntity() == thePlayer)
  935. {
  936. selectedItemId = thePlayer.GetSelectedItemId();
  937. for(i=0; i<ids.Size(); i+=1)
  938. {
  939. if(selectedItemId == ids[i] )
  940. {
  941. thePlayer.ClearSelectedItemId();
  942. break;
  943. }
  944. }
  945. }
  946.  
  947. InternalRemoveItems(ids, quantity);
  948.  
  949. return true;
  950. }
  951.  
  952.  
  953.  
  954. public function RemoveItemByTag(itemTag : name, optional quantity : int) : bool
  955. {
  956. var totalItemCount : int;
  957. var ids : array<SItemUniqueId>;
  958. var i : int;
  959. var selectedItemId : SItemUniqueId;
  960.  
  961.  
  962. totalItemCount = GetItemQuantityByTag(itemTag);
  963. if(totalItemCount < quantity)
  964. {
  965. return false;
  966. }
  967.  
  968. if(quantity == 0)
  969. {
  970. quantity = 1;
  971. }
  972. else if(quantity < 0)
  973. {
  974. quantity = totalItemCount;
  975. }
  976.  
  977. ids = GetItemsByTag(itemTag);
  978.  
  979. if(GetEntity() == thePlayer)
  980. {
  981. selectedItemId = thePlayer.GetSelectedItemId();
  982. for(i=0; i<ids.Size(); i+=1)
  983. {
  984. if(selectedItemId == ids[i] )
  985. {
  986. thePlayer.ClearSelectedItemId();
  987. break;
  988. }
  989. }
  990. }
  991.  
  992. InternalRemoveItems(ids, quantity);
  993.  
  994. return true;
  995. }
  996.  
  997.  
  998. import final function RemoveAllItems();
  999.  
  1000.  
  1001. import final function GetItemEntityUnsafe( itemId : SItemUniqueId ) : CItemEntity;
  1002.  
  1003.  
  1004. import final function GetDeploymentItemEntity( itemId : SItemUniqueId, optional position : Vector, optional rotation : EulerAngles, optional allocateIdTag : bool ) : CEntity;
  1005.  
  1006.  
  1007. import final function MountItem( itemId : SItemUniqueId, optional toHand : bool, optional force : bool ) : bool;
  1008.  
  1009.  
  1010. import final function UnmountItem( itemId : SItemUniqueId, optional destroyEntity : bool ) : bool;
  1011.  
  1012.  
  1013.  
  1014. import final function IsItemMounted( itemId : SItemUniqueId ) : bool;
  1015.  
  1016.  
  1017.  
  1018. import final function IsItemHeld( itemId : SItemUniqueId ) : bool;
  1019.  
  1020.  
  1021. import final function DropItem( itemId : SItemUniqueId, optional removeFromInv : bool );
  1022.  
  1023.  
  1024. import final function GetItemHoldSlot( itemId : SItemUniqueId ) : name;
  1025.  
  1026.  
  1027. import final function PlayItemEffect( itemId : SItemUniqueId, effectName : name );
  1028. import final function StopItemEffect( itemId : SItemUniqueId, effectName : name );
  1029.  
  1030.  
  1031. import final function ThrowAwayItem( itemId : SItemUniqueId, optional quantity : int ) : bool;
  1032.  
  1033.  
  1034. import final function ThrowAwayAllItems() : CEntity;
  1035.  
  1036.  
  1037. import final function ThrowAwayItemsFiltered( excludedTags : array< name > ) : CEntity;
  1038.  
  1039.  
  1040. import final function ThrowAwayLootableItems( optional skipNoDropNoShow : bool ) : CEntity;
  1041.  
  1042.  
  1043. import final function GetItemRecyclingParts( itemId : SItemUniqueId ) : array<SItemParts>;
  1044.  
  1045. import final function GetItemWeight( id : SItemUniqueId ) : float;
  1046.  
  1047.  
  1048. public final function HasQuestItem() : bool
  1049. {
  1050. var allItems : array< SItemUniqueId >;
  1051. var i : int;
  1052.  
  1053. allItems = GetItemsByTag('Quest');
  1054. for ( i=0; i<allItems.Size(); i+=1 )
  1055. {
  1056. if(!ItemHasTag(allItems[i], theGame.params.TAG_DONT_SHOW))
  1057. {
  1058. return true;
  1059. }
  1060. }
  1061.  
  1062. return false;
  1063. }
  1064.  
  1065.  
  1066.  
  1067.  
  1068.  
  1069.  
  1070. import final function HasItemDurability( itemId : SItemUniqueId ) : bool;
  1071. import final function GetItemDurability( itemId : SItemUniqueId ) : float;
  1072. import private final function SetItemDurability( itemId : SItemUniqueId, durability : float );
  1073. import final function GetItemInitialDurability( itemId : SItemUniqueId ) : float;
  1074. import final function GetItemMaxDurability( itemId : SItemUniqueId ) : float;
  1075. import final function GetItemGridSize( itemId : SItemUniqueId ) : int;
  1076.  
  1077.  
  1078. import final function NotifyItemLooted( item : SItemUniqueId );
  1079. import final function ResetContainerData();
  1080.  
  1081. public function SetItemDurabilityScript( itemId : SItemUniqueId, durability : float )
  1082. {
  1083. var oldDur : float;
  1084.  
  1085. oldDur = GetItemDurability(itemId);
  1086.  
  1087. if(oldDur == durability)
  1088. return;
  1089.  
  1090. if(durability < oldDur)
  1091. {
  1092. if ( ItemHasAbility( itemId, 'MA_Indestructible' ) )
  1093. {
  1094. return;
  1095. }
  1096.  
  1097. if(GetEntity() == thePlayer && ShouldProcessTutorial('TutorialDurability'))
  1098. {
  1099. if ( durability <= theGame.params.ITEM_DAMAGED_DURABILITY && oldDur > theGame.params.ITEM_DAMAGED_DURABILITY )
  1100. {
  1101. FactsAdd( "tut_item_damaged", 1 );
  1102. }
  1103. }
  1104. }
  1105.  
  1106. SetItemDurability( itemId, durability );
  1107. }
  1108.  
  1109.  
  1110. public function ReduceItemDurability(itemId : SItemUniqueId, optional forced : bool) : bool
  1111. {
  1112. var dur, value, durabilityDiff, itemToughness : float;
  1113. var chance : int;
  1114. if(!IsIdValid(itemId) || !HasItemDurability(itemId) || ItemHasAbility(itemId, 'MA_Indestructible'))
  1115. {
  1116. return false;
  1117. }
  1118.  
  1119.  
  1120. if(IsItemWeapon(itemId))
  1121. {
  1122. chance = theGame.params.DURABILITY_WEAPON_LOSE_CHANCE;
  1123. value = theGame.params.GetWeaponDurabilityLoseValue();
  1124. }
  1125. else if(IsItemAnyArmor(itemId))
  1126. {
  1127. chance = theGame.params.DURABILITY_ARMOR_LOSE_CHANCE;
  1128. value = theGame.params.DURABILITY_ARMOR_LOSE_VALUE;
  1129. }
  1130.  
  1131. dur = GetItemDurability(itemId);
  1132.  
  1133. if ( dur == 0 )
  1134. {
  1135. return false;
  1136. }
  1137.  
  1138.  
  1139. if ( forced || RandRange( 100 ) < chance )
  1140. {
  1141. itemToughness = CalculateAttributeValue( GetItemAttributeValue( itemId, 'toughness' ) );
  1142.  
  1143. if ( itemToughness > 0.0f && itemToughness <= 1.0f )
  1144. {
  1145. durabilityDiff = ( dur - value ) * itemToughness;
  1146.  
  1147. SetItemDurabilityScript( itemId, MaxF(durabilityDiff, 0 ) );
  1148. }
  1149. else
  1150. {
  1151. SetItemDurabilityScript( itemId, MaxF( dur - value, 0 ) );
  1152. }
  1153. }
  1154.  
  1155. return true;
  1156. }
  1157.  
  1158. public function GetItemDurabilityRatio(itemId : SItemUniqueId) : float
  1159. {
  1160. if ( !IsIdValid( itemId ) || !HasItemDurability( itemId ) )
  1161. return -1;
  1162.  
  1163. return GetItemDurability(itemId) / GetItemMaxDurability(itemId);
  1164. }
  1165.  
  1166.  
  1167.  
  1168.  
  1169.  
  1170.  
  1171. public function GetItemResistStatWithDurabilityModifiers(itemId : SItemUniqueId, stat : ECharacterDefenseStats, out points : SAbilityAttributeValue, out percents : SAbilityAttributeValue)
  1172. {
  1173. var mult : float;
  1174. var null : SAbilityAttributeValue;
  1175.  
  1176. points = null;
  1177. percents = null;
  1178. if(!IsItemAnyArmor(itemId))
  1179. return;
  1180.  
  1181. mult = theGame.params.GetDurabilityMultiplier(GetItemDurabilityRatio(itemId), false);
  1182.  
  1183. points = GetItemAttributeValue(itemId, ResistStatEnumToName(stat, true));
  1184. percents = GetItemAttributeValue(itemId, ResistStatEnumToName(stat, false));
  1185.  
  1186. points = points * mult;
  1187. percents = percents * mult;
  1188. }
  1189.  
  1190.  
  1191. public function GetItemResistanceTypes(id : SItemUniqueId) : array<ECharacterDefenseStats>
  1192. {
  1193. var ret : array<ECharacterDefenseStats>;
  1194. var i : int;
  1195. var stat : ECharacterDefenseStats;
  1196. var atts : array<name>;
  1197. var tmpBool : bool;
  1198.  
  1199. if(!IsIdValid(id))
  1200. return ret;
  1201.  
  1202. GetItemAttributes(id, atts);
  1203. for(i=0; i<atts.Size(); i+=1)
  1204. {
  1205. stat = ResistStatNameToEnum(atts[i], tmpBool);
  1206. if(stat != CDS_None && !ret.Contains(stat))
  1207. ret.PushBack(stat);
  1208. }
  1209.  
  1210. return ret;
  1211. }
  1212.  
  1213. import final function GetItemModifierFloat( itemId : SItemUniqueId, modName : name, optional defValue : float ) : float;
  1214. import final function SetItemModifierFloat( itemId : SItemUniqueId, modName : name, val : float);
  1215. import final function GetItemModifierInt ( itemId : SItemUniqueId, modName : name, optional defValue : int ) : int;
  1216. import final function SetItemModifierInt ( itemId : SItemUniqueId, modName : name, val : int );
  1217.  
  1218.  
  1219. import final function ActivateQuestBonus();
  1220.  
  1221.  
  1222. import final function GetItemSetName( itemId : SItemUniqueId ) : name;
  1223.  
  1224.  
  1225. import final function AddItemCraftedAbility( itemId : SItemUniqueId, abilityName : name, optional allowDuplicate : bool );
  1226.  
  1227.  
  1228. import final function RemoveItemCraftedAbility( itemId : SItemUniqueId, abilityName : name );
  1229.  
  1230.  
  1231. import final function AddItemBaseAbility(item : SItemUniqueId, abilityName : name);
  1232.  
  1233.  
  1234. import final function RemoveItemBaseAbility(item : SItemUniqueId, abilityName : name);
  1235.  
  1236.  
  1237. import final function DespawnItem( itemId : SItemUniqueId );
  1238.  
  1239.  
  1240.  
  1241.  
  1242.  
  1243.  
  1244. import final function GetInventoryItemUIData( item : SItemUniqueId ) : SInventoryItemUIData;
  1245.  
  1246.  
  1247. import final function SetInventoryItemUIData( item : SItemUniqueId, data : SInventoryItemUIData );
  1248.  
  1249. import final function SortInventoryUIData();
  1250.  
  1251.  
  1252.  
  1253.  
  1254.  
  1255.  
  1256. import final function PrintInfo();
  1257.  
  1258.  
  1259.  
  1260.  
  1261.  
  1262.  
  1263. import final function EnableLoot( enable : bool );
  1264.  
  1265.  
  1266. import final function UpdateLoot();
  1267.  
  1268.  
  1269. import final function AddItemsFromLootDefinition( lootDefinitionName : name );
  1270.  
  1271.  
  1272. import final function IsLootRenewable() : bool;
  1273.  
  1274.  
  1275. import final function IsReadyToRenew() : bool;
  1276.  
  1277.  
  1278.  
  1279.  
  1280.  
  1281.  
  1282. function Created()
  1283. {
  1284. LoadBooksDefinitions();
  1285. }
  1286.  
  1287. function ClearGwintCards()
  1288. {
  1289. var attr : SAbilityAttributeValue;
  1290. var allItems : array<SItemUniqueId>;
  1291. var card : array<SItemUniqueId>;
  1292. var iHave, shopHave : int;
  1293. var i : int;
  1294.  
  1295. allItems = GetItemsByCategory('gwint');
  1296. for(i=allItems.Size()-1; i >= 0; i-=1)
  1297. {
  1298. attr = GetItemAttributeValue( allItems[i], 'max_count');
  1299. card = thePlayer.GetInventory().GetItemsByName( GetItemName( allItems[i] ) );
  1300. iHave = thePlayer.GetInventory().GetItemQuantity( card[0] );
  1301. shopHave = RoundF(attr.valueBase);
  1302. if ( iHave >= shopHave )
  1303. {
  1304. RemoveItem( allItems[i], GetItemQuantity( allItems[i] ) );
  1305. }
  1306. }
  1307. }
  1308.  
  1309. function ClearTHmaps()
  1310. {
  1311. var attr : SAbilityAttributeValue;
  1312. var allItems : array<SItemUniqueId>;
  1313. var map : array<SItemUniqueId>;
  1314. var i : int;
  1315. var thCompleted : bool;
  1316. var iHave, shopHave : int;
  1317.  
  1318. allItems = GetItemsByTag('ThMap');
  1319. for(i=allItems.Size()-1; i >= 0; i-=1)
  1320. {
  1321. attr = GetItemAttributeValue( allItems[i], 'max_count');
  1322. map = thePlayer.GetInventory().GetItemsByName( GetItemName( allItems[i] ) );
  1323. thCompleted = FactsDoesExist(GetItemName(allItems[i]));
  1324. iHave = thePlayer.GetInventory().GetItemQuantity( map[0] );
  1325. shopHave = RoundF(attr.valueBase);
  1326.  
  1327. if ( iHave >= shopHave || thCompleted )
  1328. {
  1329. RemoveItem( allItems[i], GetItemQuantity( allItems[i] ) );
  1330. }
  1331. }
  1332. }
  1333.  
  1334.  
  1335. public final function ClearKnownRecipes()
  1336. {
  1337. var witcher : W3PlayerWitcher;
  1338. var recipes, craftRecipes : array<name>;
  1339. var i : int;
  1340. var itemName : name;
  1341. var allItems : array<SItemUniqueId>;
  1342.  
  1343. witcher = GetWitcherPlayer();
  1344. if(!witcher)
  1345. return;
  1346.  
  1347.  
  1348. recipes = witcher.GetAlchemyRecipes();
  1349. craftRecipes = witcher.GetCraftingSchematicsNames();
  1350. ArrayOfNamesAppend(recipes, craftRecipes);
  1351.  
  1352.  
  1353. GetAllItems(allItems);
  1354.  
  1355.  
  1356. for(i=allItems.Size()-1; i>=0; i-=1)
  1357. {
  1358. itemName = GetItemName(allItems[i]);
  1359. if(recipes.Contains(itemName))
  1360. RemoveItem(allItems[i], GetItemQuantity(allItems[i]));
  1361. }
  1362. }
  1363.  
  1364.  
  1365.  
  1366.  
  1367.  
  1368. function LoadBooksDefinitions() : void
  1369. {
  1370. var readableArray : array<SItemUniqueId>;
  1371. var i : int;
  1372.  
  1373. readableArray = GetItemsByTag('ReadableItem');
  1374.  
  1375. for( i = 0; i < readableArray.Size(); i += 1 )
  1376. {
  1377. if( IsBookRead(readableArray[i]))
  1378. {
  1379. continue;
  1380. }
  1381. UpdateInitialReadState(readableArray[i]);
  1382. }
  1383. }
  1384.  
  1385. function UpdateInitialReadState( item : SItemUniqueId )
  1386. {
  1387. var abilitiesArray : array<name>;
  1388. var i : int;
  1389. GetItemAbilities(item,abilitiesArray);
  1390.  
  1391. for( i = 0; i < abilitiesArray.Size(); i += 1 )
  1392. {
  1393. if( abilitiesArray[i] == 'WasRead' )
  1394. {
  1395. ReadBook(item);
  1396. break;
  1397. }
  1398. }
  1399. }
  1400.  
  1401. function IsBookRead( item : SItemUniqueId ) : bool
  1402. {
  1403. var bookName : name;
  1404. var bResult : bool;
  1405.  
  1406. bookName = GetItemName( item );
  1407.  
  1408. bResult = IsBookReadByName( bookName );
  1409. return bResult;
  1410. }
  1411.  
  1412. function IsBookReadByName( bookName : name ) : bool
  1413. {
  1414. var bookFactName : string;
  1415.  
  1416. bookFactName = GetBookReadFactName( bookName );
  1417. if( FactsDoesExist(bookFactName) )
  1418. {
  1419. return FactsQuerySum( bookFactName );
  1420. }
  1421.  
  1422. return false;
  1423. }
  1424.  
  1425. function ReadBook( item : SItemUniqueId )
  1426. {
  1427.  
  1428. var bookName : name;
  1429. var abilitiesArray : array<name>;
  1430. var i : int;
  1431. var commonMapManager : CCommonMapManager = theGame.GetCommonMapManager();
  1432.  
  1433. bookName = GetItemName( item );
  1434.  
  1435. if ( !IsBookRead ( item ) && ItemHasTag ( item, 'FastTravel' ))
  1436. {
  1437. GetItemAbilities(item, abilitiesArray);
  1438.  
  1439. for ( i = 0; i < abilitiesArray.Size(); i+=1 )
  1440. {
  1441. commonMapManager.SetEntityMapPinDiscoveredScript(true, abilitiesArray[i], true );
  1442. }
  1443. }
  1444. ReadBookByNameId( bookName, item, false );
  1445.  
  1446.  
  1447.  
  1448.  
  1449. if(ItemHasTag(item, 'PerkBook'))
  1450. {
  1451.  
  1452. }
  1453.  
  1454. }
  1455.  
  1456. public function GetBookText(item : SItemUniqueId) : string
  1457. {
  1458. return ReplaceTagsToIcons(GetLocStringByKeyExt(GetItemLocalizedNameByUniqueID(item)+"_text"));
  1459. }
  1460.  
  1461. function ReadSchematicsAndRecipes( item : SItemUniqueId )
  1462. {
  1463. var itemCategory : name;
  1464. var itemName : name;
  1465. var player : W3PlayerWitcher;
  1466.  
  1467. ReadBook( item );
  1468.  
  1469. player = GetWitcherPlayer();
  1470. if ( !player )
  1471. {
  1472. return;
  1473. }
  1474.  
  1475. itemName = GetItemName( item );
  1476. itemCategory = GetItemCategory( item );
  1477. if ( itemCategory == 'alchemy_recipe' )
  1478. {
  1479. if ( player.CanLearnAlchemyRecipe( itemName ) )
  1480. {
  1481. player.AddAlchemyRecipe( itemName );
  1482. player.GetInventory().AddItemTag(item, 'NoShow');
  1483.  
  1484. }
  1485. }
  1486. else if ( itemCategory == 'crafting_schematic' )
  1487. {
  1488. player.AddCraftingSchematic( itemName );
  1489. player.GetInventory().AddItemTag(item, 'NoShow');
  1490.  
  1491. }
  1492. }
  1493.  
  1494. function ReadBookByName( bookName : name , unread : bool )
  1495. {
  1496. var bookFactName : string;
  1497.  
  1498. if( IsBookReadByName( bookName ) != unread )
  1499. {
  1500. return;
  1501. }
  1502.  
  1503. bookFactName = "BookReadState_"+bookName;
  1504. bookFactName = StrReplace(bookFactName," ","_");
  1505.  
  1506. if( unread )
  1507. {
  1508. FactsSubstract( bookFactName, 1 );
  1509. }
  1510. else
  1511. {
  1512. FactsAdd( bookFactName, 1 );
  1513.  
  1514.  
  1515. if(!IsAlchemyRecipe(bookName) && !IsCraftingSchematic(bookName))
  1516. theGame.GetGamerProfile().IncStat(ES_ReadBooks);
  1517.  
  1518.  
  1519. if ( AddBestiaryFromBook(bookName) )
  1520. return;
  1521.  
  1522.  
  1523.  
  1524. }
  1525. }
  1526.  
  1527. function ReadBookByNameId( bookName : name , itemId:SItemUniqueId, unread : bool )
  1528. {
  1529. var bookFactName : string;
  1530.  
  1531. if( IsBookReadByName( bookName ) != unread )
  1532. {
  1533. return;
  1534. }
  1535.  
  1536. bookFactName = "BookReadState_"+bookName;
  1537. bookFactName = StrReplace(bookFactName," ","_");
  1538.  
  1539. if( unread )
  1540. {
  1541. FactsSubstract( bookFactName, 1 );
  1542. }
  1543. else
  1544. {
  1545. FactsAdd( bookFactName, 1 );
  1546.  
  1547.  
  1548. if(!IsAlchemyRecipe(bookName) && !IsCraftingSchematic(bookName))
  1549. theGame.GetGamerProfile().IncStat(ES_ReadBooks);
  1550.  
  1551.  
  1552. if ( AddBestiaryFromBook(bookName) )
  1553. return;
  1554. else
  1555. ReadSchematicsAndRecipes( itemId );
  1556. }
  1557. }
  1558.  
  1559.  
  1560. private function AddBestiaryFromBook( bookName : name ) : bool
  1561. {
  1562. var i, j, r : int;
  1563. var manager : CWitcherJournalManager;
  1564. var resource : array<CJournalResource>;
  1565. var entryBase : CJournalBase;
  1566. var childGroups : array<CJournalBase>;
  1567. var childEntries : array<CJournalBase>;
  1568. var descriptionGroup : CJournalCreatureDescriptionGroup;
  1569. var descriptionEntry : CJournalCreatureDescriptionEntry;
  1570.  
  1571. manager = theGame.GetJournalManager();
  1572.  
  1573. switch ( bookName )
  1574. {
  1575. case 'Beasts vol 1':
  1576. resource.PushBack( (CJournalResource)LoadResource( "BestiaryWolf" ) );
  1577. resource.PushBack( (CJournalResource)LoadResource( "BestiaryDog" ) );
  1578. break;
  1579. case 'Beasts vol 2':
  1580. resource.PushBack( (CJournalResource)LoadResource( "BestiaryBear" ) );
  1581. break;
  1582. case 'Cursed Monsters vol 1':
  1583. resource.PushBack( (CJournalResource)LoadResource( "BestiaryWerewolf" ) );
  1584. resource.PushBack( (CJournalResource)LoadResource( "BestiaryLycanthrope" ) );
  1585. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 24');
  1586. break;
  1587. case 'Cursed Monsters vol 2':
  1588. resource.PushBack( (CJournalResource)LoadResource( "BestiaryWerebear" ) );
  1589. resource.PushBack( (CJournalResource)LoadResource( "BestiaryMiscreant" ) );
  1590. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 11');
  1591. break;
  1592. case 'Draconides vol 1':
  1593. resource.PushBack( (CJournalResource)LoadResource( "BestiaryCockatrice" ) );
  1594. resource.PushBack( (CJournalResource)LoadResource( "BestiaryBasilisk" ) );
  1595. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 3');
  1596. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 23');
  1597. break;
  1598. case 'Draconides vol 2':
  1599. resource.PushBack( (CJournalResource)LoadResource( "BestiaryWyvern" ) );
  1600. resource.PushBack( (CJournalResource)LoadResource( "BestiaryForktail" ) );
  1601. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 10');
  1602. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 17');
  1603. break;
  1604. case 'Hybrid Monsters vol 1':
  1605. resource.PushBack( (CJournalResource)LoadResource( "BestiaryHarpy" ) );
  1606. resource.PushBack( (CJournalResource)LoadResource( "BestiaryErynia" ) );
  1607. resource.PushBack( (CJournalResource)LoadResource( "BestiarySiren" ) );
  1608. resource.PushBack( (CJournalResource)LoadResource( "BestiarySuccubus" ) );
  1609. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 14');
  1610. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 21');
  1611. break;
  1612. case 'Hybrid Monsters vol 2':
  1613. resource.PushBack( (CJournalResource)LoadResource( "BestiaryGriffin" ) );
  1614. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 4');
  1615. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 27');
  1616. break;
  1617. case 'Insectoids vol 1':
  1618. resource.PushBack( (CJournalResource)LoadResource( "BestiaryEndriagaWorker" ) );
  1619. resource.PushBack( (CJournalResource)LoadResource( "BestiaryEndriagaTruten" ) );
  1620. resource.PushBack( (CJournalResource)LoadResource( "BestiaryEndriaga" ) );
  1621. break;
  1622. case 'Insectoids vol 2':
  1623. resource.PushBack( (CJournalResource)LoadResource( "BestiaryCrabSpider" ) );
  1624. resource.PushBack( (CJournalResource)LoadResource( "BestiaryArmoredArachas" ) );
  1625. resource.PushBack( (CJournalResource)LoadResource( "BestiaryPoisonousArachas" ) );
  1626. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 2');
  1627. break;
  1628. case 'Magical Monsters vol 1':
  1629. resource.PushBack( (CJournalResource)LoadResource( "BestiaryGolem" ) );
  1630. break;
  1631. case 'Magical Monsters vol 2':
  1632. resource.PushBack( (CJournalResource)LoadResource( "BestiaryElemental" ) );
  1633. resource.PushBack( (CJournalResource)LoadResource( "BestiaryIceGolem" ) );
  1634. resource.PushBack( (CJournalResource)LoadResource( "BestiaryFireElemental" ) );
  1635. resource.PushBack( (CJournalResource)LoadResource( "BestiaryWhMinion" ) );
  1636. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 20');
  1637. break;
  1638. case 'Necrophage vol 1':
  1639. resource.PushBack( (CJournalResource)LoadResource( "BestiaryGhoul" ) );
  1640. resource.PushBack( (CJournalResource)LoadResource( "BestiaryAlghoul" ) );
  1641. resource.PushBack( (CJournalResource)LoadResource( "BestiaryGreaterRotFiend" ) );
  1642. resource.PushBack( (CJournalResource)LoadResource( "BestiaryDrowner" ) );
  1643. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 15');
  1644. break;
  1645. case 'Necrophage vol 2':
  1646. resource.PushBack( (CJournalResource)LoadResource( "BestiaryGraveHag" ) );
  1647. resource.PushBack( (CJournalResource)LoadResource( "BestiaryWaterHag" ) );
  1648. resource.PushBack( (CJournalResource)LoadResource( "BestiaryFogling" ) );
  1649. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 5');
  1650. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 9');
  1651. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 18');
  1652. break;
  1653. case 'Relict Monsters vol 1':
  1654. resource.PushBack( (CJournalResource)LoadResource( "BestiaryBies" ) );
  1655. resource.PushBack( (CJournalResource)LoadResource( "BestiaryCzart" ) );
  1656. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 8');
  1657. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 16');
  1658. break;
  1659. case 'Relict Monsters vol 2':
  1660. resource.PushBack( (CJournalResource)LoadResource( "BestiaryLeshy" ) );
  1661. resource.PushBack( (CJournalResource)LoadResource( "BestiarySilvan" ) );
  1662. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 22');
  1663. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 26');
  1664. break;
  1665. case 'Specters vol 1':
  1666. resource.PushBack( (CJournalResource)LoadResource( "BestiaryMoonwright" ) );
  1667. resource.PushBack( (CJournalResource)LoadResource( "BestiaryNoonwright" ) );
  1668. resource.PushBack( (CJournalResource)LoadResource( "BestiaryPesta" ) );
  1669. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 6');
  1670. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 13');
  1671. break;
  1672. case 'Specters vol 2':
  1673. resource.PushBack( (CJournalResource)LoadResource( "BestiaryWraith" ) );
  1674. resource.PushBack( (CJournalResource)LoadResource( "BestiaryHim" ) );
  1675. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 19');
  1676. break;
  1677. case 'Ogres vol 1':
  1678. resource.PushBack( (CJournalResource)LoadResource( "BestiaryNekker" ) );
  1679. resource.PushBack( (CJournalResource)LoadResource( "BestiaryIceTroll" ) );
  1680. resource.PushBack( (CJournalResource)LoadResource( "BestiaryCaveTroll" ) );
  1681. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 12');
  1682. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 25');
  1683. break;
  1684. case 'Ogres vol 2':
  1685. resource.PushBack( (CJournalResource)LoadResource( "BestiaryCyclop" ) );
  1686. resource.PushBack( (CJournalResource)LoadResource( "BestiaryIceGiant" ) );
  1687. break;
  1688. case 'Vampires vol 1':
  1689. resource.PushBack( (CJournalResource)LoadResource( "BestiaryEkkima" ) );
  1690. resource.PushBack( (CJournalResource)LoadResource( "BestiaryHigherVampire" ) );
  1691. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 7');
  1692. break;
  1693. case 'Vampires vol 2':
  1694. resource.PushBack( (CJournalResource)LoadResource( "BestiaryKatakan" ) );
  1695. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 1');
  1696. break;
  1697. default:
  1698. return false;
  1699. }
  1700.  
  1701.  
  1702. for (r=0; r < resource.Size(); r += 1 )
  1703. {
  1704. if ( !resource[ r ] )
  1705. {
  1706.  
  1707. continue;
  1708. }
  1709. entryBase = resource[r].GetEntry();
  1710. if ( entryBase )
  1711. {
  1712. manager.ActivateEntry( entryBase, JS_Active );
  1713. manager.SetEntryHasAdvancedInfo( entryBase, true );
  1714.  
  1715.  
  1716. theGame.GetGuiManager().ShowNotification(GetLocStringByKeyExt("panel_hud_journal_entry_bestiary_new"));
  1717. theSound.SoundEvent("gui_ingame_new_journal");
  1718.  
  1719.  
  1720. manager.GetAllChildren( entryBase, childGroups );
  1721. for ( i = 0; i < childGroups.Size(); i += 1 )
  1722. {
  1723. descriptionGroup = ( CJournalCreatureDescriptionGroup )childGroups[ i ];
  1724. if ( descriptionGroup )
  1725. {
  1726. manager.GetAllChildren( descriptionGroup, childEntries );
  1727. for ( j = 0; j < childEntries.Size(); j += 1 )
  1728. {
  1729. descriptionEntry = ( CJournalCreatureDescriptionEntry )childEntries[ j ];
  1730. if ( descriptionEntry )
  1731. {
  1732. manager.ActivateEntry( descriptionEntry, JS_Active );
  1733. }
  1734. }
  1735. break;
  1736. }
  1737. }
  1738. }
  1739. }
  1740.  
  1741. if ( resource.Size() > 0 )
  1742. return true;
  1743. else
  1744. return false;
  1745. }
  1746.  
  1747.  
  1748.  
  1749.  
  1750.  
  1751.  
  1752.  
  1753.  
  1754. function GetWeaponDTNames( id : SItemUniqueId, out dmgNames : array< name > ) : int
  1755. {
  1756. var attrs : array< name >;
  1757. var i, size : int;
  1758.  
  1759. dmgNames.Clear();
  1760.  
  1761. if( IsIdValid(id) )
  1762. {
  1763. GetItemAttributes( id, attrs );
  1764. size = attrs.Size();
  1765.  
  1766. for( i = 0; i < size; i += 1 )
  1767. if( IsDamageTypeNameValid(attrs[i]) )
  1768. dmgNames.PushBack( attrs[i] );
  1769.  
  1770. if(dmgNames.Size() == 0)
  1771. LogAssert(false, "CInventoryComponent.GetWeaponDTNames: weapon <<" + GetItemName(id) + ">> has no damage types defined!");
  1772. }
  1773. return dmgNames.Size();
  1774. }
  1775.  
  1776. public function GetWeapons() : array<SItemUniqueId>
  1777. {
  1778. var ids, ids2 : array<SItemUniqueId>;
  1779.  
  1780. ids = GetItemsByCategory('monster_weapon');
  1781. ids2 = GetItemsByTag('Weapon');
  1782. ArrayOfIdsAppend(ids, ids2);
  1783.  
  1784. return ids;
  1785. }
  1786.  
  1787. public function GetHeldWeapons() : array<SItemUniqueId>
  1788. {
  1789. var i : int;
  1790. var w : array<SItemUniqueId>;
  1791.  
  1792. w = GetWeapons();
  1793.  
  1794. for(i=w.Size()-1; i>=0; i-=1)
  1795. {
  1796. if(!IsItemHeld(w[i]))
  1797. {
  1798. w.EraseFast( i );
  1799. }
  1800. }
  1801.  
  1802. return w;
  1803. }
  1804.  
  1805. public function GetHeldWeaponsWithCategory( category : name, out items : array<SItemUniqueId> )
  1806. {
  1807. var i : int;
  1808.  
  1809. items = GetItemsByCategory( category );
  1810.  
  1811. for ( i = items.Size()-1; i >= 0; i -= 1)
  1812. {
  1813. if ( !IsItemHeld( items[i] ) )
  1814. {
  1815. items.EraseFast( i );
  1816. }
  1817. }
  1818. }
  1819.  
  1820. public function GetPotionItemBuffData(id : SItemUniqueId, out type : EEffectType, out customAbilityName : name) : bool
  1821. {
  1822. var size, i : int;
  1823. var arr : array<name>;
  1824.  
  1825. if(IsIdValid(id))
  1826. {
  1827. GetItemContainedAbilities( id, arr );
  1828. size = arr.Size();
  1829.  
  1830. for( i = 0; i < size; i += 1 )
  1831. {
  1832. if( IsEffectNameValid(arr[i]) )
  1833. {
  1834. EffectNameToType(arr[i], type, customAbilityName);
  1835. return true;
  1836. }
  1837. }
  1838. }
  1839.  
  1840. return false;
  1841. }
  1842.  
  1843.  
  1844. public function RecycleItem( id : SItemUniqueId, level : ECraftsmanLevel ) : array<SItemUniqueId>
  1845. {
  1846. var itemsAdded : array<SItemUniqueId>;
  1847. var currentAdded : array<SItemUniqueId>;
  1848.  
  1849. var parts : array<SItemParts>;
  1850. var i : int;
  1851.  
  1852. parts = GetItemRecyclingParts( id );
  1853.  
  1854. for ( i = 0; i < parts.Size(); i += 1 )
  1855. {
  1856. if ( ECL_Grand_Master == level )
  1857. {
  1858. currentAdded = AddAnItem( parts[i].itemName, parts[i].quantity );
  1859. }
  1860. else if ( ECL_Master == level && parts[i].quantity > 1 )
  1861. {
  1862. currentAdded = AddAnItem( parts[i].itemName, RandRange( parts[i].quantity, 1 ) );
  1863. }
  1864. else
  1865. {
  1866. currentAdded = AddAnItem( parts[i].itemName, 1 );
  1867. }
  1868. itemsAdded.PushBack(currentAdded[0]);
  1869. }
  1870.  
  1871. RemoveItem(id);
  1872.  
  1873. return itemsAdded;
  1874. }
  1875.  
  1876.  
  1877.  
  1878.  
  1879.  
  1880.  
  1881. public function GetItemBuffs( id : SItemUniqueId, out buffs : array<SEffectInfo>) : int
  1882. {
  1883. var attrs, abs, absFast : array< name >;
  1884. var i, k : int;
  1885. var type : EEffectType;
  1886. var abilityName : name;
  1887. var buff : SEffectInfo;
  1888. var dm : CDefinitionsManagerAccessor;
  1889.  
  1890. buffs.Clear();
  1891.  
  1892. if( !IsIdValid(id) )
  1893. return 0;
  1894.  
  1895.  
  1896. GetItemContainedAbilities(id, absFast);
  1897. if(absFast.Size() == 0)
  1898. return 0;
  1899.  
  1900. GetItemAbilities(id, abs);
  1901. dm = theGame.GetDefinitionsManager();
  1902. for(k=0; k<abs.Size(); k+=1)
  1903. {
  1904. dm.GetContainedAbilities(abs[k], attrs);
  1905. buff.applyChance = CalculateAttributeValue(GetItemAbilityAttributeValue(id, 'buff_apply_chance', abs[k])) * ArrayOfNamesCount(abs, abs[k]);
  1906.  
  1907. for( i = 0; i < attrs.Size(); i += 1 )
  1908. {
  1909. if( IsEffectNameValid(attrs[i]) )
  1910. {
  1911. EffectNameToType(attrs[i], type, abilityName);
  1912.  
  1913. buff.effectType = type;
  1914. buff.effectAbilityName = abilityName;
  1915.  
  1916. buffs.PushBack(buff);
  1917.  
  1918.  
  1919. if(absFast.Size() == 1)
  1920. return buffs.Size();
  1921. else
  1922. absFast.EraseFast(0);
  1923. }
  1924. }
  1925. }
  1926.  
  1927. return buffs.Size();
  1928. }
  1929.  
  1930.  
  1931. public function DropItemInBag( item : SItemUniqueId, quantity : int )
  1932. {
  1933. var entities : array<CGameplayEntity>;
  1934. var i : int;
  1935. var owner : CActor;
  1936. var bag : W3ActorRemains;
  1937. var template : CEntityTemplate;
  1938. var tabbags : array <name>;
  1939.  
  1940. if(ItemHasTag(item, 'NoDrop'))
  1941. return;
  1942.  
  1943. owner = (CActor)GetEntity();
  1944. FindGameplayEntitiesInRange(entities, owner, 0.5, 100);
  1945.  
  1946. for(i=0; i<entities.Size(); i+=1)
  1947. {
  1948. bag = (W3ActorRemains)entities[i];
  1949.  
  1950. if(bag)
  1951. break;
  1952. }
  1953.  
  1954.  
  1955. if(!bag)
  1956. {
  1957. template = (CEntityTemplate)LoadResource("lootbag");
  1958. tabbags.PushBack('lootbag');
  1959. bag = (W3ActorRemains)theGame.CreateEntity(template, owner.GetWorldPosition(), owner.GetWorldRotation(), true, false, false, PM_Persist,tabbags);
  1960. }
  1961.  
  1962.  
  1963. GiveItemTo(bag.GetInventory(), item, quantity, false);
  1964.  
  1965.  
  1966. if(bag.GetInventory().IsEmpty())
  1967. {
  1968. delete bag;
  1969. return;
  1970. }
  1971.  
  1972. bag.LootDropped();
  1973. theTelemetry.LogWithLabelAndValue(TE_INV_ITEM_DROPPED, GetItemName(item), quantity);
  1974.  
  1975.  
  1976. if( thePlayer.IsSwimming() )
  1977. {
  1978. bag.PlayPropertyAnimation( 'float', 0 );
  1979. }
  1980. }
  1981.  
  1982.  
  1983.  
  1984.  
  1985.  
  1986.  
  1987. public final function AddRepairObjectItemBonuses(buffArmor : bool, buffSwords : bool, ammoArmor : int, ammoWeapon : int) : bool
  1988. {
  1989. var upgradedSomething, isArmor : bool;
  1990. var i, ammo, currAmmo : int;
  1991. var items, items2 : array<SItemUniqueId>;
  1992.  
  1993.  
  1994. if(buffArmor)
  1995. {
  1996. items = GetItemsByTag(theGame.params.TAG_ARMOR);
  1997. }
  1998. if(buffSwords)
  1999. {
  2000. items2 = GetItemsByTag(theGame.params.TAG_PLAYER_STEELSWORD);
  2001. ArrayOfIdsAppend(items, items2);
  2002. items2.Clear();
  2003. items2 = GetItemsByTag(theGame.params.TAG_PLAYER_SILVERSWORD);
  2004. ArrayOfIdsAppend(items, items2);
  2005. }
  2006.  
  2007. upgradedSomething = false;
  2008.  
  2009. for(i=0; i<items.Size(); i+=1)
  2010. {
  2011.  
  2012. if(IsItemAnyArmor(items[i]))
  2013. {
  2014. isArmor = true;
  2015. ammo = ammoArmor;
  2016. }
  2017. else
  2018. {
  2019. isArmor = false;
  2020. ammo = ammoWeapon;
  2021. }
  2022.  
  2023.  
  2024. currAmmo = GetItemModifierInt(items[i], 'repairObjectBonusAmmo', 0);
  2025.  
  2026.  
  2027. if(ammo > currAmmo)
  2028. {
  2029. SetItemModifierInt(items[i], 'repairObjectBonusAmmo', ammo);
  2030. upgradedSomething = true;
  2031.  
  2032.  
  2033. if(currAmmo == 0)
  2034. {
  2035. if(isArmor)
  2036. AddItemCraftedAbility(items[i], theGame.params.REPAIR_OBJECT_BONUS_ARMOR_ABILITY, false);
  2037. else
  2038. AddItemCraftedAbility(items[i], theGame.params.REPAIR_OBJECT_BONUS_WEAPON_ABILITY, false);
  2039. }
  2040. }
  2041. }
  2042.  
  2043. return upgradedSomething;
  2044. }
  2045.  
  2046. public final function ReduceItemRepairObjectBonusCharge(item : SItemUniqueId)
  2047. {
  2048. var currAmmo : int;
  2049.  
  2050. currAmmo = GetItemModifierInt(item, 'repairObjectBonusAmmo', 0);
  2051.  
  2052. if(currAmmo > 0)
  2053. {
  2054. SetItemModifierInt(item, 'repairObjectBonusAmmo', currAmmo - 1);
  2055.  
  2056. if(currAmmo == 1)
  2057. {
  2058. if(IsItemAnyArmor(item))
  2059. RemoveItemCraftedAbility(item, theGame.params.REPAIR_OBJECT_BONUS_ARMOR_ABILITY);
  2060. else
  2061. RemoveItemCraftedAbility(item, theGame.params.REPAIR_OBJECT_BONUS_WEAPON_ABILITY);
  2062. }
  2063. }
  2064. }
  2065.  
  2066.  
  2067. public final function GetRepairObjectBonusValueForArmor(armor : SItemUniqueId) : SAbilityAttributeValue
  2068. {
  2069. var retVal, bonusValue, baseArmor : SAbilityAttributeValue;
  2070.  
  2071. if(GetItemModifierInt(armor, 'repairObjectBonusAmmo', 0) > 0)
  2072. {
  2073. bonusValue = GetItemAttributeValue(armor, theGame.params.REPAIR_OBJECT_BONUS);
  2074. baseArmor = GetItemAttributeValue(armor, theGame.params.ARMOR_VALUE_NAME);
  2075.  
  2076. baseArmor.valueMultiplicative += 1;
  2077. retVal.valueAdditive = bonusValue.valueAdditive + CalculateAttributeValue(baseArmor) * bonusValue.valueMultiplicative;
  2078. }
  2079.  
  2080. return retVal;
  2081. }
  2082.  
  2083.  
  2084. public function CanItemHaveOil(id : SItemUniqueId) : bool
  2085. {
  2086. return IsItemSteelSwordUsableByPlayer(id) || IsItemSilverSwordUsableByPlayer(id);
  2087. }
  2088.  
  2089. public function ItemHasOilApplied(id : SItemUniqueId) : bool
  2090. {
  2091. var dm : CDefinitionsManagerAccessor;
  2092. var i : int;
  2093. var abs : array<name>;
  2094.  
  2095. GetItemAbilities(id, abs);
  2096. dm = theGame.GetDefinitionsManager();
  2097.  
  2098. for(i=0; i<abs.Size(); i+=1)
  2099. {
  2100. if(dm.AbilityHasTag(abs[i], theGame.params.OIL_ABILITY_TAG))
  2101. return true;
  2102. }
  2103.  
  2104. return false;
  2105. }
  2106.  
  2107. public function GetSwordOil(sword : SItemUniqueId):name
  2108. {
  2109. var i, tempI : int;
  2110. var tempAF : array<float>;
  2111. var dm : CDefinitionsManagerAccessor;
  2112. var oilAbility : name;
  2113. var isSteelSword : bool;
  2114. var itemCategory : name;
  2115. var swordAbilities, oilAbs, items : array<name>;
  2116.  
  2117. if (!IsIdValid(sword))
  2118. {
  2119. return '';
  2120. }
  2121. itemCategory = GetItemCategory(sword);
  2122. if (itemCategory == 'steelsword')
  2123. {
  2124. isSteelSword = true;
  2125. }
  2126. else if (itemCategory == 'silversword')
  2127. {
  2128. isSteelSword = false;
  2129. }
  2130. else
  2131. {
  2132.  
  2133. return '';
  2134. }
  2135.  
  2136. GetItemAbilities(sword, swordAbilities);
  2137. dm = theGame.GetDefinitionsManager();
  2138. oilAbility = '';
  2139. for(i=0; i<swordAbilities.Size(); i+=1)
  2140. {
  2141. if(dm.AbilityHasTag(swordAbilities[i], theGame.params.OIL_ABILITY_TAG))
  2142. {
  2143. oilAbility = swordAbilities[i];
  2144. break;
  2145. }
  2146. }
  2147.  
  2148. if(!IsNameValid(oilAbility))
  2149. return '';
  2150.  
  2151.  
  2152. if(isSteelSword)
  2153. items = dm.GetItemsWithTag('SteelOil');
  2154. else
  2155. items = dm.GetItemsWithTag('SilverOil');
  2156.  
  2157.  
  2158. for(i=0; i<items.Size(); i+=1)
  2159. {
  2160. dm.GetItemAbilitiesWithWeights(items[i], GetEntity() == thePlayer, oilAbs, tempAF, tempI, tempI);
  2161. if(oilAbs.Contains(oilAbility))
  2162. {
  2163. return items[i];
  2164. }
  2165. }
  2166.  
  2167. LogAssert(false, "W3PlayerWitcher.GetOilAppliedOnSword: sword has some oil but this oil is not defined in XMLs!");
  2168. return '';
  2169. }
  2170.  
  2171.  
  2172.  
  2173.  
  2174.  
  2175.  
  2176.  
  2177. // PN
  2178. if ( IsItemFood(potionId) ) {
  2179. newAttr.originName = 'expire';
  2180. newAttr.attributeName = GetLocStringByKeyExt("ToolTip_Expiration");
  2181. newAttr.value = PNGetExpireLevel( this , potionId );
  2182. newAttr.percentageValue = false ;
  2183. if ( newAttr.value != 0.0 ) tips.PushBack(newAttr);
  2184.  
  2185. newAttr.originName = 'feed';
  2186. newAttr.attributeName = GetLocStringByKeyExt("ToolTip_Hunger");
  2187. newAttr.value = (float) PNGetFeedLevel( this , potionId ) / 100.0 ;
  2188. newAttr.percentageValue = true ;
  2189. if ( newAttr.value != 0.0 ) tips.PushBack(newAttr);
  2190.  
  2191. newAttr.originName = 'drink';
  2192. newAttr.attributeName = GetLocStringByKeyExt("ToolTip_Thirst");
  2193. newAttr.value = (float) PNGetDrinkLevel( this , potionId ) / 100.0 ;
  2194. newAttr.percentageValue = true ;
  2195. if ( newAttr.value != 0.0 ) tips.PushBack(newAttr);
  2196. }
  2197. // PN
  2198.  
  2199.  
  2200. public function GetItemRelativeTooltipType(id :SItemUniqueId, invOther : CInventoryComponent, idOther : SItemUniqueId) : ECompareType
  2201. {
  2202.  
  2203. if( (GetItemCategory(id) == invOther.GetItemCategory(idOther)) ||
  2204. ItemHasTag(id, 'PlayerSteelWeapon') && invOther.ItemHasTag(idOther, 'PlayerSteelWeapon') ||
  2205. ItemHasTag(id, 'PlayerSilverWeapon') && invOther.ItemHasTag(idOther, 'PlayerSilverWeapon') ||
  2206. ItemHasTag(id, 'PlayerSecondaryWeapon') && invOther.ItemHasTag(idOther, 'PlayerSecondaryWeapon')
  2207. )
  2208. {
  2209. return ECT_Compare;
  2210. }
  2211. return ECT_Incomparable;
  2212. }
  2213.  
  2214.  
  2215. private function FormatFloatForTooltip(fValue : float) : string
  2216. {
  2217. var valueInt, valueDec : int;
  2218. var strValue : string;
  2219.  
  2220. if(fValue < 0)
  2221. {
  2222. valueInt = CeilF(fValue);
  2223. valueDec = RoundMath((fValue - valueInt)*(-100));
  2224. }
  2225. else
  2226. {
  2227. valueInt = FloorF(fValue);
  2228. valueDec = RoundMath((fValue - valueInt)*(100));
  2229. }
  2230. strValue = valueInt+".";
  2231. if(valueDec < 10)
  2232. strValue += "0"+valueDec;
  2233. else
  2234. strValue += ""+valueDec;
  2235.  
  2236. return strValue;
  2237. }
  2238.  
  2239. public function SetPriceMultiplier( mult : float )
  2240. {
  2241. priceMult = mult;
  2242. }
  2243.  
  2244.  
  2245. public function GetMerchantPriceModifier( shopNPC : CNewNPC, item : SItemUniqueId ) : float
  2246. {
  2247. var areaPriceMult : float;
  2248. var itemPriceMult : float;
  2249. var importPriceMult : float;
  2250. var finalPriceMult : float;
  2251. var tag : name;
  2252. var zoneName : EZoneName;
  2253.  
  2254. zoneName = theGame.GetCurrentZone();
  2255.  
  2256. switch ( zoneName )
  2257. {
  2258. case ZN_NML_CrowPerch : areaPriceMult = CalculateAttributeValue(thePlayer.GetAttributeValue('crow_perch_price_mult'));
  2259. case ZN_NML_SpitfireBluff : areaPriceMult = CalculateAttributeValue(thePlayer.GetAttributeValue('spitfire_bluff_price_mult'));
  2260. case ZN_NML_TheMire : areaPriceMult = CalculateAttributeValue(thePlayer.GetAttributeValue('the_mire_price_mult'));
  2261. case ZN_NML_Mudplough : areaPriceMult = CalculateAttributeValue(thePlayer.GetAttributeValue('mudplough_price_mult'));
  2262. case ZN_NML_Grayrocks : areaPriceMult = CalculateAttributeValue(thePlayer.GetAttributeValue('grayrocks_price_mult'));
  2263. case ZN_NML_TheDescent : areaPriceMult = CalculateAttributeValue(thePlayer.GetAttributeValue('the_descent_price_mult'));
  2264. case ZN_NML_CrookbackBog : areaPriceMult = CalculateAttributeValue(thePlayer.GetAttributeValue('crookback_bog_price_mult'));
  2265. case ZN_NML_BaldMountain : areaPriceMult = CalculateAttributeValue(thePlayer.GetAttributeValue('bald_mountain_price_mult'));
  2266. case ZN_NML_Novigrad : areaPriceMult = CalculateAttributeValue(thePlayer.GetAttributeValue('novigrad_price_mult'));
  2267. case ZN_NML_Homestead : areaPriceMult = CalculateAttributeValue(thePlayer.GetAttributeValue('homestead_price_mult'));
  2268. case ZN_NML_Gustfields : areaPriceMult = CalculateAttributeValue(thePlayer.GetAttributeValue('gustfields_price_mult'));
  2269. case ZN_NML_Oxenfurt : areaPriceMult = CalculateAttributeValue(thePlayer.GetAttributeValue('oxenfurt_price_mult'));
  2270. case ZN_Undefined : areaPriceMult = 1;
  2271. }
  2272.  
  2273. if (ItemHasTag(item,'weapon')) { itemPriceMult = CalculateAttributeValue(shopNPC.GetAttributeValue('weapon_price_mult')); }
  2274. else if (ItemHasTag(item,'armor')) { itemPriceMult = CalculateAttributeValue(shopNPC.GetAttributeValue('armor_price_mult')); }
  2275. else if (ItemHasTag(item,'crafting')) { itemPriceMult = CalculateAttributeValue(shopNPC.GetAttributeValue('crafting_price_mult')); }
  2276. else if (ItemHasTag(item,'alchemy')) { itemPriceMult = CalculateAttributeValue(shopNPC.GetAttributeValue('alchemy_price_mult')); }
  2277. else if (ItemHasTag(item,'alcohol')) { itemPriceMult = CalculateAttributeValue(shopNPC.GetAttributeValue('alcohol_price_mult')); }
  2278. else if (ItemHasTag(item,'food')) { itemPriceMult = CalculateAttributeValue(shopNPC.GetAttributeValue('food_price_mult')); }
  2279. else if (ItemHasTag(item,'fish')) { itemPriceMult = CalculateAttributeValue(shopNPC.GetAttributeValue('fish_price_mult')); }
  2280. else if (ItemHasTag(item,'books')) { itemPriceMult = CalculateAttributeValue(shopNPC.GetAttributeValue('books_price_mult')); }
  2281. else if (ItemHasTag(item,'valuables')) { itemPriceMult = CalculateAttributeValue(shopNPC.GetAttributeValue('valuables_price_mult')); }
  2282. else if (ItemHasTag(item,'junk')) { itemPriceMult = CalculateAttributeValue(shopNPC.GetAttributeValue('junk_price_mult')); }
  2283. else if (ItemHasTag(item,'orens')) { itemPriceMult = CalculateAttributeValue(shopNPC.GetAttributeValue('orens_price_mult')); }
  2284. else if (ItemHasTag(item,'florens')) { itemPriceMult = CalculateAttributeValue(shopNPC.GetAttributeValue('florens_price_mult')); }
  2285. else { itemPriceMult = 1; }
  2286.  
  2287. if (ItemHasTag(item,'novigrad')) { importPriceMult = CalculateAttributeValue(shopNPC.GetAttributeValue('novigrad_price_mult')); }
  2288. else if (ItemHasTag(item,'nilfgard')) { importPriceMult = CalculateAttributeValue(shopNPC.GetAttributeValue('nilfgard_price_mult')); }
  2289. else if (ItemHasTag(item,'nomansland')) { importPriceMult = CalculateAttributeValue(shopNPC.GetAttributeValue('nomansland_price_mult')); }
  2290. else if (ItemHasTag(item,'skellige')) { importPriceMult = CalculateAttributeValue(shopNPC.GetAttributeValue('skellige_price_mult')); }
  2291. else if (ItemHasTag(item,'nonhuman')) { importPriceMult = CalculateAttributeValue(shopNPC.GetAttributeValue('nonhuman_price_mult')); }
  2292. else { importPriceMult = 1; }
  2293.  
  2294. finalPriceMult = areaPriceMult*itemPriceMult*importPriceMult*priceMult;
  2295. return finalPriceMult;
  2296. }
  2297.  
  2298. public function SetRepairPriceMultiplier( mult : float )
  2299. {
  2300. priceRepairMult = mult;
  2301. }
  2302.  
  2303.  
  2304. public function GetRepairPriceModifier( repairNPC : CNewNPC ) : float
  2305. {
  2306. return priceRepairMult;
  2307. }
  2308.  
  2309. public function GetRepairPrice( item : SItemUniqueId ) : float
  2310. {
  2311. var currDiff : float;
  2312. currDiff = GetItemMaxDurability(item) - GetItemDurability(item);
  2313.  
  2314. return priceRepair * currDiff;
  2315. }
  2316.  
  2317.  
  2318. public function GetTooltipData(itemId : SItemUniqueId, out localizedName : string, out localizedDescription : string, out price : int, out localizedCategory : string,
  2319. out itemStats : array<SAttributeTooltip>, out localizedFluff : string)
  2320. {
  2321. if( !IsIdValid(itemId) )
  2322. {
  2323. return;
  2324. }
  2325. localizedName = GetItemLocalizedNameByUniqueID(itemId);
  2326. localizedDescription = GetItemLocalizedDescriptionByUniqueID(itemId);
  2327. localizedFluff = "IMPLEMENT ME - fluff text";
  2328. price = GetItemPriceModified( itemId, false );
  2329. localizedCategory = GetItemCategoryLocalisedString(GetItemCategory(itemId));
  2330. GetItemStats(itemId, itemStats);
  2331. }
  2332.  
  2333.  
  2334. public function GetItemBaseStats(itemId : SItemUniqueId, out itemStats : array<SAttributeTooltip>)
  2335. {
  2336. var attributes : array<name>;
  2337.  
  2338. var dm : CDefinitionsManagerAccessor;
  2339. var oilAbilities, oilAttributes : array<name>;
  2340. var weights : array<float>;
  2341. var i, j : int;
  2342.  
  2343. var idx : int;
  2344. var oilStatsCount : int;
  2345. var oilName : name;
  2346. var oilStats : array<SAttributeTooltip>;
  2347. var oilStatFirst : SAttributeTooltip;
  2348.  
  2349. GetItemBaseAttributes(itemId, attributes);
  2350.  
  2351.  
  2352. oilName = GetSwordOil(itemId);
  2353. if (oilName != '')
  2354. {
  2355. dm = theGame.GetDefinitionsManager();
  2356. dm.GetItemAbilitiesWithWeights(oilName, GetEntity() == thePlayer, oilAbilities, weights, i, j);
  2357. oilAttributes = dm.GetAbilitiesAttributes(oilAbilities);
  2358. oilStatsCount = oilAttributes.Size();
  2359. for (idx = 0; idx < oilStatsCount; idx+=1)
  2360. {
  2361. attributes.Remove(oilAttributes[idx]);
  2362. }
  2363. }
  2364.  
  2365. GetItemTooltipAttributes(itemId, attributes, itemStats);
  2366. }
  2367.  
  2368.  
  2369. public function GetItemStats(itemId : SItemUniqueId, out itemStats : array<SAttributeTooltip>)
  2370. {
  2371. var attributes : array<name>;
  2372.  
  2373. GetItemAttributes(itemId, attributes);
  2374. GetItemTooltipAttributes(itemId, attributes, itemStats);
  2375. }
  2376.  
  2377. private function GetItemTooltipAttributes(itemId : SItemUniqueId, attributes : array<name>, out itemStats : array<SAttributeTooltip>):void
  2378. {
  2379. var itemCategory:name;
  2380. var i, j, settingsSize : int;
  2381. var attributeString : string;
  2382. var attributeColor : string;
  2383. var attributeName : name;
  2384. var isPercentageValue : string;
  2385. var primaryStatLabel : string;
  2386. var statLabel : string;
  2387.  
  2388. var stat : SAttributeTooltip;
  2389. var attributeVal : SAbilityAttributeValue;
  2390.  
  2391. settingsSize = theGame.tooltipSettings.GetNumRows();
  2392. itemStats.Clear();
  2393. itemCategory = GetItemCategory(itemId);
  2394. for(i=0; i<settingsSize; i+=1)
  2395. {
  2396.  
  2397. attributeString = theGame.tooltipSettings.GetValueAt(0,i);
  2398. if(StrLen(attributeString) <= 0)
  2399. continue;
  2400.  
  2401. attributeName = '';
  2402.  
  2403.  
  2404. for(j=0; j<attributes.Size(); j+=1)
  2405. {
  2406. if(NameToString(attributes[j]) == attributeString)
  2407. {
  2408. attributeName = attributes[j];
  2409. break;
  2410. }
  2411. }
  2412. if(!IsNameValid(attributeName))
  2413. continue;
  2414.  
  2415.  
  2416. if(itemCategory == 'silversword' && attributeName == 'SlashingDamage') continue;
  2417. if(itemCategory == 'steelsword' && attributeName == 'SilverDamage') continue;
  2418.  
  2419.  
  2420. attributeColor = theGame.tooltipSettings.GetValueAt(1,i);
  2421.  
  2422. isPercentageValue = theGame.tooltipSettings.GetValueAt(2,i);
  2423.  
  2424.  
  2425. attributeVal = GetItemAttributeValue(itemId, attributeName);
  2426. stat.attributeColor = attributeColor;
  2427. stat.percentageValue = isPercentageValue;
  2428. stat.primaryStat = IsPrimaryStatById(itemId, attributeName, primaryStatLabel);
  2429. stat.value = 0;
  2430. stat.originName = attributeName;
  2431. if(attributeVal.valueBase != 0)
  2432. {
  2433. statLabel = GetAttributeNameLocStr(attributeName, false);
  2434. stat.value = attributeVal.valueBase;
  2435. }
  2436. if(attributeVal.valueMultiplicative != 0)
  2437. {
  2438.  
  2439.  
  2440. statLabel = GetAttributeNameLocStr(attributeName, false);
  2441. stat.value = attributeVal.valueMultiplicative;
  2442. stat.percentageValue = true;
  2443. }
  2444. if(attributeVal.valueAdditive != 0)
  2445. {
  2446. statLabel = GetAttributeNameLocStr(attributeName, false);
  2447. stat.value = attributeVal.valueAdditive;
  2448. }
  2449. if (stat.value != 0)
  2450. {
  2451. stat.attributeName = statLabel;
  2452.  
  2453. itemStats.PushBack(stat);
  2454. }
  2455. }
  2456. }
  2457.  
  2458.  
  2459. public function GetItemStatsFromName(itemName : name, out itemStats : array<SAttributeTooltip>)
  2460. {
  2461. var itemCategory : name;
  2462. var i, j, settingsSize : int;
  2463. var attributeString : string;
  2464. var attributeColor : string;
  2465. var attributeName : name;
  2466. var isPercentageValue : string;
  2467. var attributes, itemAbilities, tmpArray : array<name>;
  2468. var weights : array<float>;
  2469. var stat : SAttributeTooltip;
  2470. var attributeVal, min, max : SAbilityAttributeValue;
  2471. var dm : CDefinitionsManagerAccessor;
  2472. var primaryStatLabel : string;
  2473. var statLabel : string;
  2474.  
  2475. settingsSize = theGame.tooltipSettings.GetNumRows();
  2476. dm = theGame.GetDefinitionsManager();
  2477. dm.GetItemAbilitiesWithWeights(itemName, GetEntity() == thePlayer, itemAbilities, weights, i, j);
  2478. attributes = dm.GetAbilitiesAttributes(itemAbilities);
  2479.  
  2480. itemStats.Clear();
  2481. itemCategory = dm.GetItemCategory(itemName);
  2482. for(i=0; i<settingsSize; i+=1)
  2483. {
  2484.  
  2485. attributeString = theGame.tooltipSettings.GetValueAt(0,i);
  2486. if(StrLen(attributeString) <= 0)
  2487. continue;
  2488.  
  2489. attributeName = '';
  2490.  
  2491.  
  2492. for(j=0; j<attributes.Size(); j+=1)
  2493. {
  2494. if(NameToString(attributes[j]) == attributeString)
  2495. {
  2496. attributeName = attributes[j];
  2497. break;
  2498. }
  2499. }
  2500. if(!IsNameValid(attributeName))
  2501. continue;
  2502.  
  2503.  
  2504. if(itemCategory == 'silversword' && attributeName == 'SlashingDamage') continue;
  2505. if(itemCategory == 'steelsword' && attributeName == 'SilverDamage') continue;
  2506.  
  2507.  
  2508. attributeColor = theGame.tooltipSettings.GetValueAt(1,i);
  2509.  
  2510. isPercentageValue = theGame.tooltipSettings.GetValueAt(2,i);
  2511.  
  2512.  
  2513. dm.GetAbilitiesAttributeValue(itemAbilities, attributeName, min, max);
  2514. attributeVal = GetAttributeRandomizedValue(min, max);
  2515.  
  2516. stat.attributeColor = attributeColor;
  2517. stat.percentageValue = isPercentageValue;
  2518.  
  2519. stat.primaryStat = IsPrimaryStat(itemCategory, attributeName, primaryStatLabel);
  2520.  
  2521. stat.value = 0;
  2522. stat.originName = attributeName;
  2523.  
  2524. if (attributeName == 'toxicity_offset')
  2525. statLabel = GetAttributeNameLocStr('toxicity', false);
  2526. else
  2527. statLabel = GetAttributeNameLocStr(attributeName, false);
  2528.  
  2529.  
  2530. if(attributeVal.valueBase != 0)
  2531. {
  2532. stat.value = attributeVal.valueBase;
  2533. }
  2534. if(attributeVal.valueMultiplicative != 0)
  2535. {
  2536. stat.value = attributeVal.valueMultiplicative;
  2537. stat.percentageValue = true;
  2538. }
  2539. if(attributeVal.valueAdditive != 0)
  2540. {
  2541. statLabel = GetAttributeNameLocStr(attributeName, false);
  2542. stat.value = stat.value + attributeVal.valueAdditive;
  2543. }
  2544.  
  2545. if (stat.value != 0)
  2546. {
  2547. stat.attributeName = statLabel;
  2548.  
  2549. itemStats.PushBack(stat);
  2550. }
  2551.  
  2552.  
  2553. }
  2554. }
  2555.  
  2556. public function IsThereItemOnSlot(slot : EEquipmentSlots) : bool
  2557. {
  2558. var player : W3PlayerWitcher;
  2559.  
  2560. player = ((W3PlayerWitcher)GetEntity());
  2561. if(player)
  2562. {
  2563. return player.IsAnyItemEquippedOnSlot(slot);
  2564. }
  2565. else
  2566. {
  2567. return false;
  2568. }
  2569. }
  2570.  
  2571. public function GetItemEquippedOnSlot(slot : EEquipmentSlots, out item : SItemUniqueId) : bool
  2572. {
  2573. var player : W3PlayerWitcher;
  2574.  
  2575. player = ((W3PlayerWitcher)GetEntity());
  2576. if(player)
  2577. {
  2578. return player.GetItemEquippedOnSlot(slot, item);
  2579. }
  2580. else
  2581. {
  2582. return false;
  2583. }
  2584. }
  2585.  
  2586. public function IsItemExcluded ( itemID : SItemUniqueId, excludedItems : array < SItemNameProperty > ) : bool
  2587. {
  2588. var i : int;
  2589. var currItemName : name;
  2590.  
  2591. currItemName = GetItemName( itemID );
  2592.  
  2593. for ( i = 0; i < excludedItems.Size(); i+=1 )
  2594. {
  2595. if ( currItemName == excludedItems[i].itemName )
  2596. {
  2597. return true;
  2598. }
  2599. }
  2600. return false;
  2601. }
  2602. public function GetOilNameOnSword(steel:bool):name
  2603. {
  2604. var player : W3PlayerWitcher;
  2605.  
  2606. player = ((W3PlayerWitcher)GetEntity());
  2607. if(player)
  2608. {
  2609. return player.GetOilAppliedOnSword(steel);
  2610. }
  2611. else
  2612. {
  2613. return '';
  2614. }
  2615. }
  2616.  
  2617.  
  2618. public function GetItemPrimaryStat(itemId : SItemUniqueId, out attributeLabel : string, out attributeVal : float ) : void
  2619. {
  2620. var attributeName : name;
  2621. var attributeValue:SAbilityAttributeValue;
  2622.  
  2623. GetItemPrimaryStatImplById(itemId, attributeLabel, attributeVal, attributeName);
  2624.  
  2625. attributeValue = GetItemAttributeValue(itemId, attributeName);
  2626.  
  2627. if(attributeValue.valueBase != 0)
  2628. {
  2629. attributeVal = attributeValue.valueBase;
  2630. }
  2631. if(attributeValue.valueMultiplicative != 0)
  2632. {
  2633. attributeVal = attributeValue.valueMultiplicative;
  2634. }
  2635. if(attributeValue.valueAdditive != 0)
  2636. {
  2637. attributeVal = attributeValue.valueAdditive;
  2638. }
  2639. }
  2640.  
  2641. public function GetItemStatByName(itemName : name, statName : name, out resultValue : float) : void
  2642. {
  2643. var dm : CDefinitionsManagerAccessor;
  2644. var attributes, itemAbilities : array<name>;
  2645. var min, max, attributeValue : SAbilityAttributeValue;
  2646. var tmpInt : int;
  2647. var tmpArray : array<float>;
  2648.  
  2649. dm = theGame.GetDefinitionsManager();
  2650. dm.GetItemAbilitiesWithWeights(itemName, GetEntity() == thePlayer, itemAbilities, tmpArray, tmpInt, tmpInt);
  2651. attributes = dm.GetAbilitiesAttributes(itemAbilities);
  2652.  
  2653. dm.GetAbilitiesAttributeValue(itemAbilities, statName, min, max);
  2654. attributeValue = GetAttributeRandomizedValue(min, max);
  2655.  
  2656. if(attributeValue.valueBase != 0)
  2657. {
  2658. resultValue = attributeValue.valueBase;
  2659. }
  2660. if(attributeValue.valueMultiplicative != 0)
  2661. {
  2662. resultValue = attributeValue.valueMultiplicative;
  2663. }
  2664. if(attributeValue.valueAdditive != 0)
  2665. {
  2666. resultValue = attributeValue.valueAdditive;
  2667. }
  2668. }
  2669.  
  2670. public function GetItemPrimaryStatFromName(itemName : name, out attributeLabel : string, out attributeVal : float, out primAttrName : name) : void
  2671. {
  2672. var dm : CDefinitionsManagerAccessor;
  2673. var attributeName : name;
  2674. var attributes, itemAbilities : array<name>;
  2675. var attributeValue, min, max : SAbilityAttributeValue;
  2676.  
  2677. var tmpInt : int;
  2678. var tmpArray : array<float>;
  2679.  
  2680. dm = theGame.GetDefinitionsManager();
  2681.  
  2682. GetItemPrimaryStatImpl(dm.GetItemCategory(itemName), attributeLabel, attributeVal, attributeName);
  2683. dm.GetItemAbilitiesWithWeights(itemName, GetEntity() == thePlayer, itemAbilities, tmpArray, tmpInt, tmpInt);
  2684. attributes = dm.GetAbilitiesAttributes(itemAbilities);
  2685. for (tmpInt = 0; tmpInt < attributes.Size(); tmpInt += 1)
  2686. if (attributes[tmpInt] == attributeName)
  2687. {
  2688. dm.GetAbilitiesAttributeValue(itemAbilities, attributeName, min, max);
  2689. attributeValue = GetAttributeRandomizedValue(min, max);
  2690. primAttrName = attributeName;
  2691. break;
  2692. }
  2693.  
  2694. if(attributeValue.valueBase != 0)
  2695. {
  2696. attributeVal = attributeValue.valueBase;
  2697. }
  2698. if(attributeValue.valueMultiplicative != 0)
  2699. {
  2700. attributeVal = attributeValue.valueMultiplicative;
  2701. }
  2702. if(attributeValue.valueAdditive != 0)
  2703. {
  2704. attributeVal = attributeValue.valueAdditive;
  2705. }
  2706.  
  2707. }
  2708.  
  2709. public function IsPrimaryStatById(itemId : SItemUniqueId, attributeName : name, out attributeLabel : string) : bool
  2710. {
  2711. var attrValue : float;
  2712. var attrName : name;
  2713.  
  2714. GetItemPrimaryStatImplById(itemId, attributeLabel, attrValue, attrName);
  2715. return attrName == attributeName;
  2716. }
  2717.  
  2718. private function GetItemPrimaryStatImplById(itemId : SItemUniqueId, out attributeLabel : string, out attributeVal : float, out attributeName : name ) : void
  2719. {
  2720. var itemOnSlot : SItemUniqueId;
  2721. var categoryName : name;
  2722. var abList : array<name>;
  2723.  
  2724. attributeName = '';
  2725. attributeLabel = "";
  2726. categoryName = GetItemCategory(itemId);
  2727.  
  2728.  
  2729. if (categoryName == 'bolt' || categoryName == 'petard')
  2730. {
  2731. GetItemAttributes(itemId, abList);
  2732. if (abList.Contains('FireDamage'))
  2733. {
  2734. attributeName = 'FireDamage';
  2735. }
  2736. else if (abList.Contains('PiercingDamage'))
  2737. {
  2738. attributeName = 'PiercingDamage';
  2739. }
  2740. else if (abList.Contains('PiercingDamage'))
  2741. {
  2742. attributeName = 'PiercingDamage';
  2743. }
  2744. else if (abList.Contains('PoisonDamage'))
  2745. {
  2746. attributeName = 'PoisonDamage';
  2747. }
  2748. else if (abList.Contains('BludgeoningDamage'))
  2749. {
  2750. attributeName = 'BludgeoningDamage';
  2751. }
  2752. else
  2753. {
  2754. attributeName = 'PhysicalDamage';
  2755. }
  2756. attributeLabel = GetAttributeNameLocStr(attributeName, false);
  2757. }
  2758. else if (categoryName == 'secondary')
  2759. {
  2760. GetItemAttributes(itemId, abList);
  2761. if (abList.Contains('BludgeoningDamage'))
  2762. {
  2763. attributeName = 'BludgeoningDamage';
  2764. }
  2765. else
  2766. {
  2767. attributeName = 'PhysicalDamage';
  2768. }
  2769. attributeLabel = GetAttributeNameLocStr(attributeName, false);
  2770. }
  2771. else if (categoryName == 'steelsword')
  2772. {
  2773. GetItemAttributes(itemId, abList);
  2774. if (abList.Contains('SlashingDamage'))
  2775. {
  2776. attributeName = 'SlashingDamage';
  2777. attributeLabel = GetLocStringByKeyExt("panel_inventory_tooltip_damage");
  2778. }
  2779. else if (abList.Contains('BludgeoningDamage'))
  2780. {
  2781. attributeName = 'BludgeoningDamage';
  2782. }
  2783. else if (abList.Contains('PiercingDamage'))
  2784. {
  2785. attributeName = 'PiercingDamage';
  2786. }
  2787. else
  2788. {
  2789. attributeName = 'PhysicalDamage';
  2790. }
  2791. if (attributeLabel == "")
  2792. {
  2793. attributeLabel = GetAttributeNameLocStr(attributeName, false);
  2794. }
  2795. }
  2796. else
  2797. {
  2798. GetItemPrimaryStatImpl(categoryName, attributeLabel, attributeVal, attributeName);
  2799. }
  2800. }
  2801.  
  2802. public function IsPrimaryStat(categoryName : name, attributeName : name, out attributeLabel : string) : bool
  2803. {
  2804. var attrValue : float;
  2805. var attrName : name;
  2806.  
  2807. GetItemPrimaryStatImpl(categoryName, attributeLabel, attrValue, attrName);
  2808. return attrName == attributeName;
  2809. }
  2810.  
  2811. private function GetItemPrimaryStatImpl(categoryName : name, out attributeLabel : string, out attributeVal : float, out attributeName : name ) : void
  2812. {
  2813. attributeName = '';
  2814. attributeLabel = "";
  2815. switch (categoryName)
  2816. {
  2817. case 'steelsword':
  2818. attributeName = 'SlashingDamage';
  2819. attributeLabel = GetLocStringByKeyExt("panel_inventory_tooltip_damage");
  2820. break;
  2821. case 'silversword':
  2822. attributeName = 'SilverDamage';
  2823. attributeLabel = GetLocStringByKeyExt("panel_inventory_tooltip_damage");
  2824. break;
  2825. case 'armor':
  2826. case 'gloves':
  2827. case 'gloves':
  2828. case 'boots':
  2829. case 'pants':
  2830. attributeName = 'armor';
  2831. break;
  2832. case 'potion':
  2833. case 'oil':
  2834.  
  2835. break;
  2836. case 'bolt':
  2837. case 'petard':
  2838. attributeName = 'PhysicalDamage';
  2839. break;
  2840. case 'crossbow':
  2841. default:
  2842. attributeLabel = "";
  2843. attributeVal = 0;
  2844. return;
  2845. break;
  2846. }
  2847.  
  2848. if (attributeLabel == "")
  2849. {
  2850. attributeLabel = GetAttributeNameLocStr(attributeName, false);
  2851. }
  2852. }
  2853.  
  2854. public function CanBeCompared(itemId : SItemUniqueId) : bool
  2855. {
  2856. var wplayer : W3PlayerWitcher;
  2857. var itemSlot : EEquipmentSlots;
  2858. var equipedItem : SItemUniqueId;
  2859. var horseManager : W3HorseManager;
  2860.  
  2861. var isArmorOrWeapon : bool;
  2862.  
  2863. if (IsItemHorseItem(itemId))
  2864. {
  2865. horseManager = GetWitcherPlayer().GetHorseManager();
  2866.  
  2867. if (!horseManager)
  2868. {
  2869. return false;
  2870. }
  2871.  
  2872. if (horseManager.IsItemEquipped(itemId))
  2873. {
  2874. return false;
  2875. }
  2876.  
  2877. itemSlot = GetHorseSlotForItem(itemId);
  2878. equipedItem = horseManager.GetItemInSlot(itemSlot);
  2879. if (!horseManager.GetInventoryComponent().IsIdValid(equipedItem))
  2880. {
  2881. return false;
  2882. }
  2883. }
  2884. else
  2885. {
  2886. isArmorOrWeapon = IsItemAnyArmor(itemId) || IsItemWeapon(itemId);
  2887. if (!isArmorOrWeapon)
  2888. {
  2889. return false;
  2890. }
  2891.  
  2892. wplayer = GetWitcherPlayer();
  2893. if (wplayer.IsItemEquipped(itemId))
  2894. {
  2895. return false;
  2896. }
  2897.  
  2898. itemSlot = GetSlotForItemId(itemId);
  2899. wplayer.GetItemEquippedOnSlot(itemSlot, equipedItem);
  2900. if (!wplayer.inv.IsIdValid(equipedItem))
  2901. {
  2902. return false;
  2903. }
  2904. }
  2905.  
  2906. return true;
  2907. }
  2908.  
  2909. public function GetHorseSlotForItem(id : SItemUniqueId) : EEquipmentSlots
  2910. {
  2911. var tags : array<name>;
  2912.  
  2913. GetItemTags(id, tags);
  2914.  
  2915. if(tags.Contains('Saddle')) return EES_HorseSaddle;
  2916. else if(tags.Contains('HorseBag')) return EES_HorseBag;
  2917. else if(tags.Contains('Trophy')) return EES_HorseTrophy;
  2918. else if(tags.Contains('Blinders')) return EES_HorseBlinders;
  2919. else return EES_InvalidSlot;
  2920. }
  2921.  
  2922.  
  2923.  
  2924.  
  2925.  
  2926. public final function SingletonItemRefillAmmo(id : SItemUniqueId)
  2927. {
  2928. SetItemModifierInt(id, 'ammo_current', SingletonItemGetMaxAmmo(id));
  2929. theGame.GetGlobalEventsManager().OnScriptedEvent( SEC_OnAmmoChanged );
  2930. }
  2931.  
  2932. public function SingletonItemSetAmmo(id : SItemUniqueId, quantity : int)
  2933. {
  2934. var amount : int;
  2935.  
  2936. if(ItemHasTag(id, theGame.params.TAG_INFINITE_AMMO))
  2937. amount = -1;
  2938. else
  2939. amount = Clamp(quantity, 0, SingletonItemGetMaxAmmo(id));
  2940.  
  2941. SetItemModifierInt(id, 'ammo_current', amount);
  2942. theGame.GetGlobalEventsManager().OnScriptedEvent( SEC_OnAmmoChanged );
  2943. }
  2944.  
  2945. public function SingletonItemAddAmmo(id : SItemUniqueId, quantity : int)
  2946. {
  2947. var ammo : int;
  2948.  
  2949. if(quantity <= 0)
  2950. return;
  2951.  
  2952. ammo = GetItemModifierInt(id, 'ammo_current');
  2953.  
  2954. if(ammo == -1)
  2955. return;
  2956.  
  2957. ammo = Clamp(ammo + quantity, 0, SingletonItemGetMaxAmmo(id));
  2958. SetItemModifierInt(id, 'ammo_current', ammo);
  2959. theGame.GetGlobalEventsManager().OnScriptedEvent( SEC_OnAmmoChanged );
  2960. }
  2961.  
  2962. public function SingletonItemsRefillAmmo()
  2963. {
  2964. var i : int;
  2965. var singletonItems : array<SItemUniqueId>;
  2966. var alco : SItemUniqueId;
  2967. var arrStr : array<string>;
  2968. var witcher : W3PlayerWitcher;
  2969. var itemLabel : string;
  2970.  
  2971. witcher = GetWitcherPlayer();
  2972. if(GetEntity() == witcher && HasNotFilledSingletonItem())
  2973. {
  2974. alco = witcher.GetAlcoholForAlchemicalItemsRefill();
  2975.  
  2976. if(!IsIdValid(alco))
  2977. {
  2978.  
  2979. theGame.GetGuiManager().ShowNotification(GetLocStringByKeyExt("message_common_alchemy_items_cannot_refill"));
  2980. theSound.SoundEvent("gui_global_denied");
  2981. return;
  2982. }
  2983. else
  2984. {
  2985.  
  2986. arrStr.PushBack(GetItemName(alco));
  2987. itemLabel = GetLocStringByKeyExt(GetItemLocalizedNameByUniqueID(alco));
  2988. theGame.GetGuiManager().ShowNotification( itemLabel + " - " + GetLocStringByKeyExtWithParams("message_common_alchemy_items_refilled", , , arrStr));
  2989. theSound.SoundEvent("gui_alchemy_brew");
  2990. RemoveItem(alco);
  2991. }
  2992. }
  2993.  
  2994. singletonItems = GetSingletonItems();
  2995. for(i=0; i<singletonItems.Size(); i+=1)
  2996. {
  2997. SingletonItemRefillAmmo(singletonItems[i]);
  2998. }
  2999. }
  3000.  
  3001. public function SingletonItemsRefillAmmoNoAlco()
  3002. {
  3003. var i : int;
  3004. var singletonItems : array<SItemUniqueId>;
  3005. var alco : SItemUniqueId;
  3006. var arrStr : array<string>;
  3007. var witcher : W3PlayerWitcher;
  3008. var itemLabel : string;
  3009.  
  3010. witcher = GetWitcherPlayer();
  3011. if(GetEntity() == witcher && HasNotFilledSingletonItem())
  3012. {
  3013.  
  3014. arrStr.PushBack(GetItemName(alco));
  3015. itemLabel = GetLocStringByKeyExt(GetItemLocalizedNameByUniqueID(alco));
  3016. theGame.GetGuiManager().ShowNotification( itemLabel + " - " + GetLocStringByKeyExtWithParams("message_common_alchemy_items_refilled", , , arrStr));
  3017. theSound.SoundEvent("gui_alchemy_brew");
  3018. }
  3019.  
  3020. singletonItems = GetSingletonItems();
  3021. for(i=0; i<singletonItems.Size(); i+=1)
  3022. {
  3023. SingletonItemRefillAmmo(singletonItems[i]);
  3024. }
  3025. }
  3026.  
  3027.  
  3028. private final function HasNotFilledSingletonItem() : bool
  3029. {
  3030. var i : int;
  3031. var singletonItems : array<SItemUniqueId>;
  3032.  
  3033. singletonItems = GetSingletonItems();
  3034. for(i=0; i<singletonItems.Size(); i+=1)
  3035. {
  3036. if(SingletonItemGetAmmo(singletonItems[i]) < SingletonItemGetMaxAmmo(singletonItems[i]))
  3037. {
  3038. return true;
  3039. }
  3040. }
  3041.  
  3042. return false;
  3043. }
  3044.  
  3045. public function SingletonItemRemoveAmmo(itemID : SItemUniqueId, optional quantity : int)
  3046. {
  3047. var ammo : int;
  3048.  
  3049. if(!IsItemSingletonItem(itemID) || ItemHasTag(itemID, theGame.params.TAG_INFINITE_AMMO))
  3050. return;
  3051.  
  3052. if(quantity <= 0)
  3053. quantity = 1;
  3054.  
  3055. ammo = GetItemModifierInt(itemID, 'ammo_current');
  3056. ammo = Max(0, ammo - quantity);
  3057. SetItemModifierInt(itemID, 'ammo_current', ammo);
  3058.  
  3059.  
  3060. if(ammo == 0 && ShouldProcessTutorial('TutorialAlchemyRefill') && FactsQuerySum("q001_nightmare_ended") > 0)
  3061. {
  3062. FactsAdd('tut_alch_refill', 1);
  3063. }
  3064. theGame.GetGlobalEventsManager().OnScriptedEvent( SEC_OnAmmoChanged );
  3065. }
  3066.  
  3067. public function SingletonItemGetAmmo(itemID : SItemUniqueId) : int
  3068. {
  3069. if(!IsItemSingletonItem(itemID))
  3070. return 0;
  3071.  
  3072. return GetItemModifierInt(itemID, 'ammo_current');
  3073. }
  3074.  
  3075. public function SingletonItemGetMaxAmmo(itemID : SItemUniqueId) : int
  3076. {
  3077. var ammo : int;
  3078.  
  3079. ammo = RoundMath(CalculateAttributeValue(GetItemAttributeValue(itemID, 'ammo')));
  3080.  
  3081. if(GetEntity() == GetWitcherPlayer() && ammo > 0)
  3082. {
  3083. if(IsItemBomb(itemID) && thePlayer.CanUseSkill(S_Alchemy_s08) )
  3084. ammo += thePlayer.GetSkillLevel(S_Alchemy_s08);
  3085.  
  3086.  
  3087. if(thePlayer.HasBuff(EET_Mutagen03) && (IsItemBomb(itemID) || (!IsItemMutagenPotion(itemID) && IsItemPotion(itemID))) )
  3088. ammo += 1;
  3089. }
  3090.  
  3091. return ammo;
  3092. }
  3093.  
  3094.  
  3095.  
  3096.  
  3097.  
  3098. public final function IsItemSteelSwordUsableByPlayer(item : SItemUniqueId) : bool
  3099. {
  3100. return ItemHasTag(item, theGame.params.TAG_PLAYER_STEELSWORD) && !ItemHasTag(item, 'SecondaryWeapon');
  3101. }
  3102.  
  3103. public final function IsItemSilverSwordUsableByPlayer(item : SItemUniqueId) : bool
  3104. {
  3105. return ItemHasTag(item, theGame.params.TAG_PLAYER_SILVERSWORD) && !ItemHasTag(item, 'SecondaryWeapon');
  3106. }
  3107.  
  3108. public final function IsItemFists(item : SItemUniqueId) : bool {return GetItemCategory(item) == 'fist';}
  3109. public final function IsItemWeapon(item : SItemUniqueId) : bool {return ItemHasTag(item, 'Weapon') || ItemHasTag(item, 'WeaponTab');}
  3110. public final function IsItemCrossbow(item : SItemUniqueId) : bool {return GetItemCategory(item) == 'crossbow';}
  3111. public final function IsItemChestArmor(item : SItemUniqueId) : bool {return GetItemCategory(item) == 'armor';}
  3112. public final function IsItemBody(item : SItemUniqueId) : bool {return ItemHasTag(item, 'Body');}
  3113. public final function IsItemBoots(item : SItemUniqueId) : bool {return GetItemCategory(item) == 'boots';}
  3114. public final function IsItemGloves(item : SItemUniqueId) : bool {return GetItemCategory(item) == 'gloves';}
  3115. public final function IsItemPants(item : SItemUniqueId) : bool {return GetItemCategory(item) == 'trousers' || GetItemCategory(item) == 'pants';}
  3116. public final function IsItemTrophy(item : SItemUniqueId) : bool {return GetItemCategory(item) == 'trophy';}
  3117. public final function IsItemMask(item : SItemUniqueId) : bool {return GetItemCategory(item) == 'mask';}
  3118. public final function IsItemBomb(item : SItemUniqueId) : bool {return GetItemCategory(item) == 'petard';}
  3119. public final function IsItemBolt(item : SItemUniqueId) : bool {return GetItemCategory(item) == 'bolt';}
  3120. public final function IsItemUpgrade(item : SItemUniqueId) : bool {return GetItemCategory(item) == 'upgrade';}
  3121. public final function IsItemTool(item : SItemUniqueId) : bool {return GetItemCategory(item) == 'tool';}
  3122. public final function IsItemPotion(item : SItemUniqueId) : bool {return ItemHasTag(item, 'Potion');}
  3123. public final function IsItemOil(item : SItemUniqueId) : bool {return ItemHasTag(item, 'SilverOil') || ItemHasTag(item, 'SteelOil');}
  3124. public final function IsItemAnyArmor(item : SItemUniqueId) : bool {return ItemHasTag(item, theGame.params.TAG_ARMOR);}
  3125. public final function IsItemUpgradeable(item : SItemUniqueId) : bool {return ItemHasTag(item, theGame.params.TAG_ITEM_UPGRADEABLE);}
  3126. public final function IsItemIngredient(item : SItemUniqueId) : bool {return ItemHasTag(item, 'AlchemyIngredient') || ItemHasTag(item, 'CraftingIngredient');}
  3127. public final function IsItemDismantleKit(item : SItemUniqueId) : bool {return ItemHasTag(item, 'DismantleKit');}
  3128. public final function IsItemHorseBag(item : SItemUniqueId) : bool {return ItemHasTag(item, 'HorseBag');}
  3129. public final function IsItemReadable(item : SItemUniqueId) : bool {return ItemHasTag(item, 'ReadableItem');}
  3130. public final function IsItemAlchemyItem(item : SItemUniqueId) : bool {return IsItemOil(item) || IsItemPotion(item) || IsItemBomb(item) || ItemHasTag(item, 'QuickSlot'); }
  3131. public final function IsItemSingletonItem(item : SItemUniqueId) : bool {return ItemHasTag(item, theGame.params.TAG_ITEM_SINGLETON);}
  3132. public final function IsItemQuest(item : SItemUniqueId) : bool {return ItemHasTag(item, 'Quest');}
  3133. public final function IsItemFood(item : SItemUniqueId) : bool {return ItemHasTag(item, 'Edibles') || ItemHasTag(item, 'Drinks');}
  3134. public final function IsItemSecondaryWeapon(item : SItemUniqueId) : bool {return ItemHasTag(item, 'SecondaryWeapon');}
  3135. public final function IsItemHorseItem(item: SItemUniqueId) : bool {return ItemHasTag(item, 'Saddle') || ItemHasTag(item, 'HorseBag') || ItemHasTag(item, 'Trophy') || ItemHasTag(item, 'Blinders'); }
  3136.  
  3137. public final function IsItemMutagenPotion(item : SItemUniqueId) : bool
  3138. {
  3139. return IsItemPotion(item) && ItemHasTag(item, 'Mutagen');
  3140. }
  3141.  
  3142. public final function IsItemSetItem(item : SItemUniqueId) : bool
  3143. {
  3144. return ItemHasTag(item, theGame.params.ITEM_SET_TAG_BEAR) || ItemHasTag(item, theGame.params.ITEM_SET_TAG_GRYPHON) || ItemHasTag(item, theGame.params.ITEM_SET_TAG_LYNX) || ItemHasTag(item, theGame.params.ITEM_SET_TAG_WOLF);
  3145. }
  3146.  
  3147. public function GetArmorType(item : SItemUniqueId) : EArmorType
  3148. {
  3149. if(ItemHasTag(item, 'LightArmor'))
  3150. return EAT_Light;
  3151. else if(ItemHasTag(item, 'MediumArmor'))
  3152. return EAT_Medium;
  3153. else if(ItemHasTag(item, 'HeavyArmor'))
  3154. return EAT_Heavy;
  3155.  
  3156. return EAT_Undefined;
  3157. }
  3158.  
  3159. public final function GetAlchemyCraftableItems() : array<SItemUniqueId>
  3160. {
  3161. var items : array<SItemUniqueId>;
  3162. var i : int;
  3163.  
  3164. GetAllItems(items);
  3165.  
  3166. for(i=items.Size()-1; i>=0; i-=1)
  3167. {
  3168. if(!IsItemPotion(items[i]) && !IsItemBomb(items[i]) && !IsItemOil(items[i]))
  3169. items.EraseFast(i);
  3170. }
  3171.  
  3172. return items;
  3173. }
  3174.  
  3175. public function IsItemEncumbranceItem(item : SItemUniqueId) : bool
  3176. {
  3177. if(ItemHasTag(item, theGame.params.TAG_ENCUMBRANCE_ITEM_FORCE_YES))
  3178. return true;
  3179.  
  3180. if(ItemHasTag(item, theGame.params.TAG_ENCUMBRANCE_ITEM_FORCE_NO))
  3181. return false;
  3182.  
  3183.  
  3184. if (
  3185. IsItemBody(item)
  3186.  
  3187.  
  3188.  
  3189.  
  3190.  
  3191.  
  3192.  
  3193.  
  3194.  
  3195.  
  3196.  
  3197.  
  3198. )
  3199. return false;
  3200.  
  3201. return true;
  3202. }
  3203.  
  3204. public function GetItemEncumbrance(item : SItemUniqueId) : float
  3205. {
  3206. if ( IsItemEncumbranceItem( item ) )
  3207. {
  3208. if ( GetItemCategory( item ) == 'quest' || GetItemCategory( item ) == 'key' )
  3209. {
  3210. return 0.01 * GetItemQuantity( item );
  3211. }
  3212. else if ( GetItemCategory( item ) == 'usable' || GetItemCategory( item ) == 'upgrade' || GetItemCategory( item ) == 'junk' )
  3213. {
  3214. return 0.01 + GetItemWeight( item ) * GetItemQuantity( item ) * 0.2;
  3215. }
  3216. else if ( IsItemAlchemyItem( item ) || IsItemIngredient( item ) )
  3217. {
  3218. return 0.0;
  3219. }
  3220. else
  3221. {
  3222. return 0.01 + GetItemWeight( item ) * GetItemQuantity( item ) * 0.5;
  3223. }
  3224. }
  3225. return 0;
  3226. }
  3227.  
  3228. public function GetFilterTypeByItem( item : SItemUniqueId ) : EInventoryFilterType
  3229. {
  3230. var filterType : EInventoryFilterType;
  3231.  
  3232. if( ItemHasTag( item, 'Quest' ) )
  3233. {
  3234. return IFT_QuestItems;
  3235. }
  3236. else if( IsItemIngredient( item ) )
  3237. {
  3238. return IFT_Ingredients;
  3239. }
  3240. else if( IsItemAlchemyItem(item) )
  3241. {
  3242. return IFT_AlchemyItems;
  3243. }
  3244. else if( IsItemAnyArmor(item) )
  3245. {
  3246. return IFT_Armors;
  3247. }
  3248. else if( IsItemWeapon( item ) )
  3249. {
  3250. return IFT_Weapons;
  3251. }
  3252. else
  3253. {
  3254. return IFT_Default;
  3255. }
  3256. }
  3257.  
  3258.  
  3259. public function IsItemQuickslotItem(item : SItemUniqueId) : bool
  3260. {
  3261. return IsSlotQuickslot( GetSlotForItemId(item) );
  3262. }
  3263.  
  3264. public function GetCrossbowAmmo(id : SItemUniqueId) : int
  3265. {
  3266. if(!IsItemCrossbow(id))
  3267. return -1;
  3268.  
  3269. return (int)CalculateAttributeValue(GetItemAttributeValue(id, 'ammo'));
  3270. }
  3271.  
  3272.  
  3273.  
  3274. public function GetSlotForItemId(item : SItemUniqueId) : EEquipmentSlots
  3275. {
  3276. var tags : array<name>;
  3277. var player : W3PlayerWitcher;
  3278. var slot : EEquipmentSlots;
  3279.  
  3280. player = ((W3PlayerWitcher)GetEntity());
  3281.  
  3282. GetItemTags(item, tags);
  3283. slot = GetSlotForItem( GetItemCategory(item), tags, player );
  3284.  
  3285. if(!player)
  3286. return slot;
  3287.  
  3288. if(IsMultipleSlot(slot))
  3289. {
  3290. if(slot == EES_Petard1 && player.IsAnyItemEquippedOnSlot(slot))
  3291. {
  3292. if(!player.IsAnyItemEquippedOnSlot(EES_Petard2))
  3293. slot = EES_Petard2;
  3294. }
  3295. else if(slot == EES_Quickslot1 && player.IsAnyItemEquippedOnSlot(slot))
  3296. {
  3297. if(!player.IsAnyItemEquippedOnSlot(EES_Quickslot2))
  3298. slot = EES_Quickslot2;
  3299. }
  3300. else if(slot == EES_Potion1 && player.IsAnyItemEquippedOnSlot(slot))
  3301. {
  3302. if(!player.IsAnyItemEquippedOnSlot(EES_Potion2))
  3303. slot = EES_Potion2;
  3304. }
  3305. else if(slot == EES_PotionMutagen1 && player.IsAnyItemEquippedOnSlot(slot))
  3306. {
  3307. if(!player.IsAnyItemEquippedOnSlot(EES_PotionMutagen2))
  3308. {
  3309. slot = EES_PotionMutagen2;
  3310. }
  3311. else
  3312. {
  3313. if(!player.IsAnyItemEquippedOnSlot(EES_PotionMutagen3))
  3314. {
  3315. slot = EES_PotionMutagen3;
  3316. }
  3317. else
  3318. {
  3319. if(!player.IsAnyItemEquippedOnSlot(EES_PotionMutagen4))
  3320. {
  3321. slot = EES_PotionMutagen4;
  3322. }
  3323. }
  3324. }
  3325. }
  3326. else if(slot == EES_SkillMutagen1 && player.IsAnyItemEquippedOnSlot(slot))
  3327. {
  3328. if(!player.IsAnyItemEquippedOnSlot(EES_SkillMutagen2))
  3329. {
  3330. slot = EES_SkillMutagen2;
  3331. }
  3332. else
  3333. {
  3334. if(!player.IsAnyItemEquippedOnSlot(EES_SkillMutagen3))
  3335. {
  3336. slot = EES_SkillMutagen3;
  3337. }
  3338. else
  3339. {
  3340. if(!player.IsAnyItemEquippedOnSlot(EES_SkillMutagen4))
  3341. {
  3342. slot = EES_SkillMutagen4;
  3343. }
  3344. }
  3345. }
  3346. }
  3347. }
  3348.  
  3349. return slot;
  3350. }
  3351.  
  3352.  
  3353.  
  3354. public function GetAllWeapons() : array<SItemUniqueId>
  3355. {
  3356. return GetItemsByTag('Weapon');
  3357. }
  3358.  
  3359.  
  3360. public function GetSpecifiedPlayerItemsQuest(steelSword, silverSword, armor, boots, gloves, pants, trophy, mask, bombs, crossbow, secondaryWeapon, equippedOnly : bool) : array<SItemUniqueId>
  3361. {
  3362. var items, allItems : array<SItemUniqueId>;
  3363. var i : int;
  3364.  
  3365. GetAllItems(allItems);
  3366.  
  3367. for(i=0; i<allItems.Size(); i+=1)
  3368. {
  3369. if(
  3370. (steelSword && IsItemSteelSwordUsableByPlayer(allItems[i])) ||
  3371. (silverSword && IsItemSilverSwordUsableByPlayer(allItems[i])) ||
  3372. (armor && IsItemChestArmor(allItems[i])) ||
  3373. (boots && IsItemBoots(allItems[i])) ||
  3374. (gloves && IsItemGloves(allItems[i])) ||
  3375. (pants && IsItemPants(allItems[i])) ||
  3376. (trophy && IsItemTrophy(allItems[i])) ||
  3377. (mask && IsItemMask(allItems[i])) ||
  3378. (bombs && IsItemBomb(allItems[i])) ||
  3379. (crossbow && (IsItemCrossbow(allItems[i]) || IsItemBolt(allItems[i]))) ||
  3380. (secondaryWeapon && IsItemSecondaryWeapon(allItems[i]))
  3381. )
  3382. {
  3383. if(!equippedOnly || (equippedOnly && ((W3PlayerWitcher)GetEntity()) && GetWitcherPlayer().IsItemEquipped(allItems[i])) )
  3384. {
  3385. if(!ItemHasTag(allItems[i], 'NoDrop'))
  3386. items.PushBack(allItems[i]);
  3387. }
  3388. }
  3389. }
  3390.  
  3391. return items;
  3392. }
  3393.  
  3394.  
  3395.  
  3396. event OnItemRemoved( itemId : SItemUniqueId, quantity : int )
  3397. {
  3398. var ent : CGameplayEntity;
  3399. var crossbows : array<SItemUniqueId>;
  3400. var witcher : W3PlayerWitcher;
  3401. var refill : W3RefillableContainer;
  3402.  
  3403. witcher = GetWitcherPlayer();
  3404.  
  3405. if(GetEntity() == witcher)
  3406. {
  3407.  
  3408.  
  3409.  
  3410.  
  3411.  
  3412. if(IsItemCrossbow(itemId) && HasInfiniteBolts())
  3413. {
  3414. crossbows = GetItemsByCategory('crossbow');
  3415. crossbows.Remove(itemId);
  3416.  
  3417. if(crossbows.Size() == 0)
  3418. {
  3419. RemoveItemByName('Bodkin Bolt', GetItemQuantityByName('Bodkin Bolt'));
  3420. RemoveItemByName('Harpoon Bolt', GetItemQuantityByName('Harpoon Bolt'));
  3421. }
  3422. }
  3423. else if(IsItemBolt(itemId) && witcher.IsItemEquipped(itemId) && witcher.inv.GetItemQuantity(itemId) == quantity)
  3424. {
  3425.  
  3426. witcher.UnequipItem(itemId);
  3427. }
  3428.  
  3429.  
  3430. if(IsItemCrossbow(itemId) && witcher.IsItemEquipped(itemId) && witcher.rangedWeapon)
  3431. {
  3432. witcher.rangedWeapon.ClearDeployedEntity(true);
  3433. witcher.rangedWeapon = NULL;
  3434. }
  3435. if( GetItemCategory(itemId) == 'usable' )
  3436. {
  3437. if(witcher.IsHoldingItemInLHand() && itemId == witcher.currentlyEquipedItemL )
  3438. {
  3439. witcher.HideUsableItem(true);
  3440. }
  3441. }
  3442.  
  3443.  
  3444. if(witcher.IsItemEquipped(itemId) && quantity >= witcher.inv.GetItemQuantity(itemId))
  3445. witcher.UnequipItem(itemId);
  3446. }
  3447.  
  3448.  
  3449. if(GetEntity() == thePlayer && IsItemWeapon(itemId) && (IsItemHeld(itemId) || IsItemMounted(itemId) ))
  3450. {
  3451. thePlayer.OnHolsteredItem(GetItemCategory(itemId),'r_weapon');
  3452. }
  3453.  
  3454.  
  3455. ent = (CGameplayEntity)GetEntity();
  3456. if(ent)
  3457. ent.OnItemTaken( itemId, quantity );
  3458.  
  3459.  
  3460. if(IsLootRenewable())
  3461. {
  3462. refill = (W3RefillableContainer)GetEntity();
  3463. if(refill)
  3464. refill.AddTimer('Refill', 20, true);
  3465. }
  3466. }
  3467.  
  3468.  
  3469. function GenerateItemLevel( item : SItemUniqueId )
  3470. {
  3471. var stat : SAbilityAttributeValue;
  3472. var playerLevel : int;
  3473. var lvl, i : int;
  3474. var quality : int;
  3475.  
  3476. playerLevel = GetWitcherPlayer().GetLevel();
  3477.  
  3478. lvl = playerLevel - 1;
  3479.  
  3480.  
  3481. if ( ( W3MerchantNPC )GetEntity() )
  3482. {
  3483. lvl = RoundF( playerLevel + RandRangeF( 4, 1 ) );
  3484. }
  3485. else if ( !ItemHasTag( item, 'AutogenForceLevel') )
  3486. {
  3487. quality = RoundMath( CalculateAttributeValue( GetItemAttributeValue( item, 'quality' ) ) );
  3488.  
  3489. if ( quality == 5 )
  3490. {
  3491. lvl = RoundF( playerLevel + RandRangeF( 2, 0 ) );
  3492. }
  3493. else if ( quality == 4 )
  3494. {
  3495. lvl = RoundF( playerLevel + RandRangeF( 1, -2 ) );
  3496. }
  3497. else if ( quality == 3 )
  3498. {
  3499. lvl = RoundF( playerLevel + RandRangeF( -1, -3 ) );
  3500.  
  3501. if ( RandF() > 0.9 )
  3502. {
  3503. lvl = playerLevel;
  3504. }
  3505. }
  3506. else if ( quality == 2 )
  3507. {
  3508. lvl = RoundF( playerLevel + RandRangeF( -2, -5 ) );
  3509.  
  3510. if ( RandF() > 0.95 )
  3511. {
  3512. lvl = playerLevel;
  3513. }
  3514. }
  3515. else
  3516. {
  3517. lvl = RoundF( playerLevel + RandRangeF( -2, -8 ) );
  3518.  
  3519. if ( RandF() == 0 )
  3520. {
  3521. lvl = playerLevel;
  3522. }
  3523. }
  3524. }
  3525.  
  3526. if ( lvl < 1 ) lvl = 1;
  3527. if ( lvl > 70 ) lvl = 70;
  3528.  
  3529. if ( ItemHasTag( item, 'PlayerSteelWeapon' ) && !ItemHasAbility( item, 'autogen_steel_base') )
  3530. {
  3531. AddItemCraftedAbility(item, 'autogen_steel_base' );
  3532. for( i=0; i<lvl; i+=1 )
  3533. {
  3534. if ( !ItemHasTag( item, 'AutogenForceLevel') )
  3535. AddItemCraftedAbility(item, 'autogen_steel_dmg', true ); else
  3536. AddItemCraftedAbility(item, 'autogen_fixed_steel_dmg', true );
  3537. }
  3538. }
  3539. else if ( ItemHasTag( item, 'PlayerSilverWeapon' ) && !ItemHasAbility( item, 'autogen_silver_base') )
  3540. {
  3541. AddItemCraftedAbility(item, 'autogen_silver_base' );
  3542. for( i=0; i<lvl; i+=1 )
  3543. {
  3544. if ( !ItemHasTag( item, 'AutogenForceLevel') )
  3545. AddItemCraftedAbility(item, 'autogen_silver_dmg', true ); else
  3546. AddItemCraftedAbility(item, 'autogen_fixed_silver_dmg', true );
  3547. }
  3548. }
  3549. else if ( GetItemCategory( item ) == 'armor' && !ItemHasAbility( item, 'autogen_armor_base') )
  3550. {
  3551. AddItemCraftedAbility(item, 'autogen_armor_base' );
  3552. for( i=0; i<lvl; i+=1 )
  3553. {
  3554. if ( !ItemHasTag( item, 'AutogenForceLevel') )
  3555. AddItemCraftedAbility(item, 'autogen_armor_armor', true ); else
  3556. AddItemCraftedAbility(item, 'autogen_fixed_armor_armor', true );
  3557. }
  3558. }
  3559. else if ( ( GetItemCategory( item ) == 'boots' || GetItemCategory( item ) == 'pants' ) && !ItemHasAbility( item, 'autogen_pants_base') )
  3560. {
  3561. AddItemCraftedAbility(item, 'autogen_pants_base' );
  3562. for( i=0; i<lvl; i+=1 )
  3563. {
  3564. if ( !ItemHasTag( item, 'AutogenForceLevel') )
  3565. AddItemCraftedAbility(item, 'autogen_pants_armor', true ); else
  3566. AddItemCraftedAbility(item, 'autogen_fixed_pants_armor', true );
  3567. }
  3568. }
  3569. else if ( GetItemCategory( item ) == 'gloves' && !ItemHasAbility( item, 'autogen_gloves_base') )
  3570. {
  3571. AddItemCraftedAbility(item, 'autogen_gloves_base' );
  3572. for( i=0; i<lvl; i+=1 )
  3573. {
  3574. if ( !ItemHasTag( item, 'AutogenForceLevel') )
  3575. AddItemCraftedAbility(item, 'autogen_gloves_armor', true ); else
  3576. AddItemCraftedAbility(item, 'autogen_fixed_gloves_armor', true );
  3577. }
  3578. }
  3579. }
  3580.  
  3581.  
  3582. event OnItemAdded(data : SItemChangedData)
  3583. {
  3584. var i, j : int;
  3585. var ent : CGameplayEntity;
  3586. var allCardsNames, foundCardsNames : array<name>;
  3587. var allStringNamesOfCards : array<string>;
  3588. var foundCardsStringNames : array<string>;
  3589. var gwintCards : array<SItemUniqueId>;
  3590. var itemName : name;
  3591. var witcher : W3PlayerWitcher;
  3592. var itemCategory : name;
  3593. var dm : CDefinitionsManagerAccessor;
  3594. var locKey : string;
  3595. var leaderCards : array<name>;
  3596.  
  3597. ent = (CGameplayEntity)GetEntity();
  3598.  
  3599.  
  3600. if( data.informGui )
  3601. {
  3602. recentlyAddedItems.PushBack(data.ids[0]);
  3603. if( ItemHasTag(data.ids[0],'FocusObject') )
  3604. {
  3605. GetWitcherPlayer().GetMedallion().Activate(true,3.0);
  3606. }
  3607. }
  3608.  
  3609.  
  3610. if ( ItemHasTag(data.ids[0], 'Autogen') ) GenerateItemLevel( data.ids[0] );
  3611.  
  3612. witcher = GetWitcherPlayer();
  3613. if(ent == witcher)
  3614. {
  3615.  
  3616. for(i=0; i<data.ids.Size(); i+=1)
  3617. {
  3618.  
  3619. if ( GetItemModifierInt(data.ids[i], 'ItemQualityModified') <= 0 )
  3620. AddRandomEnhancementToItem(data.ids[i]);
  3621.  
  3622.  
  3623. if(ItemHasTag(data.ids[0], theGame.params.GWINT_CARD_ACHIEVEMENT_TAG) || !FactsDoesExist("fix_for_gwent_achievement_bug_121588"))
  3624. {
  3625.  
  3626. leaderCards.PushBack('gwint_card_emhyr_gold');
  3627. leaderCards.PushBack('gwint_card_emhyr_silver');
  3628. leaderCards.PushBack('gwint_card_emhyr_bronze');
  3629. leaderCards.PushBack('gwint_card_foltest_gold');
  3630. leaderCards.PushBack('gwint_card_foltest_silver');
  3631. leaderCards.PushBack('gwint_card_foltest_bronze');
  3632. leaderCards.PushBack('gwint_card_francesca_gold');
  3633. leaderCards.PushBack('gwint_card_francesca_silver');
  3634. leaderCards.PushBack('gwint_card_francesca_bronze');
  3635. leaderCards.PushBack('gwint_card_eredin_gold');
  3636. leaderCards.PushBack('gwint_card_eredin_silver');
  3637. leaderCards.PushBack('gwint_card_eredin_bronze');
  3638.  
  3639. dm = theGame.GetDefinitionsManager();
  3640.  
  3641. allCardsNames = theGame.GetDefinitionsManager().GetItemsWithTag(theGame.params.GWINT_CARD_ACHIEVEMENT_TAG);
  3642.  
  3643.  
  3644. gwintCards = GetItemsByTag(theGame.params.GWINT_CARD_ACHIEVEMENT_TAG);
  3645.  
  3646.  
  3647. allStringNamesOfCards.PushBack('gwint_name_emhyr');
  3648. allStringNamesOfCards.PushBack('gwint_name_emhyr');
  3649. allStringNamesOfCards.PushBack('gwint_name_emhyr');
  3650. allStringNamesOfCards.PushBack('gwint_name_foltest');
  3651. allStringNamesOfCards.PushBack('gwint_name_foltest');
  3652. allStringNamesOfCards.PushBack('gwint_name_foltest');
  3653. allStringNamesOfCards.PushBack('gwint_name_francesca');
  3654. allStringNamesOfCards.PushBack('gwint_name_francesca');
  3655. allStringNamesOfCards.PushBack('gwint_name_francesca');
  3656. allStringNamesOfCards.PushBack('gwint_name_eredin');
  3657. allStringNamesOfCards.PushBack('gwint_name_eredin');
  3658. allStringNamesOfCards.PushBack('gwint_name_eredin');
  3659.  
  3660.  
  3661. for(j=0; j<allCardsNames.Size(); j+=1)
  3662. {
  3663. itemName = allCardsNames[j];
  3664. locKey = dm.GetItemLocalisationKeyName(allCardsNames[j]);
  3665. if (!allStringNamesOfCards.Contains(locKey))
  3666. {
  3667. allStringNamesOfCards.PushBack(locKey);
  3668. }
  3669. }
  3670.  
  3671.  
  3672. if(gwintCards.Size() >= allStringNamesOfCards.Size())
  3673. {
  3674. foundCardsNames.Clear();
  3675. for(j=0; j<gwintCards.Size(); j+=1)
  3676. {
  3677. itemName = GetItemName(gwintCards[j]);
  3678. locKey = dm.GetItemLocalisationKeyName(itemName);
  3679.  
  3680. if(!foundCardsStringNames.Contains(locKey) || leaderCards.Contains(itemName))
  3681. {
  3682. foundCardsStringNames.PushBack(locKey);
  3683. }
  3684. }
  3685.  
  3686. if(foundCardsStringNames.Size() >= allStringNamesOfCards.Size())
  3687. {
  3688. theGame.GetGamerProfile().AddAchievement(EA_GwintCollector);
  3689. FactsAdd("gwint_all_cards_collected", 1, -1);
  3690. }
  3691. }
  3692.  
  3693. if(!FactsDoesExist("fix_for_gwent_achievement_bug_121588"))
  3694. FactsAdd("fix_for_gwent_achievement_bug_121588", 1, -1);
  3695. }
  3696.  
  3697. itemCategory = GetItemCategory( data.ids[0] );
  3698. if( itemCategory == 'alchemy_recipe' || itemCategory == 'crafting_schematic' )
  3699. {
  3700. ReadSchematicsAndRecipes( data.ids[0] );
  3701. }
  3702.  
  3703.  
  3704. if(ItemHasTag(data.ids[i], 'GwintCard'))
  3705. witcher.AddGwentCard(GetItemName(data.ids[i]), data.quantity);
  3706. }
  3707. }
  3708.  
  3709.  
  3710. if(IsItemSingletonItem(data.ids[0]))
  3711. {
  3712. for(i=0; i<data.ids.Size(); i+=1)
  3713. {
  3714. if(!GetItemModifierInt(data.ids[i], 'is_initialized', 0))
  3715. {
  3716. SingletonItemRefillAmmo(data.ids[i]);
  3717. SetItemModifierInt(data.ids[i], 'is_initialized', 1);
  3718. }
  3719. }
  3720. }
  3721.  
  3722.  
  3723. if(ent)
  3724. ent.OnItemGiven(data);
  3725. }
  3726.  
  3727. public function AddRandomEnhancementToItem(item : SItemUniqueId)
  3728. {
  3729. var itemCategory : name;
  3730. var itemQuality : int;
  3731. var ability : name;
  3732. var ent : CGameplayEntity;
  3733.  
  3734.  
  3735.  
  3736. itemCategory = GetItemCategory(item);
  3737. itemQuality = RoundMath(CalculateAttributeValue(GetItemAttributeValue(item, 'quality' )));
  3738.  
  3739. if ( itemCategory == 'armor' )
  3740. {
  3741. switch ( itemQuality )
  3742. {
  3743. case 2 :
  3744. ability = 'quality_masterwork_armor';
  3745. AddItemCraftedAbility(item, theGame.params.GetRandomMasterworkArmorAbility(), true);
  3746. break;
  3747. case 3 :
  3748. ability = 'quality_magical_armor';
  3749.  
  3750. if ( RandF() > 0.5 )
  3751. AddItemCraftedAbility(item, theGame.params.GetRandomMagicalArmorAbility(), true);
  3752. else
  3753. AddItemCraftedAbility(item, theGame.params.GetRandomMasterworkArmorAbility(), true);
  3754.  
  3755. if ( RandF() > 0.5 )
  3756. AddItemCraftedAbility(item, theGame.params.GetRandomMagicalArmorAbility(), true);
  3757. else
  3758. AddItemCraftedAbility(item, theGame.params.GetRandomMasterworkArmorAbility(), true);
  3759. break;
  3760. default : break;
  3761. }
  3762. }
  3763. else if ( itemCategory == 'gloves' )
  3764. {
  3765. switch ( itemQuality )
  3766. {
  3767. case 2 :
  3768. ability = 'quality_masterwork_gloves';
  3769. AddItemCraftedAbility(item, theGame.params.GetRandomMasterworkGlovesAbility(), true);
  3770. break;
  3771. case 3 :
  3772. ability = 'quality_magical_gloves';
  3773.  
  3774. if ( RandF() > 0.5 )
  3775. AddItemCraftedAbility(item, theGame.params.GetRandomMagicalGlovesAbility(), true);
  3776. else
  3777. AddItemCraftedAbility(item, theGame.params.GetRandomMasterworkGlovesAbility(), true);
  3778.  
  3779. if ( RandF() > 0.5 )
  3780. AddItemCraftedAbility(item, theGame.params.GetRandomMagicalGlovesAbility(), true);
  3781. else
  3782. AddItemCraftedAbility(item, theGame.params.GetRandomMasterworkGlovesAbility(), true);
  3783. break;
  3784. default : break;
  3785. }
  3786. }
  3787. else if ( itemCategory == 'pants' )
  3788. {
  3789. switch ( itemQuality )
  3790. {
  3791. case 2 :
  3792. ability = 'quality_masterwork_pants';
  3793. AddItemCraftedAbility(item, theGame.params.GetRandomMasterworkPantsAbility(), true);
  3794. break;
  3795. case 3 :
  3796. ability = 'quality_magical_pants';
  3797.  
  3798. if ( RandF() > 0.5 )
  3799. AddItemCraftedAbility(item, theGame.params.GetRandomMagicalPantsAbility(), true);
  3800. else
  3801. AddItemCraftedAbility(item, theGame.params.GetRandomMasterworkPantsAbility(), true);
  3802.  
  3803. if ( RandF() > 0.5 )
  3804. AddItemCraftedAbility(item, theGame.params.GetRandomMagicalPantsAbility(), true);
  3805. else
  3806. AddItemCraftedAbility(item, theGame.params.GetRandomMasterworkPantsAbility(), true);
  3807. break;
  3808. default : break;
  3809. }
  3810. }
  3811. else if ( itemCategory == 'boots' )
  3812. {
  3813. switch ( itemQuality )
  3814. {
  3815. case 2 :
  3816. ability = 'quality_masterwork_boots';
  3817. AddItemCraftedAbility(item, theGame.params.GetRandomMasterworkBootsAbility(), true);
  3818. break;
  3819. case 3 :
  3820. ability = 'quality_magical_boots';
  3821.  
  3822. if ( RandF() > 0.5 )
  3823. AddItemCraftedAbility(item, theGame.params.GetRandomMagicalBootsAbility(), true);
  3824. else
  3825. AddItemCraftedAbility(item, theGame.params.GetRandomMasterworkBootsAbility(), true);
  3826.  
  3827. if ( RandF() > 0.5 )
  3828. AddItemCraftedAbility(item, theGame.params.GetRandomMagicalBootsAbility(), true);
  3829. else
  3830. AddItemCraftedAbility(item, theGame.params.GetRandomMasterworkBootsAbility(), true);
  3831. break;
  3832. default : break;
  3833. }
  3834. }
  3835. else if ( itemCategory == 'steelsword' )
  3836. {
  3837. switch ( itemQuality )
  3838. {
  3839. case 2 :
  3840. ability = 'quality_masterwork_steelsword';
  3841. AddItemCraftedAbility(item, theGame.params.GetRandomMasterworkWeaponAbility(), true);
  3842. break;
  3843. case 3 :
  3844. ability = 'quality_magical_steelsword';
  3845.  
  3846. if ( RandF() > 0.5 )
  3847. AddItemCraftedAbility(item, theGame.params.GetRandomMagicalWeaponAbility(), true);
  3848. else
  3849. AddItemCraftedAbility(item, theGame.params.GetRandomMasterworkWeaponAbility(), true);
  3850.  
  3851. if ( RandF() > 0.5 )
  3852. AddItemCraftedAbility(item, theGame.params.GetRandomMagicalWeaponAbility(), true);
  3853. else
  3854. AddItemCraftedAbility(item, theGame.params.GetRandomMasterworkWeaponAbility(), true);
  3855. break;
  3856. default : break;
  3857. }
  3858. }
  3859. else if ( itemCategory == 'silversword' )
  3860. {
  3861. switch ( itemQuality )
  3862. {
  3863. case 2 :
  3864. ability = 'quality_masterwork_silversword';
  3865. AddItemCraftedAbility(item, theGame.params.GetRandomMasterworkWeaponAbility(), true);
  3866. break;
  3867. case 3 :
  3868. ability = 'quality_magical_silversword';
  3869.  
  3870. if ( RandF() > 0.5 )
  3871. AddItemCraftedAbility(item, theGame.params.GetRandomMagicalWeaponAbility(), true);
  3872. else
  3873. AddItemCraftedAbility(item, theGame.params.GetRandomMasterworkWeaponAbility(), true);
  3874.  
  3875. if ( RandF() > 0.5 )
  3876. AddItemCraftedAbility(item, theGame.params.GetRandomMagicalWeaponAbility(), true);
  3877. else
  3878. AddItemCraftedAbility(item, theGame.params.GetRandomMasterworkWeaponAbility(), true);
  3879. break;
  3880.  
  3881. default : break;
  3882. }
  3883. }
  3884.  
  3885. if(IsNameValid(ability))
  3886. {
  3887. AddItemCraftedAbility(item, ability, false);
  3888. SetItemModifierInt(item, 'ItemQualityModified', 1);
  3889. }
  3890. }
  3891.  
  3892. public function GetItemQuality( itemId : SItemUniqueId ) : int
  3893. {
  3894. var itemQuality : float;
  3895. var itemQualityAtribute : SAbilityAttributeValue;
  3896. var excludedTags : array<name>;
  3897. var tempItemQualityAtribute : SAbilityAttributeValue;
  3898.  
  3899.  
  3900. excludedTags.PushBack(theGame.params.OIL_ABILITY_TAG);
  3901. itemQualityAtribute = GetItemAttributeValue( itemId, 'quality', excludedTags, true );
  3902.  
  3903. itemQuality = itemQualityAtribute.valueAdditive;
  3904. if( itemQuality == 0 )
  3905. {
  3906. itemQuality = 1;
  3907. }
  3908. return RoundMath(itemQuality);
  3909. }
  3910.  
  3911. public function GetItemQualityFromName( itemName : name, out min : int, out max : int)
  3912. {
  3913. var dm : CDefinitionsManagerAccessor;
  3914. var attributeName : name;
  3915. var attributes, itemAbilities : array<name>;
  3916. var attributeMin, attributeMax : SAbilityAttributeValue;
  3917.  
  3918. var tmpInt : int;
  3919. var tmpArray : array<float>;
  3920.  
  3921. dm = theGame.GetDefinitionsManager();
  3922.  
  3923. dm.GetItemAbilitiesWithWeights(itemName, GetEntity() == thePlayer, itemAbilities, tmpArray, tmpInt, tmpInt);
  3924. attributes = dm.GetAbilitiesAttributes(itemAbilities);
  3925. for (tmpInt = 0; tmpInt < attributes.Size(); tmpInt += 1)
  3926. {
  3927. if (attributes[tmpInt] == 'quality')
  3928. {
  3929. dm.GetAbilitiesAttributeValue(itemAbilities, 'quality', attributeMin, attributeMax);
  3930. min = RoundMath(CalculateAttributeValue(attributeMin));
  3931. max = RoundMath(CalculateAttributeValue(attributeMax));
  3932. break;
  3933. }
  3934. }
  3935. }
  3936.  
  3937. public function GetRecentlyAddedItems() : array<SItemUniqueId>
  3938. {
  3939. return recentlyAddedItems;
  3940. }
  3941.  
  3942. public function GetRecentlyAddedItemsListSize() : int
  3943. {
  3944. return recentlyAddedItems.Size();
  3945. }
  3946.  
  3947. public function RemoveItemFromRecentlyAddedList( itemId : SItemUniqueId ) : bool
  3948. {
  3949. var i : int;
  3950.  
  3951. for( i = 0; i < recentlyAddedItems.Size(); i += 1 )
  3952. {
  3953. if( recentlyAddedItems[i] == itemId )
  3954. {
  3955. recentlyAddedItems.EraseFast( i );
  3956. return true;
  3957. }
  3958. }
  3959.  
  3960. return false;
  3961. }
  3962.  
  3963.  
  3964.  
  3965.  
  3966. import final function NotifyScriptedListeners( notify : bool );
  3967.  
  3968. var listeners : array< IInventoryScriptedListener >;
  3969.  
  3970. function AddListener( listener : IInventoryScriptedListener )
  3971. {
  3972. if ( listeners.FindFirst( listener ) == -1 )
  3973. {
  3974. listeners.PushBack( listener );
  3975. if ( listeners.Size() == 1 )
  3976. {
  3977. NotifyScriptedListeners( true );
  3978. }
  3979. }
  3980. }
  3981.  
  3982. function RemoveListener( listener : IInventoryScriptedListener )
  3983. {
  3984. if ( listeners.Remove( listener ) )
  3985. {
  3986. if ( listeners.Size() == 0 )
  3987. {
  3988. NotifyScriptedListeners( false );
  3989. }
  3990. }
  3991. }
  3992.  
  3993. event OnInventoryScriptedEvent( eventType : EInventoryEventType, itemId : SItemUniqueId, quantity : int, fromAssociatedInventory : bool )
  3994. {
  3995. var i, size : int;
  3996.  
  3997. size = listeners.Size();
  3998. for (i=size-1; i>=0; i-=1 )
  3999. {
  4000. listeners[i].OnInventoryScriptedEvent( eventType, itemId, quantity, fromAssociatedInventory );
  4001. }
  4002.  
  4003.  
  4004. if(GetEntity() == GetWitcherPlayer() && (eventType == IET_ItemRemoved || eventType == IET_ItemQuantityChanged) )
  4005. GetWitcherPlayer().UpdateEncumbrance();
  4006. }
  4007.  
  4008.  
  4009.  
  4010.  
  4011.  
  4012. public function GetSkillMutagenColor(item : SItemUniqueId) : ESkillColor
  4013. {
  4014. var abs : array<name>;
  4015.  
  4016.  
  4017. if(!ItemHasTag(item, 'MutagenIngredient'))
  4018. return SC_None;
  4019.  
  4020. GetItemAbilities(item, abs);
  4021.  
  4022. if(abs.Contains('mutagen_color_green')) return SC_Green;
  4023. if(abs.Contains('mutagen_color_blue')) return SC_Blue;
  4024. if(abs.Contains('mutagen_color_red')) return SC_Red;
  4025. if(abs.Contains('lesser_mutagen_color_green')) return SC_Green;
  4026. if(abs.Contains('lesser_mutagen_color_blue')) return SC_Blue;
  4027. if(abs.Contains('lesser_mutagen_color_red')) return SC_Red;
  4028. if(abs.Contains('greater_mutagen_color_green')) return SC_Green;
  4029. if(abs.Contains('greater_mutagen_color_blue')) return SC_Blue;
  4030. if(abs.Contains('greater_mutagen_color_red')) return SC_Red;
  4031.  
  4032. return SC_None;
  4033. }
  4034.  
  4035.  
  4036.  
  4037.  
  4038.  
  4039.  
  4040.  
  4041.  
  4042.  
  4043. import final function GetItemEnhancementSlotsCount( itemId : SItemUniqueId ) : int;
  4044. import final function GetItemEnhancementItems( itemId : SItemUniqueId, out names : array< name > );
  4045. import final function GetItemEnhancementCount( itemId : SItemUniqueId ) : int;
  4046. import private function EnhanceItem( enhancedItemId : SItemUniqueId, extensionItemId : SItemUniqueId ) : bool;
  4047. import private function RemoveItemEnhancementByIndex( enhancedItemId : SItemUniqueId, slotIndex : int ) : bool;
  4048. import private function RemoveItemEnhancementByName( enhancedItemId : SItemUniqueId, extensionItemName : name ) : bool;
  4049. import final function PreviewItemAttributeAfterUpgrade( baseItemId : SItemUniqueId, upgradeItemId : SItemUniqueId, attributeName : name, optional baseInventory : CInventoryComponent, optional upgradeInventory : CInventoryComponent ) : SAbilityAttributeValue;
  4050. import final function HasEnhancementItemTag( enhancedItemId : SItemUniqueId, slotIndex : int, tag : name ) : bool;
  4051.  
  4052.  
  4053. function NotifyEnhancedItem( enhancedItemId : SItemUniqueId )
  4054. {
  4055. var weapons : array<SItemUniqueId>;
  4056. var sword : CWitcherSword;
  4057. var i : int;
  4058.  
  4059. sword = (CWitcherSword) GetItemEntityUnsafe( enhancedItemId );
  4060. sword.UpdateEnhancements( GetItemEnhancementCount( enhancedItemId ) );
  4061. }
  4062.  
  4063. function EnhanceItemScript( enhancedItemId : SItemUniqueId, extensionItemId : SItemUniqueId ) : bool
  4064. {
  4065. var i : int;
  4066. var enhancements : array<name>;
  4067. var runeword : Runeword;
  4068.  
  4069. if ( EnhanceItem( enhancedItemId, extensionItemId ) )
  4070. {
  4071. NotifyEnhancedItem( enhancedItemId );
  4072.  
  4073. GetItemEnhancementItems( enhancedItemId, enhancements );
  4074. if ( theGame.runewordMgr.GetRuneword( enhancements, runeword ) )
  4075. {
  4076. for ( i = 0; i < runeword.abilities.Size(); i+=1 )
  4077. {
  4078. AddItemBaseAbility( enhancedItemId, runeword.abilities[i] );
  4079. }
  4080. }
  4081. return true;
  4082. }
  4083. return false;
  4084. }
  4085.  
  4086. function RemoveItemEnhancementByIndexScript( enhancedItemId : SItemUniqueId, slotIndex : int ) : bool
  4087. {
  4088. var i : int;
  4089. var enhancements : array<name>;
  4090. var runeword : Runeword;
  4091. var hasRuneword : bool;
  4092. var names : array< name >;
  4093.  
  4094. GetItemEnhancementItems( enhancedItemId, enhancements );
  4095. hasRuneword = theGame.runewordMgr.GetRuneword( enhancements, runeword );
  4096.  
  4097. GetItemEnhancementItems( enhancedItemId, names );
  4098.  
  4099. if ( RemoveItemEnhancementByIndex( enhancedItemId, slotIndex ) )
  4100. {
  4101. NotifyEnhancedItem( enhancedItemId );
  4102.  
  4103.  
  4104.  
  4105. if ( hasRuneword )
  4106. {
  4107.  
  4108. for ( i = 0; i < runeword.abilities.Size(); i+=1 )
  4109. {
  4110. RemoveItemBaseAbility( enhancedItemId, runeword.abilities[i] );
  4111. }
  4112. }
  4113. return true;
  4114. }
  4115. return false;
  4116. }
  4117.  
  4118.  
  4119. function RemoveItemEnhancementByNameScript( enhancedItemId : SItemUniqueId, extensionItemName : name ) : bool
  4120. {
  4121. var i : int;
  4122. var enhancements : array<name>;
  4123. var runeword : Runeword;
  4124. var hasRuneword : bool;
  4125.  
  4126. GetItemEnhancementItems( enhancedItemId, enhancements );
  4127. hasRuneword = theGame.runewordMgr.GetRuneword( enhancements, runeword );
  4128.  
  4129.  
  4130. if ( RemoveItemEnhancementByName( enhancedItemId, extensionItemName ) )
  4131. {
  4132. NotifyEnhancedItem( enhancedItemId );
  4133.  
  4134.  
  4135. AddAnItem( extensionItemName, 1, true, true );
  4136. if ( hasRuneword )
  4137. {
  4138.  
  4139. for ( i = 0; i < runeword.abilities.Size(); i+=1 )
  4140. {
  4141. RemoveItemBaseAbility( enhancedItemId, runeword.abilities[i] );
  4142. }
  4143. }
  4144. return true;
  4145. }
  4146. return false;
  4147. }
  4148.  
  4149. function RemoveAllItemEnhancements( enhancedItemId : SItemUniqueId )
  4150. {
  4151. var count, i : int;
  4152.  
  4153. count = GetItemEnhancementCount( enhancedItemId );
  4154. for ( i = count - 1; i >= 0; i-=1 )
  4155. {
  4156. RemoveItemEnhancementByIndexScript( enhancedItemId, i );
  4157. }
  4158. }
  4159.  
  4160. function GetHeldAndMountedItems( out items : array< name > )
  4161. {
  4162. var allItems : array< SItemUniqueId >;
  4163. var i : int;
  4164. var itemName : name;
  4165.  
  4166. GetAllItems( allItems );
  4167.  
  4168. items.Clear();
  4169. for( i = 0; i < allItems.Size(); i += 1 )
  4170. {
  4171. if ( IsItemHeld( allItems[ i ] ) || IsItemMounted( allItems[ i ] ) )
  4172. {
  4173. itemName = GetItemName( allItems[ i ] );
  4174. items.PushBack( itemName );
  4175. }
  4176. }
  4177. }
  4178. }
  4179.  
  4180. exec function slotTest()
  4181. {
  4182. var inv : CInventoryComponent = thePlayer.inv;
  4183. var weaponItemId : SItemUniqueId;
  4184. var upgradeItemId : SItemUniqueId;
  4185. var i : int;
  4186.  
  4187. LogChannel('SlotTest', "----------------------------------------------------------------");
  4188.  
  4189.  
  4190. inv.AddAnItem( 'Perun rune', 1);
  4191. inv.AddAnItem( 'Svarog rune', 1);
  4192.  
  4193.  
  4194. for ( i = 0; i < 2; i += 1 )
  4195. {
  4196.  
  4197. if ( !GetItem( inv, 'steelsword', weaponItemId ) ||
  4198. !GetItem( inv, 'upgrade', upgradeItemId ) )
  4199. {
  4200. return;
  4201. }
  4202.  
  4203.  
  4204. PrintItem( inv, weaponItemId );
  4205.  
  4206.  
  4207. if ( inv.EnhanceItemScript( weaponItemId, upgradeItemId ) )
  4208. {
  4209. LogChannel('SlotTest', "Enhanced item");
  4210. }
  4211. else
  4212. {
  4213. LogChannel('SlotTest', "Failed to enhance item!");
  4214. }
  4215. }
  4216.  
  4217.  
  4218. if ( !GetItem( inv, 'steelsword', weaponItemId ) )
  4219. {
  4220. return;
  4221. }
  4222.  
  4223.  
  4224. PrintItem( inv, weaponItemId );
  4225.  
  4226.  
  4227. if ( inv.RemoveItemEnhancementByNameScript( weaponItemId, 'Svarog rune' ) )
  4228. {
  4229. LogChannel('SlotTest', "Removed enhancement");
  4230. }
  4231. else
  4232. {
  4233. LogChannel('SlotTest', "Failed to remove enhancement!");
  4234. }
  4235.  
  4236.  
  4237. if ( !GetItem( inv, 'steelsword', weaponItemId ) )
  4238. {
  4239. return;
  4240. }
  4241.  
  4242.  
  4243. PrintItem( inv, weaponItemId );
  4244.  
  4245.  
  4246. if ( inv.RemoveItemEnhancementByIndexScript( weaponItemId, 0 ) )
  4247. {
  4248. LogChannel('SlotTest', "Removed enhancement");
  4249. }
  4250. else
  4251. {
  4252. LogChannel('SlotTest', "Failed to remove enhancement!");
  4253. }
  4254.  
  4255.  
  4256. if ( !GetItem( inv, 'steelsword', weaponItemId ) )
  4257. {
  4258. return;
  4259. }
  4260.  
  4261.  
  4262. PrintItem( inv, weaponItemId );
  4263. }
  4264.  
  4265. function GetItem( inv : CInventoryComponent, category : name, out itemId : SItemUniqueId ) : bool
  4266. {
  4267. var itemIds : array< SItemUniqueId >;
  4268.  
  4269. itemIds = inv.GetItemsByCategory( category );
  4270. if ( itemIds.Size() > 0 )
  4271. {
  4272. itemId = itemIds[ 0 ];
  4273. return true;
  4274. }
  4275. LogChannel( 'SlotTest', "Failed to get item with GetItemsByCategory( '" + category + "' )" );
  4276. return false;
  4277. }
  4278.  
  4279. function PrintItem( inv : CInventoryComponent, weaponItemId : SItemUniqueId )
  4280. {
  4281. var names : array< name >;
  4282. var tags : array< name >;
  4283. var i : int;
  4284. var line : string;
  4285. var attribute : SAbilityAttributeValue;
  4286.  
  4287. LogChannel('SlotTest', "Slots: " + inv.GetItemEnhancementCount( weaponItemId ) + "/" + inv.GetItemEnhancementSlotsCount( weaponItemId ) );
  4288. inv.GetItemEnhancementItems( weaponItemId, names );
  4289. if ( names.Size() > 0 )
  4290. {
  4291. for ( i = 0; i < names.Size(); i += 1 )
  4292. {
  4293. if ( i == 0 )
  4294. {
  4295. line += "[";
  4296. }
  4297. line += names[ i ];
  4298. if ( i < names.Size() - 1 )
  4299. {
  4300. line += ", ";
  4301. }
  4302. if ( i == names.Size() - 1 )
  4303. {
  4304. line += "]";
  4305. }
  4306. }
  4307. }
  4308. else
  4309. {
  4310. line += "[]";
  4311. }
  4312. LogChannel('SlotTest', "Upgrade item names " + line );
  4313.  
  4314. tags.PushBack('Upgrade');
  4315.  
  4316. attribute = inv.GetItemAttributeValue( weaponItemId, 'PhysicalDamage' );
  4317. LogChannel('SlotTest', "Attribute '" + 'PhysicalDamage' + "' " + attribute.valueBase + " " + attribute.valueMultiplicative + " " + attribute.valueAdditive );
  4318. attribute = inv.GetItemAttributeValue( weaponItemId, 'SilverDamage' );
  4319. LogChannel('SlotTest', "Attribute '" + 'SilverDamage' + "' " + attribute.valueBase + " " + attribute.valueMultiplicative + " " + attribute.valueAdditive );
  4320.  
  4321. attribute = inv.GetItemAttributeValue( weaponItemId, 'PhysicalDamage', tags, true );
  4322. LogChannel('SlotTest', "Attribute '" + 'PhysicalDamage' + "' " + attribute.valueBase + " " + attribute.valueMultiplicative + " " + attribute.valueAdditive );
  4323. attribute = inv.GetItemAttributeValue( weaponItemId, 'SilverDamage', tags, true );
  4324. LogChannel('SlotTest', "Attribute '" + 'SilverDamage' + "' " + attribute.valueBase + " " + attribute.valueMultiplicative + " " + attribute.valueAdditive );
  4325.  
  4326. attribute = inv.GetItemAttributeValue( weaponItemId, 'PhysicalDamage', tags );
  4327. LogChannel('SlotTest', "Attribute '" + 'PhysicalDamage' + "' " + attribute.valueBase + " " + attribute.valueMultiplicative + " " + attribute.valueAdditive );
  4328. attribute = inv.GetItemAttributeValue( weaponItemId, 'SilverDamage', tags );
  4329. LogChannel('SlotTest', "Attribute '" + 'SilverDamage' + "' " + attribute.valueBase + " " + attribute.valueMultiplicative + " " + attribute.valueAdditive );
  4330.  
  4331. }
  4332.  
  4333. function PlayItemEquipSound( itemCategory : name ) : void
  4334. {
  4335. switch( itemCategory )
  4336. {
  4337. case 'steelsword' :
  4338. theSound.SoundEvent("gui_inventory_steelsword_attach");
  4339. return;
  4340. case 'silversword' :
  4341. theSound.SoundEvent("gui_inventory_silversword_attach");
  4342. return;
  4343. case 'secondary' :
  4344. theSound.SoundEvent("gui_inventory_weapon_attach");
  4345. return;
  4346. case 'armor' :
  4347. theSound.SoundEvent("gui_inventory_armor_attach");
  4348. return;
  4349. case 'pants' :
  4350. theSound.SoundEvent("gui_inventory_pants_attach");
  4351. return;
  4352. case 'boots' :
  4353. theSound.SoundEvent("gui_inventory_boots_attach");
  4354. return;
  4355. case 'gloves' :
  4356. theSound.SoundEvent("gui_inventory_gauntlet_attach");
  4357. return;
  4358. case 'potion' :
  4359. theSound.SoundEvent("gui_inventory_potion_attach");
  4360. return;
  4361. case 'petard' :
  4362. theSound.SoundEvent("gui_inventory_bombs_attach");
  4363. return;
  4364. case 'ranged' :
  4365. theSound.SoundEvent("gui_inventory_ranged_attach");
  4366. return;
  4367. case 'herb' :
  4368. theSound.SoundEvent("gui_pick_up_herbs");
  4369. return;
  4370. case 'trophy' :
  4371. case 'horse_bag' :
  4372. theSound.SoundEvent("gui_inventory_horse_bage_attach");
  4373. return;
  4374. case 'horse_blinder' :
  4375. theSound.SoundEvent("gui_inventory_horse_blinder_attach");
  4376. return;
  4377. case 'horse_saddle' :
  4378. theSound.SoundEvent("gui_inventory_horse_saddle_attach");
  4379. return;
  4380. default :
  4381. theSound.SoundEvent("gui_inventory_other_attach");
  4382. return;
  4383. }
  4384. }
  4385.  
  4386. function PlayItemUnequipSound( itemCategory : name ) : void
  4387. {
  4388. switch( itemCategory )
  4389. {
  4390. case 'steelsword' :
  4391. theSound.SoundEvent("gui_inventory_steelsword_back");
  4392. return;
  4393. case 'silversword' :
  4394. theSound.SoundEvent("gui_inventory_silversword_back");
  4395. return;
  4396. case 'secondary' :
  4397. theSound.SoundEvent("gui_inventory_weapon_back");
  4398. return;
  4399. case 'armor' :
  4400. theSound.SoundEvent("gui_inventory_armor_back");
  4401. return;
  4402. case 'pants' :
  4403. theSound.SoundEvent("gui_inventory_pants_back");
  4404. return;
  4405. case 'boots' :
  4406. theSound.SoundEvent("gui_inventory_boots_back");
  4407. return;
  4408. case 'gloves' :
  4409. theSound.SoundEvent("gui_inventory_gauntlet_back");
  4410. return;
  4411. case 'petard' :
  4412. theSound.SoundEvent("gui_inventory_bombs_back");
  4413. return;
  4414. case 'potion' :
  4415. theSound.SoundEvent("gui_inventory_potion_back");
  4416. return;
  4417. case 'ranged' :
  4418. theSound.SoundEvent("gui_inventory_ranged_back");
  4419. return;
  4420. case 'trophy' :
  4421. case 'horse_bag' :
  4422. theSound.SoundEvent("gui_inventory_horse_bage_back");
  4423. return;
  4424. case 'horse_blinder' :
  4425. theSound.SoundEvent("gui_inventory_horse_blinder_back");
  4426. return;
  4427. case 'horse_saddle' :
  4428. theSound.SoundEvent("gui_inventory_horse_saddle_back");
  4429. return;
  4430. default :
  4431. theSound.SoundEvent("gui_inventory_other_back");
  4432. return;
  4433. }
  4434. }
  4435.  
  4436. function PlayItemConsumeSound( item : SItemUniqueId ) : void
  4437. {
  4438. if( thePlayer.GetInventory().ItemHasTag( item, 'Drinks' ) || thePlayer.GetInventory().ItemHasTag( item, 'Alcohol' ) )
  4439. {
  4440. theSound.SoundEvent('gui_inventory_drink');
  4441. }
  4442. else
  4443. {
  4444. theSound.SoundEvent('gui_inventory_eat');
  4445. }
  4446. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement