Guest User

inventorycomponent.ws

a guest
Sep 1st, 2021
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 173.49 KB | None | 0 0
  1. /***********************************************************************/
  2. /** © 2015 CD PROJEKT S.A. All rights reserved.
  3. /** THE WITCHER® is a trademark of CD PROJEKT S. A.
  4. /** The Witcher game is based on the prose of Andrzej Sapkowski.
  5. /***********************************************************************/
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12. class IInventoryScriptedListener
  13. {
  14. event OnInventoryScriptedEvent( eventType : EInventoryEventType, itemId : SItemUniqueId, quantity : int, fromAssociatedInventory : bool ) {}
  15. }
  16.  
  17. import struct SItemNameProperty
  18. {
  19. import editable var itemName : name;
  20. };
  21.  
  22. import struct SR4LootNameProperty
  23. {
  24. import editable var lootName : name;
  25. };
  26.  
  27. struct SItemExt
  28. {
  29. editable var itemName : SItemNameProperty;
  30. editable var quantity : int;
  31. default quantity = 1;
  32. };
  33.  
  34. struct SCardSourceData
  35. {
  36. var cardName : name;
  37. var source : string;
  38. var originArea : string;
  39. var originQuest : string;
  40. var details : string;
  41. var coords : string;
  42. };
  43.  
  44.  
  45. import struct SItemChangedData
  46. {
  47. import const var itemName : name;
  48. import const var quantity : int;
  49. import const var informGui : bool;
  50. import const var ids : array< SItemUniqueId >;
  51. };
  52.  
  53. import class CInventoryComponent extends CComponent
  54. {
  55. editable var priceMult : float;
  56. editable var priceRepairMult : float;
  57. editable var priceRepair : float;
  58. editable var fundsType : EInventoryFundsType;
  59.  
  60. private var recentlyAddedItems : array<SItemUniqueId>;
  61. private var fundsMax : int;
  62. private var daysToIncreaseFunds : int;
  63.  
  64. // FCR3 --
  65. private var enemies : array<CGameplayEntity>;
  66. private var highestEnemyLevel : int;
  67. private var lastEnemyCount : int;
  68. private var lvlCheck1,lvlCheck2 : bool;
  69. private var emptyCheck,mapCheck : bool;
  70. private var empty : bool;
  71. // -- FCR3
  72.  
  73. default priceMult = 1.0;
  74. default priceRepairMult = 1.0;
  75. default priceRepair = 10.0;
  76. default fundsType = EInventoryFunds_Avg;
  77. default daysToIncreaseFunds = 5;
  78.  
  79.  
  80.  
  81.  
  82. public function GetFundsType() : EInventoryFundsType
  83. {
  84. return fundsType;
  85. }
  86.  
  87. public function GetDaysToIncreaseFunds() : int
  88. {
  89. return daysToIncreaseFunds;
  90. }
  91.  
  92. public function GetFundsMax() : float
  93. {
  94. if ( EInventoryFunds_Broke == fundsType )
  95. {
  96. return 0;
  97. }
  98. else if ( EInventoryFunds_Avg == fundsType )
  99. {
  100. return 5000;
  101. }
  102. else if ( EInventoryFunds_Poor == fundsType )
  103. {
  104. return 2500;
  105. }
  106. else if ( EInventoryFunds_Rich == fundsType )
  107. {
  108. return 7500;
  109. }
  110. else if ( EInventoryFunds_RichQuickStart == fundsType )
  111. {
  112. return 15000;
  113. }
  114. return -1;
  115. }
  116.  
  117. public function SetupFunds()
  118. {
  119. if ( EInventoryFunds_Broke == fundsType )
  120. {
  121. AddMoney( 0 );
  122. }
  123. else if ( EInventoryFunds_Poor == fundsType )
  124. {
  125. AddMoney( (int)( 200 * GetFundsModifier() ) );
  126. }
  127. else if ( EInventoryFunds_Avg == fundsType )
  128. {
  129. AddMoney( (int)( 500 * GetFundsModifier() ) );
  130. }
  131. else if ( EInventoryFunds_Rich == fundsType )
  132. {
  133. AddMoney( (int)( 1000 * GetFundsModifier() ) );
  134. }
  135. else if ( EInventoryFunds_RichQuickStart == fundsType )
  136. {
  137. AddMoney( (int)( 5000 * GetFundsModifier() ) );
  138. }
  139. }
  140.  
  141. public function IncreaseFunds()
  142. {
  143. if ( GetMoney() < GetFundsMax() )
  144. {
  145. if ( EInventoryFunds_Avg == fundsType )
  146. {
  147. AddMoney( (int)( 150 * GetFundsModifier()) );
  148. }
  149. else if ( EInventoryFunds_Poor == fundsType )
  150. {
  151. AddMoney( (int)( 100 * GetFundsModifier() ) );
  152. }
  153. else if ( EInventoryFunds_Rich == fundsType )
  154. {
  155. AddMoney( (int)( 1000 * GetFundsModifier() ) );
  156. }
  157. else if ( EInventoryFunds_RichQuickStart == fundsType )
  158. {
  159. AddMoney( 1000 + (int)( 2500 * GetFundsModifier() ) );
  160. }
  161. }
  162. }
  163.  
  164. public function GetMoney() : int
  165. {
  166. return GetItemQuantityByName( 'Crowns' );
  167. }
  168.  
  169. public function SetMoney( amount : int )
  170. {
  171. var currentMoney : int;
  172.  
  173. if ( amount >= 0 )
  174. {
  175. currentMoney = GetMoney();
  176. RemoveMoney( currentMoney );
  177.  
  178. AddAnItem( 'Crowns', amount );
  179. }
  180. }
  181.  
  182. public function AddMoney( amount : int )
  183. {
  184. if ( amount > 0 )
  185. {
  186. AddAnItem( 'Crowns', amount );
  187.  
  188. if ( thePlayer == GetEntity() )
  189. {
  190. theTelemetry.LogWithValue( TE_HERO_CASH_CHANGED, amount );
  191. }
  192. }
  193. }
  194.  
  195. public function RemoveMoney( amount : int )
  196. {
  197. if ( amount > 0 )
  198. {
  199. RemoveItemByName( 'Crowns', amount );
  200.  
  201. if ( thePlayer == GetEntity() )
  202. {
  203. theTelemetry.LogWithValue( TE_HERO_CASH_CHANGED, -amount );
  204. }
  205. }
  206. }
  207.  
  208.  
  209.  
  210.  
  211.  
  212. import final function GetItemAbilityAttributeValue( itemId : SItemUniqueId, attributeName : name, abilityName : name) : SAbilityAttributeValue;
  213.  
  214. import final function GetItemFromSlot( slotName : name ) : SItemUniqueId;
  215.  
  216.  
  217. import final function IsIdValid( itemId : SItemUniqueId ) : bool;
  218.  
  219.  
  220. import final function GetItemCount( optional useAssociatedInventory : bool ) : int;
  221.  
  222.  
  223. import final function GetItemsNames() : array< name >;
  224.  
  225.  
  226. import final function GetAllItems( out items : array< SItemUniqueId > );
  227.  
  228.  
  229. import public function GetItemId( itemName : name ) : SItemUniqueId;
  230.  
  231.  
  232. import public function GetItemsIds( itemName : name ) : array< SItemUniqueId >;
  233.  
  234.  
  235. import final function GetItemsByTag( tag : name ) : array< SItemUniqueId >;
  236.  
  237.  
  238. import final function GetItemsByCategory( category : name ) : array< SItemUniqueId >;
  239.  
  240.  
  241. import final function GetSchematicIngredients(itemName : SItemUniqueId, out quantity : array<int>, out names : array<name>);
  242.  
  243.  
  244. import final function GetSchematicRequiredCraftsmanType(craftName : SItemUniqueId) : name;
  245.  
  246.  
  247. import final function GetSchematicRequiredCraftsmanLevel(craftName : SItemUniqueId) : name;
  248.  
  249.  
  250. import final function GetNumOfStackedItems( itemUniqueId: SItemUniqueId ) : int;
  251.  
  252. import final function InitInvFromTemplate( resource : CEntityTemplate );
  253.  
  254.  
  255.  
  256.  
  257. import final function SplitItem( itemID : SItemUniqueId, quantity : int ) : SItemUniqueId;
  258.  
  259.  
  260.  
  261. import final function SetItemStackable( itemID : SItemUniqueId, flag : bool );
  262.  
  263.  
  264. import final function GetCategoryDefaultItem( category : name ) : name;
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271. import final function GetItemLocalizedNameByName( itemName : CName ) : string;
  272.  
  273.  
  274. import final function GetItemLocalizedDescriptionByName( itemName : CName ) : string;
  275.  
  276.  
  277. import final function GetItemLocalizedNameByUniqueID( itemUniqueId : SItemUniqueId ) : string;
  278.  
  279.  
  280. import final function GetItemLocalizedDescriptionByUniqueID( itemUniqueId : SItemUniqueId ) : string;
  281.  
  282.  
  283. import final function GetItemIconPathByUniqueID( itemUniqueId : SItemUniqueId ) : string;
  284.  
  285.  
  286. import final function GetItemIconPathByName( itemName : CName ) : string;
  287.  
  288. import final function AddSlot( itemUniqueId : SItemUniqueId ) : bool;
  289.  
  290. import final function GetSlotItemsLimit( itemUniqueId : SItemUniqueId ) : int;
  291.  
  292. import private final function BalanceItemsWithPlayerLevel( playerLevel : int );
  293.  
  294. public function ForceSpawnItemOnStart( itemId : SItemUniqueId ) : bool
  295. {
  296. return ItemHasTag(itemId, 'MutagenIngredient');
  297. }
  298.  
  299.  
  300. public final function GetItemArmorTotal(item : SItemUniqueId) : SAbilityAttributeValue
  301. {
  302. var armor, armorBonus : SAbilityAttributeValue;
  303. var durMult : float;
  304.  
  305. armor = GetItemAttributeValue(item, theGame.params.ARMOR_VALUE_NAME);
  306. armorBonus = GetRepairObjectBonusValueForArmor(item);
  307. durMult = theGame.params.GetDurabilityMultiplier( GetItemDurabilityRatio(item), false);
  308.  
  309. return armor * durMult + armorBonus;
  310. }
  311.  
  312. public final function GetItemLevel(item : SItemUniqueId) : int
  313. {
  314. var itemCategory : name;
  315. var itemAttributes : array<SAbilityAttributeValue>;
  316. var itemName : name;
  317. var isWitcherGear : bool;
  318. var isRelicGear : bool;
  319. var level, baseLevel : int;
  320. var quality : int; // FCR3
  321.  
  322. itemCategory = GetItemCategory(item);
  323. itemName = GetItemName(item);
  324.  
  325. isWitcherGear = false;
  326. isRelicGear = false;
  327.  
  328. // FCR3 --
  329. //if ( RoundMath(CalculateAttributeValue( GetItemAttributeValue(item, 'quality' ) )) == 5 ) isWitcherGear = true;
  330. //if ( RoundMath(CalculateAttributeValue( GetItemAttributeValue(item, 'quality' ) )) == 4 ) isRelicGear = true;
  331. quality = RoundMath(CalculateAttributeValue( GetItemAttributeValue(item, 'quality' ) ) );
  332. if ( quality == 5 ) isWitcherGear = true;
  333. if ( quality == 4 ) isRelicGear = true;
  334. // -- FCR3
  335.  
  336.  
  337. switch(itemCategory)
  338. {
  339. case 'armor' :
  340. case 'boots' :
  341. case 'gloves' :
  342. case 'pants' :
  343. itemAttributes.PushBack( GetItemAttributeValue(item, 'armor') );
  344. break;
  345.  
  346. case 'silversword' :
  347. itemAttributes.PushBack( GetItemAttributeValue(item, 'SilverDamage') );
  348. itemAttributes.PushBack( GetItemAttributeValue(item, 'BludgeoningDamage') );
  349. itemAttributes.PushBack( GetItemAttributeValue(item, 'RendingDamage') );
  350. itemAttributes.PushBack( GetItemAttributeValue(item, 'ElementalDamage') );
  351. itemAttributes.PushBack( GetItemAttributeValue(item, 'FireDamage') );
  352. itemAttributes.PushBack( GetItemAttributeValue(item, 'PiercingDamage') );
  353. break;
  354.  
  355. case 'steelsword' :
  356. itemAttributes.PushBack( GetItemAttributeValue(item, 'SlashingDamage') );
  357. itemAttributes.PushBack( GetItemAttributeValue(item, 'BludgeoningDamage') );
  358. itemAttributes.PushBack( GetItemAttributeValue(item, 'RendingDamage') );
  359. itemAttributes.PushBack( GetItemAttributeValue(item, 'ElementalDamage') );
  360. itemAttributes.PushBack( GetItemAttributeValue(item, 'FireDamage') );
  361. itemAttributes.PushBack( GetItemAttributeValue(item, 'SilverDamage') );
  362. itemAttributes.PushBack( GetItemAttributeValue(item, 'PiercingDamage') );
  363. break;
  364.  
  365. case 'crossbow' :
  366. itemAttributes.PushBack( GetItemAttributeValue(item, 'attack_power') );
  367. break;
  368.  
  369. // FCR3 --
  370. case 'bolt' :
  371. itemAttributes.PushBack( GetItemAttributeValue(item, 'SilverDamage') );
  372. break;
  373. // -- FCR3
  374.  
  375. default :
  376. break;
  377. }
  378.  
  379. level = theGame.params.GetItemLevel(itemCategory, itemAttributes, itemName, baseLevel);
  380.  
  381. if ( FactsQuerySum("NewGamePlus") > 0 )
  382. {
  383. if ( baseLevel > GetWitcherPlayer().GetMaxLevel() )
  384. {
  385. level = baseLevel;
  386. }
  387. }
  388.  
  389. // FCR3 --
  390. if ( itemCategory == 'bolt' )
  391. {
  392. if ( quality == 5 ) level = level - 14;
  393. else if ( quality == 4 ) level = level - 10;
  394. else if ( quality == 3 ) level = level - 6;
  395. else if ( quality == 2 ) level = level - 4;
  396. }
  397. // -- FCR3
  398. else if ( isWitcherGear ) level = level - 2;
  399. else if ( isRelicGear ) level = level - 1;
  400. if ( level < 1 ) level = 1;
  401. if ( ItemHasTag(item, 'OlgierdSabre') ) level = level - 3;
  402. if ( (isRelicGear || isWitcherGear) && ItemHasTag(item, 'EP1') ) level = level - 1;
  403.  
  404. if ( FactsQuerySum("NewGamePlus") > 0 )
  405. {
  406. if ( level > GetWitcherPlayer().GetMaxLevel() )
  407. {
  408. level = GetWitcherPlayer().GetMaxLevel();
  409. }
  410. }
  411.  
  412. return level;
  413. }
  414.  
  415. public function GetItemLevelColorById( itemId : SItemUniqueId ) : string
  416. {
  417. var color : string;
  418.  
  419. if (GetItemLevel(itemId) <= thePlayer.GetLevel())
  420. {
  421. color = "<font color = '#A09588'>";
  422. }
  423. else
  424. {
  425. color = "<font color = '#9F1919'>";
  426. }
  427.  
  428. return color;
  429. }
  430.  
  431. public function GetItemLevelColor( lvl_item : int ) : string
  432. {
  433. var color : string;
  434.  
  435. if ( lvl_item > thePlayer.GetLevel() )
  436. {
  437. color = "<font color = '#9F1919'>";
  438. } else
  439. {
  440. color = "<font color = '#A09588'>";
  441. }
  442.  
  443. return color;
  444. }
  445.  
  446. public final function AutoBalanaceItemsWithPlayerLevel()
  447. {
  448. var playerLevel : int;
  449.  
  450. playerLevel = thePlayer.GetLevel();
  451.  
  452. if( playerLevel < 0 )
  453. {
  454. playerLevel = 0;
  455. }
  456.  
  457. BalanceItemsWithPlayerLevel( playerLevel );
  458. }
  459.  
  460. public function GetItemsByName(itemName : name) : array<SItemUniqueId>
  461. {
  462. var ret : array<SItemUniqueId>;
  463. var i : int;
  464.  
  465. if(!IsNameValid(itemName))
  466. return ret;
  467.  
  468. GetAllItems(ret);
  469.  
  470. for(i=ret.Size()-1; i>=0; i-=1)
  471. {
  472. if(GetItemName(ret[i]) != itemName)
  473. {
  474. ret.EraseFast( i );
  475. }
  476. }
  477.  
  478. return ret;
  479. }
  480.  
  481. public final function GetSingletonItems() : array<SItemUniqueId>
  482. {
  483. return GetItemsByTag(theGame.params.TAG_ITEM_SINGLETON);
  484. }
  485.  
  486.  
  487. import final function GetItemQuantityByName( itemName : name, optional useAssociatedInventory : bool , optional ignoreTags : array< name > ) : int;
  488.  
  489.  
  490. import final function GetItemQuantityByCategory( itemCategory : name, optional useAssociatedInventory : bool , optional ignoreTags : array< name > ) : int;
  491.  
  492.  
  493. import final function GetItemQuantityByTag( itemTag : name, optional useAssociatedInventory : bool , optional ignoreTags : array< name > ) : int;
  494.  
  495.  
  496. import final function GetAllItemsQuantity( optional useAssociatedInventory : bool , optional ignoreTags : array< name > ) : int;
  497.  
  498. // FCR3 --
  499. public function RelevantMappinsInRange() : bool
  500. {
  501. var mappinsInRange : array<CGameplayEntity>;
  502. var worldPath : string;
  503. var localMapPins : array< SCommonMapPinInstance >;
  504. var i : int;
  505.  
  506.  
  507. if ( mapCheck )
  508. {
  509. return true;
  510. }
  511.  
  512. localMapPins = theGame.GetCommonMapManager().GetMapPinInstances( theGame.GetWorld().GetDepotPath() );
  513. if ( localMapPins.Size() > 0 )
  514. {
  515. for ( i = 0; i < localMapPins.Size(); i += 1 )
  516. {
  517. if ( localMapPins[i].type == 'DungeonCrawl' )
  518. {
  519. if ( VecDistance( localMapPins[i].position, GetEntity().GetWorldPosition() ) <= 60 )
  520. {
  521. mapCheck = true;
  522. return true;
  523. }
  524. }
  525. else if ( localMapPins[i].type == 'SpoilsOfWar' || localMapPins[i].type == 'BanditCamp' || localMapPins[i].type == 'BanditCampfire'
  526. || localMapPins[i].type == 'BossAndTreasure' || localMapPins[i].type == 'Contraband' || localMapPins[i].type == 'ContrabandShip'
  527. || localMapPins[i].type == 'MonsterNest' || localMapPins[i].type == 'TreasureHuntMappin' || theGame.GetCommonMapManager().IsQuestPinType( localMapPins[i].type ) )
  528. {
  529. if ( localMapPins[i].radius > 5 && VecDistance( localMapPins[i].position, GetEntity().GetWorldPosition() ) <= localMapPins[i].radius )
  530. {
  531. mapCheck = true;
  532. return true;
  533. }
  534. else if ( VecDistance( localMapPins[i].position, GetEntity().GetWorldPosition() ) <= 5 )
  535. {
  536. mapCheck = true;
  537. return true;
  538. }
  539. }
  540. }
  541. }
  542.  
  543. return false;
  544. }
  545. // -- FCR3
  546.  
  547. public function IsEmpty(optional bSkipNoDropNoShow : bool) : bool
  548. {
  549. var i : int;
  550. var itemIds : array<SItemUniqueId>;
  551. // FCR3 --
  552. var enemyLevel : int;
  553.  
  554.  
  555. // first check for enemy level since enemies might spawn and dispawn fron this moment up until item level is generated
  556. if ( !lvlCheck1 )
  557. {
  558. FindGameplayEntitiesInSphere( enemies, GetEntity().GetWorldPosition(), 30, 999, '', FLAG_Attitude_Hostile, thePlayer );
  559. if ( enemies.Size() > 0 )
  560. {
  561. if ( lastEnemyCount != enemies.Size() )
  562. {
  563. lastEnemyCount = enemies.Size();
  564. for( i = lastEnemyCount - 1; i >= 0; i -= 1 )
  565. {
  566. enemyLevel = ((CNewNPC)enemies[i]).GetLevel();
  567. if ( highestEnemyLevel < enemyLevel )
  568. {
  569. highestEnemyLevel = enemyLevel;
  570. }
  571. }
  572. }
  573. lvlCheck1 = true;
  574. }
  575. }
  576. // -- FCR3
  577.  
  578. if(bSkipNoDropNoShow)
  579. {
  580. // FCR3 --
  581. GetAllItems( itemIds );
  582. if ( !RelevantMappinsInRange() )
  583. {
  584. if ( !emptyCheck && itemIds.Size() > 0 )
  585. {
  586. if ( !HasQuestItem() && !theGame.questInventoryComponents.Contains( this ) && !((W3treasureHuntContainer)GetEntity())
  587. && ((W3Container)GetEntity()).focusModeHighlight != FMV_Clue )
  588. {
  589. for( i = itemIds.Size() - 1; i >= 0; i -= 1 )
  590. {
  591. if( ItemHasTag( itemIds[ i ], 'EmptyContainer' ) )
  592. {
  593. empty = true;
  594. }
  595. if( ItemHasTag( itemIds[ i ], 'ReadableItem' ) || ItemHasTag( itemIds[ i ], 'PlayerOwned' ) )
  596. {
  597. empty = false;
  598. return false;
  599. }
  600. }
  601. }
  602. emptyCheck = true;
  603. }
  604.  
  605. if ( empty )
  606. {
  607. return true;
  608. }
  609. }
  610. // -- FCR3
  611.  
  612. for( i = itemIds.Size() - 1; i >= 0; i -= 1 )
  613. {
  614. //if( !ItemHasTag( itemIds[ i ],theGame.params.TAG_DONT_SHOW ) && !ItemHasTag( itemIds[ i ], 'NoDrop' ) )
  615. if( !ItemHasTag( itemIds[ i ],theGame.params.TAG_DONT_SHOW ) && !ItemHasTag( itemIds[ i ], 'NoDrop' ) && !ItemHasTag( itemIds[ i ], 'EmptyContainer' ) ) // FCR3
  616. {
  617. return false;
  618. }
  619. else if ( ItemHasTag( itemIds[ i ], 'Lootable') )
  620. {
  621. return false;
  622. }
  623. }
  624.  
  625. return true;
  626. }
  627.  
  628. return GetItemCount() <= 0;
  629. }
  630.  
  631. public function GetAllHeldAndMountedItemsCategories( out heldItems : array<name>, optional out mountedItems : array<name> )
  632. {
  633. var allItems : array<SItemUniqueId>;
  634. var i : int;
  635.  
  636. GetAllItems(allItems);
  637. for(i=allItems.Size()-1; i >= 0; i-=1)
  638. {
  639. if ( IsItemHeld(allItems[i]) )
  640. heldItems.PushBack(GetItemCategory(allItems[i]));
  641. else if ( IsItemMounted(allItems[i]) )
  642. mountedItems.PushBack(GetItemCategory(allItems[i]));
  643. }
  644. }
  645.  
  646. public function GetAllHeldItemsNames( out heldItems : array<name> )
  647. {
  648. var allItems : array<SItemUniqueId>;
  649. var i : int;
  650.  
  651. GetAllItems(allItems);
  652. for(i=allItems.Size()-1; i >= 0; i-=1)
  653. {
  654. if ( IsItemHeld(allItems[i]) )
  655. heldItems.PushBack(GetItemName(allItems[i]));
  656. }
  657. }
  658.  
  659. public function HasMountedItemByTag(tag : name) : bool
  660. {
  661. var i : int;
  662. var allItems : array<SItemUniqueId>;
  663.  
  664. if(!IsNameValid(tag))
  665. return false;
  666.  
  667. allItems = GetItemsByTag(tag);
  668. for(i=0; i<allItems.Size(); i+=1)
  669. if(IsItemMounted(allItems[i]))
  670. return true;
  671.  
  672. return false;
  673. }
  674.  
  675. public function HasHeldOrMountedItemByTag(tag : name) : bool
  676. {
  677. var i : int;
  678. var allItems : array<SItemUniqueId>;
  679.  
  680. if(!IsNameValid(tag))
  681. return false;
  682.  
  683. allItems = GetItemsByTag(tag);
  684. for(i=0; i<allItems.Size(); i+=1)
  685. if( IsItemMounted(allItems[i]) || IsItemHeld(allItems[i]) )
  686. return true;
  687.  
  688. return false;
  689. }
  690.  
  691.  
  692. import final function GetItem( itemId : SItemUniqueId ) : SInventoryItem;
  693.  
  694.  
  695. import final function GetItemName( itemId : SItemUniqueId ) : name;
  696.  
  697.  
  698. import final function GetItemCategory( itemId : SItemUniqueId ) : name;
  699.  
  700.  
  701. import final function GetItemClass( itemId : SItemUniqueId ) : EInventoryItemClass;
  702.  
  703.  
  704. import final function GetItemTags( itemId : SItemUniqueId, out tags : array<name> ) : bool;
  705.  
  706.  
  707. import final function GetCraftedItemName( itemId : SItemUniqueId ) : name;
  708.  
  709.  
  710. import final function TotalItemStats( invItem : SInventoryItem ) : float;
  711.  
  712. import final function GetItemPrice( itemId : SItemUniqueId ) : int;
  713.  
  714.  
  715. import final function GetItemPriceModified( itemId : SItemUniqueId, optional playerSellingItem : Bool ) : int;
  716.  
  717.  
  718. import final function GetInventoryItemPriceModified( invItem : SInventoryItem, optional playerSellingItem : Bool ) : int;
  719.  
  720.  
  721. import final function GetItemPriceRepair( invItem : SInventoryItem, out costRepairPoint : int, out costRepairTotal : int );
  722.  
  723.  
  724. import final function GetItemPriceRemoveUpgrade( invItem : SInventoryItem ) : int;
  725.  
  726.  
  727. import final function GetItemPriceDisassemble( invItem : SInventoryItem ) : int;
  728.  
  729.  
  730. import final function GetItemPriceAddSlot( invItem : SInventoryItem ) : int;
  731.  
  732.  
  733. import final function GetItemPriceCrafting( invItem : SInventoryItem ) : int;
  734.  
  735.  
  736. import final function GetItemPriceEnchantItem( invItem : SInventoryItem ) : int;
  737.  
  738.  
  739. import final function GetItemPriceRemoveEnchantment( invItem : SInventoryItem ) : int;
  740.  
  741. import final function GetFundsModifier() : float;
  742.  
  743.  
  744. import final function GetItemQuantity( itemId : SItemUniqueId ) : int;
  745.  
  746.  
  747. import final function ItemHasTag( itemId : SItemUniqueId, tag : name ) : bool;
  748.  
  749.  
  750. import final function AddItemTag( itemId : SItemUniqueId, tag : name ) : bool;
  751.  
  752.  
  753. import final function RemoveItemTag( itemId : SItemUniqueId, tag : name ) : bool;
  754.  
  755.  
  756. public final function ManageItemsTag( items : array<SItemUniqueId>, tag : name, add : bool )
  757. {
  758. var i : int;
  759.  
  760. if( add )
  761. {
  762. for( i = 0 ; i < items.Size() ; i += 1 )
  763. {
  764. AddItemTag( items[ i ], tag );
  765. }
  766. }
  767. else
  768. {
  769. for( i = 0 ; i < items.Size() ; i += 1 )
  770. {
  771. RemoveItemTag( items[ i ], tag );
  772. }
  773. }
  774. }
  775.  
  776.  
  777. import final function GetItemByItemEntity( itemEntity : CItemEntity ) : SItemUniqueId;
  778.  
  779.  
  780. public function ItemHasAbility(item : SItemUniqueId, abilityName : name) : bool
  781. {
  782. var abilities : array<name>;
  783.  
  784. GetItemAbilities(item, abilities);
  785. return abilities.Contains(abilityName);
  786. }
  787.  
  788. import final function GetItemAttributeValue( itemId : SItemUniqueId, attributeName : name, optional abilityTags : array< name >, optional withoutTags : bool ) : SAbilityAttributeValue;
  789.  
  790.  
  791. import final function GetItemBaseAttributes( itemId : SItemUniqueId, out attributes : array<name> );
  792.  
  793.  
  794. import final function GetItemAttributes( itemId : SItemUniqueId, out attributes : array<name> );
  795.  
  796.  
  797. import final function GetItemAbilities( itemId : SItemUniqueId, out abilities : array<name> );
  798.  
  799.  
  800. import final function GetItemContainedAbilities( itemId : SItemUniqueId, out abilities : array<name> );
  801.  
  802.  
  803. public function GetItemAbilitiesWithAttribute(id : SItemUniqueId, attributeName : name, attributeVal : float) : array<name>
  804. {
  805. var i : int;
  806. var abs, ret : array<name>;
  807. var dm : CDefinitionsManagerAccessor;
  808. var val : float;
  809. var min, max : SAbilityAttributeValue;
  810.  
  811. GetItemAbilities(id, abs);
  812. dm = theGame.GetDefinitionsManager();
  813.  
  814. for(i=0; i<abs.Size(); i+=1)
  815. {
  816. dm.GetAbilityAttributeValue(abs[i], attributeName, min, max);
  817. val = CalculateAttributeValue(GetAttributeRandomizedValue(min, max));
  818.  
  819. if(val == attributeVal)
  820. ret.PushBack(abs[i]);
  821. }
  822.  
  823. return ret;
  824. }
  825. public function GetItemAbilitiesWithTag( itemId : SItemUniqueId, tag : name, out abilities : array<name> )
  826. {
  827. var i : int;
  828. var dm : CDefinitionsManagerAccessor;
  829. var allAbilities : array<name>;
  830.  
  831. dm = theGame.GetDefinitionsManager();
  832. GetItemAbilities(itemId, allAbilities);
  833.  
  834. for(i=0; i<allAbilities.Size(); i+=1)
  835. {
  836. if(dm.AbilityHasTag(allAbilities[i], tag))
  837. {
  838. abilities.PushBack(allAbilities[i]);
  839. }
  840. }
  841. }
  842.  
  843.  
  844.  
  845.  
  846. import private final function GiveItem( otherInventory : CInventoryComponent, itemId : SItemUniqueId, optional quantity : int ) : array<SItemUniqueId>;
  847.  
  848. public final function GiveMoneyTo(otherInventory : CInventoryComponent, optional quantity : int, optional informGUI : bool )
  849. {
  850. var moneyId : array<SItemUniqueId>;
  851.  
  852. moneyId = GetItemsByName('Crowns');
  853. GiveItemTo(otherInventory, moneyId[0], quantity, false, true, informGUI);
  854. }
  855.  
  856. public final function GiveItemTo( otherInventory : CInventoryComponent, itemId : SItemUniqueId, optional quantity : int, optional refreshNewFlag : bool, optional forceTransferNoDrops : bool, optional informGUI : bool ) : SItemUniqueId
  857. {
  858. var arr : array<SItemUniqueId>;
  859. var itemName : name;
  860. var i : int;
  861. var uiData : SInventoryItemUIData;
  862. var isQuestItem : bool;
  863.  
  864.  
  865. if(quantity == 0)
  866. quantity = 1;
  867.  
  868. quantity = Clamp(quantity, 0, GetItemQuantity(itemId));
  869. if(quantity == 0)
  870. return GetInvalidUniqueId();
  871.  
  872. itemName = GetItemName(itemId);
  873.  
  874. if(!forceTransferNoDrops && ( ItemHasTag(itemId, 'NoDrop') && !ItemHasTag(itemId, 'Lootable') ))
  875. {
  876. LogItems("Cannot transfer item <<" + itemName + ">> as it has the NoDrop tag set!!!");
  877. return GetInvalidUniqueId();
  878. }
  879.  
  880.  
  881. if(IsItemSingletonItem(itemId))
  882. {
  883.  
  884. if(otherInventory == thePlayer.inv && otherInventory.GetItemQuantityByName(itemName) > 0)
  885. {
  886. LogAssert(false, "CInventoryComponent.GiveItemTo: cannot add singleton item as player already has this item!");
  887. return GetInvalidUniqueId();
  888. }
  889.  
  890. else
  891. {
  892. arr = GiveItem(otherInventory, itemId, quantity);
  893. }
  894. }
  895. else
  896. {
  897.  
  898. arr = GiveItem(otherInventory, itemId, quantity);
  899. }
  900.  
  901.  
  902. if(otherInventory == thePlayer.inv)
  903. {
  904. isQuestItem = this.IsItemQuest( itemId );
  905. theTelemetry.LogWithLabelAndValue(TE_INV_ITEM_PICKED, itemName, quantity);
  906.  
  907. if ( !theGame.AreSavesLocked() && ( isQuestItem || this.GetItemQuality( itemId ) >= 4 ) )
  908. {
  909. theGame.RequestAutoSave( "item gained", false );
  910. }
  911. }
  912.  
  913. if (refreshNewFlag)
  914. {
  915. for (i = 0; i < arr.Size(); i += 1)
  916. {
  917. uiData = otherInventory.GetInventoryItemUIData( arr[i] );
  918. uiData.isNew = true;
  919. otherInventory.SetInventoryItemUIData( arr[i], uiData );
  920. }
  921. }
  922.  
  923. return arr[0];
  924. }
  925.  
  926. public final function GiveAllItemsTo(otherInventory : CInventoryComponent, optional forceTransferNoDrops : bool, optional informGUI : bool)
  927. {
  928. var items : array<SItemUniqueId>;
  929.  
  930. GetAllItems(items);
  931. GiveItemsTo(otherInventory, items, forceTransferNoDrops, informGUI);
  932. }
  933.  
  934. public final function GiveItemsTo(otherInventory : CInventoryComponent, items : array<SItemUniqueId>, optional forceTransferNoDrops : bool, optional informGUI : bool) : array<SItemUniqueId>
  935. {
  936. var i : int;
  937. var ret : array<SItemUniqueId>;
  938.  
  939. for( i = 0; i < items.Size(); i += 1 )
  940. {
  941. ret.PushBack(GiveItemTo(otherInventory, items[i], GetItemQuantity(items[i]), true, forceTransferNoDrops, informGUI));
  942. }
  943.  
  944. return ret;
  945. }
  946.  
  947.  
  948. import final function HasItem( item : name ) : bool;
  949.  
  950.  
  951.  
  952. final function HasItemById(id : SItemUniqueId) : bool
  953. {
  954. var arr : array<SItemUniqueId>;
  955.  
  956. GetAllItems(arr);
  957. return arr.Contains(id);
  958. }
  959.  
  960. public function HasItemByTag(tag : name) : bool
  961. {
  962. var quantity : int;
  963.  
  964. quantity = GetItemQuantityByTag( tag );
  965. return quantity > 0;
  966. }
  967.  
  968. public function HasItemByCategory(category : name) : bool
  969. {
  970. var quantity : int;
  971.  
  972. quantity = GetItemQuantityByCategory( category );
  973. return quantity > 0;
  974. }
  975.  
  976.  
  977. public function HasInfiniteBolts() : bool
  978. {
  979. var ids : array<SItemUniqueId>;
  980. var i : int;
  981.  
  982. ids = GetItemsByTag(theGame.params.TAG_INFINITE_AMMO);
  983. for(i=0; i<ids.Size(); i+=1)
  984. {
  985. if(IsItemBolt(ids[i]))
  986. {
  987. return true;
  988. }
  989. }
  990.  
  991. return false;
  992. }
  993.  
  994.  
  995. public function HasGroundBolts() : bool
  996. {
  997. var ids : array<SItemUniqueId>;
  998. var i : int;
  999.  
  1000. ids = GetItemsByTag(theGame.params.TAG_GROUND_AMMO);
  1001. for(i=0; i<ids.Size(); i+=1)
  1002. {
  1003. if(IsItemBolt(ids[i]))
  1004. {
  1005. return true;
  1006. }
  1007. }
  1008.  
  1009. return false;
  1010. }
  1011.  
  1012.  
  1013. public function HasUnderwaterBolts() : bool
  1014. {
  1015. var ids : array<SItemUniqueId>;
  1016. var i : int;
  1017.  
  1018. ids = GetItemsByTag(theGame.params.TAG_UNDERWATER_AMMO);
  1019. for(i=0; i<ids.Size(); i+=1)
  1020. {
  1021. if(IsItemBolt(ids[i]))
  1022. {
  1023. return true;
  1024. }
  1025. }
  1026.  
  1027. return false;
  1028. }
  1029.  
  1030.  
  1031.  
  1032. import private final function AddMultiItem( item : name, optional quantity : int, optional informGui : bool , optional markAsNew : bool , optional lootable : bool ) : array<SItemUniqueId>;
  1033. import private final function AddSingleItem( item : name, optional informGui : bool , optional markAsNew : bool , optional lootable : bool ) : SItemUniqueId;
  1034.  
  1035.  
  1036. public final function AddAnItem(item : name, optional quantity : int, optional dontInformGui : bool, optional dontMarkAsNew : bool, optional showAsRewardInUIHax : bool) : array<SItemUniqueId>
  1037. {
  1038. var arr : array<SItemUniqueId>;
  1039. var i : int;
  1040. var isReadableItem : bool;
  1041.  
  1042.  
  1043. if( theGame.GetDefinitionsManager().IsItemSingletonItem(item) && GetEntity() == thePlayer)
  1044. {
  1045. if(GetItemQuantityByName(item) > 0)
  1046. {
  1047. arr = GetItemsIds(item);
  1048. }
  1049. else
  1050. {
  1051. arr.PushBack(AddSingleItem(item, !dontInformGui, !dontMarkAsNew));
  1052. }
  1053.  
  1054. quantity = 1;
  1055. }
  1056. else
  1057. {
  1058. if(quantity < 2 )
  1059. {
  1060. arr.PushBack(AddSingleItem(item, !dontInformGui, !dontMarkAsNew));
  1061. }
  1062. else
  1063. {
  1064. arr = AddMultiItem(item, quantity, !dontInformGui, !dontMarkAsNew);
  1065. }
  1066. }
  1067.  
  1068.  
  1069. if(this == thePlayer.GetInventory())
  1070. {
  1071. if(ItemHasTag(arr[0],'ReadableItem'))
  1072. UpdateInitialReadState(arr[0]);
  1073.  
  1074.  
  1075. if(showAsRewardInUIHax || ItemHasTag(arr[0],'GwintCard'))
  1076. thePlayer.DisplayItemRewardNotification(GetItemName(arr[0]), quantity );
  1077. }
  1078.  
  1079. return arr;
  1080. }
  1081.  
  1082.  
  1083. import final function RemoveItem( itemId : SItemUniqueId, optional quantity : int ) : bool;
  1084.  
  1085.  
  1086. private final function InternalRemoveItems(ids : array<SItemUniqueId>, quantity : int)
  1087. {
  1088. var i, currQuantityToTake : int;
  1089.  
  1090.  
  1091. for(i=0; i<ids.Size(); i+=1 )
  1092. {
  1093.  
  1094. currQuantityToTake = Min(quantity, GetItemQuantity(ids[i]) );
  1095.  
  1096.  
  1097. if( GetEntity() == thePlayer )
  1098. {
  1099. GetWitcherPlayer().RemoveGwentCard( GetItemName(ids[i]) , currQuantityToTake);
  1100. }
  1101.  
  1102.  
  1103. RemoveItem(ids[i], currQuantityToTake);
  1104.  
  1105.  
  1106. quantity -= currQuantityToTake;
  1107.  
  1108.  
  1109. if ( quantity == 0 )
  1110. {
  1111. return;
  1112. }
  1113.  
  1114.  
  1115. LogAssert(quantity>0, "CInventoryComponent.InternalRemoveItems(" + GetItemName(ids[i]) + "): somehow took too many items! Should be " + (-quantity) + " less... Investigate!");
  1116. }
  1117. }
  1118.  
  1119.  
  1120.  
  1121. public function RemoveItemByName(itemName : name, optional quantity : int) : bool
  1122. {
  1123. var totalItemCount : int;
  1124. var ids : array<SItemUniqueId>;
  1125.  
  1126.  
  1127. totalItemCount = GetItemQuantityByName(itemName);
  1128. if(totalItemCount < quantity || quantity == 0)
  1129. {
  1130. return false;
  1131. }
  1132.  
  1133. if(quantity == 0)
  1134. {
  1135. quantity = 1;
  1136. }
  1137. else if(quantity < 0)
  1138. {
  1139. quantity = totalItemCount;
  1140. }
  1141.  
  1142. ids = GetItemsIds(itemName);
  1143.  
  1144. if(GetEntity() == thePlayer && thePlayer.GetSelectedItemId() == ids[0] )
  1145. {
  1146. thePlayer.ClearSelectedItemId();
  1147. }
  1148.  
  1149. InternalRemoveItems(ids, quantity);
  1150.  
  1151. return true;
  1152. }
  1153.  
  1154.  
  1155.  
  1156. public function RemoveItemByCategory(itemCategory : name, optional quantity : int) : bool
  1157. {
  1158. var totalItemCount : int;
  1159. var ids : array<SItemUniqueId>;
  1160. var selectedItemId : SItemUniqueId;
  1161. var i : int;
  1162.  
  1163.  
  1164. totalItemCount = GetItemQuantityByCategory(itemCategory);
  1165. if(totalItemCount < quantity)
  1166. {
  1167. return false;
  1168. }
  1169.  
  1170. if(quantity == 0)
  1171. {
  1172. quantity = 1;
  1173. }
  1174. else if(quantity < 0)
  1175. {
  1176. quantity = totalItemCount;
  1177. }
  1178.  
  1179. ids = GetItemsByCategory(itemCategory);
  1180.  
  1181. if(GetEntity() == thePlayer)
  1182. {
  1183. selectedItemId = thePlayer.GetSelectedItemId();
  1184. for(i=0; i<ids.Size(); i+=1)
  1185. {
  1186. if(selectedItemId == ids[i] )
  1187. {
  1188. thePlayer.ClearSelectedItemId();
  1189. break;
  1190. }
  1191. }
  1192. }
  1193.  
  1194. InternalRemoveItems(ids, quantity);
  1195.  
  1196. return true;
  1197. }
  1198.  
  1199.  
  1200.  
  1201. public function RemoveItemByTag(itemTag : name, optional quantity : int) : bool
  1202. {
  1203. var totalItemCount : int;
  1204. var ids : array<SItemUniqueId>;
  1205. var i : int;
  1206. var selectedItemId : SItemUniqueId;
  1207.  
  1208.  
  1209. totalItemCount = GetItemQuantityByTag(itemTag);
  1210. if(totalItemCount < quantity)
  1211. {
  1212. return false;
  1213. }
  1214.  
  1215. if(quantity == 0)
  1216. {
  1217. quantity = 1;
  1218. }
  1219. else if(quantity < 0)
  1220. {
  1221. quantity = totalItemCount;
  1222. }
  1223.  
  1224. ids = GetItemsByTag(itemTag);
  1225.  
  1226. if(GetEntity() == thePlayer)
  1227. {
  1228. selectedItemId = thePlayer.GetSelectedItemId();
  1229. for(i=0; i<ids.Size(); i+=1)
  1230. {
  1231. if(selectedItemId == ids[i] )
  1232. {
  1233. thePlayer.ClearSelectedItemId();
  1234. break;
  1235. }
  1236. }
  1237. }
  1238.  
  1239. InternalRemoveItems(ids, quantity);
  1240.  
  1241. return true;
  1242. }
  1243.  
  1244.  
  1245. import final function RemoveAllItems();
  1246.  
  1247.  
  1248. import final function GetItemEntityUnsafe( itemId : SItemUniqueId ) : CItemEntity;
  1249.  
  1250.  
  1251. import final function GetDeploymentItemEntity( itemId : SItemUniqueId, optional position : Vector, optional rotation : EulerAngles, optional allocateIdTag : bool ) : CEntity;
  1252.  
  1253.  
  1254. import final function MountItem( itemId : SItemUniqueId, optional toHand : bool, optional force : bool ) : bool;
  1255.  
  1256.  
  1257. import final function UnmountItem( itemId : SItemUniqueId, optional destroyEntity : bool ) : bool;
  1258.  
  1259.  
  1260.  
  1261. import final function IsItemMounted( itemId : SItemUniqueId ) : bool;
  1262.  
  1263.  
  1264.  
  1265. import final function IsItemHeld( itemId : SItemUniqueId ) : bool;
  1266.  
  1267.  
  1268. import final function DropItem( itemId : SItemUniqueId, optional removeFromInv : bool );
  1269.  
  1270.  
  1271. import final function GetItemHoldSlot( itemId : SItemUniqueId ) : name;
  1272.  
  1273.  
  1274. import final function PlayItemEffect( itemId : SItemUniqueId, effectName : name );
  1275. import final function StopItemEffect( itemId : SItemUniqueId, effectName : name );
  1276.  
  1277.  
  1278. import final function ThrowAwayItem( itemId : SItemUniqueId, optional quantity : int ) : bool;
  1279.  
  1280.  
  1281. import final function ThrowAwayAllItems() : CEntity;
  1282.  
  1283.  
  1284. import final function ThrowAwayItemsFiltered( excludedTags : array< name > ) : CEntity;
  1285.  
  1286.  
  1287. import final function ThrowAwayLootableItems( optional skipNoDropNoShow : bool ) : CEntity;
  1288.  
  1289.  
  1290. import final function GetItemRecyclingParts( itemId : SItemUniqueId ) : array<SItemParts>;
  1291.  
  1292. import final function GetItemWeight( id : SItemUniqueId ) : float;
  1293.  
  1294.  
  1295. public final function HasQuestItem() : bool
  1296. {
  1297. var allItems : array< SItemUniqueId >;
  1298. var i : int;
  1299.  
  1300. allItems = GetItemsByTag('Quest');
  1301. for ( i=0; i<allItems.Size(); i+=1 )
  1302. {
  1303. if(!ItemHasTag(allItems[i], theGame.params.TAG_DONT_SHOW))
  1304. {
  1305. return true;
  1306. }
  1307. }
  1308.  
  1309. return false;
  1310. }
  1311.  
  1312.  
  1313.  
  1314.  
  1315.  
  1316.  
  1317. import final function HasItemDurability( itemId : SItemUniqueId ) : bool;
  1318. import final function GetItemDurability( itemId : SItemUniqueId ) : float;
  1319. import private final function SetItemDurability( itemId : SItemUniqueId, durability : float );
  1320. import final function GetItemInitialDurability( itemId : SItemUniqueId ) : float;
  1321. import final function GetItemMaxDurability( itemId : SItemUniqueId ) : float;
  1322. import final function GetItemGridSize( itemId : SItemUniqueId ) : int;
  1323.  
  1324.  
  1325. import final function NotifyItemLooted( item : SItemUniqueId );
  1326. import final function ResetContainerData();
  1327.  
  1328. public function SetItemDurabilityScript( itemId : SItemUniqueId, durability : float )
  1329. {
  1330. var oldDur : float;
  1331.  
  1332. oldDur = GetItemDurability(itemId);
  1333.  
  1334. if(oldDur == durability)
  1335. return;
  1336.  
  1337. if(durability < oldDur)
  1338. {
  1339. if ( ItemHasAbility( itemId, 'MA_Indestructible' ) )
  1340. {
  1341. return;
  1342. }
  1343.  
  1344. if(GetEntity() == thePlayer && ShouldProcessTutorial('TutorialDurability'))
  1345. {
  1346. if ( durability <= theGame.params.ITEM_DAMAGED_DURABILITY && oldDur > theGame.params.ITEM_DAMAGED_DURABILITY )
  1347. {
  1348. FactsAdd( "tut_item_damaged", 1 );
  1349. }
  1350. }
  1351. }
  1352.  
  1353. SetItemDurability( itemId, durability );
  1354. }
  1355.  
  1356.  
  1357. public function ReduceItemDurability(itemId : SItemUniqueId, optional forced : bool) : bool
  1358. {
  1359. var dur, value, durabilityDiff, itemToughness, indestructible : float;
  1360. var chance : int;
  1361. if(!IsIdValid(itemId) || !HasItemDurability(itemId) || ItemHasAbility(itemId, 'MA_Indestructible'))
  1362. {
  1363. return false;
  1364. }
  1365.  
  1366.  
  1367. if(IsItemWeapon(itemId))
  1368. {
  1369. chance = theGame.params.DURABILITY_WEAPON_LOSE_CHANCE;
  1370. value = theGame.params.GetWeaponDurabilityLoseValue();
  1371. }
  1372. else if(IsItemAnyArmor(itemId))
  1373. {
  1374. chance = theGame.params.DURABILITY_ARMOR_LOSE_CHANCE;
  1375. value = theGame.params.DURABILITY_ARMOR_LOSE_VALUE;
  1376. }
  1377.  
  1378. dur = GetItemDurability(itemId);
  1379.  
  1380. if ( dur == 0 )
  1381. {
  1382. return false;
  1383. }
  1384.  
  1385.  
  1386. if ( forced || RandRange( 100 ) < chance )
  1387. {
  1388. itemToughness = CalculateAttributeValue( GetItemAttributeValue( itemId, 'toughness' ) );
  1389. indestructible = CalculateAttributeValue( GetItemAttributeValue( itemId, 'indestructible' ) );
  1390.  
  1391. value = value * ( 1 - indestructible );
  1392.  
  1393. if ( itemToughness > 0.0f && itemToughness <= 1.0f )
  1394. {
  1395. durabilityDiff = ( dur - value ) * itemToughness;
  1396.  
  1397. SetItemDurabilityScript( itemId, MaxF(durabilityDiff, 0 ) );
  1398. }
  1399. else
  1400. {
  1401. SetItemDurabilityScript( itemId, MaxF( dur - value, 0 ) );
  1402. }
  1403. }
  1404.  
  1405. return true;
  1406. }
  1407.  
  1408. public function GetItemDurabilityRatio(itemId : SItemUniqueId) : float
  1409. {
  1410. if ( !IsIdValid( itemId ) || !HasItemDurability( itemId ) )
  1411. return -1;
  1412.  
  1413. return GetItemDurability(itemId) / GetItemMaxDurability(itemId);
  1414. }
  1415.  
  1416.  
  1417.  
  1418.  
  1419.  
  1420.  
  1421. public function GetItemResistStatWithDurabilityModifiers(itemId : SItemUniqueId, stat : ECharacterDefenseStats, out points : SAbilityAttributeValue, out percents : SAbilityAttributeValue)
  1422. {
  1423. var mult : float;
  1424. var null : SAbilityAttributeValue;
  1425.  
  1426. points = null;
  1427. percents = null;
  1428. if(!IsItemAnyArmor(itemId))
  1429. return;
  1430.  
  1431. mult = theGame.params.GetDurabilityMultiplier(GetItemDurabilityRatio(itemId), false);
  1432.  
  1433. points = GetItemAttributeValue(itemId, ResistStatEnumToName(stat, true));
  1434. percents = GetItemAttributeValue(itemId, ResistStatEnumToName(stat, false));
  1435.  
  1436. points = points * mult;
  1437. percents = percents * mult;
  1438. }
  1439.  
  1440.  
  1441. public function GetItemResistanceTypes(id : SItemUniqueId) : array<ECharacterDefenseStats>
  1442. {
  1443. var ret : array<ECharacterDefenseStats>;
  1444. var i : int;
  1445. var stat : ECharacterDefenseStats;
  1446. var atts : array<name>;
  1447. var tmpBool : bool;
  1448.  
  1449. if(!IsIdValid(id))
  1450. return ret;
  1451.  
  1452. GetItemAttributes(id, atts);
  1453. for(i=0; i<atts.Size(); i+=1)
  1454. {
  1455. stat = ResistStatNameToEnum(atts[i], tmpBool);
  1456. if(stat != CDS_None && !ret.Contains(stat))
  1457. ret.PushBack(stat);
  1458. }
  1459.  
  1460. return ret;
  1461. }
  1462.  
  1463. import final function GetItemModifierFloat( itemId : SItemUniqueId, modName : name, optional defValue : float ) : float;
  1464. import final function SetItemModifierFloat( itemId : SItemUniqueId, modName : name, val : float);
  1465. import final function GetItemModifierInt ( itemId : SItemUniqueId, modName : name, optional defValue : int ) : int;
  1466. import final function SetItemModifierInt ( itemId : SItemUniqueId, modName : name, val : int );
  1467.  
  1468.  
  1469. import final function ActivateQuestBonus();
  1470.  
  1471.  
  1472. import final function GetItemSetName( itemId : SItemUniqueId ) : name;
  1473.  
  1474.  
  1475. import final function AddItemCraftedAbility( itemId : SItemUniqueId, abilityName : name, optional allowDuplicate : bool );
  1476.  
  1477.  
  1478. import final function RemoveItemCraftedAbility( itemId : SItemUniqueId, abilityName : name );
  1479.  
  1480.  
  1481. import final function AddItemBaseAbility(item : SItemUniqueId, abilityName : name);
  1482.  
  1483.  
  1484. import final function RemoveItemBaseAbility(item : SItemUniqueId, abilityName : name);
  1485.  
  1486.  
  1487. import final function DespawnItem( itemId : SItemUniqueId );
  1488.  
  1489.  
  1490.  
  1491.  
  1492.  
  1493.  
  1494. import final function GetInventoryItemUIData( item : SItemUniqueId ) : SInventoryItemUIData;
  1495.  
  1496.  
  1497. import final function SetInventoryItemUIData( item : SItemUniqueId, data : SInventoryItemUIData );
  1498.  
  1499. import final function SortInventoryUIData();
  1500.  
  1501.  
  1502.  
  1503.  
  1504.  
  1505.  
  1506. import final function PrintInfo();
  1507.  
  1508.  
  1509.  
  1510.  
  1511.  
  1512.  
  1513. import final function EnableLoot( enable : bool );
  1514.  
  1515.  
  1516. import final function UpdateLoot();
  1517.  
  1518.  
  1519. import final function AddItemsFromLootDefinition( lootDefinitionName : name );
  1520.  
  1521.  
  1522. import final function IsLootRenewable() : bool;
  1523.  
  1524.  
  1525. import final function IsReadyToRenew() : bool;
  1526.  
  1527.  
  1528.  
  1529.  
  1530.  
  1531.  
  1532. function Created()
  1533. {
  1534. LoadBooksDefinitions();
  1535. }
  1536.  
  1537. function ClearGwintCards()
  1538. {
  1539. var attr : SAbilityAttributeValue;
  1540. var allItems : array<SItemUniqueId>;
  1541. var card : array<SItemUniqueId>;
  1542. var iHave, shopHave, cardLimit, delta : int;
  1543. var curItem : SItemUniqueId;
  1544. var i : int;
  1545.  
  1546. allItems = GetItemsByCategory('gwint');
  1547. for(i=allItems.Size()-1; i >= 0; i-=1)
  1548. {
  1549. curItem = allItems[i];
  1550.  
  1551. attr = GetItemAttributeValue( curItem, 'max_count');
  1552. card = thePlayer.GetInventory().GetItemsByName( GetItemName( curItem ) );
  1553. iHave = thePlayer.GetInventory().GetItemQuantity( card[0] );
  1554. cardLimit = RoundF(attr.valueBase);
  1555. shopHave = GetItemQuantity( curItem );
  1556.  
  1557. if (iHave > 0 && shopHave > 0)
  1558. {
  1559. delta = shopHave - (cardLimit - iHave);
  1560.  
  1561. if ( delta > 0 )
  1562. {
  1563. RemoveItem( curItem, delta );
  1564. }
  1565. }
  1566. }
  1567. }
  1568.  
  1569. function ClearTHmaps()
  1570. {
  1571. var attr : SAbilityAttributeValue;
  1572. var allItems : array<SItemUniqueId>;
  1573. var map : array<SItemUniqueId>;
  1574. var i : int;
  1575. var thCompleted : bool;
  1576. var iHave, shopHave : int;
  1577.  
  1578. allItems = GetItemsByTag('ThMap');
  1579. for(i=allItems.Size()-1; i >= 0; i-=1)
  1580. {
  1581. attr = GetItemAttributeValue( allItems[i], 'max_count');
  1582. map = thePlayer.GetInventory().GetItemsByName( GetItemName( allItems[i] ) );
  1583. thCompleted = FactsDoesExist(GetItemName(allItems[i]));
  1584. iHave = thePlayer.GetInventory().GetItemQuantity( map[0] );
  1585. shopHave = RoundF(attr.valueBase);
  1586.  
  1587. if ( iHave >= shopHave || thCompleted )
  1588. {
  1589. RemoveItem( allItems[i], GetItemQuantity( allItems[i] ) );
  1590. }
  1591. }
  1592. }
  1593.  
  1594.  
  1595. public final function ClearKnownRecipes()
  1596. {
  1597. var witcher : W3PlayerWitcher;
  1598. var recipes, craftRecipes : array<name>;
  1599. var i : int;
  1600. var itemName : name;
  1601. var allItems : array<SItemUniqueId>;
  1602.  
  1603. witcher = GetWitcherPlayer();
  1604. if(!witcher)
  1605. return;
  1606.  
  1607.  
  1608. recipes = witcher.GetAlchemyRecipes();
  1609. craftRecipes = witcher.GetCraftingSchematicsNames();
  1610. ArrayOfNamesAppend(recipes, craftRecipes);
  1611.  
  1612.  
  1613. GetAllItems(allItems);
  1614.  
  1615.  
  1616. for(i=allItems.Size()-1; i>=0; i-=1)
  1617. {
  1618. itemName = GetItemName(allItems[i]);
  1619. if(recipes.Contains(itemName))
  1620. RemoveItem(allItems[i], GetItemQuantity(allItems[i]));
  1621. }
  1622. }
  1623.  
  1624.  
  1625.  
  1626.  
  1627.  
  1628. function LoadBooksDefinitions() : void
  1629. {
  1630. var readableArray : array<SItemUniqueId>;
  1631. var i : int;
  1632.  
  1633. readableArray = GetItemsByTag('ReadableItem');
  1634.  
  1635. for( i = 0; i < readableArray.Size(); i += 1 )
  1636. {
  1637. if( IsBookRead(readableArray[i]))
  1638. {
  1639. continue;
  1640. }
  1641. UpdateInitialReadState(readableArray[i]);
  1642. }
  1643. }
  1644.  
  1645. function UpdateInitialReadState( item : SItemUniqueId )
  1646. {
  1647. var abilitiesArray : array<name>;
  1648. var i : int;
  1649. GetItemAbilities(item,abilitiesArray);
  1650.  
  1651. for( i = 0; i < abilitiesArray.Size(); i += 1 )
  1652. {
  1653. if( abilitiesArray[i] == 'WasRead' )
  1654. {
  1655. ReadBook(item);
  1656. break;
  1657. }
  1658. }
  1659. }
  1660.  
  1661. function IsBookRead( item : SItemUniqueId ) : bool
  1662. {
  1663. var bookName : name;
  1664. var bResult : bool;
  1665.  
  1666. bookName = GetItemName( item );
  1667.  
  1668. bResult = IsBookReadByName( bookName );
  1669. return bResult;
  1670. }
  1671.  
  1672. function IsBookReadByName( bookName : name ) : bool
  1673. {
  1674. var bookFactName : string;
  1675.  
  1676. bookFactName = GetBookReadFactName( bookName );
  1677. if( FactsDoesExist(bookFactName) )
  1678. {
  1679. return FactsQuerySum( bookFactName );
  1680. }
  1681.  
  1682. return false;
  1683. }
  1684.  
  1685. function ReadBook( item : SItemUniqueId, optional noNotification : bool )
  1686. {
  1687.  
  1688. var bookName : name;
  1689. var abilitiesArray : array<name>;
  1690. var i : int;
  1691. var commonMapManager : CCommonMapManager = theGame.GetCommonMapManager();
  1692.  
  1693. bookName = GetItemName( item );
  1694.  
  1695. if ( !IsBookRead ( item ) && ItemHasTag ( item, 'FastTravel' ))
  1696. {
  1697. GetItemAbilities(item, abilitiesArray);
  1698.  
  1699. for ( i = 0; i < abilitiesArray.Size(); i+=1 )
  1700. {
  1701. commonMapManager.SetEntityMapPinDiscoveredScript(true, abilitiesArray[i], true );
  1702. }
  1703. }
  1704. ReadBookByNameId( bookName, item, false, noNotification );
  1705.  
  1706.  
  1707.  
  1708.  
  1709. if(ItemHasTag(item, 'PerkBook'))
  1710. {
  1711.  
  1712. }
  1713. }
  1714.  
  1715. public function GetBookText(item : SItemUniqueId) : string
  1716. {
  1717. if ( GetItemName( item ) != 'Gwent Almanac' )
  1718. {
  1719. return ReplaceTagsToIcons(GetLocStringByKeyExt(GetItemLocalizedNameByUniqueID(item)+"_text"));
  1720. }
  1721. else
  1722. {
  1723. return GetGwentAlmanacContents();
  1724. }
  1725. }
  1726.  
  1727. public function GetBookTextByName( bookName : name ) : string
  1728. {
  1729. if( bookName != 'Gwent Almanac' )
  1730. {
  1731. return ReplaceTagsToIcons( GetLocStringByKeyExt( GetItemLocalizedNameByName( bookName ) + "_text" ) );
  1732. }
  1733. else
  1734. {
  1735. return GetGwentAlmanacContents();
  1736. }
  1737. }
  1738.  
  1739. function ReadSchematicsAndRecipes( item : SItemUniqueId )
  1740. {
  1741. var itemCategory : name;
  1742. var itemName : name;
  1743. var player : W3PlayerWitcher;
  1744.  
  1745. ReadBook( item );
  1746.  
  1747. player = GetWitcherPlayer();
  1748. if ( !player )
  1749. {
  1750. return;
  1751. }
  1752.  
  1753. itemName = GetItemName( item );
  1754. itemCategory = GetItemCategory( item );
  1755. if ( itemCategory == 'alchemy_recipe' )
  1756. {
  1757. if ( player.CanLearnAlchemyRecipe( itemName ) )
  1758. {
  1759. player.AddAlchemyRecipe( itemName );
  1760. player.GetInventory().AddItemTag(item, 'NoShow');
  1761. //---=== modFriendlyHUD ===---
  1762. if (!thePlayer.newCraftables.Contains(itemName))
  1763. {
  1764. thePlayer.newCraftables.PushBack(itemName);
  1765. }
  1766. //---=== modFriendlyHUD ===---
  1767. }
  1768. }
  1769. else if ( itemCategory == 'crafting_schematic' )
  1770. {
  1771. player.AddCraftingSchematic( itemName );
  1772. player.GetInventory().AddItemTag(item, 'NoShow');
  1773. //---=== modFriendlyHUD ===---
  1774. if (!thePlayer.newCraftables.Contains(itemName))
  1775. {
  1776. thePlayer.newCraftables.PushBack(itemName);
  1777. }
  1778. //---=== modFriendlyHUD ===---
  1779. }
  1780. }
  1781.  
  1782. function ReadBookByName( bookName : name , unread : bool, optional noNotification : bool )
  1783. {
  1784. var defMgr : CDefinitionsManagerAccessor;
  1785. var bookFactName : string;
  1786.  
  1787. if( IsBookReadByName( bookName ) != unread )
  1788. {
  1789. return;
  1790. }
  1791.  
  1792. bookFactName = "BookReadState_"+bookName;
  1793. bookFactName = StrReplace(bookFactName," ","_");
  1794.  
  1795. if( unread )
  1796. {
  1797. FactsSubstract( bookFactName, 1 );
  1798. }
  1799. else
  1800. {
  1801. FactsAdd( bookFactName, 1 );
  1802.  
  1803.  
  1804. defMgr = theGame.GetDefinitionsManager();
  1805. if(!IsAlchemyRecipe(bookName) && !IsCraftingSchematic(bookName) && !defMgr.ItemHasTag( bookName, 'Painting' ) )
  1806. {
  1807. theGame.GetGamerProfile().IncStat(ES_ReadBooks);
  1808.  
  1809. if( !noNotification )
  1810. {
  1811. theGame.GetGuiManager().ShowNotification( GetLocStringByKeyExt( "notification_book_moved" ), 0, false );
  1812. }
  1813. }
  1814.  
  1815.  
  1816. if ( AddBestiaryFromBook(bookName) )
  1817. return;
  1818.  
  1819.  
  1820.  
  1821. }
  1822. }
  1823.  
  1824. function ReadBookByNameId( bookName : name, itemId:SItemUniqueId, unread : bool, optional noNotification : bool )
  1825. {
  1826. var bookFactName : string;
  1827.  
  1828. if( IsBookReadByName( bookName ) != unread )
  1829. {
  1830. return;
  1831. }
  1832.  
  1833. bookFactName = "BookReadState_"+bookName;
  1834. bookFactName = StrReplace(bookFactName," ","_");
  1835.  
  1836. if( unread )
  1837. {
  1838. FactsSubstract( bookFactName, 1 );
  1839. }
  1840. else
  1841. {
  1842. FactsAdd( bookFactName, 1 );
  1843.  
  1844.  
  1845. if( !IsAlchemyRecipe( bookName ) && !IsCraftingSchematic( bookName ) )
  1846. {
  1847. theGame.GetGamerProfile().IncStat(ES_ReadBooks);
  1848.  
  1849. if( !noNotification )
  1850. {
  1851.  
  1852. GetWitcherPlayer().AddReadBook( bookName );
  1853. }
  1854. }
  1855.  
  1856.  
  1857. if ( AddBestiaryFromBook(bookName) )
  1858. return;
  1859. else
  1860. ReadSchematicsAndRecipes( itemId );
  1861. }
  1862. }
  1863.  
  1864.  
  1865. private function AddBestiaryFromBook( bookName : name ) : bool
  1866. {
  1867. var i, j, r, len : int;
  1868. var manager : CWitcherJournalManager;
  1869. var resource : array<CJournalResource>;
  1870. var entryBase : CJournalBase;
  1871. var childGroups : array<CJournalBase>;
  1872. var childEntries : array<CJournalBase>;
  1873. var descriptionGroup : CJournalCreatureDescriptionGroup;
  1874. var descriptionEntry : CJournalCreatureDescriptionEntry;
  1875.  
  1876. manager = theGame.GetJournalManager();
  1877.  
  1878. switch ( bookName )
  1879. {
  1880. case 'Beasts vol 1':
  1881. resource.PushBack( (CJournalResource)LoadResource( "BestiaryWolf" ) );
  1882. resource.PushBack( (CJournalResource)LoadResource( "BestiaryDog" ) );
  1883. break;
  1884. case 'Beasts vol 2':
  1885. resource.PushBack( (CJournalResource)LoadResource( "BestiaryBear" ) );
  1886. break;
  1887. case 'Cursed Monsters vol 1':
  1888. resource.PushBack( (CJournalResource)LoadResource( "BestiaryWerewolf" ) );
  1889. resource.PushBack( (CJournalResource)LoadResource( "BestiaryLycanthrope" ) );
  1890. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 24');
  1891. break;
  1892. case 'Cursed Monsters vol 2':
  1893. resource.PushBack( (CJournalResource)LoadResource( "BestiaryWerebear" ) );
  1894. resource.PushBack( (CJournalResource)LoadResource( "BestiaryMiscreant" ) );
  1895. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 11');
  1896. break;
  1897. case 'Draconides vol 1':
  1898. resource.PushBack( (CJournalResource)LoadResource( "BestiaryCockatrice" ) );
  1899. resource.PushBack( (CJournalResource)LoadResource( "BestiaryBasilisk" ) );
  1900. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 3');
  1901. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 23');
  1902. break;
  1903. case 'Draconides vol 2':
  1904. resource.PushBack( (CJournalResource)LoadResource( "BestiaryWyvern" ) );
  1905. resource.PushBack( (CJournalResource)LoadResource( "BestiaryForktail" ) );
  1906. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 10');
  1907. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 17');
  1908. break;
  1909. case 'Hybrid Monsters vol 1':
  1910. resource.PushBack( (CJournalResource)LoadResource( "BestiaryHarpy" ) );
  1911. resource.PushBack( (CJournalResource)LoadResource( "BestiaryErynia" ) );
  1912. resource.PushBack( (CJournalResource)LoadResource( "BestiarySiren" ) );
  1913. resource.PushBack( (CJournalResource)LoadResource( "BestiarySuccubus" ) );
  1914. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 14');
  1915. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 21');
  1916. break;
  1917. case 'Hybrid Monsters vol 2':
  1918. resource.PushBack( (CJournalResource)LoadResource( "BestiaryGriffin" ) );
  1919. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 4');
  1920. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 27');
  1921. break;
  1922. case 'Insectoids vol 1':
  1923. resource.PushBack( (CJournalResource)LoadResource( "BestiaryEndriagaWorker" ) );
  1924. resource.PushBack( (CJournalResource)LoadResource( "BestiaryEndriagaTruten" ) );
  1925. resource.PushBack( (CJournalResource)LoadResource( "BestiaryEndriaga" ) );
  1926. break;
  1927. case 'Insectoids vol 2':
  1928. resource.PushBack( (CJournalResource)LoadResource( "BestiaryCrabSpider" ) );
  1929. resource.PushBack( (CJournalResource)LoadResource( "BestiaryArmoredArachas" ) );
  1930. resource.PushBack( (CJournalResource)LoadResource( "BestiaryPoisonousArachas" ) );
  1931. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 2');
  1932. break;
  1933. case 'Magical Monsters vol 1':
  1934. resource.PushBack( (CJournalResource)LoadResource( "BestiaryGolem" ) );
  1935. break;
  1936. case 'Magical Monsters vol 2':
  1937. resource.PushBack( (CJournalResource)LoadResource( "BestiaryElemental" ) );
  1938. resource.PushBack( (CJournalResource)LoadResource( "BestiaryIceGolem" ) );
  1939. resource.PushBack( (CJournalResource)LoadResource( "BestiaryFireElemental" ) );
  1940. resource.PushBack( (CJournalResource)LoadResource( "BestiaryWhMinion" ) );
  1941. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 20');
  1942. break;
  1943. case 'Necrophage vol 1':
  1944. resource.PushBack( (CJournalResource)LoadResource( "BestiaryGhoul" ) );
  1945. resource.PushBack( (CJournalResource)LoadResource( "BestiaryAlghoul" ) );
  1946. resource.PushBack( (CJournalResource)LoadResource( "BestiaryGreaterRotFiend" ) );
  1947. resource.PushBack( (CJournalResource)LoadResource( "BestiaryDrowner" ) );
  1948. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 15');
  1949. break;
  1950. case 'Necrophage vol 2':
  1951. resource.PushBack( (CJournalResource)LoadResource( "BestiaryGraveHag" ) );
  1952. resource.PushBack( (CJournalResource)LoadResource( "BestiaryWaterHag" ) );
  1953. resource.PushBack( (CJournalResource)LoadResource( "BestiaryFogling" ) );
  1954. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 5');
  1955. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 9');
  1956. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 18');
  1957. break;
  1958. case 'Relict Monsters vol 1':
  1959. resource.PushBack( (CJournalResource)LoadResource( "BestiaryBies" ) );
  1960. resource.PushBack( (CJournalResource)LoadResource( "BestiaryCzart" ) );
  1961. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 8');
  1962. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 16');
  1963. break;
  1964. case 'Relict Monsters vol 2':
  1965. resource.PushBack( (CJournalResource)LoadResource( "BestiaryLeshy" ) );
  1966. resource.PushBack( (CJournalResource)LoadResource( "BestiarySilvan" ) );
  1967. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 22');
  1968. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 26');
  1969. break;
  1970. case 'Specters vol 1':
  1971. resource.PushBack( (CJournalResource)LoadResource( "BestiaryMoonwright" ) );
  1972. resource.PushBack( (CJournalResource)LoadResource( "BestiaryNoonwright" ) );
  1973. resource.PushBack( (CJournalResource)LoadResource( "BestiaryPesta" ) );
  1974. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 6');
  1975. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 13');
  1976. break;
  1977. case 'Specters vol 2':
  1978. resource.PushBack( (CJournalResource)LoadResource( "BestiaryWraith" ) );
  1979. resource.PushBack( (CJournalResource)LoadResource( "BestiaryHim" ) );
  1980. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 19');
  1981. break;
  1982. case 'Ogres vol 1':
  1983. resource.PushBack( (CJournalResource)LoadResource( "BestiaryNekker" ) );
  1984. resource.PushBack( (CJournalResource)LoadResource( "BestiaryIceTroll" ) );
  1985. resource.PushBack( (CJournalResource)LoadResource( "BestiaryCaveTroll" ) );
  1986. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 12');
  1987. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 25');
  1988. break;
  1989. case 'Ogres vol 2':
  1990. resource.PushBack( (CJournalResource)LoadResource( "BestiaryCyclop" ) );
  1991. resource.PushBack( (CJournalResource)LoadResource( "BestiaryIceGiant" ) );
  1992. break;
  1993. case 'Vampires vol 1':
  1994. resource.PushBack( (CJournalResource)LoadResource( "BestiaryEkkima" ) );
  1995. resource.PushBack( (CJournalResource)LoadResource( "BestiaryHigherVampire" ) );
  1996. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 7');
  1997. break;
  1998. case 'Vampires vol 2':
  1999. resource.PushBack( (CJournalResource)LoadResource( "BestiaryKatakan" ) );
  2000. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 1');
  2001. break;
  2002.  
  2003. case 'bestiary_sharley_book':
  2004. resource.PushBack( (CJournalResource)LoadResource( "BestiarySharley" ) );
  2005. break;
  2006. case 'bestiary_barghest_book':
  2007. resource.PushBack( (CJournalResource)LoadResource( "BestiaryBarghest" ) );
  2008. break;
  2009. case 'bestiary_garkain_book':
  2010. resource.PushBack( (CJournalResource)LoadResource( "BestiaryGarkain" ) );
  2011. break;
  2012. case 'bestiary_alp_book':
  2013. resource.PushBack( (CJournalResource)LoadResource( "BestiaryAlp" ) );
  2014. break;
  2015. case 'bestiary_bruxa_book':
  2016. resource.PushBack( (CJournalResource)LoadResource( "BestiaryBruxa" ) );
  2017. break;
  2018. case 'bestiary_spriggan_book':
  2019. resource.PushBack( (CJournalResource)LoadResource( "BestiarySpriggan" ) );
  2020. break;
  2021. case 'bestiary_fleder_book':
  2022. resource.PushBack( (CJournalResource)LoadResource( "BestiaryFleder" ) );
  2023. break;
  2024. case 'bestiary_wight_book':
  2025. resource.PushBack( (CJournalResource)LoadResource( "BestiaryWicht" ) );
  2026. break;
  2027. case 'bestiary_dracolizard_book':
  2028. resource.PushBack( (CJournalResource)LoadResource( "BestiaryDracolizard" ) );
  2029. break;
  2030. case 'bestiary_panther_book':
  2031. resource.PushBack( (CJournalResource)LoadResource( "BestiaryPanther" ) );
  2032. break;
  2033. case 'bestiary_kikimore_book':
  2034. resource.PushBack( (CJournalResource)LoadResource( "BestiaryKikimoraWarrior" ) );
  2035. resource.PushBack( (CJournalResource)LoadResource( "BestiaryKikimoraWorker" ) );
  2036. break;
  2037. case 'bestiary_scolopendromorph_book':
  2038. case 'mq7023_fluff_book_scolopendromorphs':
  2039. resource.PushBack( (CJournalResource)LoadResource( "BestiaryScolopendromorph" ) );
  2040. break;
  2041. case 'bestiary_archespore_book':
  2042. resource.PushBack( (CJournalResource)LoadResource( "BestiaryArchespore" ) );
  2043. break;
  2044. case 'bestiary_protofleder_book':
  2045. resource.PushBack( (CJournalResource)LoadResource( "BestiaryProtofleder" ) );
  2046. break;
  2047. default:
  2048. return false;
  2049. }
  2050.  
  2051.  
  2052.  
  2053.  
  2054. len = resource.Size();
  2055. if( len > 0)
  2056. {
  2057.  
  2058. theGame.GetGuiManager().ShowNotification( GetLocStringByKeyExt( "panel_hud_journal_entry_bestiary_new" ), 0, true );
  2059. theSound.SoundEvent("gui_ingame_new_journal");
  2060. }
  2061.  
  2062. for (r=0; r < len; r += 1 )
  2063. {
  2064. if ( !resource[ r ] )
  2065. {
  2066.  
  2067. continue;
  2068. }
  2069. entryBase = resource[r].GetEntry();
  2070. if ( entryBase )
  2071. {
  2072. manager.ActivateEntry( entryBase, JS_Active );
  2073. manager.SetEntryHasAdvancedInfo( entryBase, true );
  2074.  
  2075.  
  2076. manager.GetAllChildren( entryBase, childGroups );
  2077. for ( i = 0; i < childGroups.Size(); i += 1 )
  2078. {
  2079. descriptionGroup = ( CJournalCreatureDescriptionGroup )childGroups[ i ];
  2080. if ( descriptionGroup )
  2081. {
  2082. manager.GetAllChildren( descriptionGroup, childEntries );
  2083. for ( j = 0; j < childEntries.Size(); j += 1 )
  2084. {
  2085. descriptionEntry = ( CJournalCreatureDescriptionEntry )childEntries[ j ];
  2086. if ( descriptionEntry )
  2087. {
  2088. manager.ActivateEntry( descriptionEntry, JS_Active );
  2089. }
  2090. }
  2091. break;
  2092. }
  2093. }
  2094. }
  2095. }
  2096.  
  2097. if ( resource.Size() > 0 )
  2098. return true;
  2099. else
  2100. return false;
  2101. }
  2102.  
  2103.  
  2104.  
  2105.  
  2106.  
  2107.  
  2108.  
  2109.  
  2110. function GetWeaponDTNames( id : SItemUniqueId, out dmgNames : array< name > ) : int
  2111. {
  2112. var attrs : array< name >;
  2113. var i, size : int;
  2114.  
  2115. dmgNames.Clear();
  2116.  
  2117. if( IsIdValid(id) )
  2118. {
  2119. GetItemAttributes( id, attrs );
  2120. size = attrs.Size();
  2121.  
  2122. for( i = 0; i < size; i += 1 )
  2123. if( IsDamageTypeNameValid(attrs[i]) )
  2124. dmgNames.PushBack( attrs[i] );
  2125.  
  2126. if(dmgNames.Size() == 0)
  2127. LogAssert(false, "CInventoryComponent.GetWeaponDTNames: weapon <<" + GetItemName(id) + ">> has no damage types defined!");
  2128. }
  2129. return dmgNames.Size();
  2130. }
  2131.  
  2132. public function GetWeapons() : array<SItemUniqueId>
  2133. {
  2134. var ids, ids2 : array<SItemUniqueId>;
  2135.  
  2136. ids = GetItemsByCategory('monster_weapon');
  2137. ids2 = GetItemsByTag('Weapon');
  2138. ArrayOfIdsAppend(ids, ids2);
  2139.  
  2140. return ids;
  2141. }
  2142.  
  2143. public function GetHeldWeapons() : array<SItemUniqueId>
  2144. {
  2145. var i : int;
  2146. var w : array<SItemUniqueId>;
  2147.  
  2148. w = GetWeapons();
  2149.  
  2150. for(i=w.Size()-1; i>=0; i-=1)
  2151. {
  2152. if(!IsItemHeld(w[i]))
  2153. {
  2154. w.EraseFast( i );
  2155. }
  2156. }
  2157.  
  2158. return w;
  2159. }
  2160.  
  2161. public function GetCurrentlyHeldSword() : SItemUniqueId
  2162. {
  2163. var i : int;
  2164. var w : array<SItemUniqueId>;
  2165.  
  2166. w = GetHeldWeapons();
  2167.  
  2168. for( i = 0 ; i < w.Size() ; i+=1 )
  2169. {
  2170. if( IsItemSteelSwordUsableByPlayer( w[i] ) || IsItemSilverSwordUsableByPlayer( w[i] ) )
  2171. {
  2172. return w[i];
  2173. }
  2174. }
  2175.  
  2176. return GetInvalidUniqueId();
  2177. }
  2178.  
  2179. public function GetCurrentlyHeldSwordEntity( out ent : CItemEntity ) : bool
  2180. {
  2181. var id : SItemUniqueId;
  2182.  
  2183. id = GetCurrentlyHeldSword();
  2184.  
  2185. if( IsIdValid( id ) )
  2186. {
  2187. ent = GetItemEntityUnsafe( id );
  2188.  
  2189. if( ent )
  2190. {
  2191. return true;
  2192. }
  2193. else
  2194. {
  2195. return false;
  2196. }
  2197. }
  2198. return false;
  2199. }
  2200.  
  2201. public function GetHeldWeaponsWithCategory( category : name, out items : array<SItemUniqueId> )
  2202. {
  2203. var i : int;
  2204.  
  2205. items = GetItemsByCategory( category );
  2206.  
  2207. for ( i = items.Size()-1; i >= 0; i -= 1)
  2208. {
  2209. if ( !IsItemHeld( items[i] ) )
  2210. {
  2211. items.EraseFast( i );
  2212. }
  2213. }
  2214. }
  2215.  
  2216. public function GetPotionItemBuffData(id : SItemUniqueId, out type : EEffectType, out customAbilityName : name) : bool
  2217. {
  2218. var size, i : int;
  2219. var arr : array<name>;
  2220.  
  2221. if(IsIdValid(id))
  2222. {
  2223. GetItemContainedAbilities( id, arr );
  2224. size = arr.Size();
  2225.  
  2226. for( i = 0; i < size; i += 1 )
  2227. {
  2228. if( IsEffectNameValid(arr[i]) )
  2229. {
  2230. EffectNameToType(arr[i], type, customAbilityName);
  2231. return true;
  2232. }
  2233. }
  2234. }
  2235.  
  2236. return false;
  2237. }
  2238.  
  2239.  
  2240. public function RecycleItem( id : SItemUniqueId, level : ECraftsmanLevel ) : array<SItemUniqueId>
  2241. {
  2242. var itemsAdded : array<SItemUniqueId>;
  2243. var currentAdded : array<SItemUniqueId>;
  2244.  
  2245. var parts : array<SItemParts>;
  2246. var i : int;
  2247.  
  2248. parts = GetItemRecyclingParts( id );
  2249.  
  2250. for ( i = 0; i < parts.Size(); i += 1 )
  2251. {
  2252. if ( ECL_Grand_Master == level || ECL_Arch_Master == level )
  2253. {
  2254. currentAdded = AddAnItem( parts[i].itemName, parts[i].quantity );
  2255. }
  2256. else if ( ECL_Master == level && parts[i].quantity > 1 )
  2257. {
  2258. currentAdded = AddAnItem( parts[i].itemName, RandRange( parts[i].quantity, 1 ) );
  2259. }
  2260. else
  2261. {
  2262. currentAdded = AddAnItem( parts[i].itemName, 1 );
  2263. }
  2264. itemsAdded.PushBack(currentAdded[0]);
  2265. }
  2266.  
  2267. RemoveItem(id);
  2268.  
  2269. return itemsAdded;
  2270. }
  2271.  
  2272.  
  2273.  
  2274.  
  2275.  
  2276.  
  2277. public function GetItemBuffs( id : SItemUniqueId, out buffs : array<SEffectInfo>) : int
  2278. {
  2279. var attrs, abs, absFast : array< name >;
  2280. var i, k : int;
  2281. var type : EEffectType;
  2282. var abilityName : name;
  2283. var buff : SEffectInfo;
  2284. var dm : CDefinitionsManagerAccessor;
  2285.  
  2286. buffs.Clear();
  2287.  
  2288. if( !IsIdValid(id) )
  2289. return 0;
  2290.  
  2291.  
  2292. GetItemContainedAbilities(id, absFast);
  2293. if(absFast.Size() == 0)
  2294. return 0;
  2295.  
  2296. GetItemAbilities(id, abs);
  2297. dm = theGame.GetDefinitionsManager();
  2298. for(k=0; k<abs.Size(); k+=1)
  2299. {
  2300. dm.GetContainedAbilities(abs[k], attrs);
  2301. buff.applyChance = CalculateAttributeValue(GetItemAbilityAttributeValue(id, 'buff_apply_chance', abs[k])) * ArrayOfNamesCount(abs, abs[k]);
  2302.  
  2303. for( i = 0; i < attrs.Size(); i += 1 )
  2304. {
  2305. if( IsEffectNameValid(attrs[i]) )
  2306. {
  2307. EffectNameToType(attrs[i], type, abilityName);
  2308.  
  2309. buff.effectType = type;
  2310. buff.effectAbilityName = abilityName;
  2311.  
  2312. buffs.PushBack(buff);
  2313.  
  2314.  
  2315. if(absFast.Size() == 1)
  2316. return buffs.Size();
  2317. else
  2318. absFast.EraseFast(0);
  2319. }
  2320. }
  2321. }
  2322.  
  2323. return buffs.Size();
  2324. }
  2325.  
  2326.  
  2327. public function DropItemInBag( item : SItemUniqueId, quantity : int )
  2328. {
  2329. var entities : array<CGameplayEntity>;
  2330. var i : int;
  2331. var owner : CActor;
  2332. var bag : W3ActorRemains;
  2333. var template : CEntityTemplate;
  2334. var bagtags : array <name>;
  2335. var bagPosition : Vector;
  2336. var tracedPosition, tracedNormal : Vector;
  2337.  
  2338. if(ItemHasTag(item, 'NoDrop'))
  2339. return;
  2340.  
  2341. owner = (CActor)GetEntity();
  2342. FindGameplayEntitiesInRange(entities, owner, 0.5, 100);
  2343.  
  2344. for(i=0; i<entities.Size(); i+=1)
  2345. {
  2346. bag = (W3ActorRemains)entities[i];
  2347.  
  2348. if(bag)
  2349. break;
  2350. }
  2351.  
  2352.  
  2353. if(!bag)
  2354. {
  2355. template = (CEntityTemplate)LoadResource("lootbag");
  2356. bagtags.PushBack('lootbag');
  2357.  
  2358.  
  2359. bagPosition = owner.GetWorldPosition();
  2360. if ( theGame.GetWorld().StaticTrace( bagPosition, bagPosition + Vector( 0.0f, 0.0f, -10.0f, 0.0f ), tracedPosition, tracedNormal ) )
  2361. {
  2362. bagPosition = tracedPosition;
  2363. }
  2364. bag = (W3ActorRemains)theGame.CreateEntity(template, bagPosition, owner.GetWorldRotation(), true, false, false, PM_Persist,bagtags);
  2365. }
  2366.  
  2367.  
  2368. GiveItemTo(bag.GetInventory(), item, quantity, false);
  2369.  
  2370.  
  2371. if(bag.GetInventory().IsEmpty())
  2372. {
  2373. delete bag;
  2374. return;
  2375. }
  2376.  
  2377. bag.LootDropped();
  2378. theTelemetry.LogWithLabelAndValue(TE_INV_ITEM_DROPPED, GetItemName(item), quantity);
  2379.  
  2380.  
  2381. if( thePlayer.IsSwimming() )
  2382. {
  2383. bag.PlayPropertyAnimation( 'float', 0 );
  2384. }
  2385. }
  2386.  
  2387.  
  2388.  
  2389.  
  2390.  
  2391.  
  2392. public final function AddRepairObjectItemBonuses(buffArmor : bool, buffSwords : bool, ammoArmor : int, ammoWeapon : int) : bool
  2393. {
  2394. var upgradedSomething, isArmor : bool;
  2395. var i, ammo, currAmmo : int;
  2396. var items, items2 : array<SItemUniqueId>;
  2397.  
  2398.  
  2399. if(buffArmor)
  2400. {
  2401. items = GetItemsByTag(theGame.params.TAG_ARMOR);
  2402. }
  2403. if(buffSwords)
  2404. {
  2405. items2 = GetItemsByTag(theGame.params.TAG_PLAYER_STEELSWORD);
  2406. ArrayOfIdsAppend(items, items2);
  2407. items2.Clear();
  2408. items2 = GetItemsByTag(theGame.params.TAG_PLAYER_SILVERSWORD);
  2409. ArrayOfIdsAppend(items, items2);
  2410. }
  2411.  
  2412. upgradedSomething = false;
  2413.  
  2414. for(i=0; i<items.Size(); i+=1)
  2415. {
  2416.  
  2417. if(IsItemAnyArmor(items[i]))
  2418. {
  2419. isArmor = true;
  2420. ammo = ammoArmor;
  2421. }
  2422. else
  2423. {
  2424. isArmor = false;
  2425. ammo = ammoWeapon;
  2426. }
  2427.  
  2428.  
  2429. currAmmo = GetItemModifierInt(items[i], 'repairObjectBonusAmmo', 0);
  2430.  
  2431.  
  2432. if(ammo > currAmmo)
  2433. {
  2434. SetItemModifierInt(items[i], 'repairObjectBonusAmmo', ammo);
  2435. upgradedSomething = true;
  2436.  
  2437.  
  2438. if(currAmmo == 0)
  2439. {
  2440. if(isArmor)
  2441. AddItemCraftedAbility(items[i], theGame.params.REPAIR_OBJECT_BONUS_ARMOR_ABILITY, false);
  2442. else
  2443. AddItemCraftedAbility(items[i], theGame.params.REPAIR_OBJECT_BONUS_WEAPON_ABILITY, false);
  2444. }
  2445. }
  2446. }
  2447.  
  2448. return upgradedSomething;
  2449. }
  2450.  
  2451. public final function ReduceItemRepairObjectBonusCharge(item : SItemUniqueId)
  2452. {
  2453. var currAmmo : int;
  2454.  
  2455. currAmmo = GetItemModifierInt(item, 'repairObjectBonusAmmo', 0);
  2456.  
  2457. if(currAmmo > 0)
  2458. {
  2459. SetItemModifierInt(item, 'repairObjectBonusAmmo', currAmmo - 1);
  2460.  
  2461. if(currAmmo == 1)
  2462. {
  2463. if(IsItemAnyArmor(item))
  2464. RemoveItemCraftedAbility(item, theGame.params.REPAIR_OBJECT_BONUS_ARMOR_ABILITY);
  2465. else
  2466. RemoveItemCraftedAbility(item, theGame.params.REPAIR_OBJECT_BONUS_WEAPON_ABILITY);
  2467. }
  2468. }
  2469. }
  2470.  
  2471.  
  2472. public final function GetRepairObjectBonusValueForArmor(armor : SItemUniqueId) : SAbilityAttributeValue
  2473. {
  2474. var retVal, bonusValue, baseArmor : SAbilityAttributeValue;
  2475.  
  2476. if(GetItemModifierInt(armor, 'repairObjectBonusAmmo', 0) > 0)
  2477. {
  2478. bonusValue = GetItemAttributeValue(armor, theGame.params.REPAIR_OBJECT_BONUS);
  2479. baseArmor = GetItemAttributeValue(armor, theGame.params.ARMOR_VALUE_NAME);
  2480.  
  2481. baseArmor.valueMultiplicative += 1;
  2482. retVal.valueAdditive = bonusValue.valueAdditive + CalculateAttributeValue(baseArmor) * bonusValue.valueMultiplicative;
  2483. }
  2484.  
  2485. return retVal;
  2486. }
  2487.  
  2488.  
  2489.  
  2490.  
  2491.  
  2492.  
  2493. public function CanItemHaveOil(id : SItemUniqueId) : bool
  2494. {
  2495. return IsItemSteelSwordUsableByPlayer(id) || IsItemSilverSwordUsableByPlayer(id);
  2496. }
  2497.  
  2498. public final function RemoveAllOilsFromItem( id : SItemUniqueId )
  2499. {
  2500. var i : int;
  2501. var oils : array< W3Effect_Oil >;
  2502. var actor : CActor;
  2503.  
  2504. actor = ( CActor ) GetEntity();
  2505. oils = GetOilsAppliedOnItem( id );
  2506. for( i = oils.Size() - 1; i >= 0; i -= 1 )
  2507. {
  2508. actor.RemoveEffect( oils[ i ] );
  2509. }
  2510. }
  2511.  
  2512. public final function GetActiveOilsAppliedOnItemCount( id : SItemUniqueId ) : int
  2513. {
  2514. var oils : array< W3Effect_Oil >;
  2515. var i, count : int;
  2516.  
  2517. count = 0;
  2518. oils = GetOilsAppliedOnItem( id );
  2519. for( i=0; i<oils.Size(); i+=1 )
  2520. {
  2521. if( oils[ i ].GetAmmoCurrentCount() > 0 )
  2522. {
  2523. count += 1;
  2524. }
  2525. }
  2526. return count;
  2527. }
  2528.  
  2529. public final function RemoveOldestOilFromItem( id : SItemUniqueId )
  2530. {
  2531. var buffToRemove : W3Effect_Oil;
  2532. var actor : CActor;
  2533.  
  2534. actor = ( CActor ) GetEntity();
  2535. if(! actor )
  2536. return;
  2537.  
  2538. buffToRemove = GetOldestOilAppliedOnItem(id, false);
  2539.  
  2540. if(buffToRemove)
  2541. {
  2542. actor.RemoveEffect( buffToRemove );
  2543. }
  2544. }
  2545.  
  2546. public final function GetOilsAppliedOnItem( id : SItemUniqueId ) : array< W3Effect_Oil >
  2547. {
  2548. var i : int;
  2549. var oils : array< CBaseGameplayEffect >;
  2550. var buff : W3Effect_Oil;
  2551. var ret : array < W3Effect_Oil >;
  2552. var actor : CActor;
  2553.  
  2554. actor = ( CActor ) GetEntity();
  2555. if(! actor )
  2556. return ret;
  2557.  
  2558. oils = actor.GetBuffs( EET_Oil );
  2559. for( i = oils.Size() - 1; i >= 0; i -= 1 )
  2560. {
  2561. buff = ( W3Effect_Oil ) oils[ i ];
  2562. if(buff && buff.GetSwordItemId() == id )
  2563. {
  2564. ret.PushBack( buff );
  2565. }
  2566. }
  2567.  
  2568. return ret;
  2569. }
  2570.  
  2571. public final function GetNewestOilAppliedOnItem( id : SItemUniqueId, onlyShowable : bool ) : W3Effect_Oil
  2572. {
  2573. return GetOilAppliedOnItemInternal( id, onlyShowable, true );
  2574. }
  2575.  
  2576. public final function GetOldestOilAppliedOnItem( id : SItemUniqueId, onlyShowable : bool ) : W3Effect_Oil
  2577. {
  2578. return GetOilAppliedOnItemInternal( id, onlyShowable, false );
  2579. }
  2580.  
  2581. private final function GetOilAppliedOnItemInternal( id : SItemUniqueId, onlyShowable : bool, newest : bool ) : W3Effect_Oil
  2582. {
  2583. var oils : array< W3Effect_Oil >;
  2584. var i, lastIndex : int;
  2585.  
  2586. oils = GetOilsAppliedOnItem( id );
  2587. lastIndex = -1;
  2588.  
  2589. for( i=0; i<oils.Size(); i+=1 )
  2590. {
  2591. if( onlyShowable && !oils[i].GetShowOnHUD() )
  2592. {
  2593. continue;
  2594. }
  2595.  
  2596. if( lastIndex == -1 )
  2597. {
  2598. lastIndex = i;
  2599. }
  2600. else if( newest && oils[i].GetQueueTimer() < oils[lastIndex].GetQueueTimer() )
  2601. {
  2602. lastIndex = i;
  2603. }
  2604. else if( !newest && oils[i].GetQueueTimer() > oils[lastIndex].GetQueueTimer() )
  2605. {
  2606. lastIndex = i;
  2607. }
  2608. }
  2609.  
  2610. if( lastIndex == -1 )
  2611. {
  2612. return NULL;
  2613. }
  2614.  
  2615. return oils[lastIndex];
  2616. }
  2617.  
  2618. public final function ItemHasAnyActiveOilApplied( id : SItemUniqueId ) : bool
  2619. {
  2620. return GetActiveOilsAppliedOnItemCount( id );
  2621. }
  2622.  
  2623. public final function ItemHasActiveOilApplied( id : SItemUniqueId, monsterCategory : EMonsterCategory ) : bool
  2624. {
  2625. var i : int;
  2626. var oils : array< W3Effect_Oil >;
  2627.  
  2628. oils = GetOilsAppliedOnItem( id );
  2629. for( i=0; i<oils.Size(); i+=1 )
  2630. {
  2631. if( oils[ i ].GetMonsterCategory() == monsterCategory && oils[ i ].GetAmmoCurrentCount() > 0 )
  2632. {
  2633. return true;
  2634. }
  2635. }
  2636.  
  2637. return false;
  2638. }
  2639.  
  2640.  
  2641.  
  2642.  
  2643.  
  2644. public final function GetParamsForRunewordTooltip(runewordName : name, out i : array<int>, out f : array<float>, out s : array<string>)
  2645. {
  2646. var min, max : SAbilityAttributeValue;
  2647. var val : float;
  2648. var attackRangeBase, attackRangeExt : CAIAttackRange;
  2649.  
  2650. i.Clear();
  2651. f.Clear();
  2652. s.Clear();
  2653.  
  2654. switch(runewordName)
  2655. {
  2656. case 'Glyphword 5':
  2657. theGame.GetDefinitionsManager().GetAbilityAttributeValue('Glyphword 5 _Stats', 'glyphword5_chance', min, max);
  2658. i.PushBack( RoundMath( CalculateAttributeValue(min) * 100) );
  2659. break;
  2660. case 'Glyphword 6' :
  2661. theGame.GetDefinitionsManager().GetAbilityAttributeValue('Glyphword 6 _Stats', 'glyphword6_stamina_drain_perc', min, max);
  2662. i.PushBack( RoundMath( CalculateAttributeValue(min) * 100) );
  2663. break;
  2664. case 'Glyphword 12' :
  2665. theGame.GetDefinitionsManager().GetAbilityAttributeValue('Glyphword 12 _Stats', 'glyphword12_range', min, max);
  2666. val = CalculateAttributeValue(min);
  2667. s.PushBack( NoTrailZeros(val) );
  2668.  
  2669. theGame.GetDefinitionsManager().GetAbilityAttributeValue('Glyphword 12 _Stats', 'glyphword12_chance', min, max);
  2670. i.PushBack( RoundMath( min.valueAdditive * 100) );
  2671. break;
  2672. case 'Glyphword 17' :
  2673. theGame.GetDefinitionsManager().GetAbilityAttributeValue('Glyphword 17 _Stats', 'quen_apply_chance', min, max);
  2674. val = CalculateAttributeValue(min);
  2675. i.PushBack( RoundMath(val * 100) );
  2676. break;
  2677. case 'Glyphword 14' :
  2678. case 'Glyphword 18' :
  2679. theGame.GetDefinitionsManager().GetAbilityAttributeValue('Glyphword 18 _Stats', 'increas_duration', min, max);
  2680. val = CalculateAttributeValue(min);
  2681. s.PushBack( NoTrailZeros(val) );
  2682. break;
  2683.  
  2684. case 'Runeword 2' :
  2685. attackRangeBase = theGame.GetAttackRangeForEntity(GetWitcherPlayer(), 'specialattacklight');
  2686. attackRangeExt = theGame.GetAttackRangeForEntity(GetWitcherPlayer(), 'runeword2_light');
  2687. s.PushBack( NoTrailZeros(attackRangeExt.rangeMax - attackRangeBase.rangeMax) );
  2688.  
  2689. attackRangeBase = theGame.GetAttackRangeForEntity(GetWitcherPlayer(), 'slash_long');
  2690. attackRangeExt = theGame.GetAttackRangeForEntity(GetWitcherPlayer(), 'runeword2_heavy');
  2691. s.PushBack( NoTrailZeros(attackRangeExt.rangeMax - attackRangeBase.rangeMax) );
  2692.  
  2693. break;
  2694. case 'Runeword 4' :
  2695. theGame.GetDefinitionsManager().GetAbilityAttributeValue('Runeword 4 _Stats', 'max_bonus', min, max);
  2696. i.PushBack( RoundMath(max.valueMultiplicative * 100) );
  2697. break;
  2698. case 'Runeword 6' :
  2699. theGame.GetDefinitionsManager().GetAbilityAttributeValue( 'Runeword 6 _Stats', 'runeword6_duration_bonus', min, max );
  2700. i.PushBack( RoundMath(min.valueMultiplicative * 100) );
  2701. break;
  2702. case 'Runeword 7' :
  2703. theGame.GetDefinitionsManager().GetAbilityAttributeValue( 'Runeword 7 _Stats', 'stamina', min, max );
  2704. i.PushBack( RoundMath(min.valueMultiplicative * 100) );
  2705. break;
  2706. case 'Runeword 10' :
  2707. theGame.GetDefinitionsManager().GetAbilityAttributeValue( 'Runeword 10 _Stats', 'stamina_runeword_gain', min, max );
  2708. i.PushBack( RoundMath(min.valueMultiplicative * 100) );
  2709. break;
  2710. case 'Runeword 11' :
  2711. theGame.GetDefinitionsManager().GetAbilityAttributeValue( 'Runeword 11 _Stats', 'duration', min, max );
  2712. s.PushBack( NoTrailZeros(min.valueAdditive) );
  2713. break;
  2714. case 'Runeword 12' :
  2715. theGame.GetDefinitionsManager().GetAbilityAttributeValue( 'Runeword 12 _Stats', 'focus_runeword_gain', min, max );
  2716. f.PushBack(min.valueAdditive);
  2717. f.PushBack(max.valueAdditive);
  2718. break;
  2719. default:
  2720. break;
  2721. }
  2722. }
  2723.  
  2724. public final function GetPotionAttributesForTooltip(potionId : SItemUniqueId, out tips : array<SAttributeTooltip>):void
  2725. {
  2726. var i, j, settingsSize : int;
  2727. var buffType : EEffectType;
  2728. var abilityName : name;
  2729. var abs, attrs : array<name>;
  2730. var val : SAbilityAttributeValue;
  2731. var newAttr : SAttributeTooltip;
  2732. var attributeString : string;
  2733.  
  2734.  
  2735. if(!( IsItemPotion(potionId) || IsItemFood(potionId) ) )
  2736. return;
  2737.  
  2738.  
  2739. GetItemContainedAbilities(potionId, abs);
  2740. for(i=0; i<abs.Size(); i+=1)
  2741. {
  2742. EffectNameToType(abs[i], buffType, abilityName);
  2743.  
  2744.  
  2745. if(buffType == EET_Undefined)
  2746. continue;
  2747.  
  2748.  
  2749. theGame.GetDefinitionsManager().GetAbilityAttributes(abs[i], attrs);
  2750. break;
  2751. }
  2752.  
  2753.  
  2754. attrs.Remove('duration');
  2755. attrs.Remove('level');
  2756.  
  2757. if(buffType == EET_Cat)
  2758. {
  2759.  
  2760. attrs.Remove('highlightObjectsRange');
  2761. }
  2762. else if(buffType == EET_GoldenOriole)
  2763. {
  2764.  
  2765. attrs.Remove('poison_resistance_perc');
  2766. }
  2767. else if(buffType == EET_MariborForest)
  2768. {
  2769.  
  2770. attrs.Remove('focus_on_drink');
  2771. }
  2772. else if(buffType == EET_KillerWhale)
  2773. {
  2774.  
  2775. attrs.Remove('swimmingStamina');
  2776. attrs.Remove('vision_strength');
  2777. }
  2778. else if(buffType == EET_Thunderbolt)
  2779. {
  2780.  
  2781. attrs.Remove('critical_hit_chance');
  2782. }
  2783. else if(buffType == EET_WhiteRaffardDecoction)
  2784. {
  2785. val = GetItemAttributeValue(potionId, 'level');
  2786. if(val.valueAdditive == 3)
  2787. attrs.Insert(0, 'duration');
  2788. }
  2789. else if(buffType == EET_Mutagen20)
  2790. {
  2791. attrs.Remove('burning_DoT_damage_resistance_perc');
  2792. attrs.Remove('poison_DoT_damage_resistance_perc');
  2793. attrs.Remove('bleeding_DoT_damage_resistance_perc');
  2794. }
  2795. else if(buffType == EET_Mutagen27)
  2796. {
  2797. attrs.Remove('mutagen27_max_stack');
  2798. }
  2799. else if(buffType == EET_Mutagen18)
  2800. {
  2801. attrs.Remove('mutagen18_max_stack');
  2802. }
  2803. else if(buffType == EET_Mutagen19)
  2804. {
  2805. attrs.Remove('max_hp_perc_trigger');
  2806. }
  2807. else if(buffType == EET_Mutagen21)
  2808. {
  2809. attrs.Remove('healingRatio');
  2810. }
  2811. else if(buffType == EET_Mutagen22)
  2812. {
  2813. attrs.Remove('mutagen22_max_stack');
  2814. }
  2815. else if(buffType == EET_Mutagen02)
  2816. {
  2817. attrs.Remove('resistGainRate');
  2818. }
  2819. else if(buffType == EET_Mutagen04)
  2820. {
  2821. attrs.Remove('staminaCostPerc');
  2822. attrs.Remove('healthReductionPerc');
  2823. }
  2824. else if(buffType == EET_Mutagen08)
  2825. {
  2826. attrs.Remove('resistGainRate');
  2827. }
  2828. else if(buffType == EET_Mutagen10)
  2829. {
  2830. attrs.Remove('mutagen10_max_stack');
  2831. }
  2832. else if(buffType == EET_Mutagen14)
  2833. {
  2834. attrs.Remove('mutagen14_max_stack');
  2835. }
  2836.  
  2837.  
  2838. for(j=0; j<attrs.Size(); j+=1)
  2839. {
  2840. val = GetItemAbilityAttributeValue(potionId, attrs[j], abs[i]);
  2841.  
  2842. newAttr.originName = attrs[j];
  2843. newAttr.attributeName = GetAttributeNameLocStr(attrs[j], false);
  2844.  
  2845. if(buffType == EET_MariborForest && attrs[j] == 'focus_gain')
  2846. {
  2847. newAttr.value = val.valueAdditive;
  2848. newAttr.percentageValue = false;
  2849. }
  2850. // FCR3 --
  2851. else if(buffType == EET_Cat && attrs[j] == 'critical_hit_chance')
  2852. {
  2853. newAttr.value = val.valueAdditive;
  2854. newAttr.percentageValue = true;
  2855. }
  2856. // -- FCR3
  2857. else if(val.valueMultiplicative != 0)
  2858. {
  2859. if(buffType == EET_Mutagen26)
  2860. {
  2861.  
  2862. newAttr.value = val.valueAdditive;
  2863. newAttr.percentageValue = false;
  2864. tips.PushBack(newAttr);
  2865.  
  2866. newAttr.value = val.valueMultiplicative;
  2867. newAttr.percentageValue = true;
  2868.  
  2869. attrs.Erase(1);
  2870. }
  2871. else if(buffType == EET_Mutagen07)
  2872. {
  2873.  
  2874. attrs.Erase(1);
  2875. newAttr.value = val.valueBase;
  2876. newAttr.percentageValue = true;
  2877. }
  2878. else
  2879. {
  2880. newAttr.value = val.valueMultiplicative;
  2881. newAttr.percentageValue = true;
  2882. }
  2883. }
  2884. else if(val.valueAdditive != 0)
  2885. {
  2886. if(buffType == EET_Thunderbolt)
  2887. {
  2888. newAttr.value = val.valueAdditive * 100;
  2889. newAttr.percentageValue = true;
  2890. }
  2891. else if(buffType == EET_Blizzard)
  2892. {
  2893. newAttr.value = 1 - val.valueAdditive;
  2894. newAttr.percentageValue = true;
  2895. }
  2896. else if(buffType == EET_Mutagen01 || buffType == EET_Mutagen15 || buffType == EET_Mutagen28 || buffType == EET_Mutagen27)
  2897. {
  2898. newAttr.value = val.valueAdditive;
  2899. newAttr.percentageValue = true;
  2900. }
  2901. else
  2902. {
  2903. newAttr.value = val.valueAdditive;
  2904. newAttr.percentageValue = false;
  2905. }
  2906. }
  2907. else if(buffType == EET_GoldenOriole)
  2908. {
  2909. newAttr.value = val.valueBase;
  2910. newAttr.percentageValue = true;
  2911. }
  2912. else
  2913. {
  2914. newAttr.value = val.valueBase;
  2915. newAttr.percentageValue = false;
  2916. }
  2917.  
  2918. tips.PushBack(newAttr);
  2919. }
  2920. }
  2921.  
  2922.  
  2923. public function GetItemRelativeTooltipType(id :SItemUniqueId, invOther : CInventoryComponent, idOther : SItemUniqueId) : ECompareType
  2924. {
  2925.  
  2926. if( (GetItemCategory(id) == invOther.GetItemCategory(idOther)) ||
  2927. ItemHasTag(id, 'PlayerSteelWeapon') && invOther.ItemHasTag(idOther, 'PlayerSteelWeapon') ||
  2928. ItemHasTag(id, 'PlayerSilverWeapon') && invOther.ItemHasTag(idOther, 'PlayerSilverWeapon') ||
  2929. ItemHasTag(id, 'PlayerSecondaryWeapon') && invOther.ItemHasTag(idOther, 'PlayerSecondaryWeapon')
  2930. )
  2931. {
  2932. return ECT_Compare;
  2933. }
  2934. return ECT_Incomparable;
  2935. }
  2936.  
  2937.  
  2938. private function FormatFloatForTooltip(fValue : float) : string
  2939. {
  2940. var valueInt, valueDec : int;
  2941. var strValue : string;
  2942.  
  2943. if(fValue < 0)
  2944. {
  2945. valueInt = CeilF(fValue);
  2946. valueDec = RoundMath((fValue - valueInt)*(-100));
  2947. }
  2948. else
  2949. {
  2950. valueInt = FloorF(fValue);
  2951. valueDec = RoundMath((fValue - valueInt)*(100));
  2952. }
  2953. strValue = valueInt+".";
  2954. if(valueDec < 10)
  2955. strValue += "0"+valueDec;
  2956. else
  2957. strValue += ""+valueDec;
  2958.  
  2959. return strValue;
  2960. }
  2961.  
  2962. public function SetPriceMultiplier( mult : float )
  2963. {
  2964. priceMult = mult;
  2965. }
  2966.  
  2967.  
  2968. public function GetMerchantPriceModifier( shopNPC : CNewNPC, item : SItemUniqueId ) : float
  2969. {
  2970. var areaPriceMult : float;
  2971. var itemPriceMult : float;
  2972. var importPriceMult : float;
  2973. var finalPriceMult : float;
  2974. var tag : name;
  2975. var zoneName : EZoneName;
  2976.  
  2977. zoneName = theGame.GetCurrentZone();
  2978.  
  2979. switch ( zoneName )
  2980. {
  2981. case ZN_NML_CrowPerch : areaPriceMult = CalculateAttributeValue(thePlayer.GetAttributeValue('crow_perch_price_mult'));
  2982. case ZN_NML_SpitfireBluff : areaPriceMult = CalculateAttributeValue(thePlayer.GetAttributeValue('spitfire_bluff_price_mult'));
  2983. case ZN_NML_TheMire : areaPriceMult = CalculateAttributeValue(thePlayer.GetAttributeValue('the_mire_price_mult'));
  2984. case ZN_NML_Mudplough : areaPriceMult = CalculateAttributeValue(thePlayer.GetAttributeValue('mudplough_price_mult'));
  2985. case ZN_NML_Grayrocks : areaPriceMult = CalculateAttributeValue(thePlayer.GetAttributeValue('grayrocks_price_mult'));
  2986. case ZN_NML_TheDescent : areaPriceMult = CalculateAttributeValue(thePlayer.GetAttributeValue('the_descent_price_mult'));
  2987. case ZN_NML_CrookbackBog : areaPriceMult = CalculateAttributeValue(thePlayer.GetAttributeValue('crookback_bog_price_mult'));
  2988. case ZN_NML_BaldMountain : areaPriceMult = CalculateAttributeValue(thePlayer.GetAttributeValue('bald_mountain_price_mult'));
  2989. case ZN_NML_Novigrad : areaPriceMult = CalculateAttributeValue(thePlayer.GetAttributeValue('novigrad_price_mult'));
  2990. case ZN_NML_Homestead : areaPriceMult = CalculateAttributeValue(thePlayer.GetAttributeValue('homestead_price_mult'));
  2991. case ZN_NML_Gustfields : areaPriceMult = CalculateAttributeValue(thePlayer.GetAttributeValue('gustfields_price_mult'));
  2992. case ZN_NML_Oxenfurt : areaPriceMult = CalculateAttributeValue(thePlayer.GetAttributeValue('oxenfurt_price_mult'));
  2993. case ZN_Undefined : areaPriceMult = 1;
  2994. }
  2995.  
  2996. if (ItemHasTag(item,'weapon')) { itemPriceMult = CalculateAttributeValue(shopNPC.GetAttributeValue('weapon_price_mult')); }
  2997. else if (ItemHasTag(item,'armor')) { itemPriceMult = CalculateAttributeValue(shopNPC.GetAttributeValue('armor_price_mult')); }
  2998. else if (ItemHasTag(item,'crafting')) { itemPriceMult = CalculateAttributeValue(shopNPC.GetAttributeValue('crafting_price_mult')); }
  2999. else if (ItemHasTag(item,'alchemy')) { itemPriceMult = CalculateAttributeValue(shopNPC.GetAttributeValue('alchemy_price_mult')); }
  3000. else if (ItemHasTag(item,'alcohol')) { itemPriceMult = CalculateAttributeValue(shopNPC.GetAttributeValue('alcohol_price_mult')); }
  3001. else if (ItemHasTag(item,'food')) { itemPriceMult = CalculateAttributeValue(shopNPC.GetAttributeValue('food_price_mult')); }
  3002. else if (ItemHasTag(item,'fish')) { itemPriceMult = CalculateAttributeValue(shopNPC.GetAttributeValue('fish_price_mult')); }
  3003. else if (ItemHasTag(item,'books')) { itemPriceMult = CalculateAttributeValue(shopNPC.GetAttributeValue('books_price_mult')); }
  3004. else if (ItemHasTag(item,'valuables')) { itemPriceMult = CalculateAttributeValue(shopNPC.GetAttributeValue('valuables_price_mult')); }
  3005. else if (ItemHasTag(item,'junk')) { itemPriceMult = CalculateAttributeValue(shopNPC.GetAttributeValue('junk_price_mult')); }
  3006. else if (ItemHasTag(item,'orens')) { itemPriceMult = CalculateAttributeValue(shopNPC.GetAttributeValue('orens_price_mult')); }
  3007. else if (ItemHasTag(item,'florens')) { itemPriceMult = CalculateAttributeValue(shopNPC.GetAttributeValue('florens_price_mult')); }
  3008. else { itemPriceMult = 1; }
  3009.  
  3010. if (ItemHasTag(item,'novigrad')) { importPriceMult = CalculateAttributeValue(shopNPC.GetAttributeValue('novigrad_price_mult')); }
  3011. else if (ItemHasTag(item,'nilfgard')) { importPriceMult = CalculateAttributeValue(shopNPC.GetAttributeValue('nilfgard_price_mult')); }
  3012. else if (ItemHasTag(item,'nomansland')) { importPriceMult = CalculateAttributeValue(shopNPC.GetAttributeValue('nomansland_price_mult')); }
  3013. else if (ItemHasTag(item,'skellige')) { importPriceMult = CalculateAttributeValue(shopNPC.GetAttributeValue('skellige_price_mult')); }
  3014. else if (ItemHasTag(item,'nonhuman')) { importPriceMult = CalculateAttributeValue(shopNPC.GetAttributeValue('nonhuman_price_mult')); }
  3015. else { importPriceMult = 1; }
  3016.  
  3017. finalPriceMult = areaPriceMult*itemPriceMult*importPriceMult*priceMult;
  3018. return finalPriceMult;
  3019. }
  3020.  
  3021. public function SetRepairPriceMultiplier( mult : float )
  3022. {
  3023. priceRepairMult = mult;
  3024. }
  3025.  
  3026.  
  3027. public function GetRepairPriceModifier( repairNPC : CNewNPC ) : float
  3028. {
  3029. return priceRepairMult;
  3030. }
  3031.  
  3032. public function GetRepairPrice( item : SItemUniqueId ) : float
  3033. {
  3034. var currDiff : float;
  3035. currDiff = GetItemMaxDurability(item) - GetItemDurability(item);
  3036.  
  3037. return priceRepair * currDiff;
  3038. }
  3039.  
  3040.  
  3041. public function GetTooltipData(itemId : SItemUniqueId, out localizedName : string, out localizedDescription : string, out price : int, out localizedCategory : string,
  3042. out itemStats : array<SAttributeTooltip>, out localizedFluff : string)
  3043. {
  3044. if( !IsIdValid(itemId) )
  3045. {
  3046. return;
  3047. }
  3048. localizedName = GetItemLocalizedNameByUniqueID(itemId);
  3049. localizedDescription = GetItemLocalizedDescriptionByUniqueID(itemId);
  3050. localizedFluff = "IMPLEMENT ME - fluff text";
  3051. price = GetItemPriceModified( itemId, false );
  3052. localizedCategory = GetItemCategoryLocalisedString(GetItemCategory(itemId));
  3053. GetItemStats(itemId, itemStats);
  3054. }
  3055.  
  3056.  
  3057. public function GetItemBaseStats(itemId : SItemUniqueId, out itemStats : array<SAttributeTooltip>)
  3058. {
  3059. var attributes : array<name>;
  3060.  
  3061. var dm : CDefinitionsManagerAccessor;
  3062. var oilAbilities, oilAttributes : array<name>;
  3063. var weights : array<float>;
  3064. var i, j : int;
  3065. var tmpI, tmpJ : int;
  3066.  
  3067. var idx : int;
  3068. var oilStatsCount : int;
  3069. var oilName : name;
  3070. var oilStats : array<SAttributeTooltip>;
  3071. var oilStatFirst : SAttributeTooltip;
  3072. var oils : array< W3Effect_Oil >;
  3073.  
  3074. GetItemBaseAttributes(itemId, attributes);
  3075.  
  3076.  
  3077. oils = GetOilsAppliedOnItem( itemId );
  3078. dm = theGame.GetDefinitionsManager();
  3079. for( i=0; i<oils.Size(); i+=1 )
  3080. {
  3081. oilName = oils[ i ].GetOilItemName();
  3082.  
  3083. oilAbilities.Clear();
  3084. weights.Clear();
  3085. dm.GetItemAbilitiesWithWeights(oilName, GetEntity() == thePlayer, oilAbilities, weights, tmpI, tmpJ);
  3086.  
  3087. oilAttributes.Clear();
  3088. oilAttributes = dm.GetAbilitiesAttributes(oilAbilities);
  3089.  
  3090. oilStatsCount = oilAttributes.Size();
  3091. for (idx = 0; idx < oilStatsCount; idx+=1)
  3092. {
  3093. attributes.Remove(oilAttributes[idx]);
  3094. }
  3095. }
  3096.  
  3097. GetItemTooltipAttributes(itemId, attributes, itemStats);
  3098. }
  3099.  
  3100.  
  3101. public function GetItemStats(itemId : SItemUniqueId, out itemStats : array<SAttributeTooltip>)
  3102. {
  3103. var attributes : array<name>;
  3104.  
  3105. GetItemAttributes(itemId, attributes);
  3106. GetItemTooltipAttributes(itemId, attributes, itemStats);
  3107. }
  3108.  
  3109. private function GetItemTooltipAttributes(itemId : SItemUniqueId, attributes : array<name>, out itemStats : array<SAttributeTooltip>):void
  3110. {
  3111. var itemCategory:name;
  3112. var i, j, settingsSize : int;
  3113. var attributeString : string;
  3114. var attributeColor : string;
  3115. var attributeName : name;
  3116. var isPercentageValue : string;
  3117. var primaryStatLabel : string;
  3118. var statLabel : string;
  3119.  
  3120. var stat : SAttributeTooltip;
  3121. var attributeVal : SAbilityAttributeValue;
  3122.  
  3123. settingsSize = theGame.tooltipSettings.GetNumRows();
  3124. itemStats.Clear();
  3125. itemCategory = GetItemCategory(itemId);
  3126. for(i=0; i<settingsSize; i+=1)
  3127. {
  3128.  
  3129. attributeString = theGame.tooltipSettings.GetValueAt(0,i);
  3130. if(StrLen(attributeString) <= 0)
  3131. continue;
  3132.  
  3133. attributeName = '';
  3134.  
  3135.  
  3136. for(j=0; j<attributes.Size(); j+=1)
  3137. {
  3138. if(NameToString(attributes[j]) == attributeString)
  3139. {
  3140. attributeName = attributes[j];
  3141. break;
  3142. }
  3143. }
  3144. if(!IsNameValid(attributeName))
  3145. continue;
  3146.  
  3147.  
  3148. if(itemCategory == 'silversword' && attributeName == 'SlashingDamage') continue;
  3149. if(itemCategory == 'steelsword' && attributeName == 'SilverDamage') continue;
  3150.  
  3151.  
  3152. attributeColor = theGame.tooltipSettings.GetValueAt(1,i);
  3153.  
  3154. isPercentageValue = theGame.tooltipSettings.GetValueAt(2,i);
  3155.  
  3156.  
  3157. attributeVal = GetItemAttributeValue(itemId, attributeName);
  3158. stat.attributeColor = attributeColor;
  3159. stat.percentageValue = isPercentageValue;
  3160. stat.primaryStat = IsPrimaryStatById(itemId, attributeName, primaryStatLabel);
  3161. stat.value = 0;
  3162. stat.originName = attributeName;
  3163. if(attributeVal.valueBase != 0)
  3164. {
  3165. statLabel = GetAttributeNameLocStr(attributeName, false);
  3166. stat.value = attributeVal.valueBase;
  3167. }
  3168. if(attributeVal.valueMultiplicative != 0)
  3169. {
  3170.  
  3171.  
  3172. statLabel = GetAttributeNameLocStr(attributeName, false);
  3173. stat.value = attributeVal.valueMultiplicative;
  3174. stat.percentageValue = true;
  3175. }
  3176. if(attributeVal.valueAdditive != 0)
  3177. {
  3178. statLabel = GetAttributeNameLocStr(attributeName, false);
  3179. stat.value = attributeVal.valueAdditive;
  3180. }
  3181. if (stat.value != 0)
  3182. {
  3183. stat.attributeName = statLabel;
  3184.  
  3185. itemStats.PushBack(stat);
  3186. }
  3187. }
  3188. }
  3189.  
  3190.  
  3191. public function GetItemStatsFromName(itemName : name, out itemStats : array<SAttributeTooltip>)
  3192. {
  3193. var itemCategory : name;
  3194. var i, j, settingsSize : int;
  3195. var attributeString : string;
  3196. var attributeColor : string;
  3197. var attributeName : name;
  3198. var isPercentageValue : string;
  3199. var attributes, itemAbilities, tmpArray : array<name>;
  3200. var weights : array<float>;
  3201. var stat : SAttributeTooltip;
  3202. var attributeVal, min, max : SAbilityAttributeValue;
  3203. var dm : CDefinitionsManagerAccessor;
  3204. var primaryStatLabel : string;
  3205. var statLabel : string;
  3206.  
  3207. settingsSize = theGame.tooltipSettings.GetNumRows();
  3208. dm = theGame.GetDefinitionsManager();
  3209. dm.GetItemAbilitiesWithWeights(itemName, GetEntity() == thePlayer, itemAbilities, weights, i, j);
  3210. attributes = dm.GetAbilitiesAttributes(itemAbilities);
  3211.  
  3212. itemStats.Clear();
  3213. itemCategory = dm.GetItemCategory(itemName);
  3214. for(i=0; i<settingsSize; i+=1)
  3215. {
  3216.  
  3217. attributeString = theGame.tooltipSettings.GetValueAt(0,i);
  3218. if(StrLen(attributeString) <= 0)
  3219. continue;
  3220.  
  3221. attributeName = '';
  3222.  
  3223.  
  3224. for(j=0; j<attributes.Size(); j+=1)
  3225. {
  3226. if(NameToString(attributes[j]) == attributeString)
  3227. {
  3228. attributeName = attributes[j];
  3229. break;
  3230. }
  3231. }
  3232. if(!IsNameValid(attributeName))
  3233. continue;
  3234.  
  3235.  
  3236. if(itemCategory == 'silversword' && attributeName == 'SlashingDamage') continue;
  3237. if(itemCategory == 'steelsword' && attributeName == 'SilverDamage') continue;
  3238.  
  3239.  
  3240. attributeColor = theGame.tooltipSettings.GetValueAt(1,i);
  3241.  
  3242. isPercentageValue = theGame.tooltipSettings.GetValueAt(2,i);
  3243.  
  3244.  
  3245. dm.GetAbilitiesAttributeValue(itemAbilities, attributeName, min, max);
  3246. attributeVal = GetAttributeRandomizedValue(min, max);
  3247.  
  3248. stat.attributeColor = attributeColor;
  3249. stat.percentageValue = isPercentageValue;
  3250.  
  3251. stat.primaryStat = IsPrimaryStat(itemCategory, attributeName, primaryStatLabel);
  3252.  
  3253. stat.value = 0;
  3254. stat.originName = attributeName;
  3255.  
  3256. if(attributeVal.valueBase != 0)
  3257. {
  3258. stat.value = attributeVal.valueBase;
  3259. }
  3260. if(attributeVal.valueMultiplicative != 0)
  3261. {
  3262. stat.value = attributeVal.valueMultiplicative;
  3263. stat.percentageValue = true;
  3264. }
  3265. if(attributeVal.valueAdditive != 0)
  3266. {
  3267. statLabel = GetAttributeNameLocStr(attributeName, false);
  3268. stat.value = attributeVal.valueBase + attributeVal.valueAdditive;
  3269. }
  3270.  
  3271. if (attributeName == 'toxicity_offset')
  3272. {
  3273. statLabel = GetAttributeNameLocStr('toxicity', false);
  3274. stat.percentageValue = false;
  3275. }
  3276. else
  3277. {
  3278. statLabel = GetAttributeNameLocStr(attributeName, false);
  3279. }
  3280.  
  3281. if (stat.value != 0)
  3282. {
  3283. stat.attributeName = statLabel;
  3284.  
  3285. itemStats.PushBack(stat);
  3286. }
  3287.  
  3288.  
  3289. }
  3290. }
  3291.  
  3292. public function IsThereItemOnSlot(slot : EEquipmentSlots) : bool
  3293. {
  3294. var player : W3PlayerWitcher;
  3295.  
  3296. player = ((W3PlayerWitcher)GetEntity());
  3297. if(player)
  3298. {
  3299. return player.IsAnyItemEquippedOnSlot(slot);
  3300. }
  3301. else
  3302. {
  3303. return false;
  3304. }
  3305. }
  3306.  
  3307. public function GetItemEquippedOnSlot(slot : EEquipmentSlots, out item : SItemUniqueId) : bool
  3308. {
  3309. var player : W3PlayerWitcher;
  3310.  
  3311. player = ((W3PlayerWitcher)GetEntity());
  3312. if(player)
  3313. {
  3314. return player.GetItemEquippedOnSlot(slot, item);
  3315. }
  3316. else
  3317. {
  3318. return false;
  3319. }
  3320. }
  3321.  
  3322. public function IsItemExcluded ( itemID : SItemUniqueId, excludedItems : array < SItemNameProperty > ) : bool
  3323. {
  3324. var i : int;
  3325. var currItemName : name;
  3326.  
  3327. currItemName = GetItemName( itemID );
  3328.  
  3329. for ( i = 0; i < excludedItems.Size(); i+=1 )
  3330. {
  3331. if ( currItemName == excludedItems[i].itemName )
  3332. {
  3333. return true;
  3334. }
  3335. }
  3336. return false;
  3337. }
  3338.  
  3339.  
  3340. public function GetItemPrimaryStat(itemId : SItemUniqueId, out attributeLabel : string, out attributeVal : float ) : void
  3341. {
  3342. var attributeName : name;
  3343. var attributeValue:SAbilityAttributeValue;
  3344.  
  3345. GetItemPrimaryStatImplById(itemId, attributeLabel, attributeVal, attributeName);
  3346.  
  3347. attributeValue = GetItemAttributeValue(itemId, attributeName);
  3348.  
  3349. if(attributeValue.valueBase != 0)
  3350. {
  3351. attributeVal = attributeValue.valueBase;
  3352. }
  3353. if(attributeValue.valueMultiplicative != 0)
  3354. {
  3355. attributeVal = attributeValue.valueMultiplicative;
  3356. }
  3357. if(attributeValue.valueAdditive != 0)
  3358. {
  3359. attributeVal = attributeValue.valueAdditive;
  3360. }
  3361. }
  3362.  
  3363. public function GetItemStatByName(itemName : name, statName : name, out resultValue : float) : void
  3364. {
  3365. var dm : CDefinitionsManagerAccessor;
  3366. var attributes, itemAbilities : array<name>;
  3367. var min, max, attributeValue : SAbilityAttributeValue;
  3368. var tmpInt : int;
  3369. var tmpArray : array<float>;
  3370.  
  3371. dm = theGame.GetDefinitionsManager();
  3372. dm.GetItemAbilitiesWithWeights(itemName, GetEntity() == thePlayer, itemAbilities, tmpArray, tmpInt, tmpInt);
  3373. attributes = dm.GetAbilitiesAttributes(itemAbilities);
  3374.  
  3375. dm.GetAbilitiesAttributeValue(itemAbilities, statName, min, max);
  3376. attributeValue = GetAttributeRandomizedValue(min, max);
  3377.  
  3378. if(attributeValue.valueBase != 0)
  3379. {
  3380. resultValue = attributeValue.valueBase;
  3381. }
  3382. if(attributeValue.valueMultiplicative != 0)
  3383. {
  3384. resultValue = attributeValue.valueMultiplicative;
  3385. }
  3386. if(attributeValue.valueAdditive != 0)
  3387. {
  3388. resultValue = attributeValue.valueAdditive;
  3389. }
  3390. }
  3391.  
  3392. public function GetItemPrimaryStatFromName(itemName : name, out attributeLabel : string, out attributeVal : float, out primAttrName : name) : void
  3393. {
  3394. var dm : CDefinitionsManagerAccessor;
  3395. var attributeName : name;
  3396. var attributes, itemAbilities : array<name>;
  3397. var attributeValue, min, max : SAbilityAttributeValue;
  3398.  
  3399. var tmpInt : int;
  3400. var tmpArray : array<float>;
  3401.  
  3402. dm = theGame.GetDefinitionsManager();
  3403.  
  3404. GetItemPrimaryStatImpl(dm.GetItemCategory(itemName), attributeLabel, attributeVal, attributeName);
  3405. dm.GetItemAbilitiesWithWeights(itemName, GetEntity() == thePlayer, itemAbilities, tmpArray, tmpInt, tmpInt);
  3406. attributes = dm.GetAbilitiesAttributes(itemAbilities);
  3407. for (tmpInt = 0; tmpInt < attributes.Size(); tmpInt += 1)
  3408. if (attributes[tmpInt] == attributeName)
  3409. {
  3410. dm.GetAbilitiesAttributeValue(itemAbilities, attributeName, min, max);
  3411. attributeValue = GetAttributeRandomizedValue(min, max);
  3412. primAttrName = attributeName;
  3413. break;
  3414. }
  3415.  
  3416. if(attributeValue.valueBase != 0)
  3417. {
  3418. attributeVal = attributeValue.valueBase;
  3419. }
  3420. if(attributeValue.valueMultiplicative != 0)
  3421. {
  3422. attributeVal = attributeValue.valueMultiplicative;
  3423. }
  3424. if(attributeValue.valueAdditive != 0)
  3425. {
  3426. attributeVal = attributeValue.valueAdditive;
  3427. }
  3428.  
  3429. }
  3430.  
  3431. public function IsPrimaryStatById(itemId : SItemUniqueId, attributeName : name, out attributeLabel : string) : bool
  3432. {
  3433. var attrValue : float;
  3434. var attrName : name;
  3435.  
  3436. GetItemPrimaryStatImplById(itemId, attributeLabel, attrValue, attrName);
  3437. return attrName == attributeName;
  3438. }
  3439.  
  3440. private function GetItemPrimaryStatImplById(itemId : SItemUniqueId, out attributeLabel : string, out attributeVal : float, out attributeName : name ) : void
  3441. {
  3442. var itemOnSlot : SItemUniqueId;
  3443. var categoryName : name;
  3444. var abList : array<name>;
  3445.  
  3446. attributeName = '';
  3447. attributeLabel = "";
  3448. categoryName = GetItemCategory(itemId);
  3449.  
  3450.  
  3451. if (categoryName == 'bolt' || categoryName == 'petard')
  3452. {
  3453. GetItemAttributes(itemId, abList);
  3454. if (abList.Contains('FireDamage'))
  3455. {
  3456. attributeName = 'FireDamage';
  3457. }
  3458. else if (abList.Contains('PiercingDamage'))
  3459. {
  3460. attributeName = 'PiercingDamage';
  3461. }
  3462. else if (abList.Contains('PiercingDamage'))
  3463. {
  3464. attributeName = 'PiercingDamage';
  3465. }
  3466. else if (abList.Contains('PoisonDamage'))
  3467. {
  3468. attributeName = 'PoisonDamage';
  3469. }
  3470. else if (abList.Contains('BludgeoningDamage'))
  3471. {
  3472. attributeName = 'BludgeoningDamage';
  3473. }
  3474. else
  3475. {
  3476. attributeName = 'PhysicalDamage';
  3477. }
  3478. attributeLabel = GetAttributeNameLocStr(attributeName, false);
  3479. }
  3480. else if (categoryName == 'secondary')
  3481. {
  3482. GetItemAttributes(itemId, abList);
  3483. if (abList.Contains('BludgeoningDamage'))
  3484. {
  3485. attributeName = 'BludgeoningDamage';
  3486. }
  3487. else
  3488. {
  3489. attributeName = 'PhysicalDamage';
  3490. }
  3491. attributeLabel = GetAttributeNameLocStr(attributeName, false);
  3492. }
  3493. else if (categoryName == 'steelsword')
  3494. {
  3495. GetItemAttributes(itemId, abList);
  3496. if (abList.Contains('SlashingDamage'))
  3497. {
  3498. attributeName = 'SlashingDamage';
  3499. attributeLabel = GetLocStringByKeyExt("panel_inventory_tooltip_damage");
  3500. }
  3501. else if (abList.Contains('BludgeoningDamage'))
  3502. {
  3503. attributeName = 'BludgeoningDamage';
  3504. }
  3505. else if (abList.Contains('PiercingDamage'))
  3506. {
  3507. attributeName = 'PiercingDamage';
  3508. }
  3509. else
  3510. {
  3511. attributeName = 'PhysicalDamage';
  3512. }
  3513. if (attributeLabel == "")
  3514. {
  3515. attributeLabel = GetAttributeNameLocStr(attributeName, false);
  3516. }
  3517. }
  3518. else
  3519. {
  3520. GetItemPrimaryStatImpl(categoryName, attributeLabel, attributeVal, attributeName);
  3521. }
  3522. }
  3523.  
  3524. public function IsPrimaryStat(categoryName : name, attributeName : name, out attributeLabel : string) : bool
  3525. {
  3526. var attrValue : float;
  3527. var attrName : name;
  3528.  
  3529. GetItemPrimaryStatImpl(categoryName, attributeLabel, attrValue, attrName);
  3530. return attrName == attributeName;
  3531. }
  3532.  
  3533. private function GetItemPrimaryStatImpl(categoryName : name, out attributeLabel : string, out attributeVal : float, out attributeName : name ) : void
  3534. {
  3535. attributeName = '';
  3536. attributeLabel = "";
  3537. switch (categoryName)
  3538. {
  3539. case 'steelsword':
  3540. attributeName = 'SlashingDamage';
  3541. attributeLabel = GetLocStringByKeyExt("panel_inventory_tooltip_damage");
  3542. break;
  3543. case 'silversword':
  3544. attributeName = 'SilverDamage';
  3545. attributeLabel = GetLocStringByKeyExt("panel_inventory_tooltip_damage");
  3546. break;
  3547. case 'armor':
  3548. case 'gloves':
  3549. case 'gloves':
  3550. case 'boots':
  3551. case 'pants':
  3552. attributeName = 'armor';
  3553. break;
  3554. case 'potion':
  3555. case 'oil':
  3556.  
  3557. break;
  3558. case 'bolt':
  3559. case 'petard':
  3560. attributeName = 'PhysicalDamage';
  3561. break;
  3562. case 'crossbow':
  3563. default:
  3564. attributeLabel = "";
  3565. attributeVal = 0;
  3566. return;
  3567. break;
  3568. }
  3569.  
  3570. if (attributeLabel == "")
  3571. {
  3572. attributeLabel = GetAttributeNameLocStr(attributeName, false);
  3573. }
  3574. }
  3575.  
  3576. public function CanBeCompared(itemId : SItemUniqueId) : bool
  3577. {
  3578. var wplayer : W3PlayerWitcher;
  3579. var itemSlot : EEquipmentSlots;
  3580. var equipedItem : SItemUniqueId;
  3581. var horseManager : W3HorseManager;
  3582.  
  3583. var isArmorOrWeapon : bool;
  3584.  
  3585. if (IsItemHorseItem(itemId))
  3586. {
  3587. horseManager = GetWitcherPlayer().GetHorseManager();
  3588.  
  3589. if (!horseManager)
  3590. {
  3591. return false;
  3592. }
  3593.  
  3594. if (horseManager.IsItemEquipped(itemId))
  3595. {
  3596. return false;
  3597. }
  3598.  
  3599. itemSlot = GetHorseSlotForItem(itemId);
  3600. equipedItem = horseManager.GetItemInSlot(itemSlot);
  3601. if (!horseManager.GetInventoryComponent().IsIdValid(equipedItem))
  3602. {
  3603. return false;
  3604. }
  3605. }
  3606. else
  3607. {
  3608. isArmorOrWeapon = IsItemAnyArmor(itemId) || IsItemWeapon(itemId);
  3609. if (!isArmorOrWeapon)
  3610. {
  3611. return false;
  3612. }
  3613.  
  3614. wplayer = GetWitcherPlayer();
  3615. if (wplayer.IsItemEquipped(itemId))
  3616. {
  3617. return false;
  3618. }
  3619.  
  3620. itemSlot = GetSlotForItemId(itemId);
  3621. wplayer.GetItemEquippedOnSlot(itemSlot, equipedItem);
  3622. if (!wplayer.inv.IsIdValid(equipedItem))
  3623. {
  3624. return false;
  3625. }
  3626. }
  3627.  
  3628. return true;
  3629. }
  3630.  
  3631. public function GetHorseSlotForItem(id : SItemUniqueId) : EEquipmentSlots
  3632. {
  3633. var tags : array<name>;
  3634.  
  3635. GetItemTags(id, tags);
  3636.  
  3637. if(tags.Contains('Saddle')) return EES_HorseSaddle;
  3638. else if(tags.Contains('HorseBag')) return EES_HorseBag;
  3639. else if(tags.Contains('Trophy')) return EES_HorseTrophy;
  3640. else if(tags.Contains('Blinders')) return EES_HorseBlinders;
  3641. else return EES_InvalidSlot;
  3642. }
  3643.  
  3644.  
  3645.  
  3646.  
  3647.  
  3648. public final function SingletonItemRefillAmmo( id : SItemUniqueId, optional alchemyTableUsed : bool )
  3649. {
  3650. var l_bed : W3WitcherBed;
  3651. var refilledByBed : bool;
  3652.  
  3653. refilledByBed = false;
  3654.  
  3655.  
  3656. if( FactsQuerySum( "PlayerInsideOuterWitcherHouse" ) >= 1 && FactsQuerySum( "AlchemyTableExists" ) >= 1 && !IsItemMutagenPotion( id ) )
  3657. {
  3658. l_bed = (W3WitcherBed)theGame.GetEntityByTag( 'witcherBed' );
  3659.  
  3660. if( l_bed.GetWasUsed() || alchemyTableUsed )
  3661. {
  3662. SetItemModifierInt( id, 'ammo_current', SingletonItemGetMaxAmmo(id) + theGame.params.QUANTITY_INCREASED_BY_ALCHEMY_TABLE ) ;
  3663. refilledByBed = true;
  3664. if( !l_bed.GetWereItemsRefilled() )
  3665. {
  3666. l_bed.SetWereItemsRefilled( true );
  3667. }
  3668. }
  3669. }
  3670.  
  3671.  
  3672. if( !refilledByBed && SingletonItemGetAmmo( id ) < SingletonItemGetMaxAmmo( id ) )
  3673. {
  3674. SetItemModifierInt(id, 'ammo_current', SingletonItemGetMaxAmmo(id));
  3675. }
  3676.  
  3677. theGame.GetGlobalEventsManager().OnScriptedEvent( SEC_OnAmmoChanged );
  3678. }
  3679.  
  3680. public function SingletonItemSetAmmo(id : SItemUniqueId, quantity : int)
  3681. {
  3682. var amount : int;
  3683.  
  3684. if(ItemHasTag(id, theGame.params.TAG_INFINITE_AMMO))
  3685. {
  3686. amount = -1;
  3687. }
  3688. else
  3689. {
  3690. amount = Clamp(quantity, 0, SingletonItemGetMaxAmmo(id));
  3691. }
  3692.  
  3693. SetItemModifierInt(id, 'ammo_current', amount);
  3694. theGame.GetGlobalEventsManager().OnScriptedEvent( SEC_OnAmmoChanged );
  3695. }
  3696.  
  3697. public function SingletonItemAddAmmo(id : SItemUniqueId, quantity : int)
  3698. {
  3699. var ammo : int;
  3700.  
  3701. if(quantity <= 0)
  3702. return;
  3703.  
  3704. ammo = GetItemModifierInt(id, 'ammo_current');
  3705.  
  3706. if(ammo == -1)
  3707. return;
  3708.  
  3709. ammo = Clamp(ammo + quantity, 0, SingletonItemGetMaxAmmo(id));
  3710. SetItemModifierInt(id, 'ammo_current', ammo);
  3711. theGame.GetGlobalEventsManager().OnScriptedEvent( SEC_OnAmmoChanged );
  3712. }
  3713.  
  3714. public function SingletonItemsRefillAmmo( optional alchemyTableUsed : bool ) : bool
  3715. {
  3716. var i : int;
  3717. var singletonItems : array<SItemUniqueId>;
  3718. var alco : SItemUniqueId;
  3719. var arrStr : array<string>;
  3720. var witcher : W3PlayerWitcher;
  3721. var itemLabel : string;
  3722.  
  3723. witcher = GetWitcherPlayer();
  3724. if(GetEntity() == witcher && HasNotFilledSingletonItem( alchemyTableUsed ) )
  3725. {
  3726. alco = witcher.GetAlcoholForAlchemicalItemsRefill();
  3727.  
  3728. if(!IsIdValid(alco))
  3729. {
  3730.  
  3731. theGame.GetGuiManager().ShowNotification(GetLocStringByKeyExt("message_common_alchemy_items_cannot_refill"));
  3732. theSound.SoundEvent("gui_global_denied");
  3733.  
  3734. return false;
  3735. }
  3736. else
  3737. {
  3738.  
  3739. arrStr.PushBack(GetItemName(alco));
  3740. itemLabel = GetLocStringByKeyExt(GetItemLocalizedNameByUniqueID(alco));
  3741. theGame.GetGuiManager().ShowNotification( itemLabel + " - " + GetLocStringByKeyExtWithParams("message_common_alchemy_items_refilled", , , arrStr));
  3742. theSound.SoundEvent("gui_alchemy_brew");
  3743.  
  3744. if(!ItemHasTag(alco, theGame.params.TAG_INFINITE_USE))
  3745. RemoveItem(alco);
  3746. }
  3747. }
  3748.  
  3749. singletonItems = GetSingletonItems();
  3750. for(i=0; i<singletonItems.Size(); i+=1)
  3751. {
  3752. SingletonItemRefillAmmo( singletonItems[i], alchemyTableUsed );
  3753. }
  3754.  
  3755. return true;
  3756. }
  3757.  
  3758. public function SingletonItemsRefillAmmoNoAlco(optional dontUpdateUI : bool)
  3759. {
  3760. var i : int;
  3761. var singletonItems : array<SItemUniqueId>;
  3762. var alco : SItemUniqueId;
  3763. var arrStr : array<string>;
  3764. var witcher : W3PlayerWitcher;
  3765. var itemLabel : string;
  3766.  
  3767. witcher = GetWitcherPlayer();
  3768. if(!dontUpdateUI && GetEntity() == witcher && HasNotFilledSingletonItem())
  3769. {
  3770.  
  3771. arrStr.PushBack(GetItemName(alco));
  3772. itemLabel = GetLocStringByKeyExt(GetItemLocalizedNameByUniqueID(alco));
  3773. theGame.GetGuiManager().ShowNotification( itemLabel + " - " + GetLocStringByKeyExtWithParams("message_common_alchemy_items_refilled", , , arrStr));
  3774. theSound.SoundEvent("gui_alchemy_brew");
  3775. }
  3776.  
  3777. singletonItems = GetSingletonItems();
  3778. for(i=0; i<singletonItems.Size(); i+=1)
  3779. {
  3780. SingletonItemRefillAmmo(singletonItems[i]);
  3781. }
  3782. }
  3783.  
  3784.  
  3785. private final function HasNotFilledSingletonItem( optional alchemyTableUsed : bool ) : bool
  3786. {
  3787. var i : int;
  3788. var singletonItems : array<SItemUniqueId>;
  3789. var hasLab : bool;
  3790. var l_bed : W3WitcherBed;
  3791.  
  3792.  
  3793. hasLab = false;
  3794. if( FactsQuerySum( "PlayerInsideOuterWitcherHouse" ) >= 1 && FactsQuerySum( "AlchemyTableExists" ) >= 1 )
  3795. {
  3796. l_bed = (W3WitcherBed)theGame.GetEntityByTag( 'witcherBed' );
  3797. if( l_bed.GetWasUsed() || alchemyTableUsed )
  3798. {
  3799. hasLab = true;
  3800. }
  3801. }
  3802.  
  3803. singletonItems = GetSingletonItems();
  3804. for(i=0; i<singletonItems.Size(); i+=1)
  3805. {
  3806. if( hasLab && !IsItemMutagenPotion( singletonItems[i] ) )
  3807. {
  3808. if(SingletonItemGetAmmo(singletonItems[i]) <= SingletonItemGetMaxAmmo(singletonItems[i]))
  3809. {
  3810. return true;
  3811. }
  3812. }
  3813. else if(SingletonItemGetAmmo(singletonItems[i]) < SingletonItemGetMaxAmmo(singletonItems[i]))
  3814. {
  3815. return true;
  3816. }
  3817. }
  3818.  
  3819. return false;
  3820. }
  3821.  
  3822. public function SingletonItemRemoveAmmo(itemID : SItemUniqueId, optional quantity : int)
  3823. {
  3824. var ammo : int;
  3825.  
  3826. if(!IsItemSingletonItem(itemID) || ItemHasTag(itemID, theGame.params.TAG_INFINITE_AMMO))
  3827. return;
  3828.  
  3829. if(quantity <= 0)
  3830. quantity = 1;
  3831.  
  3832. ammo = GetItemModifierInt(itemID, 'ammo_current');
  3833. ammo = Max(0, ammo - quantity);
  3834. SetItemModifierInt(itemID, 'ammo_current', ammo);
  3835.  
  3836.  
  3837. if(ammo == 0 && ShouldProcessTutorial('TutorialAlchemyRefill') && FactsQuerySum("q001_nightmare_ended") > 0)
  3838. {
  3839. FactsAdd('tut_alch_refill', 1);
  3840. }
  3841. theGame.GetGlobalEventsManager().OnScriptedEvent( SEC_OnAmmoChanged );
  3842. }
  3843.  
  3844. public function SingletonItemGetAmmo(itemID : SItemUniqueId) : int
  3845. {
  3846. if(!IsItemSingletonItem(itemID))
  3847. return 0;
  3848.  
  3849. return GetItemModifierInt(itemID, 'ammo_current');
  3850. }
  3851.  
  3852. public function SingletonItemGetMaxAmmo(itemID : SItemUniqueId) : int
  3853. {
  3854. var ammo, i : int;
  3855. var perk20Bonus, min, max : SAbilityAttributeValue;
  3856. var atts : array<name>;
  3857. var canUseSkill : bool;
  3858.  
  3859. ammo = RoundMath(CalculateAttributeValue(GetItemAttributeValue(itemID, 'ammo')));
  3860.  
  3861. if( !ItemHasTag( itemID, 'NoAdditionalAmmo' ) )
  3862. {
  3863. if(GetEntity() == GetWitcherPlayer() && ammo > 0)
  3864. {
  3865. if(IsItemBomb(itemID) && thePlayer.CanUseSkill(S_Alchemy_s08) )
  3866. {
  3867. ammo += thePlayer.GetSkillLevel(S_Alchemy_s08);
  3868. }
  3869.  
  3870. if(thePlayer.HasBuff(EET_Mutagen03) && (IsItemBomb(itemID) || (!IsItemMutagenPotion(itemID) && IsItemPotion(itemID))) )
  3871. {
  3872. ammo += 1;
  3873. }
  3874.  
  3875. if( GetWitcherPlayer().IsSetBonusActive( EISB_RedWolf_2 ) && !IsItemMutagenPotion(itemID) )
  3876. {
  3877. theGame.GetDefinitionsManager().GetAbilityAttributeValue( GetSetBonusAbility( EISB_RedWolf_2 ), 'amount', min, max);
  3878. ammo += (int)min.valueAdditive;
  3879. }
  3880.  
  3881.  
  3882. if( IsItemBomb( itemID ) && thePlayer.CanUseSkill( S_Perk_20 ) && GetItemName( itemID ) != 'Snow Ball' )
  3883. {
  3884. GetItemAttributes( itemID, atts );
  3885. canUseSkill = thePlayer.CanUseSkill( S_Alchemy_s10 );
  3886. perk20Bonus = GetWitcherPlayer().GetSkillAttributeValue( S_Perk_20, 'stack_multiplier', false, false );
  3887.  
  3888. for( i=0 ; i<atts.Size() ; i+=1 )
  3889. {
  3890. if( canUseSkill || IsDamageTypeNameValid( atts[i] ) )
  3891. {
  3892. ammo = RoundMath( ammo * perk20Bonus.valueMultiplicative );
  3893. break;
  3894. }
  3895. }
  3896. }
  3897. }
  3898. }
  3899.  
  3900. return ammo;
  3901. }
  3902.  
  3903. public function ManageSingletonItemsBonus()
  3904. {
  3905. var l_items : array<SItemUniqueId>;
  3906. var l_i : int;
  3907. var l_haveBombOrPot : bool;
  3908.  
  3909. l_items = GetSingletonItems();
  3910.  
  3911. for( l_i = 0 ; l_i < l_items.Size() ; l_i += 1 )
  3912. {
  3913. if( IsItemPotion( l_items[ l_i ] ) || IsItemBomb( l_items[ l_i ] ) )
  3914. {
  3915. l_haveBombOrPot = true;
  3916. if( SingletonItemGetMaxAmmo( l_items[ l_i ] ) >= SingletonItemGetAmmo( l_items[ l_i ] ) )
  3917. {
  3918. if( SingletonItemsRefillAmmo( true ) )
  3919. {
  3920. theGame.GetGuiManager().ShowNotification( GetLocStringByKeyExt( "message_common_alchemy_table_buff_applied" ),, true );
  3921. }
  3922.  
  3923. return;
  3924. }
  3925. }
  3926. }
  3927.  
  3928. if( !l_haveBombOrPot )
  3929. {
  3930. theGame.GetGuiManager().ShowNotification( GetLocStringByKeyExt( "message_common_alchemy_table_buff_no_items" ),, true );
  3931. return;
  3932. }
  3933.  
  3934. theGame.GetGuiManager().ShowNotification( GetLocStringByKeyExt( "message_common_alchemy_table_buff_already_on" ),, true );
  3935. }
  3936.  
  3937.  
  3938.  
  3939.  
  3940.  
  3941. public final function IsItemSteelSwordUsableByPlayer(item : SItemUniqueId) : bool
  3942. {
  3943. return ItemHasTag(item, theGame.params.TAG_PLAYER_STEELSWORD) && !ItemHasTag(item, 'SecondaryWeapon');
  3944. }
  3945.  
  3946. public final function IsItemSilverSwordUsableByPlayer(item : SItemUniqueId) : bool
  3947. {
  3948. return ItemHasTag(item, theGame.params.TAG_PLAYER_SILVERSWORD) && !ItemHasTag(item, 'SecondaryWeapon');
  3949. }
  3950.  
  3951. public final function IsItemFists(item : SItemUniqueId) : bool {return GetItemCategory(item) == 'fist';}
  3952. public final function IsItemWeapon(item : SItemUniqueId) : bool {return ItemHasTag(item, 'Weapon') || ItemHasTag(item, 'WeaponTab');}
  3953. public final function IsItemCrossbow(item : SItemUniqueId) : bool {return GetItemCategory(item) == 'crossbow';}
  3954. public final function IsItemChestArmor(item : SItemUniqueId) : bool {return GetItemCategory(item) == 'armor';}
  3955. public final function IsItemBody(item : SItemUniqueId) : bool {return ItemHasTag(item, 'Body');}
  3956. public final function IsRecipeOrSchematic( item : SItemUniqueId ) : bool {return GetItemCategory(item) == 'alchemy_recipe' || GetItemCategory(item) == 'crafting_schematic'; }
  3957. public final function IsItemBoots(item : SItemUniqueId) : bool {return GetItemCategory(item) == 'boots';}
  3958. public final function IsItemGloves(item : SItemUniqueId) : bool {return GetItemCategory(item) == 'gloves';}
  3959. public final function IsItemPants(item : SItemUniqueId) : bool {return GetItemCategory(item) == 'trousers' || GetItemCategory(item) == 'pants';}
  3960. public final function IsItemTrophy(item : SItemUniqueId) : bool {return GetItemCategory(item) == 'trophy';}
  3961. public final function IsItemMask(item : SItemUniqueId) : bool {return GetItemCategory(item) == 'mask';}
  3962. public final function IsItemBomb(item : SItemUniqueId) : bool {return GetItemCategory(item) == 'petard';}
  3963. public final function IsItemBolt(item : SItemUniqueId) : bool {return GetItemCategory(item) == 'bolt';}
  3964. public final function IsItemUpgrade(item : SItemUniqueId) : bool {return GetItemCategory(item) == 'upgrade';}
  3965. public final function IsItemTool(item : SItemUniqueId) : bool {return GetItemCategory(item) == 'tool';}
  3966. public final function IsItemPotion(item : SItemUniqueId) : bool {return ItemHasTag(item, 'Potion');}
  3967. public final function IsItemOil(item : SItemUniqueId) : bool {return ItemHasTag(item, 'SilverOil') || ItemHasTag(item, 'SteelOil');}
  3968. public final function IsItemAnyArmor(item : SItemUniqueId) : bool {return ItemHasTag(item, theGame.params.TAG_ARMOR);}
  3969. public final function IsItemUpgradeable(item : SItemUniqueId) : bool {return ItemHasTag(item, theGame.params.TAG_ITEM_UPGRADEABLE);}
  3970. public final function IsItemIngredient(item : SItemUniqueId) : bool {return ItemHasTag(item, 'AlchemyIngredient') || ItemHasTag(item, 'CraftingIngredient');}
  3971. public final function IsItemDismantleKit(item : SItemUniqueId) : bool {return ItemHasTag(item, 'DismantleKit');}
  3972. public final function IsItemHorseBag(item : SItemUniqueId) : bool {return ItemHasTag(item, 'HorseBag');}
  3973. public final function IsItemReadable(item : SItemUniqueId) : bool {return ItemHasTag(item, 'ReadableItem');}
  3974. public final function IsItemAlchemyItem(item : SItemUniqueId) : bool {return IsItemOil(item) || IsItemPotion(item) || IsItemBomb(item); }
  3975. public final function IsItemSingletonItem(item : SItemUniqueId) : bool {return ItemHasTag(item, theGame.params.TAG_ITEM_SINGLETON);}
  3976. public final function IsItemQuest(item : SItemUniqueId) : bool {return ItemHasTag(item, 'Quest');}
  3977. public final function IsItemFood(item : SItemUniqueId) : bool {return ItemHasTag(item, 'Edibles') || ItemHasTag(item, 'Drinks');}
  3978. public final function IsItemSecondaryWeapon(item : SItemUniqueId) : bool {return ItemHasTag(item, 'SecondaryWeapon');}
  3979. public final function IsItemHorseItem(item: SItemUniqueId) : bool {return ItemHasTag(item, 'Saddle') || ItemHasTag(item, 'HorseBag') || ItemHasTag(item, 'Trophy') || ItemHasTag(item, 'Blinders'); }
  3980. public final function IsItemSaddle(item: SItemUniqueId) : bool {return ItemHasTag(item, 'Saddle');}
  3981. public final function IsItemBlinders(item: SItemUniqueId) : bool {return ItemHasTag(item, 'Blinders');}
  3982. public final function IsItemDye( item : SItemUniqueId ) : bool { return ItemHasTag( item, 'mod_dye' ); }
  3983. public final function IsItemUsable( item : SItemUniqueId ) : bool { return GetItemCategory( item ) == 'usable'; }
  3984. public final function IsItemJunk( item : SItemUniqueId ) : bool { return ItemHasTag( item,'junk' ) || GetItemCategory( item ) == 'junk' ; }
  3985. public final function IsItemAlchemyIngredient(item : SItemUniqueId) : bool { return ItemHasTag( item, 'AlchemyIngredient' ); }
  3986. public final function IsItemCraftingIngredient(item : SItemUniqueId) : bool { return ItemHasTag( item, 'CraftingIngredient' ); }
  3987. public final function IsItemArmorReapairKit(item : SItemUniqueId) : bool { return ItemHasTag( item, 'ArmorReapairKit' ); }
  3988. public final function IsItemWeaponReapairKit(item : SItemUniqueId) : bool { return ItemHasTag( item, 'WeaponReapairKit' ); }
  3989. public final function IsQuickSlotItem( item : SItemUniqueId ) : bool { return ItemHasTag( item, 'QuickSlot' ); }
  3990.  
  3991. public final function IsItemNew( item : SItemUniqueId ) : bool
  3992. {
  3993. var uiData : SInventoryItemUIData;
  3994.  
  3995. uiData = GetInventoryItemUIData( item );
  3996. return uiData.isNew;
  3997. }
  3998.  
  3999. public final function IsItemMutagenPotion(item : SItemUniqueId) : bool
  4000. {
  4001. return IsItemPotion(item) && ItemHasTag(item, 'Mutagen');
  4002. }
  4003.  
  4004. public final function CanItemBeColored( item : SItemUniqueId) : bool
  4005. {
  4006. if ( RoundMath( CalculateAttributeValue( GetItemAttributeValue( item, 'quality' ) ) ) == 5 )
  4007. {
  4008. return true;
  4009. }
  4010. return false;
  4011. }
  4012.  
  4013. public final function IsItemSetItem(item : SItemUniqueId) : bool
  4014. {
  4015. return
  4016. ItemHasTag(item, theGame.params.ITEM_SET_TAG_BEAR) ||
  4017. ItemHasTag(item, theGame.params.ITEM_SET_TAG_GRYPHON) ||
  4018. ItemHasTag(item, theGame.params.ITEM_SET_TAG_LYNX) ||
  4019. ItemHasTag(item, theGame.params.ITEM_SET_TAG_WOLF) ||
  4020. ItemHasTag(item, theGame.params.ITEM_SET_TAG_RED_WOLF) ||
  4021. ItemHasTag( item, theGame.params.ITEM_SET_TAG_VAMPIRE ) ||
  4022. ItemHasTag(item, theGame.params.ITEM_SET_TAG_VIPER);
  4023. }
  4024.  
  4025. public function GetArmorType(item : SItemUniqueId) : EArmorType
  4026. {
  4027. var isItemEquipped : bool;
  4028.  
  4029. isItemEquipped = GetWitcherPlayer().IsItemEquipped(item);
  4030.  
  4031.  
  4032. if( thePlayer.HasAbility('Glyphword 2 _Stats', true) && isItemEquipped )
  4033. {return EAT_Light;}
  4034. if( thePlayer.HasAbility('Glyphword 3 _Stats', true) && isItemEquipped )
  4035. {return EAT_Medium;}
  4036. if( thePlayer.HasAbility('Glyphword 4 _Stats', true) && isItemEquipped )
  4037. {return EAT_Heavy;}
  4038.  
  4039. if(ItemHasTag(item, 'LightArmor'))
  4040. return EAT_Light;
  4041. else if(ItemHasTag(item, 'MediumArmor'))
  4042. return EAT_Medium;
  4043. else if(ItemHasTag(item, 'HeavyArmor'))
  4044. return EAT_Heavy;
  4045.  
  4046. return EAT_Undefined;
  4047. }
  4048.  
  4049. public final function GetAlchemyCraftableItems() : array<SItemUniqueId>
  4050. {
  4051. var items : array<SItemUniqueId>;
  4052. var i : int;
  4053.  
  4054. GetAllItems(items);
  4055.  
  4056. for(i=items.Size()-1; i>=0; i-=1)
  4057. {
  4058. if(!IsItemPotion(items[i]) && !IsItemBomb(items[i]) && !IsItemOil(items[i]))
  4059. items.EraseFast(i);
  4060. }
  4061.  
  4062. return items;
  4063. }
  4064.  
  4065. public function IsItemEncumbranceItem(item : SItemUniqueId) : bool
  4066. {
  4067. if(ItemHasTag(item, theGame.params.TAG_ENCUMBRANCE_ITEM_FORCE_YES))
  4068. return true;
  4069.  
  4070. if(ItemHasTag(item, theGame.params.TAG_ENCUMBRANCE_ITEM_FORCE_NO))
  4071. return false;
  4072.  
  4073.  
  4074. if (
  4075. IsRecipeOrSchematic( item )
  4076. || IsItemBody( item )
  4077.  
  4078.  
  4079.  
  4080.  
  4081.  
  4082.  
  4083.  
  4084.  
  4085.  
  4086.  
  4087.  
  4088.  
  4089. )
  4090. return false;
  4091.  
  4092. return true;
  4093. }
  4094.  
  4095. public function GetItemEncumbrance(item : SItemUniqueId) : float
  4096. {
  4097. var itemCategory : name;
  4098. if ( IsItemEncumbranceItem( item ) )
  4099. {
  4100. itemCategory = GetItemCategory( item );
  4101. if ( itemCategory == 'quest' || itemCategory == 'key' )
  4102. {
  4103. return 0.01 * GetItemQuantity( item );
  4104. }
  4105. else if ( itemCategory == 'usable' || itemCategory == 'upgrade' || itemCategory == 'junk' )
  4106. {
  4107. return 0.01 + GetItemWeight( item ) * GetItemQuantity( item ) * 0.2;
  4108. }
  4109. else if ( IsItemAlchemyItem( item ) || IsItemIngredient( item ) || IsItemFood( item ) || IsItemReadable( item ) )
  4110. {
  4111. return 0.0;
  4112. }
  4113. else
  4114. {
  4115. return 0.01 + GetItemWeight( item ) * GetItemQuantity( item ) * 0.5;
  4116. }
  4117. }
  4118. return 0;
  4119. }
  4120.  
  4121. public function GetFilterTypeByItem( item : SItemUniqueId ) : EInventoryFilterType
  4122. {
  4123. var filterType : EInventoryFilterType;
  4124.  
  4125. if( ItemHasTag( item, 'Quest' ) )
  4126. {
  4127. return IFT_QuestItems;
  4128. }
  4129. else if( IsItemIngredient( item ) )
  4130. {
  4131. return IFT_Ingredients;
  4132. }
  4133. else if( IsItemAlchemyItem(item) )
  4134. {
  4135. return IFT_AlchemyItems;
  4136. }
  4137. else if( IsItemAnyArmor(item) )
  4138. {
  4139. return IFT_Armors;
  4140. }
  4141. else if( IsItemWeapon( item ) )
  4142. {
  4143. return IFT_Weapons;
  4144. }
  4145. else
  4146. {
  4147. return IFT_Default;
  4148. }
  4149. }
  4150.  
  4151.  
  4152. public function IsItemQuickslotItem(item : SItemUniqueId) : bool
  4153. {
  4154. return IsSlotQuickslot( GetSlotForItemId(item) );
  4155. }
  4156.  
  4157. public function GetCrossbowAmmo(id : SItemUniqueId) : int
  4158. {
  4159. if(!IsItemCrossbow(id))
  4160. return -1;
  4161.  
  4162. return (int)CalculateAttributeValue(GetItemAttributeValue(id, 'ammo'));
  4163. }
  4164.  
  4165.  
  4166.  
  4167. public function GetSlotForItemId(item : SItemUniqueId) : EEquipmentSlots
  4168. {
  4169. var tags : array<name>;
  4170. var player : W3PlayerWitcher;
  4171. var slot : EEquipmentSlots;
  4172.  
  4173. player = ((W3PlayerWitcher)GetEntity());
  4174.  
  4175. GetItemTags(item, tags);
  4176. slot = GetSlotForItem( GetItemCategory(item), tags, player );
  4177.  
  4178. if(!player)
  4179. return slot;
  4180.  
  4181. if(IsMultipleSlot(slot))
  4182. {
  4183. if(slot == EES_Petard1 && player.IsAnyItemEquippedOnSlot(slot))
  4184. {
  4185. if(!player.IsAnyItemEquippedOnSlot(EES_Petard2))
  4186. slot = EES_Petard2;
  4187. }
  4188. else if(slot == EES_Quickslot1 && player.IsAnyItemEquippedOnSlot(slot))
  4189. {
  4190. if(!player.IsAnyItemEquippedOnSlot(EES_Quickslot2))
  4191. slot = EES_Quickslot2;
  4192. }
  4193. else if(slot == EES_Potion1 && player.IsAnyItemEquippedOnSlot(EES_Potion1))
  4194. {
  4195. if(!player.IsAnyItemEquippedOnSlot(EES_Potion2))
  4196. {
  4197. slot = EES_Potion2;
  4198. }
  4199. else
  4200. {
  4201. if(!player.IsAnyItemEquippedOnSlot(EES_Potion3))
  4202. {
  4203. slot = EES_Potion3;
  4204. }
  4205. else
  4206. {
  4207. if(!player.IsAnyItemEquippedOnSlot(EES_Potion4))
  4208. {
  4209. slot = EES_Potion4;
  4210. }
  4211. }
  4212. }
  4213. }
  4214. else if(slot == EES_PotionMutagen1 && player.IsAnyItemEquippedOnSlot(slot))
  4215. {
  4216. if(!player.IsAnyItemEquippedOnSlot(EES_PotionMutagen2))
  4217. {
  4218. slot = EES_PotionMutagen2;
  4219. }
  4220. else
  4221. {
  4222. if(!player.IsAnyItemEquippedOnSlot(EES_PotionMutagen3))
  4223. {
  4224. slot = EES_PotionMutagen3;
  4225. }
  4226. else
  4227. {
  4228. if(!player.IsAnyItemEquippedOnSlot(EES_PotionMutagen4))
  4229. {
  4230. slot = EES_PotionMutagen4;
  4231. }
  4232. }
  4233. }
  4234. }
  4235. else if(slot == EES_SkillMutagen1 && player.IsAnyItemEquippedOnSlot(slot))
  4236. {
  4237. if(!player.IsAnyItemEquippedOnSlot(EES_SkillMutagen2))
  4238. {
  4239. slot = EES_SkillMutagen2;
  4240. }
  4241. else
  4242. {
  4243. if(!player.IsAnyItemEquippedOnSlot(EES_SkillMutagen3))
  4244. {
  4245. slot = EES_SkillMutagen3;
  4246. }
  4247. else
  4248. {
  4249. if(!player.IsAnyItemEquippedOnSlot(EES_SkillMutagen4))
  4250. {
  4251. slot = EES_SkillMutagen4;
  4252. }
  4253. }
  4254. }
  4255. }
  4256. }
  4257.  
  4258. return slot;
  4259. }
  4260.  
  4261.  
  4262.  
  4263. public function GetAllWeapons() : array<SItemUniqueId>
  4264. {
  4265. return GetItemsByTag('Weapon');
  4266. }
  4267.  
  4268.  
  4269. public function GetSpecifiedPlayerItemsQuest(steelSword, silverSword, armor, boots, gloves, pants, trophy, mask, bombs, crossbow, secondaryWeapon, equippedOnly : bool) : array<SItemUniqueId>
  4270. {
  4271. var items, allItems : array<SItemUniqueId>;
  4272. var i : int;
  4273.  
  4274. GetAllItems(allItems);
  4275.  
  4276. for(i=0; i<allItems.Size(); i+=1)
  4277. {
  4278. if(
  4279. (steelSword && IsItemSteelSwordUsableByPlayer(allItems[i])) ||
  4280. (silverSword && IsItemSilverSwordUsableByPlayer(allItems[i])) ||
  4281. (armor && IsItemChestArmor(allItems[i])) ||
  4282. (boots && IsItemBoots(allItems[i])) ||
  4283. (gloves && IsItemGloves(allItems[i])) ||
  4284. (pants && IsItemPants(allItems[i])) ||
  4285. (trophy && IsItemTrophy(allItems[i])) ||
  4286. (mask && IsItemMask(allItems[i])) ||
  4287. (bombs && IsItemBomb(allItems[i])) ||
  4288. (crossbow && (IsItemCrossbow(allItems[i]) || IsItemBolt(allItems[i]))) ||
  4289. (secondaryWeapon && IsItemSecondaryWeapon(allItems[i]))
  4290. )
  4291. {
  4292. if(!equippedOnly || (equippedOnly && ((W3PlayerWitcher)GetEntity()) && GetWitcherPlayer().IsItemEquipped(allItems[i])) )
  4293. {
  4294. if(!ItemHasTag(allItems[i], 'NoDrop'))
  4295. items.PushBack(allItems[i]);
  4296. }
  4297. }
  4298. }
  4299.  
  4300. return items;
  4301. }
  4302.  
  4303.  
  4304. event OnItemAboutToGive( itemId : SItemUniqueId, quantity : int )
  4305. {
  4306. if(GetEntity() == GetWitcherPlayer())
  4307. {
  4308. if( IsItemSteelSwordUsableByPlayer( itemId ) || IsItemSilverSwordUsableByPlayer( itemId ) )
  4309. {
  4310. RemoveAllOilsFromItem( itemId );
  4311. }
  4312. }
  4313. }
  4314.  
  4315.  
  4316. event OnItemRemoved( itemId : SItemUniqueId, quantity : int )
  4317. {
  4318. var ent : CGameplayEntity;
  4319. var crossbows : array<SItemUniqueId>;
  4320. var witcher : W3PlayerWitcher;
  4321. var refill : W3RefillableContainer;
  4322.  
  4323. witcher = GetWitcherPlayer();
  4324.  
  4325. if(GetEntity() == witcher)
  4326. {
  4327.  
  4328.  
  4329.  
  4330.  
  4331.  
  4332. if(IsItemCrossbow(itemId) && HasInfiniteBolts())
  4333. {
  4334. crossbows = GetItemsByCategory('crossbow');
  4335. crossbows.Remove(itemId);
  4336.  
  4337. if(crossbows.Size() == 0)
  4338. {
  4339. RemoveItemByName('Bodkin Bolt', GetItemQuantityByName('Bodkin Bolt'));
  4340. RemoveItemByName('Harpoon Bolt', GetItemQuantityByName('Harpoon Bolt'));
  4341. }
  4342. }
  4343. else if(IsItemBolt(itemId) && witcher.IsItemEquipped(itemId) && witcher.inv.GetItemQuantity(itemId) == quantity)
  4344. {
  4345.  
  4346. witcher.UnequipItem(itemId);
  4347. }
  4348.  
  4349.  
  4350. if(IsItemCrossbow(itemId) && witcher.IsItemEquipped(itemId) && witcher.rangedWeapon)
  4351. {
  4352. witcher.rangedWeapon.ClearDeployedEntity(true);
  4353. witcher.rangedWeapon = NULL;
  4354. }
  4355. if( GetItemCategory(itemId) == 'usable' )
  4356. {
  4357. if(witcher.IsHoldingItemInLHand() && itemId == witcher.currentlyEquipedItemL )
  4358. {
  4359. witcher.HideUsableItem(true);
  4360. }
  4361. }
  4362. if( IsItemSteelSwordUsableByPlayer( itemId ) || IsItemSilverSwordUsableByPlayer( itemId ) )
  4363. {
  4364. RemoveAllOilsFromItem( itemId );
  4365. }
  4366.  
  4367.  
  4368. if(witcher.IsItemEquipped(itemId) && quantity >= witcher.inv.GetItemQuantity(itemId))
  4369. witcher.UnequipItem(itemId);
  4370. }
  4371.  
  4372.  
  4373. if(GetEntity() == thePlayer && IsItemWeapon(itemId) && (IsItemHeld(itemId) || IsItemMounted(itemId) ))
  4374. {
  4375. thePlayer.OnHolsteredItem(GetItemCategory(itemId),'r_weapon');
  4376. }
  4377.  
  4378.  
  4379. ent = (CGameplayEntity)GetEntity();
  4380. if(ent)
  4381. ent.OnItemTaken( itemId, quantity );
  4382.  
  4383.  
  4384. if(IsLootRenewable())
  4385. {
  4386. refill = (W3RefillableContainer)GetEntity();
  4387. if(refill)
  4388. refill.AddTimer('Refill', 20, true);
  4389. }
  4390. }
  4391.  
  4392.  
  4393. function GenerateItemLevel( item : SItemUniqueId, rewardItem : bool )
  4394. {
  4395. //var stat : SAbilityAttributeValue;
  4396. var stat, statAutogen : SAbilityAttributeValue; // FCR3
  4397. var playerLevel : int;
  4398. var lvl, i : int;
  4399. var quality : int;
  4400. var ilMin, ilMax : int;
  4401. var enemyLevel : int; // FCR3
  4402.  
  4403. playerLevel = GetWitcherPlayer().GetLevel();
  4404.  
  4405. lvl = playerLevel - 1;
  4406.  
  4407.  
  4408. if ( ( W3MerchantNPC )GetEntity() )
  4409. {
  4410. lvl = RoundF( playerLevel + RandRangeF( 2, 0 ) );
  4411. AddItemTag( item, 'AutogenUseLevelRange' );
  4412. }
  4413. else if ( rewardItem )
  4414. {
  4415. //lvl = RoundF( playerLevel + RandRangeF( 1, 0 ) );
  4416. lvl = RoundF( playerLevel + RandRangeF( 3, 1 ) ); // FCR3
  4417. }
  4418. else if ( ItemHasTag( item, 'AutogenUseLevelRange') )
  4419. {
  4420. quality = RoundMath( CalculateAttributeValue( GetItemAttributeValue( item, 'quality' ) ) );
  4421. ilMin = RoundMath(CalculateAttributeValue( GetItemAttributeValue( item, 'item_level_min' ) ));
  4422. ilMax = RoundMath(CalculateAttributeValue( GetItemAttributeValue( item, 'item_level_max' ) ));
  4423.  
  4424. if ( !ItemHasTag( item, 'AutogenForceLevel') )
  4425. lvl += RoundMath(RandRangeF( 1, -1 ));
  4426.  
  4427. // FCR3 --
  4428. if ( !lvlCheck2 )
  4429. {
  4430. FindGameplayEntitiesInSphere( enemies, GetEntity().GetWorldPosition(), 30, 999, '', FLAG_Attitude_Hostile, thePlayer );
  4431. if ( enemies.Size() > 0 )
  4432. {
  4433. if ( lastEnemyCount != enemies.Size() )
  4434. {
  4435. lastEnemyCount = enemies.Size();
  4436. for( i = lastEnemyCount - 1; i >= 0; i -= 1 )
  4437. {
  4438. enemyLevel = ((CNewNPC)enemies[i]).GetLevel();
  4439. if ( highestEnemyLevel < enemyLevel )
  4440. {
  4441. highestEnemyLevel = enemyLevel;
  4442. }
  4443. }
  4444.  
  4445. if ( highestEnemyLevel > lvl )
  4446. {
  4447. lvl = highestEnemyLevel;
  4448. }
  4449. else
  4450. {
  4451. lvl += 1;
  4452. }
  4453. }
  4454. lvlCheck2 = true;
  4455. }
  4456. }
  4457.  
  4458. //lvl += 1;
  4459. // -- FCR3
  4460.  
  4461. if ( FactsQuerySum("NewGamePlus") > 0 )
  4462. {
  4463. if ( lvl < ilMin + theGame.params.GetNewGamePlusLevel() ) lvl = ilMin + theGame.params.GetNewGamePlusLevel();
  4464. if ( lvl > ilMax + theGame.params.GetNewGamePlusLevel() ) lvl = ilMax + theGame.params.GetNewGamePlusLevel();
  4465. }
  4466. else
  4467. {
  4468. if ( lvl < ilMin ) lvl = ilMin;
  4469. if ( lvl > ilMax ) lvl = ilMax;
  4470. }
  4471.  
  4472. if ( quality == 5 ) lvl += 2;
  4473. if ( quality == 4 ) lvl += 1;
  4474. if ( (quality == 5 || quality == 4) && ItemHasTag(item, 'EP1') ) lvl += 1;
  4475. }
  4476. else if ( !ItemHasTag( item, 'AutogenForceLevel') )
  4477. {
  4478. quality = RoundMath( CalculateAttributeValue( GetItemAttributeValue( item, 'quality' ) ) );
  4479.  
  4480. if ( quality == 5 )
  4481. {
  4482. lvl = RoundF( playerLevel + RandRangeF( 2, 0 ) );
  4483. }
  4484. else if ( quality == 4 )
  4485. {
  4486. lvl = RoundF( playerLevel + RandRangeF( 1, -2 ) );
  4487. }
  4488. else if ( quality == 3 )
  4489. {
  4490. lvl = RoundF( playerLevel + RandRangeF( -1, -3 ) );
  4491.  
  4492. if ( RandF() > 0.9 )
  4493. {
  4494. lvl = playerLevel;
  4495. }
  4496. }
  4497. else if ( quality == 2 )
  4498. {
  4499. lvl = RoundF( playerLevel + RandRangeF( -2, -5 ) );
  4500.  
  4501. if ( RandF() > 0.95 )
  4502. {
  4503. lvl = playerLevel;
  4504. }
  4505. }
  4506. else
  4507. {
  4508. lvl = RoundF( playerLevel + RandRangeF( -2, -8 ) );
  4509.  
  4510. if ( RandF() == 0 )
  4511. {
  4512. lvl = playerLevel;
  4513. }
  4514. }
  4515.  
  4516. // FCR3 --
  4517. FindGameplayEntitiesInSphere( enemies, GetEntity().GetWorldPosition(), 30, 999, '', FLAG_Attitude_Hostile, thePlayer );
  4518. if ( lastEnemyCount != enemies.Size() )
  4519. {
  4520. lastEnemyCount = enemies.Size();
  4521. for( i = lastEnemyCount - 1; i >= 0; i -= 1 )
  4522. {
  4523. enemyLevel = ((CNewNPC)enemies[i]).GetLevel();
  4524. if ( highestEnemyLevel < enemyLevel )
  4525. {
  4526. highestEnemyLevel = enemyLevel;
  4527. }
  4528. }
  4529.  
  4530. if ( highestEnemyLevel > lvl )
  4531. {
  4532. lvl = highestEnemyLevel;
  4533.  
  4534. if ( quality == 5 )
  4535. {
  4536. lvl += 2;
  4537. }
  4538. else if ( quality == 4 )
  4539. {
  4540. lvl += 1;
  4541. }
  4542. else if ( quality == 3 )
  4543. {
  4544. if ( RandF() < 0.9 )
  4545. {
  4546. lvl -= 1;
  4547. }
  4548. }
  4549. else if ( quality == 2 )
  4550. {
  4551. if ( RandF() < 0.95 )
  4552. {
  4553. lvl -= 2;
  4554. }
  4555. }
  4556. else
  4557. {
  4558. lvl -= 2;
  4559. }
  4560. }
  4561. }
  4562. // -- FCR3
  4563. }
  4564.  
  4565. // FCR3 --
  4566. if ( GetItemCategory( item ) == 'bolt' )
  4567. {
  4568. lvl = playerLevel;
  4569. if ( quality == 5 )
  4570. {
  4571. lvl += 14;
  4572. }
  4573. else if ( quality == 4 )
  4574. {
  4575. lvl += 10;
  4576. }
  4577. else if ( quality == 3 )
  4578. {
  4579. lvl += 6;
  4580. }
  4581. else if ( quality == 2 )
  4582. {
  4583. lvl += 4;
  4584. }
  4585. }
  4586. // -- FCR3
  4587.  
  4588. lvl -= 2;
  4589. }
  4590. }
  4591. else
  4592. {
  4593. lvl -= 2;
  4594. }
  4595. }
  4596. }
  4597. // -- FCR3
  4598. }
  4599.  
  4600. // FCR3 --
  4601. if ( GetItemCategory( item ) == 'bolt' )
  4602. {
  4603. lvl = playerLevel;
  4604. if ( quality == 5 )
  4605. {
  4606. lvl += 14;
  4607. }
  4608. else if ( quality == 4 )
  4609. {
  4610. lvl += 10;
  4611. }
  4612. else if ( quality == 3 )
  4613. {
  4614. lvl += 6;
  4615. }
  4616. else if ( quality == 2 )
  4617. {
  4618. lvl += 4;
  4619. }
  4620. }
  4621. // -- FCR3
  4622.  
  4623. if ( highestEnemyLevel > lvl )
  4624. {
  4625. lvl = highestEnemyLevel;
  4626.  
  4627. if ( quality == 5 )
  4628. {
  4629. lvl += 2;
  4630. }
  4631. else if ( quality == 4 )
  4632. {
  4633. lvl += 1;
  4634. }
  4635. else if ( quality == 3 )
  4636. {
  4637. if ( RandF() < 0.9 )
  4638. {
  4639. lvl -= 1;
  4640. }
  4641. }
  4642. else if ( quality == 2 )
  4643. {
  4644. if ( RandF() < 0.95 )
  4645. {
  4646. lvl -= 2;
  4647. }
  4648. }
  4649. else
  4650. {
  4651. lvl -= 2;
  4652. }
  4653. }
  4654. }
  4655. // -- FCR3
  4656. }
  4657.  
  4658. // FCR3 --
  4659. if ( GetItemCategory( item ) == 'bolt' )
  4660. {
  4661. lvl = playerLevel;
  4662. if ( quality == 5 )
  4663. {
  4664. lvl += 14;
  4665. }
  4666. else if ( quality == 4 )
  4667. {
  4668. lvl += 10;
  4669. }
  4670. else if ( quality == 3 )
  4671. {
  4672. lvl += 6;
  4673. }
  4674. else if ( quality == 2 )
  4675. {
  4676. lvl += 4;
  4677. }
  4678. }
  4679. // -- FCR3
  4680.  
  4681. if (FactsQuerySum("StandAloneEP1") > 0)
  4682. lvl = GetWitcherPlayer().GetLevel() - 1;
  4683.  
  4684.  
  4685. //if ( FactsQuerySum("NewGamePlus") > 0 && !ItemHasTag( item, 'AutogenUseLevelRange') )
  4686. if ( FactsQuerySum("NewGamePlus") > 0 && !ItemHasTag( item, 'AutogenUseLevelRange') && GetItemCategory( item ) != 'bolt' ) // FCR3
  4687. {
  4688. if ( quality == 5 ) lvl += 2;
  4689. if ( quality == 4 ) lvl += 1;
  4690. }
  4691.  
  4692. if ( lvl < 1 ) lvl = 1;
  4693. if ( lvl > GetWitcherPlayer().GetMaxLevel() ) lvl = GetWitcherPlayer().GetMaxLevel();
  4694.  
  4695.  
  4696.  
  4697. if ( ItemHasTag( item, 'PlayerSteelWeapon' ) && !( ItemHasAbility( item, 'autogen_steel_base' ) || ItemHasAbility( item, 'autogen_fixed_steel_base' ) ) )
  4698. {
  4699. if ( ItemHasTag(item, 'AutogenUseLevelRange') && ItemHasAbility(item, 'autogen_fixed_steel_base') )
  4700. return;
  4701.  
  4702. if ( ItemHasTag(item, 'AutogenUseLevelRange') )
  4703. AddItemCraftedAbility(item, 'autogen_fixed_steel_base' );
  4704. else
  4705. AddItemCraftedAbility(item, 'autogen_steel_base' );
  4706.  
  4707. for( i=0; i<lvl; i+=1 )
  4708. {
  4709. if (FactsQuerySum("StandAloneEP1") > 0)
  4710. {
  4711. AddItemCraftedAbility(item, 'autogen_fixed_steel_dmg', true );
  4712. continue;
  4713. }
  4714.  
  4715. if ( ItemHasTag( item, 'AutogenForceLevel') || ItemHasTag(item, 'AutogenUseLevelRange') || FactsQuerySum("NewGamePlus") > 0 )
  4716. AddItemCraftedAbility(item, 'autogen_fixed_steel_dmg', true );
  4717. else
  4718. AddItemCraftedAbility(item, 'autogen_steel_dmg', true );
  4719. }
  4720. }
  4721. else if ( ItemHasTag( item, 'PlayerSilverWeapon' ) && !( ItemHasAbility( item, 'autogen_silver_base' ) || ItemHasAbility( item, 'autogen_fixed_silver_base' ) ) )
  4722. {
  4723. if ( ItemHasTag(item, 'AutogenUseLevelRange') && ItemHasAbility(item, 'autogen_fixed_silver_base') )
  4724. return;
  4725.  
  4726. if ( ItemHasTag(item, 'AutogenUseLevelRange') )
  4727. AddItemCraftedAbility(item, 'autogen_fixed_silver_base' );
  4728. else
  4729. AddItemCraftedAbility(item, 'autogen_silver_base' );
  4730.  
  4731. for( i=0; i<lvl; i+=1 )
  4732. {
  4733. if (FactsQuerySum("StandAloneEP1") > 0)
  4734. {
  4735. AddItemCraftedAbility(item, 'autogen_fixed_silver_dmg', true );
  4736. continue;
  4737. }
  4738.  
  4739. if ( ItemHasTag( item, 'AutogenForceLevel') || ItemHasTag(item, 'AutogenUseLevelRange') || FactsQuerySum("NewGamePlus") > 0 )
  4740. AddItemCraftedAbility(item, 'autogen_fixed_silver_dmg', true );
  4741. else
  4742. AddItemCraftedAbility(item, 'autogen_silver_dmg', true );
  4743. }
  4744. }
  4745. else if ( GetItemCategory( item ) == 'armor' && !( ItemHasAbility( item, 'autogen_armor_base' ) || ItemHasAbility( item, 'autogen_fixed_armor_base' ) ) )
  4746. {
  4747. if ( ItemHasTag(item, 'AutogenUseLevelRange') && ItemHasAbility(item, 'autogen_fixed_armor_base') )
  4748. return;
  4749.  
  4750. if ( ItemHasTag(item, 'AutogenUseLevelRange') )
  4751. AddItemCraftedAbility(item, 'autogen_fixed_armor_base' );
  4752. else
  4753. AddItemCraftedAbility(item, 'autogen_armor_base' );
  4754.  
  4755. for( i=0; i<lvl; i+=1 )
  4756. {
  4757. if (FactsQuerySum("StandAloneEP1") > 0)
  4758. {
  4759. AddItemCraftedAbility(item, 'autogen_fixed_armor_armor', true );
  4760. continue;
  4761. }
  4762.  
  4763. if ( ItemHasTag( item, 'AutogenForceLevel') || ItemHasTag( item, 'AutogenUseLevelRange') || FactsQuerySum("NewGamePlus") > 0 )
  4764. AddItemCraftedAbility(item, 'autogen_fixed_armor_armor', true );
  4765. else
  4766. AddItemCraftedAbility(item, 'autogen_armor_armor', true );
  4767. }
  4768. }
  4769. else if ( ( GetItemCategory( item ) == 'boots' || GetItemCategory( item ) == 'pants' ) && !( ItemHasAbility( item, 'autogen_pants_base' ) || ItemHasAbility( item, 'autogen_fixed_pants_base' ) ) )
  4770. {
  4771. if ( ItemHasTag(item, 'AutogenUseLevelRange') && ItemHasAbility(item, 'autogen_fixed_pants_base') )
  4772. return;
  4773.  
  4774. if ( ItemHasTag(item, 'AutogenUseLevelRange') )
  4775. AddItemCraftedAbility(item, 'autogen_fixed_pants_base' );
  4776. else
  4777. AddItemCraftedAbility(item, 'autogen_pants_base' );
  4778.  
  4779. for( i=0; i<lvl; i+=1 )
  4780. {
  4781. if (FactsQuerySum("StandAloneEP1") > 0)
  4782. {
  4783. AddItemCraftedAbility(item, 'autogen_fixed_pants_armor', true );
  4784. continue;
  4785. }
  4786.  
  4787. if ( ItemHasTag( item, 'AutogenForceLevel') || ItemHasTag( item, 'AutogenUseLevelRange') || FactsQuerySum("NewGamePlus") > 0 )
  4788. AddItemCraftedAbility(item, 'autogen_fixed_pants_armor', true );
  4789. else
  4790. AddItemCraftedAbility(item, 'autogen_pants_armor', true );
  4791. }
  4792. }
  4793. else if ( GetItemCategory( item ) == 'gloves' && !( ItemHasAbility( item, 'autogen_gloves_base' ) || ItemHasAbility( item, 'autogen_fixed_gloves_base' ) ) )
  4794. {
  4795. if ( ItemHasTag(item, 'AutogenUseLevelRange') && ItemHasAbility(item, 'autogen_fixed_gloves_base') )
  4796. return;
  4797.  
  4798. if ( ItemHasTag(item, 'AutogenUseLevelRange') )
  4799. AddItemCraftedAbility(item, 'autogen_fixed_gloves_base' );
  4800. else
  4801. AddItemCraftedAbility(item, 'autogen_gloves_base' );
  4802.  
  4803. for( i=0; i<lvl; i+=1 )
  4804. {
  4805. if (FactsQuerySum("StandAloneEP1") > 0)
  4806. {
  4807. AddItemCraftedAbility(item, 'autogen_fixed_gloves_armor', true );
  4808. continue;
  4809. }
  4810.  
  4811. if ( ItemHasTag( item, 'AutogenForceLevel') || ItemHasTag(item, 'AutogenUseLevelRange') || FactsQuerySum("NewGamePlus") > 0 )
  4812. AddItemCraftedAbility(item, 'autogen_fixed_gloves_armor', true );
  4813. else
  4814. AddItemCraftedAbility(item, 'autogen_gloves_armor', true );
  4815. }
  4816. }
  4817. // FCR3 --
  4818. // scale existing damage values on bolts with player level
  4819. // infinite bolts are replaced with updated version on each levelup
  4820. else if ( GetItemCategory( item ) == 'bolt' )
  4821. {
  4822. // FCR3 --
  4823. if ( ItemHasTag(item, 'BoltUpscaled') )
  4824. return;
  4825. // -- FCR3
  4826. for( i=0; i<lvl; i+=1 )
  4827. {
  4828. stat = GetItemAttributeValue(item, 'PiercingDamage');
  4829. statAutogen = GetItemAttributeValue(item, 'bolt_piercing_dmg');
  4830. if ( stat.valueAdditive > 0 && statAutogen.valueAdditive <= 0 )
  4831. AddItemCraftedAbility(item, 'bolt_piercing_dmg', true );
  4832.  
  4833. stat = GetItemAttributeValue(item, 'SilverDamage');
  4834. statAutogen = GetItemAttributeValue(item, 'bolt_silver_dmg');
  4835. if ( stat.valueAdditive > 0 && statAutogen.valueAdditive <= 0 )
  4836. AddItemCraftedAbility(item, 'bolt_silver_dmg', true );
  4837.  
  4838. stat = GetItemAttributeValue(item, 'BludgeoningDamage');
  4839. statAutogen = GetItemAttributeValue(item, 'bolt_bludgeoning_dmg');
  4840. if ( stat.valueAdditive > 0 && statAutogen.valueAdditive <= 0 )
  4841. AddItemCraftedAbility(item, 'bolt_bludgeoning_dmg', true );
  4842.  
  4843. stat = GetItemAttributeValue(item, 'FireDamage');
  4844. statAutogen = GetItemAttributeValue(item, 'bolt_fire_dmg');
  4845. if ( stat.valueAdditive > 0 && statAutogen.valueAdditive <= 0 )
  4846. AddItemCraftedAbility(item, 'bolt_fire_dmg', true );
  4847. }
  4848.  
  4849. AddItemTag( item, 'BoltUpscaled' ); // FCR3
  4850. }
  4851. // -- FCR3
  4852. }
  4853.  
  4854.  
  4855. event OnItemAdded(data : SItemChangedData)
  4856. {
  4857. var i, j : int;
  4858. var ent : CGameplayEntity;
  4859. var allCardsNames, foundCardsNames : array<name>;
  4860. var allStringNamesOfCards : array<string>;
  4861. var foundCardsStringNames : array<string>;
  4862. var gwintCards : array<SItemUniqueId>;
  4863. var itemName : name;
  4864. var witcher : W3PlayerWitcher;
  4865. var itemCategory : name;
  4866. var dm : CDefinitionsManagerAccessor;
  4867. var locKey : string;
  4868. var leaderCardsHack : array<name>;
  4869.  
  4870. var hud : CR4ScriptedHud;
  4871. var journalUpdateModule : CR4HudModuleJournalUpdate;
  4872. var itemId : SItemUniqueId;
  4873.  
  4874. var isItemShematic : bool;
  4875.  
  4876. var ngp : bool;
  4877.  
  4878.  
  4879. // FCR3 --
  4880. lvlCheck1 = false;
  4881. lvlCheck2 = false;
  4882. emptyCheck = false;
  4883. empty = false;
  4884. // -- FCR3
  4885.  
  4886. ent = (CGameplayEntity)GetEntity();
  4887.  
  4888. itemId = data.ids[0];
  4889.  
  4890. // FCR3 --
  4891. if ( ent == thePlayer )
  4892. {
  4893. AddItemTag( itemId, 'PlayerOwned' );
  4894. }
  4895. // -- FCR3
  4896.  
  4897. if( data.informGui )
  4898. {
  4899. recentlyAddedItems.PushBack( itemId );
  4900. if( ItemHasTag( itemId, 'FocusObject' ) )
  4901. {
  4902. GetWitcherPlayer().GetMedallion().Activate( true, 3.0);
  4903. }
  4904. }
  4905.  
  4906.  
  4907. //if ( ItemHasTag(itemId, 'Autogen') )
  4908. if ( ItemHasTag(itemId, 'Autogen') || GetItemCategory( itemId ) == 'bolt' ) // FCR3
  4909. {
  4910. GenerateItemLevel( itemId, false );
  4911. }
  4912.  
  4913. witcher = GetWitcherPlayer();
  4914.  
  4915.  
  4916. if(ent == witcher || ((W3MerchantNPC)ent) )
  4917. {
  4918. ngp = FactsQuerySum("NewGamePlus") > 0;
  4919. for(i=0; i<data.ids.Size(); i+=1)
  4920. {
  4921.  
  4922. if ( GetItemModifierInt(data.ids[i], 'ItemQualityModified') <= 0 )
  4923. AddRandomEnhancementToItem(data.ids[i]);
  4924.  
  4925. if ( ngp )
  4926. SetItemModifierInt(data.ids[i], 'DoNotAdjustNGPDLC', 1);
  4927.  
  4928. itemName = GetItemName(data.ids[i]);
  4929.  
  4930. if ( ngp && GetItemModifierInt(data.ids[i], 'NGPItemAdjusted') <= 0 && !ItemHasTag(data.ids[i], 'Autogen') )
  4931. {
  4932. IncreaseNGPItemlevel(data.ids[i]);
  4933. }
  4934.  
  4935. }
  4936. }
  4937. if(ent == witcher)
  4938. {
  4939. for(i=0; i<data.ids.Size(); i+=1)
  4940. {
  4941.  
  4942. if( ItemHasTag( itemId, theGame.params.GWINT_CARD_ACHIEVEMENT_TAG ) || !FactsDoesExist( "fix_for_gwent_achievement_bug_121588" ) )
  4943. {
  4944.  
  4945. leaderCardsHack.PushBack('gwint_card_emhyr_gold');
  4946. leaderCardsHack.PushBack('gwint_card_emhyr_silver');
  4947. leaderCardsHack.PushBack('gwint_card_emhyr_bronze');
  4948. leaderCardsHack.PushBack('gwint_card_foltest_gold');
  4949. leaderCardsHack.PushBack('gwint_card_foltest_silver');
  4950. leaderCardsHack.PushBack('gwint_card_foltest_bronze');
  4951. leaderCardsHack.PushBack('gwint_card_francesca_gold');
  4952. leaderCardsHack.PushBack('gwint_card_francesca_silver');
  4953. leaderCardsHack.PushBack('gwint_card_francesca_bronze');
  4954. leaderCardsHack.PushBack('gwint_card_eredin_gold');
  4955. leaderCardsHack.PushBack('gwint_card_eredin_silver');
  4956. leaderCardsHack.PushBack('gwint_card_eredin_bronze');
  4957.  
  4958. dm = theGame.GetDefinitionsManager();
  4959.  
  4960. allCardsNames = theGame.GetDefinitionsManager().GetItemsWithTag(theGame.params.GWINT_CARD_ACHIEVEMENT_TAG);
  4961.  
  4962.  
  4963. gwintCards = GetItemsByTag(theGame.params.GWINT_CARD_ACHIEVEMENT_TAG);
  4964.  
  4965.  
  4966. allStringNamesOfCards.PushBack('gwint_name_emhyr');
  4967. allStringNamesOfCards.PushBack('gwint_name_emhyr');
  4968. allStringNamesOfCards.PushBack('gwint_name_emhyr');
  4969. allStringNamesOfCards.PushBack('gwint_name_foltest');
  4970. allStringNamesOfCards.PushBack('gwint_name_foltest');
  4971. allStringNamesOfCards.PushBack('gwint_name_foltest');
  4972. allStringNamesOfCards.PushBack('gwint_name_francesca');
  4973. allStringNamesOfCards.PushBack('gwint_name_francesca');
  4974. allStringNamesOfCards.PushBack('gwint_name_francesca');
  4975. allStringNamesOfCards.PushBack('gwint_name_eredin');
  4976. allStringNamesOfCards.PushBack('gwint_name_eredin');
  4977. allStringNamesOfCards.PushBack('gwint_name_eredin');
  4978.  
  4979.  
  4980. for(j=0; j<allCardsNames.Size(); j+=1)
  4981. {
  4982. itemName = allCardsNames[j];
  4983. locKey = dm.GetItemLocalisationKeyName(allCardsNames[j]);
  4984. if (!allStringNamesOfCards.Contains(locKey))
  4985. {
  4986. allStringNamesOfCards.PushBack(locKey);
  4987. }
  4988. }
  4989.  
  4990.  
  4991. if(gwintCards.Size() >= allStringNamesOfCards.Size())
  4992. {
  4993. foundCardsNames.Clear();
  4994. for(j=0; j<gwintCards.Size(); j+=1)
  4995. {
  4996. itemName = GetItemName(gwintCards[j]);
  4997. locKey = dm.GetItemLocalisationKeyName(itemName);
  4998.  
  4999. if(!foundCardsStringNames.Contains(locKey) || leaderCardsHack.Contains(itemName))
  5000. {
  5001. foundCardsStringNames.PushBack(locKey);
  5002. }
  5003. }
  5004.  
  5005. if(foundCardsStringNames.Size() >= allStringNamesOfCards.Size())
  5006. {
  5007. theGame.GetGamerProfile().AddAchievement(EA_GwintCollector);
  5008. FactsAdd("gwint_all_cards_collected", 1, -1);
  5009. }
  5010. }
  5011.  
  5012. if(!FactsDoesExist("fix_for_gwent_achievement_bug_121588"))
  5013. FactsAdd("fix_for_gwent_achievement_bug_121588", 1, -1);
  5014. }
  5015.  
  5016. itemCategory = GetItemCategory( itemId );
  5017. isItemShematic = itemCategory == 'alchemy_recipe' || itemCategory == 'crafting_schematic';
  5018.  
  5019. if( isItemShematic )
  5020. {
  5021. ReadSchematicsAndRecipes( itemId );
  5022. }
  5023.  
  5024.  
  5025. if( ItemHasTag( data.ids[i], 'GwintCard'))
  5026. {
  5027. witcher.AddGwentCard(GetItemName(data.ids[i]), data.quantity);
  5028. }
  5029.  
  5030.  
  5031.  
  5032. if( !isItemShematic && ( this.ItemHasTag( itemId, 'ReadableItem' ) || this.ItemHasTag( itemId, 'Painting' ) ) && !this.ItemHasTag( itemId, 'NoNotification' ) )
  5033. {
  5034. hud = (CR4ScriptedHud)theGame.GetHud();
  5035. if( hud )
  5036. {
  5037. journalUpdateModule = (CR4HudModuleJournalUpdate)hud.GetHudModule( "JournalUpdateModule" );
  5038. if( journalUpdateModule )
  5039. {
  5040. journalUpdateModule.AddQuestBookInfo( itemId );
  5041. }
  5042. }
  5043. }
  5044. }
  5045. }
  5046.  
  5047.  
  5048. if( IsItemSingletonItem( itemId ) )
  5049. {
  5050. for(i=0; i<data.ids.Size(); i+=1)
  5051. {
  5052. if(!GetItemModifierInt(data.ids[i], 'is_initialized', 0))
  5053. {
  5054. SingletonItemRefillAmmo(data.ids[i]);
  5055. SetItemModifierInt(data.ids[i], 'is_initialized', 1);
  5056. }
  5057. }
  5058. }
  5059.  
  5060.  
  5061. if(ent)
  5062. ent.OnItemGiven(data);
  5063. }
  5064.  
  5065. public function AddRandomEnhancementToItem(item : SItemUniqueId)
  5066. {
  5067. var itemCategory : name;
  5068. var itemQuality : int;
  5069. var ability : name;
  5070. var ent : CGameplayEntity;
  5071.  
  5072.  
  5073.  
  5074.  
  5075. if( ItemHasTag(item, 'DoNotEnhance') )
  5076. {
  5077. SetItemModifierInt(item, 'ItemQualityModified', 1);
  5078. return;
  5079. }
  5080.  
  5081. itemCategory = GetItemCategory(item);
  5082. itemQuality = RoundMath(CalculateAttributeValue(GetItemAttributeValue(item, 'quality' )));
  5083.  
  5084. if ( itemCategory == 'armor' )
  5085. {
  5086. switch ( itemQuality )
  5087. {
  5088. case 2 :
  5089. ability = 'quality_masterwork_armor';
  5090. AddItemCraftedAbility(item, theGame.params.GetRandomMasterworkArmorAbility(), true);
  5091. break;
  5092. case 3 :
  5093. ability = 'quality_magical_armor';
  5094. if ( ItemHasTag(item, 'EP1') )
  5095. {
  5096. AddItemCraftedAbility(item, theGame.params.GetRandomMagicalArmorAbility(), true);
  5097. break;
  5098. }
  5099.  
  5100. if ( RandF() > 0.5 )
  5101. AddItemCraftedAbility(item, theGame.params.GetRandomMagicalArmorAbility(), true);
  5102. else
  5103. AddItemCraftedAbility(item, theGame.params.GetRandomMasterworkArmorAbility(), true);
  5104.  
  5105. if ( RandF() > 0.5 )
  5106. AddItemCraftedAbility(item, theGame.params.GetRandomMagicalArmorAbility(), true);
  5107. else
  5108. AddItemCraftedAbility(item, theGame.params.GetRandomMasterworkArmorAbility(), true);
  5109. break;
  5110. default : break;
  5111. }
  5112. }
  5113. else if ( itemCategory == 'gloves' )
  5114. {
  5115. switch ( itemQuality )
  5116. {
  5117. case 2 :
  5118. ability = 'quality_masterwork_gloves';
  5119. AddItemCraftedAbility(item, theGame.params.GetRandomMasterworkGlovesAbility(), true);
  5120. break;
  5121. case 3 :
  5122. ability = 'quality_magical_gloves';
  5123. if ( ItemHasTag(item, 'EP1') )
  5124. {
  5125. AddItemCraftedAbility(item, theGame.params.GetRandomMagicalArmorAbility(), true);
  5126. break;
  5127. }
  5128.  
  5129. if ( RandF() > 0.5 )
  5130. AddItemCraftedAbility(item, theGame.params.GetRandomMagicalGlovesAbility(), true);
  5131. else
  5132. AddItemCraftedAbility(item, theGame.params.GetRandomMasterworkGlovesAbility(), true);
  5133.  
  5134. if ( RandF() > 0.5 )
  5135. AddItemCraftedAbility(item, theGame.params.GetRandomMagicalGlovesAbility(), true);
  5136. else
  5137. AddItemCraftedAbility(item, theGame.params.GetRandomMasterworkGlovesAbility(), true);
  5138. break;
  5139. default : break;
  5140. }
  5141. }
  5142. else if ( itemCategory == 'pants' )
  5143. {
  5144. switch ( itemQuality )
  5145. {
  5146. case 2 :
  5147. ability = 'quality_masterwork_pants';
  5148. AddItemCraftedAbility(item, theGame.params.GetRandomMasterworkPantsAbility(), true);
  5149. break;
  5150. case 3 :
  5151. ability = 'quality_magical_pants';
  5152. if ( ItemHasTag(item, 'EP1') )
  5153. {
  5154. AddItemCraftedAbility(item, theGame.params.GetRandomMagicalArmorAbility(), true);
  5155. break;
  5156. }
  5157.  
  5158. if ( RandF() > 0.5 )
  5159. AddItemCraftedAbility(item, theGame.params.GetRandomMagicalPantsAbility(), true);
  5160. else
  5161. AddItemCraftedAbility(item, theGame.params.GetRandomMasterworkPantsAbility(), true);
  5162.  
  5163. if ( RandF() > 0.5 )
  5164. AddItemCraftedAbility(item, theGame.params.GetRandomMagicalPantsAbility(), true);
  5165. else
  5166. AddItemCraftedAbility(item, theGame.params.GetRandomMasterworkPantsAbility(), true);
  5167. break;
  5168. default : break;
  5169. }
  5170. }
  5171. else if ( itemCategory == 'boots' )
  5172. {
  5173. switch ( itemQuality )
  5174. {
  5175. case 2 :
  5176. ability = 'quality_masterwork_boots';
  5177. AddItemCraftedAbility(item, theGame.params.GetRandomMasterworkBootsAbility(), true);
  5178. break;
  5179. case 3 :
  5180. ability = 'quality_magical_boots';
  5181. if ( ItemHasTag(item, 'EP1') )
  5182. {
  5183. AddItemCraftedAbility(item, theGame.params.GetRandomMagicalArmorAbility(), true);
  5184. break;
  5185. }
  5186.  
  5187. if ( RandF() > 0.5 )
  5188. AddItemCraftedAbility(item, theGame.params.GetRandomMagicalBootsAbility(), true);
  5189. else
  5190. AddItemCraftedAbility(item, theGame.params.GetRandomMasterworkBootsAbility(), true);
  5191.  
  5192. if ( RandF() > 0.5 )
  5193. AddItemCraftedAbility(item, theGame.params.GetRandomMagicalBootsAbility(), true);
  5194. else
  5195. AddItemCraftedAbility(item, theGame.params.GetRandomMasterworkBootsAbility(), true);
  5196. break;
  5197. default : break;
  5198. }
  5199. }
  5200. else if ( itemCategory == 'steelsword' )
  5201. {
  5202. switch ( itemQuality )
  5203. {
  5204. case 2 :
  5205. ability = 'quality_masterwork_steelsword';
  5206. AddItemCraftedAbility(item, theGame.params.GetRandomMasterworkWeaponAbility(), true);
  5207. break;
  5208. case 3 :
  5209. ability = 'quality_magical_steelsword';
  5210. if ( ItemHasTag(item, 'EP1') )
  5211. {
  5212. AddItemCraftedAbility(item, theGame.params.GetRandomMagicalArmorAbility(), true);
  5213. break;
  5214. }
  5215.  
  5216. if ( RandF() > 0.5 )
  5217. AddItemCraftedAbility(item, theGame.params.GetRandomMagicalWeaponAbility(), true);
  5218. else
  5219. AddItemCraftedAbility(item, theGame.params.GetRandomMasterworkWeaponAbility(), true);
  5220.  
  5221. if ( RandF() > 0.5 )
  5222. AddItemCraftedAbility(item, theGame.params.GetRandomMagicalWeaponAbility(), true);
  5223. else
  5224. AddItemCraftedAbility(item, theGame.params.GetRandomMasterworkWeaponAbility(), true);
  5225. break;
  5226. default : break;
  5227. }
  5228. }
  5229. else if ( itemCategory == 'silversword' )
  5230. {
  5231. switch ( itemQuality )
  5232. {
  5233. case 2 :
  5234. ability = 'quality_masterwork_silversword';
  5235. AddItemCraftedAbility(item, theGame.params.GetRandomMasterworkWeaponAbility(), true);
  5236. break;
  5237. case 3 :
  5238. ability = 'quality_magical_silversword';
  5239. if ( ItemHasTag(item, 'EP1') )
  5240. {
  5241. AddItemCraftedAbility(item, theGame.params.GetRandomMagicalArmorAbility(), true);
  5242. break;
  5243. }
  5244.  
  5245. if ( RandF() > 0.5 )
  5246. AddItemCraftedAbility(item, theGame.params.GetRandomMagicalWeaponAbility(), true);
  5247. else
  5248. AddItemCraftedAbility(item, theGame.params.GetRandomMasterworkWeaponAbility(), true);
  5249.  
  5250. if ( RandF() > 0.5 )
  5251. AddItemCraftedAbility(item, theGame.params.GetRandomMagicalWeaponAbility(), true);
  5252. else
  5253. AddItemCraftedAbility(item, theGame.params.GetRandomMasterworkWeaponAbility(), true);
  5254. break;
  5255.  
  5256. default : break;
  5257. }
  5258. }
  5259.  
  5260. if(IsNameValid(ability))
  5261. {
  5262. AddItemCraftedAbility(item, ability, false);
  5263. SetItemModifierInt(item, 'ItemQualityModified', 1);
  5264. }
  5265. }
  5266.  
  5267. public function IncreaseNGPItemlevel(item : SItemUniqueId)
  5268. {
  5269. var i, diff : int;
  5270.  
  5271. diff = theGame.params.NewGamePlusLevelDifference();
  5272.  
  5273. if (diff > 0)
  5274. {
  5275. if ( ItemHasTag( item, 'PlayerSteelWeapon' ) )
  5276. {
  5277. for( i=0; i<diff; i+=1 )
  5278. {
  5279. AddItemCraftedAbility(item, 'autogen_fixed_steel_dmg', true );
  5280. }
  5281. }
  5282. else if ( ItemHasTag( item, 'PlayerSilverWeapon' ) )
  5283. {
  5284. for( i=0; i<diff; i+=1 )
  5285. {
  5286. AddItemCraftedAbility(item, 'autogen_fixed_silver_dmg', true );
  5287. }
  5288. }
  5289. else if ( IsItemChestArmor(item) )
  5290. {
  5291. for( i=0; i<diff; i+=1 )
  5292. {
  5293. AddItemCraftedAbility(item, 'autogen_fixed_armor_armor', true );
  5294. }
  5295. }
  5296. else if ( IsItemBoots(item) || IsItemPants(item) )
  5297. {
  5298. for( i=0; i<diff; i+=1 )
  5299. {
  5300. AddItemCraftedAbility(item, 'autogen_fixed_pants_armor', true );
  5301. }
  5302. }
  5303. else if ( IsItemGloves(item) )
  5304. {
  5305. for( i=0; i<diff; i+=1 )
  5306. {
  5307. AddItemCraftedAbility(item, 'autogen_fixed_gloves_armor', true );
  5308. }
  5309. }
  5310. }
  5311.  
  5312. SetItemModifierInt(item, 'NGPItemAdjusted', 1);
  5313. }
  5314.  
  5315. public function GetItemQuality( itemId : SItemUniqueId ) : int
  5316. {
  5317. var itemQuality : float;
  5318. var itemQualityAtribute : SAbilityAttributeValue;
  5319. var excludedTags : array<name>;
  5320. var tempItemQualityAtribute : SAbilityAttributeValue;
  5321.  
  5322.  
  5323. excludedTags.PushBack(theGame.params.OIL_ABILITY_TAG);
  5324. itemQualityAtribute = GetItemAttributeValue( itemId, 'quality', excludedTags, true );
  5325.  
  5326. itemQuality = itemQualityAtribute.valueAdditive;
  5327. if( itemQuality == 0 )
  5328. {
  5329. itemQuality = 1;
  5330. }
  5331. return RoundMath(itemQuality);
  5332. }
  5333.  
  5334. public function GetItemQualityFromName( itemName : name, out min : int, out max : int)
  5335. {
  5336. var dm : CDefinitionsManagerAccessor;
  5337. var attributeName : name;
  5338. var attributes, itemAbilities : array<name>;
  5339. var attributeMin, attributeMax : SAbilityAttributeValue;
  5340.  
  5341. var tmpInt : int;
  5342. var tmpArray : array<float>;
  5343.  
  5344. dm = theGame.GetDefinitionsManager();
  5345.  
  5346. dm.GetItemAbilitiesWithWeights(itemName, GetEntity() == thePlayer, itemAbilities, tmpArray, tmpInt, tmpInt);
  5347. attributes = dm.GetAbilitiesAttributes(itemAbilities);
  5348. for (tmpInt = 0; tmpInt < attributes.Size(); tmpInt += 1)
  5349. {
  5350. if (attributes[tmpInt] == 'quality')
  5351. {
  5352. dm.GetAbilitiesAttributeValue(itemAbilities, 'quality', attributeMin, attributeMax);
  5353. min = RoundMath(CalculateAttributeValue(attributeMin));
  5354. max = RoundMath(CalculateAttributeValue(attributeMax));
  5355. break;
  5356. }
  5357. }
  5358. }
  5359.  
  5360. public function GetRecentlyAddedItems() : array<SItemUniqueId>
  5361. {
  5362. return recentlyAddedItems;
  5363. }
  5364.  
  5365. public function GetRecentlyAddedItemsListSize() : int
  5366. {
  5367. return recentlyAddedItems.Size();
  5368. }
  5369.  
  5370. public function RemoveItemFromRecentlyAddedList( itemId : SItemUniqueId ) : bool
  5371. {
  5372. var i : int;
  5373.  
  5374. for( i = 0; i < recentlyAddedItems.Size(); i += 1 )
  5375. {
  5376. if( recentlyAddedItems[i] == itemId )
  5377. {
  5378. recentlyAddedItems.EraseFast( i );
  5379. return true;
  5380. }
  5381. }
  5382.  
  5383. return false;
  5384. }
  5385.  
  5386.  
  5387.  
  5388.  
  5389. import final function NotifyScriptedListeners( notify : bool );
  5390.  
  5391. var listeners : array< IInventoryScriptedListener >;
  5392.  
  5393. function AddListener( listener : IInventoryScriptedListener )
  5394. {
  5395. if ( listeners.FindFirst( listener ) == -1 )
  5396. {
  5397. listeners.PushBack( listener );
  5398. if ( listeners.Size() == 1 )
  5399. {
  5400. NotifyScriptedListeners( true );
  5401. }
  5402. }
  5403. }
  5404.  
  5405. function RemoveListener( listener : IInventoryScriptedListener )
  5406. {
  5407. if ( listeners.Remove( listener ) )
  5408. {
  5409. if ( listeners.Size() == 0 )
  5410. {
  5411. NotifyScriptedListeners( false );
  5412. }
  5413. }
  5414. }
  5415.  
  5416. event OnInventoryScriptedEvent( eventType : EInventoryEventType, itemId : SItemUniqueId, quantity : int, fromAssociatedInventory : bool )
  5417. {
  5418. var i, size : int;
  5419.  
  5420. size = listeners.Size();
  5421. for (i=size-1; i>=0; i-=1 )
  5422. {
  5423. listeners[i].OnInventoryScriptedEvent( eventType, itemId, quantity, fromAssociatedInventory );
  5424. }
  5425.  
  5426.  
  5427. if(GetEntity() == GetWitcherPlayer() && (eventType == IET_ItemRemoved || eventType == IET_ItemQuantityChanged) )
  5428. GetWitcherPlayer().UpdateEncumbrance();
  5429. }
  5430.  
  5431.  
  5432.  
  5433.  
  5434. public final function GetMutationResearchPoints( color : ESkillColor, item : SItemUniqueId ) : int
  5435. {
  5436. var val : SAbilityAttributeValue;
  5437. var colorAttribute : name;
  5438.  
  5439.  
  5440. if( color == SC_None || color == SC_Yellow || !IsIdValid( item ) )
  5441. {
  5442. return 0;
  5443. }
  5444.  
  5445.  
  5446. switch( color )
  5447. {
  5448. case SC_Red:
  5449. colorAttribute = 'mutation_research_points_red';
  5450. break;
  5451. case SC_Blue:
  5452. colorAttribute = 'mutation_research_points_blue';
  5453. break;
  5454. case SC_Green:
  5455. colorAttribute = 'mutation_research_points_green';
  5456. break;
  5457. }
  5458.  
  5459.  
  5460. val = GetItemAttributeValue( item, colorAttribute );
  5461.  
  5462. return ( int )val.valueAdditive;
  5463. }
  5464.  
  5465. public function GetSkillMutagenColor(item : SItemUniqueId) : ESkillColor
  5466. {
  5467. var abs : array<name>;
  5468.  
  5469.  
  5470. if(!ItemHasTag(item, 'MutagenIngredient'))
  5471. return SC_None;
  5472.  
  5473. GetItemAbilities(item, abs);
  5474.  
  5475. if(abs.Contains('mutagen_color_green')) return SC_Green;
  5476. if(abs.Contains('mutagen_color_blue')) return SC_Blue;
  5477. if(abs.Contains('mutagen_color_red')) return SC_Red;
  5478. if(abs.Contains('lesser_mutagen_color_green')) return SC_Green;
  5479. if(abs.Contains('lesser_mutagen_color_blue')) return SC_Blue;
  5480. if(abs.Contains('lesser_mutagen_color_red')) return SC_Red;
  5481. if(abs.Contains('greater_mutagen_color_green')) return SC_Green;
  5482. if(abs.Contains('greater_mutagen_color_blue')) return SC_Blue;
  5483. if(abs.Contains('greater_mutagen_color_red')) return SC_Red;
  5484.  
  5485. return SC_None;
  5486. }
  5487.  
  5488.  
  5489.  
  5490.  
  5491.  
  5492.  
  5493.  
  5494.  
  5495.  
  5496. import final function GetItemEnhancementSlotsCount( itemId : SItemUniqueId ) : int;
  5497. import final function GetItemEnhancementItems( itemId : SItemUniqueId, out names : array< name > );
  5498. import final function GetItemEnhancementCount( itemId : SItemUniqueId ) : int;
  5499. import final function GetItemColor( itemId : SItemUniqueId ) : name;
  5500. import final function IsItemColored( itemId : SItemUniqueId ) : bool;
  5501. import final function SetPreviewColor( itemId : SItemUniqueId, colorId : int );
  5502. import final function ClearPreviewColor( itemId : SItemUniqueId ) : bool;
  5503. import final function ColorItem( itemId : SItemUniqueId, dyeId : SItemUniqueId );
  5504. import final function ClearItemColor( itemId : SItemUniqueId ) : bool;
  5505. import final function EnchantItem( enhancedItemId : SItemUniqueId, enchantmentName : name, enchantmentStat : name ) : bool;
  5506. import final function GetEnchantment( enhancedItemId : SItemUniqueId ) : name;
  5507. import final function IsItemEnchanted( enhancedItemId : SItemUniqueId ) : bool;
  5508. import final function UnenchantItem( enhancedItemId : SItemUniqueId ) : bool;
  5509. import private function EnhanceItem( enhancedItemId : SItemUniqueId, extensionItemId : SItemUniqueId ) : bool;
  5510. import private function RemoveItemEnhancementByIndex( enhancedItemId : SItemUniqueId, slotIndex : int ) : bool;
  5511. import private function RemoveItemEnhancementByName( enhancedItemId : SItemUniqueId, extensionItemName : name ) : bool;
  5512. import final function PreviewItemAttributeAfterUpgrade( baseItemId : SItemUniqueId, upgradeItemId : SItemUniqueId, attributeName : name, optional baseInventory : CInventoryComponent, optional upgradeInventory : CInventoryComponent ) : SAbilityAttributeValue;
  5513. import final function HasEnhancementItemTag( enhancedItemId : SItemUniqueId, slotIndex : int, tag : name ) : bool;
  5514.  
  5515.  
  5516. function NotifyEnhancedItem( enhancedItemId : SItemUniqueId )
  5517. {
  5518. var weapons : array<SItemUniqueId>;
  5519. var sword : CWitcherSword;
  5520. var i : int;
  5521.  
  5522. sword = (CWitcherSword) GetItemEntityUnsafe( enhancedItemId );
  5523. sword.UpdateEnhancements( this );
  5524. }
  5525.  
  5526. function EnhanceItemScript( enhancedItemId : SItemUniqueId, extensionItemId : SItemUniqueId ) : bool
  5527. {
  5528. var i : int;
  5529. var enhancements : array<name>;
  5530. var runeword : Runeword;
  5531.  
  5532. if ( EnhanceItem( enhancedItemId, extensionItemId ) )
  5533. {
  5534. NotifyEnhancedItem( enhancedItemId );
  5535.  
  5536. GetItemEnhancementItems( enhancedItemId, enhancements );
  5537. if ( theGame.runewordMgr.GetRuneword( enhancements, runeword ) )
  5538. {
  5539. for ( i = 0; i < runeword.abilities.Size(); i+=1 )
  5540. {
  5541. AddItemBaseAbility( enhancedItemId, runeword.abilities[i] );
  5542. }
  5543. }
  5544. return true;
  5545. }
  5546. return false;
  5547. }
  5548.  
  5549. function RemoveItemEnhancementByIndexScript( enhancedItemId : SItemUniqueId, slotIndex : int ) : bool
  5550. {
  5551. var i : int;
  5552. var enhancements : array<name>;
  5553. var runeword : Runeword;
  5554. var hasRuneword : bool;
  5555. var names : array< name >;
  5556.  
  5557. GetItemEnhancementItems( enhancedItemId, enhancements );
  5558. hasRuneword = theGame.runewordMgr.GetRuneword( enhancements, runeword );
  5559.  
  5560. GetItemEnhancementItems( enhancedItemId, names );
  5561.  
  5562. if ( RemoveItemEnhancementByIndex( enhancedItemId, slotIndex ) )
  5563. {
  5564. NotifyEnhancedItem( enhancedItemId );
  5565.  
  5566.  
  5567.  
  5568. if ( hasRuneword )
  5569. {
  5570.  
  5571. for ( i = 0; i < runeword.abilities.Size(); i+=1 )
  5572. {
  5573. RemoveItemBaseAbility( enhancedItemId, runeword.abilities[i] );
  5574. }
  5575. }
  5576. return true;
  5577. }
  5578. return false;
  5579. }
  5580.  
  5581.  
  5582. function RemoveItemEnhancementByNameScript( enhancedItemId : SItemUniqueId, extensionItemName : name ) : bool
  5583. {
  5584. var i : int;
  5585. var enhancements : array<name>;
  5586. var runeword : Runeword;
  5587. var hasRuneword : bool;
  5588.  
  5589. GetItemEnhancementItems( enhancedItemId, enhancements );
  5590. hasRuneword = theGame.runewordMgr.GetRuneword( enhancements, runeword );
  5591.  
  5592.  
  5593. if ( RemoveItemEnhancementByName( enhancedItemId, extensionItemName ) )
  5594. {
  5595. NotifyEnhancedItem( enhancedItemId );
  5596.  
  5597.  
  5598. AddAnItem( extensionItemName, 1, true, true );
  5599. if ( hasRuneword )
  5600. {
  5601.  
  5602. for ( i = 0; i < runeword.abilities.Size(); i+=1 )
  5603. {
  5604. RemoveItemBaseAbility( enhancedItemId, runeword.abilities[i] );
  5605. }
  5606. }
  5607. return true;
  5608. }
  5609. return false;
  5610. }
  5611.  
  5612. function RemoveAllItemEnhancements( enhancedItemId : SItemUniqueId )
  5613. {
  5614. var count, i : int;
  5615.  
  5616. count = GetItemEnhancementCount( enhancedItemId );
  5617. for ( i = count - 1; i >= 0; i-=1 )
  5618. {
  5619. RemoveItemEnhancementByIndexScript( enhancedItemId, i );
  5620. }
  5621. }
  5622.  
  5623. function GetHeldAndMountedItems( out items : array< SItemUniqueId > )
  5624. {
  5625. var allItems : array< SItemUniqueId >;
  5626. var i : int;
  5627. var itemName : name;
  5628.  
  5629. GetAllItems( allItems );
  5630.  
  5631. items.Clear();
  5632. for( i = 0; i < allItems.Size(); i += 1 )
  5633. {
  5634. if ( IsItemHeld( allItems[ i ] ) || IsItemMounted( allItems[ i ] ) )
  5635. {
  5636. items.PushBack( allItems[ i ] );
  5637. }
  5638. }
  5639. }
  5640.  
  5641.  
  5642. public function GetHasValidDecorationItems( items : array<SItemUniqueId>, decoration : W3HouseDecorationBase ) : bool
  5643. {
  5644. var i, size : int;
  5645.  
  5646. size = items.Size();
  5647.  
  5648.  
  5649. if(size == 0 )
  5650. {
  5651. LogChannel( 'houseDecorations', "No items with valid tag were found!" );
  5652. return false;
  5653. }
  5654.  
  5655.  
  5656. for( i=0; i < size; i+= 1 )
  5657. {
  5658.  
  5659. if( GetWitcherPlayer().IsItemEquipped( items[i] ) )
  5660. {
  5661. LogChannel( 'houseDecorations', "Found item is equipped, erasing..." );
  5662. continue;
  5663. }
  5664.  
  5665.  
  5666. if( IsItemQuest( items[i] ) && decoration.GetAcceptQuestItems() == false )
  5667. {
  5668. LogChannel( 'houseDecorations', "Found item is quest item, and quest items are not accepted, erasing..." );
  5669. continue;
  5670. }
  5671.  
  5672.  
  5673. if( decoration.GetItemHasForbiddenTag( items[i] ) )
  5674. {
  5675. LogChannel( 'houseDecorations', "Found item has a forbidden tag, erasing..." );
  5676. continue;
  5677. }
  5678.  
  5679. LogChannel( 'houseDecorations', "Item checks out: "+ GetItemName( items[i] ) );
  5680. return true;
  5681. }
  5682. LogChannel( 'houseDecorations', "No valid items were found!" );
  5683.  
  5684. return false;
  5685. }
  5686.  
  5687.  
  5688. function GetMissingCards() : array< name >
  5689. {
  5690. var defMgr : CDefinitionsManagerAccessor = theGame.GetDefinitionsManager();
  5691. var allCardNames : array< name > = defMgr.GetItemsWithTag(theGame.params.GWINT_CARD_ACHIEVEMENT_TAG);
  5692. var playersCards : array< SItemUniqueId > = GetItemsByTag(theGame.params.GWINT_CARD_ACHIEVEMENT_TAG);
  5693. var playersCardLocs : array< string >;
  5694. var missingCardLocs : array< string >;
  5695. var missingCards : array< name >;
  5696. var i, j : int;
  5697. var found : bool;
  5698.  
  5699.  
  5700. for ( i = 0; i < allCardNames.Size(); i+=1 )
  5701. {
  5702. found = false;
  5703.  
  5704. for ( j = 0; j < playersCards.Size(); j+=1 )
  5705. {
  5706. if ( allCardNames[i] == GetItemName( playersCards[j] ) )
  5707. {
  5708. found = true;
  5709. playersCardLocs.PushBack( defMgr.GetItemLocalisationKeyName ( allCardNames[i] ) );
  5710. break;
  5711. }
  5712. }
  5713.  
  5714. if ( !found )
  5715. {
  5716. missingCardLocs.PushBack( defMgr.GetItemLocalisationKeyName( allCardNames[i] ) );
  5717. missingCards.PushBack( allCardNames[i] );
  5718. }
  5719. }
  5720.  
  5721. if( missingCardLocs.Size() < 2 )
  5722. {
  5723. return missingCards;
  5724. }
  5725.  
  5726.  
  5727. for ( i = missingCardLocs.Size()-1 ; i >= 0 ; i-=1 )
  5728. {
  5729. for ( j = 0 ; j < playersCardLocs.Size() ; j+=1 )
  5730. {
  5731. if ( missingCardLocs[i] == playersCardLocs[j]
  5732. && missingCardLocs[i] != "gwint_name_emhyr" && missingCardLocs[i] != "gwint_name_foltest"
  5733. && missingCardLocs[i] != "gwint_name_francesca" && missingCardLocs[i] != "gwint_name_eredin" )
  5734. {
  5735. missingCardLocs.EraseFast( i );
  5736. missingCards.EraseFast( i );
  5737. break;
  5738. }
  5739. }
  5740. }
  5741.  
  5742. return missingCards;
  5743. }
  5744.  
  5745. public function FindCardSources( missingCards : array< name > ) : array< SCardSourceData >
  5746. {
  5747. var sourceCSV : C2dArray;
  5748. var sourceTable : array< SCardSourceData >;
  5749. var sourceRemaining : array< SCardSourceData >;
  5750. var sourceCount, i, j : int;
  5751.  
  5752. if ( theGame.IsFinalBuild() )
  5753. {
  5754. sourceCSV = LoadCSV("gameplay\globals\card_sources.csv");
  5755. }
  5756. else
  5757. {
  5758. sourceCSV = LoadCSV("qa\card_sources.csv");
  5759. }
  5760.  
  5761. sourceCount = sourceCSV.GetNumRows();
  5762. sourceTable.Resize(sourceCount);
  5763.  
  5764. for ( i = 0 ; i < sourceCount ; i+=1 )
  5765. {
  5766. sourceTable[i].cardName = sourceCSV.GetValueAsName("CardName",i);
  5767. sourceTable[i].source = sourceCSV.GetValue("Source",i);
  5768. sourceTable[i].originArea = sourceCSV.GetValue("OriginArea",i);
  5769. sourceTable[i].originQuest = sourceCSV.GetValue("OriginQuest",i);
  5770. sourceTable[i].details = sourceCSV.GetValue("Details",i);
  5771. sourceTable[i].coords = sourceCSV.GetValue("Coords",i);
  5772. }
  5773.  
  5774. for ( i = 0 ; i < missingCards.Size() ; i+=1 )
  5775. {
  5776. for ( j = 0 ; j < sourceCount ; j+=1 )
  5777. {
  5778. if ( sourceTable[j].cardName == missingCards[i] )
  5779. {
  5780. sourceRemaining.PushBack( sourceTable[j] );
  5781. }
  5782. }
  5783. }
  5784.  
  5785. return sourceRemaining;
  5786. }
  5787.  
  5788. public function GetGwentAlmanacContents() : string
  5789. {
  5790. var sourcesRemaining : array< SCardSourceData >;
  5791. var missingCards : array< string >;
  5792. var almanacContents : string;
  5793. var i : int;
  5794. var NML, Novigrad, Skellige, Prologue, Vizima, KaerMorhen, Random : int;
  5795.  
  5796. sourcesRemaining = FindCardSources( GetMissingCards() );
  5797.  
  5798. for ( i = 0 ; i < sourcesRemaining.Size() ; i+=1 )
  5799. {
  5800. switch ( sourcesRemaining[i].originArea )
  5801. {
  5802. case "NML":
  5803. NML += 1;
  5804. break;
  5805. case "Novigrad":
  5806. Novigrad += 1;
  5807. break;
  5808. case "Skellige":
  5809. Skellige += 1;
  5810. break;
  5811. case "Prologue":
  5812. Prologue += 1;
  5813. break;
  5814. case "Vizima":
  5815. Vizima += 1;
  5816. break;
  5817. case "KaerMorhen":
  5818. KaerMorhen += 1;
  5819. break;
  5820. case "Random":
  5821. Random += 1;
  5822. break;
  5823. default:
  5824. break;
  5825. }
  5826. }
  5827.  
  5828. if ( NML + Novigrad + Skellige + Prologue + Vizima + KaerMorhen + Random == 0 )
  5829. {
  5830. almanacContents = GetLocStringByKeyExt( "gwent_almanac_text" ) + "<br>";
  5831. almanacContents += GetLocStringByKeyExt( "gwent_almanac_completed_text" );
  5832. }
  5833. else
  5834. {
  5835. almanacContents = GetLocStringByKeyExt( "gwent_almanac_text" ) + "<br>";
  5836. if ( NML > 0 )
  5837. {
  5838. almanacContents += GetLocStringByKeyExt( "location_name_velen" ) + ": " + NML + "<br>";
  5839. }
  5840. if ( Novigrad > 0 )
  5841. {
  5842. almanacContents += GetLocStringByKeyExt( "map_location_novigrad" ) + ": " + Novigrad + "<br>";
  5843. }
  5844. if ( Skellige > 0 )
  5845. {
  5846. almanacContents += GetLocStringByKeyExt( "map_location_skellige" ) + ": " + Skellige + "<br>";
  5847. }
  5848. if ( Prologue > 0 )
  5849. {
  5850. almanacContents += GetLocStringByKeyExt( "map_location_prolog_village" ) + ": " + Prologue + "<br>";
  5851. }
  5852. if ( Vizima > 0 )
  5853. {
  5854. almanacContents += GetLocStringByKeyExt( "map_location_wyzima_castle" ) + ": " + Vizima + "<br>";
  5855. }
  5856. if ( KaerMorhen > 0 )
  5857. {
  5858. almanacContents += GetLocStringByKeyExt( "map_location_kaer_morhen" ) + ": " + KaerMorhen + "<br>";
  5859. }
  5860. almanacContents += GetLocStringByKeyExt( "gwent_source_random" ) + ": " + Random;
  5861. }
  5862.  
  5863. return almanacContents;
  5864. }
  5865.  
  5866. public function GetUnusedMutagensCount(itemName:name):int
  5867. {
  5868. var items : array<SItemUniqueId>;
  5869. var equippedOnSlot : EEquipmentSlots;
  5870. var availableCount : int;
  5871. var res, i : int = 0;
  5872.  
  5873. items = thePlayer.inv.GetItemsByName(itemName);
  5874.  
  5875. for(i=0; i<items.Size(); i+=1)
  5876. {
  5877. equippedOnSlot = GetWitcherPlayer().GetItemSlot( items[i] );
  5878.  
  5879. if(equippedOnSlot == EES_InvalidSlot)
  5880. {
  5881. availableCount = thePlayer.inv.GetItemQuantity( items[i] );
  5882. res = res + availableCount;
  5883. }
  5884. }
  5885.  
  5886. return res;
  5887. }
  5888.  
  5889. public function GetFirstUnusedMutagenByName( itemName : name ):SItemUniqueId
  5890. {
  5891. var items : array<SItemUniqueId>;
  5892. var equippedOnSlot : EEquipmentSlots;
  5893. var availableCount : int;
  5894. var res, i : int = 0;
  5895.  
  5896. items = thePlayer.inv.GetItemsByName(itemName);
  5897.  
  5898. for(i=0; i<items.Size(); i+=1)
  5899. {
  5900. equippedOnSlot = GetWitcherPlayer().GetItemSlot( items[i] );
  5901.  
  5902. if( equippedOnSlot == EES_InvalidSlot )
  5903. {
  5904. return items[i];
  5905. }
  5906. }
  5907.  
  5908. return GetInvalidUniqueId();
  5909. }
  5910.  
  5911. //modFriendlyStash begin
  5912. public function RemoveUnusedMutagensCountById( itemId:SItemUniqueId, count:int ):bool
  5913. {
  5914. return RemoveUnusedMutagensCount( thePlayer.inv.GetItemName( itemId ), count );
  5915. }
  5916.  
  5917. public function RemoveUnusedMutagensCount( itemName:name, count:int ):bool
  5918. {
  5919. var items : array<SItemUniqueId>;
  5920. var curItem : SItemUniqueId;
  5921. var equippedOnSlot : EEquipmentSlots;
  5922.  
  5923. var i : int;
  5924. var itemRemoved : int;
  5925. var availableToRemoved : int;
  5926. var removedRes : bool;
  5927.  
  5928. itemRemoved = 0;
  5929. items = thePlayer.inv.GetItemsByName( itemName );
  5930.  
  5931. for( i=0; i < items.Size(); i+=1 )
  5932. {
  5933. curItem = items[ i ];
  5934. equippedOnSlot = GetWitcherPlayer().GetItemSlot( curItem );
  5935.  
  5936. if( equippedOnSlot == EES_InvalidSlot )
  5937. {
  5938. availableToRemoved = Min( thePlayer.inv.GetItemQuantity( curItem ), ( count - itemRemoved ) );
  5939. removedRes = thePlayer.inv.RemoveItem(items[i], availableToRemoved);
  5940.  
  5941. if (removedRes)
  5942. {
  5943. itemRemoved = itemRemoved + availableToRemoved;
  5944.  
  5945. if (itemRemoved >= count)
  5946. {
  5947. return true;
  5948. }
  5949. }
  5950.  
  5951. }
  5952. }
  5953. return false;
  5954. }
  5955. //modFriendlyStash end
  5956.  
  5957. }
  5958.  
  5959. exec function findMissingCards( optional card : name )
  5960. {
  5961. var inv : CInventoryComponent = thePlayer.GetInventory();
  5962. var sourcesRemaining : array< SCardSourceData >;
  5963. var missingCards : array< name >;
  5964. var i : int;
  5965. var sourceLogString : string;
  5966.  
  5967. if ( card != '' )
  5968. {
  5969. missingCards.PushBack( card );
  5970. }
  5971. else
  5972. {
  5973. missingCards = inv.GetMissingCards();
  5974. }
  5975.  
  5976. sourcesRemaining = inv.FindCardSources( missingCards );
  5977.  
  5978. for ( i = 0 ; i < sourcesRemaining.Size() ; i+=1 )
  5979. {
  5980. sourceLogString = sourcesRemaining[i].cardName + " is a " + sourcesRemaining[i].source ;
  5981. if ( sourcesRemaining[i].originArea == "Random" )
  5982. {
  5983. sourceLogString += " card from a random merchant.";
  5984. }
  5985. else
  5986. {
  5987. sourceLogString += " item in " + sourcesRemaining[i].originArea + " from ";
  5988.  
  5989. if ( sourcesRemaining[i].originQuest != "" )
  5990. {
  5991. sourceLogString += sourcesRemaining[i].originQuest + " , ";
  5992. }
  5993.  
  5994. sourceLogString += sourcesRemaining[i].details;
  5995. }
  5996. Log( sourceLogString );
  5997.  
  5998. if ( sourcesRemaining[i].coords != "" )
  5999. {
  6000. Log( sourcesRemaining[i].coords );
  6001. }
  6002. }
  6003. }
  6004.  
  6005. exec function slotTest()
  6006. {
  6007. var inv : CInventoryComponent = thePlayer.inv;
  6008. var weaponItemId : SItemUniqueId;
  6009. var upgradeItemId : SItemUniqueId;
  6010. var i : int;
  6011.  
  6012. LogChannel('SlotTest', "----------------------------------------------------------------");
  6013.  
  6014.  
  6015. inv.AddAnItem( 'Perun rune', 1);
  6016. inv.AddAnItem( 'Svarog rune', 1);
  6017.  
  6018.  
  6019. for ( i = 0; i < 2; i += 1 )
  6020. {
  6021.  
  6022. if ( !GetItem( inv, 'steelsword', weaponItemId ) ||
  6023. !GetItem( inv, 'upgrade', upgradeItemId ) )
  6024. {
  6025. return;
  6026. }
  6027.  
  6028.  
  6029. PrintItem( inv, weaponItemId );
  6030.  
  6031.  
  6032. if ( inv.EnhanceItemScript( weaponItemId, upgradeItemId ) )
  6033. {
  6034. LogChannel('SlotTest', "Enhanced item");
  6035. }
  6036. else
  6037. {
  6038. LogChannel('SlotTest', "Failed to enhance item!");
  6039. }
  6040. }
  6041.  
  6042.  
  6043. if ( !GetItem( inv, 'steelsword', weaponItemId ) )
  6044. {
  6045. return;
  6046. }
  6047.  
  6048.  
  6049. PrintItem( inv, weaponItemId );
  6050.  
  6051.  
  6052. if ( inv.RemoveItemEnhancementByNameScript( weaponItemId, 'Svarog rune' ) )
  6053. {
  6054. LogChannel('SlotTest', "Removed enhancement");
  6055. }
  6056. else
  6057. {
  6058. LogChannel('SlotTest', "Failed to remove enhancement!");
  6059. }
  6060.  
  6061.  
  6062. if ( !GetItem( inv, 'steelsword', weaponItemId ) )
  6063. {
  6064. return;
  6065. }
  6066.  
  6067.  
  6068. PrintItem( inv, weaponItemId );
  6069.  
  6070.  
  6071. if ( inv.RemoveItemEnhancementByIndexScript( weaponItemId, 0 ) )
  6072. {
  6073. LogChannel('SlotTest', "Removed enhancement");
  6074. }
  6075. else
  6076. {
  6077. LogChannel('SlotTest', "Failed to remove enhancement!");
  6078. }
  6079.  
  6080.  
  6081. if ( !GetItem( inv, 'steelsword', weaponItemId ) )
  6082. {
  6083. return;
  6084. }
  6085.  
  6086.  
  6087. PrintItem( inv, weaponItemId );
  6088. }
  6089.  
  6090. function GetItem( inv : CInventoryComponent, category : name, out itemId : SItemUniqueId ) : bool
  6091. {
  6092. var itemIds : array< SItemUniqueId >;
  6093.  
  6094. itemIds = inv.GetItemsByCategory( category );
  6095. if ( itemIds.Size() > 0 )
  6096. {
  6097. itemId = itemIds[ 0 ];
  6098. return true;
  6099. }
  6100. LogChannel( 'SlotTest', "Failed to get item with GetItemsByCategory( '" + category + "' )" );
  6101. return false;
  6102. }
  6103.  
  6104. function PrintItem( inv : CInventoryComponent, weaponItemId : SItemUniqueId )
  6105. {
  6106. var names : array< name >;
  6107. var tags : array< name >;
  6108. var i : int;
  6109. var line : string;
  6110. var attribute : SAbilityAttributeValue;
  6111.  
  6112. LogChannel('SlotTest', "Slots: " + inv.GetItemEnhancementCount( weaponItemId ) + "/" + inv.GetItemEnhancementSlotsCount( weaponItemId ) );
  6113. inv.GetItemEnhancementItems( weaponItemId, names );
  6114. if ( names.Size() > 0 )
  6115. {
  6116. for ( i = 0; i < names.Size(); i += 1 )
  6117. {
  6118. if ( i == 0 )
  6119. {
  6120. line += "[";
  6121. }
  6122. line += names[ i ];
  6123. if ( i < names.Size() - 1 )
  6124. {
  6125. line += ", ";
  6126. }
  6127. if ( i == names.Size() - 1 )
  6128. {
  6129. line += "]";
  6130. }
  6131. }
  6132. }
  6133. else
  6134. {
  6135. line += "[]";
  6136. }
  6137. LogChannel('SlotTest', "Upgrade item names " + line );
  6138.  
  6139. tags.PushBack('Upgrade');
  6140.  
  6141. attribute = inv.GetItemAttributeValue( weaponItemId, 'PhysicalDamage' );
  6142. LogChannel('SlotTest', "Attribute '" + 'PhysicalDamage' + "' " + attribute.valueBase + " " + attribute.valueMultiplicative + " " + attribute.valueAdditive );
  6143. attribute = inv.GetItemAttributeValue( weaponItemId, 'SilverDamage' );
  6144. LogChannel('SlotTest', "Attribute '" + 'SilverDamage' + "' " + attribute.valueBase + " " + attribute.valueMultiplicative + " " + attribute.valueAdditive );
  6145.  
  6146. attribute = inv.GetItemAttributeValue( weaponItemId, 'PhysicalDamage', tags, true );
  6147. LogChannel('SlotTest', "Attribute '" + 'PhysicalDamage' + "' " + attribute.valueBase + " " + attribute.valueMultiplicative + " " + attribute.valueAdditive );
  6148. attribute = inv.GetItemAttributeValue( weaponItemId, 'SilverDamage', tags, true );
  6149. LogChannel('SlotTest', "Attribute '" + 'SilverDamage' + "' " + attribute.valueBase + " " + attribute.valueMultiplicative + " " + attribute.valueAdditive );
  6150.  
  6151. attribute = inv.GetItemAttributeValue( weaponItemId, 'PhysicalDamage', tags );
  6152. LogChannel('SlotTest', "Attribute '" + 'PhysicalDamage' + "' " + attribute.valueBase + " " + attribute.valueMultiplicative + " " + attribute.valueAdditive );
  6153. attribute = inv.GetItemAttributeValue( weaponItemId, 'SilverDamage', tags );
  6154. LogChannel('SlotTest', "Attribute '" + 'SilverDamage' + "' " + attribute.valueBase + " " + attribute.valueMultiplicative + " " + attribute.valueAdditive );
  6155.  
  6156. }
  6157.  
  6158. function PlayItemEquipSound( itemCategory : name ) : void
  6159. {
  6160. switch( itemCategory )
  6161. {
  6162. case 'steelsword' :
  6163. theSound.SoundEvent("gui_inventory_steelsword_attach");
  6164. return;
  6165. case 'silversword' :
  6166. theSound.SoundEvent("gui_inventory_silversword_attach");
  6167. return;
  6168. case 'secondary' :
  6169. theSound.SoundEvent("gui_inventory_weapon_attach");
  6170. return;
  6171. case 'armor' :
  6172. theSound.SoundEvent("gui_inventory_armor_attach");
  6173. return;
  6174. case 'pants' :
  6175. theSound.SoundEvent("gui_inventory_pants_attach");
  6176. return;
  6177. case 'boots' :
  6178. theSound.SoundEvent("gui_inventory_boots_attach");
  6179. return;
  6180. case 'gloves' :
  6181. theSound.SoundEvent("gui_inventory_gauntlet_attach");
  6182. return;
  6183. case 'potion' :
  6184. theSound.SoundEvent("gui_inventory_potion_attach");
  6185. return;
  6186. case 'petard' :
  6187. theSound.SoundEvent("gui_inventory_bombs_attach");
  6188. return;
  6189. case 'ranged' :
  6190. theSound.SoundEvent("gui_inventory_ranged_attach");
  6191. return;
  6192. case 'herb' :
  6193. theSound.SoundEvent("gui_pick_up_herbs");
  6194. return;
  6195. case 'trophy' :
  6196. case 'horse_bag' :
  6197. theSound.SoundEvent("gui_inventory_horse_bage_attach");
  6198. return;
  6199. case 'horse_blinder' :
  6200. theSound.SoundEvent("gui_inventory_horse_blinder_attach");
  6201. return;
  6202. case 'horse_saddle' :
  6203. theSound.SoundEvent("gui_inventory_horse_saddle_attach");
  6204. return;
  6205. default :
  6206. theSound.SoundEvent("gui_inventory_other_attach");
  6207. return;
  6208. }
  6209. }
  6210.  
  6211. function PlayItemUnequipSound( itemCategory : name ) : void
  6212. {
  6213. switch( itemCategory )
  6214. {
  6215. case 'steelsword' :
  6216. theSound.SoundEvent("gui_inventory_steelsword_back");
  6217. return;
  6218. case 'silversword' :
  6219. theSound.SoundEvent("gui_inventory_silversword_back");
  6220. return;
  6221. case 'secondary' :
  6222. theSound.SoundEvent("gui_inventory_weapon_back");
  6223. return;
  6224. case 'armor' :
  6225. theSound.SoundEvent("gui_inventory_armor_back");
  6226. return;
  6227. case 'pants' :
  6228. theSound.SoundEvent("gui_inventory_pants_back");
  6229. return;
  6230. case 'boots' :
  6231. theSound.SoundEvent("gui_inventory_boots_back");
  6232. return;
  6233. case 'gloves' :
  6234. theSound.SoundEvent("gui_inventory_gauntlet_back");
  6235. return;
  6236. case 'petard' :
  6237. theSound.SoundEvent("gui_inventory_bombs_back");
  6238. return;
  6239. case 'potion' :
  6240. theSound.SoundEvent("gui_inventory_potion_back");
  6241. return;
  6242. case 'ranged' :
  6243. theSound.SoundEvent("gui_inventory_ranged_back");
  6244. return;
  6245. case 'trophy' :
  6246. case 'horse_bag' :
  6247. theSound.SoundEvent("gui_inventory_horse_bage_back");
  6248. return;
  6249. case 'horse_blinder' :
  6250. theSound.SoundEvent("gui_inventory_horse_blinder_back");
  6251. return;
  6252. case 'horse_saddle' :
  6253. theSound.SoundEvent("gui_inventory_horse_saddle_back");
  6254. return;
  6255. default :
  6256. theSound.SoundEvent("gui_inventory_other_back");
  6257. return;
  6258. }
  6259. }
  6260.  
  6261. function PlayItemConsumeSound( item : SItemUniqueId ) : void
  6262. {
  6263. if( thePlayer.GetInventory().ItemHasTag( item, 'Drinks' ) || thePlayer.GetInventory().ItemHasTag( item, 'Alcohol' ) )
  6264. {
  6265. theSound.SoundEvent('gui_inventory_drink');
  6266. }
  6267. else
  6268. {
  6269. theSound.SoundEvent('gui_inventory_eat');
  6270. }
  6271. }
  6272.  
  6273.  
  6274.  
  6275.  
  6276.  
Add Comment
Please, Sign In to add comment