Advertisement
Guest User

Error [mod0000_mergedfiles]game\components\ 4749 and 5851

a guest
Nov 8th, 2018
435
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 171.36 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. SetItemDurability( itemId, GetItemMaxDurability(itemId));
  1331. }
  1332.  
  1333.  
  1334. public function ReduceItemDurability(itemId : SItemUniqueId, optional forced : bool) : bool
  1335. {
  1336. SetItemDurabilityScript( itemId, GetItemMaxDurability(itemId));
  1337. return true;
  1338. }
  1339.  
  1340. public function GetItemDurabilityRatio(itemId : SItemUniqueId) : float
  1341. {
  1342. if ( !IsIdValid( itemId ) || !HasItemDurability( itemId ) )
  1343. return -1;
  1344.  
  1345. return GetItemDurability(itemId) / GetItemMaxDurability(itemId);
  1346. }
  1347.  
  1348.  
  1349.  
  1350.  
  1351.  
  1352.  
  1353. public function GetItemResistStatWithDurabilityModifiers(itemId : SItemUniqueId, stat : ECharacterDefenseStats, out points : SAbilityAttributeValue, out percents : SAbilityAttributeValue)
  1354. {
  1355. var mult : float;
  1356. var null : SAbilityAttributeValue;
  1357.  
  1358. points = null;
  1359. percents = null;
  1360. if(!IsItemAnyArmor(itemId))
  1361. return;
  1362.  
  1363. mult = theGame.params.GetDurabilityMultiplier(GetItemDurabilityRatio(itemId), false);
  1364.  
  1365. points = GetItemAttributeValue(itemId, ResistStatEnumToName(stat, true));
  1366. percents = GetItemAttributeValue(itemId, ResistStatEnumToName(stat, false));
  1367.  
  1368. points = points * mult;
  1369. percents = percents * mult;
  1370. }
  1371.  
  1372.  
  1373. public function GetItemResistanceTypes(id : SItemUniqueId) : array<ECharacterDefenseStats>
  1374. {
  1375. var ret : array<ECharacterDefenseStats>;
  1376. var i : int;
  1377. var stat : ECharacterDefenseStats;
  1378. var atts : array<name>;
  1379. var tmpBool : bool;
  1380.  
  1381. if(!IsIdValid(id))
  1382. return ret;
  1383.  
  1384. GetItemAttributes(id, atts);
  1385. for(i=0; i<atts.Size(); i+=1)
  1386. {
  1387. stat = ResistStatNameToEnum(atts[i], tmpBool);
  1388. if(stat != CDS_None && !ret.Contains(stat))
  1389. ret.PushBack(stat);
  1390. }
  1391.  
  1392. return ret;
  1393. }
  1394.  
  1395. import final function GetItemModifierFloat( itemId : SItemUniqueId, modName : name, optional defValue : float ) : float;
  1396. import final function SetItemModifierFloat( itemId : SItemUniqueId, modName : name, val : float);
  1397. import final function GetItemModifierInt ( itemId : SItemUniqueId, modName : name, optional defValue : int ) : int;
  1398. import final function SetItemModifierInt ( itemId : SItemUniqueId, modName : name, val : int );
  1399.  
  1400.  
  1401. import final function ActivateQuestBonus();
  1402.  
  1403.  
  1404. import final function GetItemSetName( itemId : SItemUniqueId ) : name;
  1405.  
  1406.  
  1407. import final function AddItemCraftedAbility( itemId : SItemUniqueId, abilityName : name, optional allowDuplicate : bool );
  1408.  
  1409.  
  1410. import final function RemoveItemCraftedAbility( itemId : SItemUniqueId, abilityName : name );
  1411.  
  1412.  
  1413. import final function AddItemBaseAbility(item : SItemUniqueId, abilityName : name);
  1414.  
  1415.  
  1416. import final function RemoveItemBaseAbility(item : SItemUniqueId, abilityName : name);
  1417.  
  1418.  
  1419. import final function DespawnItem( itemId : SItemUniqueId );
  1420.  
  1421.  
  1422.  
  1423.  
  1424.  
  1425.  
  1426. import final function GetInventoryItemUIData( item : SItemUniqueId ) : SInventoryItemUIData;
  1427.  
  1428.  
  1429. import final function SetInventoryItemUIData( item : SItemUniqueId, data : SInventoryItemUIData );
  1430.  
  1431. import final function SortInventoryUIData();
  1432.  
  1433.  
  1434.  
  1435.  
  1436.  
  1437.  
  1438. import final function PrintInfo();
  1439.  
  1440.  
  1441.  
  1442.  
  1443.  
  1444.  
  1445. import final function EnableLoot( enable : bool );
  1446.  
  1447.  
  1448. import final function UpdateLoot();
  1449.  
  1450.  
  1451. import final function AddItemsFromLootDefinition( lootDefinitionName : name );
  1452.  
  1453.  
  1454. import final function IsLootRenewable() : bool;
  1455.  
  1456.  
  1457. import final function IsReadyToRenew() : bool;
  1458.  
  1459.  
  1460.  
  1461.  
  1462.  
  1463.  
  1464. function Created()
  1465. {
  1466. LoadBooksDefinitions();
  1467. }
  1468.  
  1469. function ClearGwintCards()
  1470. {
  1471. var attr : SAbilityAttributeValue;
  1472. var allItems : array<SItemUniqueId>;
  1473. var card : array<SItemUniqueId>;
  1474. var iHave, shopHave, cardLimit, delta : int;
  1475. var curItem : SItemUniqueId;
  1476. var i : int;
  1477.  
  1478. allItems = GetItemsByCategory('gwint');
  1479. for(i=allItems.Size()-1; i >= 0; i-=1)
  1480. {
  1481. curItem = allItems[i];
  1482.  
  1483. attr = GetItemAttributeValue( curItem, 'max_count');
  1484. card = thePlayer.GetInventory().GetItemsByName( GetItemName( curItem ) );
  1485. iHave = thePlayer.GetInventory().GetItemQuantity( card[0] );
  1486. cardLimit = RoundF(attr.valueBase);
  1487. shopHave = GetItemQuantity( curItem );
  1488.  
  1489. if (iHave > 0 && shopHave > 0)
  1490. {
  1491. delta = shopHave - (cardLimit - iHave);
  1492.  
  1493. if ( delta > 0 )
  1494. {
  1495. RemoveItem( curItem, delta );
  1496. }
  1497. }
  1498. }
  1499. }
  1500.  
  1501. function ClearTHmaps()
  1502. {
  1503. var attr : SAbilityAttributeValue;
  1504. var allItems : array<SItemUniqueId>;
  1505. var map : array<SItemUniqueId>;
  1506. var i : int;
  1507. var thCompleted : bool;
  1508. var iHave, shopHave : int;
  1509.  
  1510. allItems = GetItemsByTag('ThMap');
  1511. for(i=allItems.Size()-1; i >= 0; i-=1)
  1512. {
  1513. attr = GetItemAttributeValue( allItems[i], 'max_count');
  1514. map = thePlayer.GetInventory().GetItemsByName( GetItemName( allItems[i] ) );
  1515. thCompleted = FactsDoesExist(GetItemName(allItems[i]));
  1516. iHave = thePlayer.GetInventory().GetItemQuantity( map[0] );
  1517. shopHave = RoundF(attr.valueBase);
  1518.  
  1519. if ( iHave >= shopHave || thCompleted )
  1520. {
  1521. RemoveItem( allItems[i], GetItemQuantity( allItems[i] ) );
  1522. }
  1523. }
  1524. }
  1525.  
  1526.  
  1527. public final function ClearKnownRecipes()
  1528. {
  1529. var witcher : W3PlayerWitcher;
  1530. var recipes, craftRecipes : array<name>;
  1531. var i : int;
  1532. var itemName : name;
  1533. var allItems : array<SItemUniqueId>;
  1534.  
  1535. witcher = GetWitcherPlayer();
  1536. if(!witcher)
  1537. return;
  1538.  
  1539.  
  1540. recipes = witcher.GetAlchemyRecipes();
  1541. craftRecipes = witcher.GetCraftingSchematicsNames();
  1542. ArrayOfNamesAppend(recipes, craftRecipes);
  1543.  
  1544.  
  1545. GetAllItems(allItems);
  1546.  
  1547.  
  1548. for(i=allItems.Size()-1; i>=0; i-=1)
  1549. {
  1550. itemName = GetItemName(allItems[i]);
  1551. if(recipes.Contains(itemName))
  1552. RemoveItem(allItems[i], GetItemQuantity(allItems[i]));
  1553. }
  1554. }
  1555.  
  1556.  
  1557.  
  1558.  
  1559.  
  1560. function LoadBooksDefinitions() : void
  1561. {
  1562. var readableArray : array<SItemUniqueId>;
  1563. var i : int;
  1564.  
  1565. readableArray = GetItemsByTag('ReadableItem');
  1566.  
  1567. for( i = 0; i < readableArray.Size(); i += 1 )
  1568. {
  1569. if( IsBookRead(readableArray[i]))
  1570. {
  1571. continue;
  1572. }
  1573. UpdateInitialReadState(readableArray[i]);
  1574. }
  1575. }
  1576.  
  1577. function UpdateInitialReadState( item : SItemUniqueId )
  1578. {
  1579. var abilitiesArray : array<name>;
  1580. var i : int;
  1581. GetItemAbilities(item,abilitiesArray);
  1582.  
  1583. for( i = 0; i < abilitiesArray.Size(); i += 1 )
  1584. {
  1585. if( abilitiesArray[i] == 'WasRead' )
  1586. {
  1587. ReadBook(item);
  1588. break;
  1589. }
  1590. }
  1591. }
  1592.  
  1593. function IsBookRead( item : SItemUniqueId ) : bool
  1594. {
  1595. var bookName : name;
  1596. var bResult : bool;
  1597.  
  1598. bookName = GetItemName( item );
  1599.  
  1600. bResult = IsBookReadByName( bookName );
  1601. return bResult;
  1602. }
  1603.  
  1604. function IsBookReadByName( bookName : name ) : bool
  1605. {
  1606. var bookFactName : string;
  1607.  
  1608. bookFactName = GetBookReadFactName( bookName );
  1609. if( FactsDoesExist(bookFactName) )
  1610. {
  1611. return FactsQuerySum( bookFactName );
  1612. }
  1613.  
  1614. return false;
  1615. }
  1616.  
  1617. function ReadBook( item : SItemUniqueId, optional noNotification : bool )
  1618. {
  1619.  
  1620. var bookName : name;
  1621. var abilitiesArray : array<name>;
  1622. var i : int;
  1623. var commonMapManager : CCommonMapManager = theGame.GetCommonMapManager();
  1624.  
  1625. bookName = GetItemName( item );
  1626.  
  1627. if ( !IsBookRead ( item ) && ItemHasTag ( item, 'FastTravel' ))
  1628. {
  1629. GetItemAbilities(item, abilitiesArray);
  1630.  
  1631. for ( i = 0; i < abilitiesArray.Size(); i+=1 )
  1632. {
  1633. commonMapManager.SetEntityMapPinDiscoveredScript(true, abilitiesArray[i], true );
  1634. }
  1635. }
  1636. ReadBookByNameId( bookName, item, false, noNotification );
  1637.  
  1638.  
  1639.  
  1640.  
  1641. if(ItemHasTag(item, 'PerkBook'))
  1642. {
  1643.  
  1644. }
  1645. }
  1646.  
  1647. public function GetBookText(item : SItemUniqueId) : string
  1648. {
  1649. if ( GetItemName( item ) != 'Gwent Almanac' )
  1650. {
  1651. return ReplaceTagsToIcons(GetLocStringByKeyExt(GetItemLocalizedNameByUniqueID(item)+"_text"));
  1652. }
  1653. else
  1654. {
  1655. return GetGwentAlmanacContents();
  1656. }
  1657. }
  1658.  
  1659. public function GetBookTextByName( bookName : name ) : string
  1660. {
  1661. if( bookName != 'Gwent Almanac' )
  1662. {
  1663. return ReplaceTagsToIcons( GetLocStringByKeyExt( GetItemLocalizedNameByName( bookName ) + "_text" ) );
  1664. }
  1665. else
  1666. {
  1667. return GetGwentAlmanacContents();
  1668. }
  1669. }
  1670.  
  1671. function ReadSchematicsAndRecipes( item : SItemUniqueId )
  1672. {
  1673. var itemCategory : name;
  1674. var itemName : name;
  1675. var player : W3PlayerWitcher;
  1676.  
  1677. ReadBook( item );
  1678.  
  1679. player = GetWitcherPlayer();
  1680. if ( !player )
  1681. {
  1682. return;
  1683. }
  1684.  
  1685. itemName = GetItemName( item );
  1686. itemCategory = GetItemCategory( item );
  1687. if ( itemCategory == 'alchemy_recipe' )
  1688. {
  1689. if ( player.CanLearnAlchemyRecipe( itemName ) )
  1690. {
  1691. player.AddAlchemyRecipe( itemName );
  1692. player.GetInventory().AddItemTag(item, 'NoShow');
  1693. //---=== modFriendlyHUD ===---
  1694. if (!thePlayer.newCraftables.Contains(itemName))
  1695. {
  1696. thePlayer.newCraftables.PushBack(itemName);
  1697. }
  1698. //---=== modFriendlyHUD ===---
  1699. }
  1700. }
  1701. else if ( itemCategory == 'crafting_schematic' )
  1702. {
  1703. player.AddCraftingSchematic( itemName );
  1704. player.GetInventory().AddItemTag(item, 'NoShow');
  1705. //---=== modFriendlyHUD ===---
  1706. if (!thePlayer.newCraftables.Contains(itemName))
  1707. {
  1708. thePlayer.newCraftables.PushBack(itemName);
  1709. }
  1710. //---=== modFriendlyHUD ===---
  1711. }
  1712. }
  1713.  
  1714. function ReadBookByName( bookName : name , unread : bool, optional noNotification : bool )
  1715. {
  1716. var defMgr : CDefinitionsManagerAccessor;
  1717. var bookFactName : string;
  1718.  
  1719. if( IsBookReadByName( bookName ) != unread )
  1720. {
  1721. return;
  1722. }
  1723.  
  1724. bookFactName = "BookReadState_"+bookName;
  1725. bookFactName = StrReplace(bookFactName," ","_");
  1726.  
  1727. if( unread )
  1728. {
  1729. FactsSubstract( bookFactName, 1 );
  1730. }
  1731. else
  1732. {
  1733. FactsAdd( bookFactName, 1 );
  1734.  
  1735.  
  1736. defMgr = theGame.GetDefinitionsManager();
  1737. if(!IsAlchemyRecipe(bookName) && !IsCraftingSchematic(bookName) && !defMgr.ItemHasTag( bookName, 'Painting' ) )
  1738. {
  1739. theGame.GetGamerProfile().IncStat(ES_ReadBooks);
  1740.  
  1741. if( !noNotification )
  1742. {
  1743. theGame.GetGuiManager().ShowNotification( GetLocStringByKeyExt( "notification_book_moved" ), 0, false );
  1744. }
  1745. }
  1746.  
  1747.  
  1748. if ( AddBestiaryFromBook(bookName) )
  1749. return;
  1750.  
  1751.  
  1752.  
  1753. }
  1754. }
  1755.  
  1756. function ReadBookByNameId( bookName : name, itemId:SItemUniqueId, unread : bool, optional noNotification : bool )
  1757. {
  1758. var bookFactName : string;
  1759.  
  1760. if( IsBookReadByName( bookName ) != unread )
  1761. {
  1762. return;
  1763. }
  1764.  
  1765. bookFactName = "BookReadState_"+bookName;
  1766. bookFactName = StrReplace(bookFactName," ","_");
  1767.  
  1768. if( unread )
  1769. {
  1770. FactsSubstract( bookFactName, 1 );
  1771. }
  1772. else
  1773. {
  1774. FactsAdd( bookFactName, 1 );
  1775.  
  1776.  
  1777. if( !IsAlchemyRecipe( bookName ) && !IsCraftingSchematic( bookName ) )
  1778. {
  1779. theGame.GetGamerProfile().IncStat(ES_ReadBooks);
  1780.  
  1781. if( !noNotification )
  1782. {
  1783.  
  1784. GetWitcherPlayer().AddReadBook( bookName );
  1785. }
  1786. }
  1787.  
  1788.  
  1789. if ( AddBestiaryFromBook(bookName) )
  1790. return;
  1791. else
  1792. ReadSchematicsAndRecipes( itemId );
  1793. }
  1794. }
  1795.  
  1796.  
  1797. private function AddBestiaryFromBook( bookName : name ) : bool
  1798. {
  1799. var i, j, r, len : int;
  1800. var manager : CWitcherJournalManager;
  1801. var resource : array<CJournalResource>;
  1802. var entryBase : CJournalBase;
  1803. var childGroups : array<CJournalBase>;
  1804. var childEntries : array<CJournalBase>;
  1805. var descriptionGroup : CJournalCreatureDescriptionGroup;
  1806. var descriptionEntry : CJournalCreatureDescriptionEntry;
  1807.  
  1808. manager = theGame.GetJournalManager();
  1809.  
  1810. switch ( bookName )
  1811. {
  1812. case 'Beasts vol 1':
  1813. resource.PushBack( (CJournalResource)LoadResource( "BestiaryWolf" ) );
  1814. resource.PushBack( (CJournalResource)LoadResource( "BestiaryDog" ) );
  1815. break;
  1816. case 'Beasts vol 2':
  1817. resource.PushBack( (CJournalResource)LoadResource( "BestiaryBear" ) );
  1818. break;
  1819. case 'Cursed Monsters vol 1':
  1820. resource.PushBack( (CJournalResource)LoadResource( "BestiaryWerewolf" ) );
  1821. resource.PushBack( (CJournalResource)LoadResource( "BestiaryLycanthrope" ) );
  1822. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 24');
  1823. break;
  1824. case 'Cursed Monsters vol 2':
  1825. resource.PushBack( (CJournalResource)LoadResource( "BestiaryWerebear" ) );
  1826. resource.PushBack( (CJournalResource)LoadResource( "BestiaryMiscreant" ) );
  1827. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 11');
  1828. break;
  1829. case 'Draconides vol 1':
  1830. resource.PushBack( (CJournalResource)LoadResource( "BestiaryCockatrice" ) );
  1831. resource.PushBack( (CJournalResource)LoadResource( "BestiaryBasilisk" ) );
  1832. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 3');
  1833. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 23');
  1834. break;
  1835. case 'Draconides vol 2':
  1836. resource.PushBack( (CJournalResource)LoadResource( "BestiaryWyvern" ) );
  1837. resource.PushBack( (CJournalResource)LoadResource( "BestiaryForktail" ) );
  1838. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 10');
  1839. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 17');
  1840. break;
  1841. case 'Hybrid Monsters vol 1':
  1842. resource.PushBack( (CJournalResource)LoadResource( "BestiaryHarpy" ) );
  1843. resource.PushBack( (CJournalResource)LoadResource( "BestiaryErynia" ) );
  1844. resource.PushBack( (CJournalResource)LoadResource( "BestiarySiren" ) );
  1845. resource.PushBack( (CJournalResource)LoadResource( "BestiarySuccubus" ) );
  1846. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 14');
  1847. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 21');
  1848. break;
  1849. case 'Hybrid Monsters vol 2':
  1850. resource.PushBack( (CJournalResource)LoadResource( "BestiaryGriffin" ) );
  1851. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 4');
  1852. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 27');
  1853. break;
  1854. case 'Insectoids vol 1':
  1855. resource.PushBack( (CJournalResource)LoadResource( "BestiaryEndriagaWorker" ) );
  1856. resource.PushBack( (CJournalResource)LoadResource( "BestiaryEndriagaTruten" ) );
  1857. resource.PushBack( (CJournalResource)LoadResource( "BestiaryEndriaga" ) );
  1858. break;
  1859. case 'Insectoids vol 2':
  1860. resource.PushBack( (CJournalResource)LoadResource( "BestiaryCrabSpider" ) );
  1861. resource.PushBack( (CJournalResource)LoadResource( "BestiaryArmoredArachas" ) );
  1862. resource.PushBack( (CJournalResource)LoadResource( "BestiaryPoisonousArachas" ) );
  1863. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 2');
  1864. break;
  1865. case 'Magical Monsters vol 1':
  1866. resource.PushBack( (CJournalResource)LoadResource( "BestiaryGolem" ) );
  1867. break;
  1868. case 'Magical Monsters vol 2':
  1869. resource.PushBack( (CJournalResource)LoadResource( "BestiaryElemental" ) );
  1870. resource.PushBack( (CJournalResource)LoadResource( "BestiaryIceGolem" ) );
  1871. resource.PushBack( (CJournalResource)LoadResource( "BestiaryFireElemental" ) );
  1872. resource.PushBack( (CJournalResource)LoadResource( "BestiaryWhMinion" ) );
  1873. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 20');
  1874. break;
  1875. case 'Necrophage vol 1':
  1876. resource.PushBack( (CJournalResource)LoadResource( "BestiaryGhoul" ) );
  1877. resource.PushBack( (CJournalResource)LoadResource( "BestiaryAlghoul" ) );
  1878. resource.PushBack( (CJournalResource)LoadResource( "BestiaryGreaterRotFiend" ) );
  1879. resource.PushBack( (CJournalResource)LoadResource( "BestiaryDrowner" ) );
  1880. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 15');
  1881. break;
  1882. case 'Necrophage vol 2':
  1883. resource.PushBack( (CJournalResource)LoadResource( "BestiaryGraveHag" ) );
  1884. resource.PushBack( (CJournalResource)LoadResource( "BestiaryWaterHag" ) );
  1885. resource.PushBack( (CJournalResource)LoadResource( "BestiaryFogling" ) );
  1886. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 5');
  1887. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 9');
  1888. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 18');
  1889. break;
  1890. case 'Relict Monsters vol 1':
  1891. resource.PushBack( (CJournalResource)LoadResource( "BestiaryBies" ) );
  1892. resource.PushBack( (CJournalResource)LoadResource( "BestiaryCzart" ) );
  1893. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 8');
  1894. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 16');
  1895. break;
  1896. case 'Relict Monsters vol 2':
  1897. resource.PushBack( (CJournalResource)LoadResource( "BestiaryLeshy" ) );
  1898. resource.PushBack( (CJournalResource)LoadResource( "BestiarySilvan" ) );
  1899. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 22');
  1900. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 26');
  1901. break;
  1902. case 'Specters vol 1':
  1903. resource.PushBack( (CJournalResource)LoadResource( "BestiaryMoonwright" ) );
  1904. resource.PushBack( (CJournalResource)LoadResource( "BestiaryNoonwright" ) );
  1905. resource.PushBack( (CJournalResource)LoadResource( "BestiaryPesta" ) );
  1906. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 6');
  1907. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 13');
  1908. break;
  1909. case 'Specters vol 2':
  1910. resource.PushBack( (CJournalResource)LoadResource( "BestiaryWraith" ) );
  1911. resource.PushBack( (CJournalResource)LoadResource( "BestiaryHim" ) );
  1912. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 19');
  1913. break;
  1914. case 'Ogres vol 1':
  1915. resource.PushBack( (CJournalResource)LoadResource( "BestiaryNekker" ) );
  1916. resource.PushBack( (CJournalResource)LoadResource( "BestiaryIceTroll" ) );
  1917. resource.PushBack( (CJournalResource)LoadResource( "BestiaryCaveTroll" ) );
  1918. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 12');
  1919. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 25');
  1920. break;
  1921. case 'Ogres vol 2':
  1922. resource.PushBack( (CJournalResource)LoadResource( "BestiaryCyclop" ) );
  1923. resource.PushBack( (CJournalResource)LoadResource( "BestiaryIceGiant" ) );
  1924. break;
  1925. case 'Vampires vol 1':
  1926. resource.PushBack( (CJournalResource)LoadResource( "BestiaryEkkima" ) );
  1927. resource.PushBack( (CJournalResource)LoadResource( "BestiaryHigherVampire" ) );
  1928. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 7');
  1929. break;
  1930. case 'Vampires vol 2':
  1931. resource.PushBack( (CJournalResource)LoadResource( "BestiaryKatakan" ) );
  1932. GetWitcherPlayer().AddAlchemyRecipe('Recipe for Mutagen 1');
  1933. break;
  1934.  
  1935. case 'bestiary_sharley_book':
  1936. resource.PushBack( (CJournalResource)LoadResource( "BestiarySharley" ) );
  1937. break;
  1938. case 'bestiary_barghest_book':
  1939. resource.PushBack( (CJournalResource)LoadResource( "BestiaryBarghest" ) );
  1940. break;
  1941. case 'bestiary_garkain_book':
  1942. resource.PushBack( (CJournalResource)LoadResource( "BestiaryGarkain" ) );
  1943. break;
  1944. case 'bestiary_alp_book':
  1945. resource.PushBack( (CJournalResource)LoadResource( "BestiaryAlp" ) );
  1946. break;
  1947. case 'bestiary_bruxa_book':
  1948. resource.PushBack( (CJournalResource)LoadResource( "BestiaryBruxa" ) );
  1949. break;
  1950. case 'bestiary_spriggan_book':
  1951. resource.PushBack( (CJournalResource)LoadResource( "BestiarySpriggan" ) );
  1952. break;
  1953. case 'bestiary_fleder_book':
  1954. resource.PushBack( (CJournalResource)LoadResource( "BestiaryFleder" ) );
  1955. break;
  1956. case 'bestiary_wight_book':
  1957. resource.PushBack( (CJournalResource)LoadResource( "BestiaryWicht" ) );
  1958. break;
  1959. case 'bestiary_dracolizard_book':
  1960. resource.PushBack( (CJournalResource)LoadResource( "BestiaryDracolizard" ) );
  1961. break;
  1962. case 'bestiary_panther_book':
  1963. resource.PushBack( (CJournalResource)LoadResource( "BestiaryPanther" ) );
  1964. break;
  1965. case 'bestiary_kikimore_book':
  1966. resource.PushBack( (CJournalResource)LoadResource( "BestiaryKikimoraWarrior" ) );
  1967. resource.PushBack( (CJournalResource)LoadResource( "BestiaryKikimoraWorker" ) );
  1968. break;
  1969. case 'bestiary_scolopendromorph_book':
  1970. case 'mq7023_fluff_book_scolopendromorphs':
  1971. resource.PushBack( (CJournalResource)LoadResource( "BestiaryScolopendromorph" ) );
  1972. break;
  1973. case 'bestiary_archespore_book':
  1974. resource.PushBack( (CJournalResource)LoadResource( "BestiaryArchespore" ) );
  1975. break;
  1976. case 'bestiary_protofleder_book':
  1977. resource.PushBack( (CJournalResource)LoadResource( "BestiaryProtofleder" ) );
  1978. break;
  1979. default:
  1980. return false;
  1981. }
  1982.  
  1983.  
  1984.  
  1985.  
  1986. len = resource.Size();
  1987. if( len > 0)
  1988. {
  1989.  
  1990. theGame.GetGuiManager().ShowNotification( GetLocStringByKeyExt( "panel_hud_journal_entry_bestiary_new" ), 0, true );
  1991. theSound.SoundEvent("gui_ingame_new_journal");
  1992. }
  1993.  
  1994. for (r=0; r < len; r += 1 )
  1995. {
  1996. if ( !resource[ r ] )
  1997. {
  1998.  
  1999. continue;
  2000. }
  2001. entryBase = resource[r].GetEntry();
  2002. if ( entryBase )
  2003. {
  2004. manager.ActivateEntry( entryBase, JS_Active );
  2005. manager.SetEntryHasAdvancedInfo( entryBase, true );
  2006.  
  2007.  
  2008. manager.GetAllChildren( entryBase, childGroups );
  2009. for ( i = 0; i < childGroups.Size(); i += 1 )
  2010. {
  2011. descriptionGroup = ( CJournalCreatureDescriptionGroup )childGroups[ i ];
  2012. if ( descriptionGroup )
  2013. {
  2014. manager.GetAllChildren( descriptionGroup, childEntries );
  2015. for ( j = 0; j < childEntries.Size(); j += 1 )
  2016. {
  2017. descriptionEntry = ( CJournalCreatureDescriptionEntry )childEntries[ j ];
  2018. if ( descriptionEntry )
  2019. {
  2020. manager.ActivateEntry( descriptionEntry, JS_Active );
  2021. }
  2022. }
  2023. break;
  2024. }
  2025. }
  2026. }
  2027. }
  2028.  
  2029. if ( resource.Size() > 0 )
  2030. return true;
  2031. else
  2032. return false;
  2033. }
  2034.  
  2035.  
  2036.  
  2037.  
  2038.  
  2039.  
  2040.  
  2041.  
  2042. function GetWeaponDTNames( id : SItemUniqueId, out dmgNames : array< name > ) : int
  2043. {
  2044. var attrs : array< name >;
  2045. var i, size : int;
  2046.  
  2047. dmgNames.Clear();
  2048.  
  2049. if( IsIdValid(id) )
  2050. {
  2051. GetItemAttributes( id, attrs );
  2052. size = attrs.Size();
  2053.  
  2054. for( i = 0; i < size; i += 1 )
  2055. if( IsDamageTypeNameValid(attrs[i]) )
  2056. dmgNames.PushBack( attrs[i] );
  2057.  
  2058. if(dmgNames.Size() == 0)
  2059. LogAssert(false, "CInventoryComponent.GetWeaponDTNames: weapon <<" + GetItemName(id) + ">> has no damage types defined!");
  2060. }
  2061. return dmgNames.Size();
  2062. }
  2063.  
  2064. public function GetWeapons() : array<SItemUniqueId>
  2065. {
  2066. var ids, ids2 : array<SItemUniqueId>;
  2067.  
  2068. ids = GetItemsByCategory('monster_weapon');
  2069. ids2 = GetItemsByTag('Weapon');
  2070. ArrayOfIdsAppend(ids, ids2);
  2071.  
  2072. return ids;
  2073. }
  2074.  
  2075. public function GetHeldWeapons() : array<SItemUniqueId>
  2076. {
  2077. var i : int;
  2078. var w : array<SItemUniqueId>;
  2079.  
  2080. w = GetWeapons();
  2081.  
  2082. for(i=w.Size()-1; i>=0; i-=1)
  2083. {
  2084. if(!IsItemHeld(w[i]))
  2085. {
  2086. w.EraseFast( i );
  2087. }
  2088. }
  2089.  
  2090. return w;
  2091. }
  2092.  
  2093. public function GetCurrentlyHeldSword() : SItemUniqueId
  2094. {
  2095. var i : int;
  2096. var w : array<SItemUniqueId>;
  2097.  
  2098. w = GetHeldWeapons();
  2099.  
  2100. for( i = 0 ; i < w.Size() ; i+=1 )
  2101. {
  2102. if( IsItemSteelSwordUsableByPlayer( w[i] ) || IsItemSilverSwordUsableByPlayer( w[i] ) )
  2103. {
  2104. return w[i];
  2105. }
  2106. }
  2107.  
  2108. return GetInvalidUniqueId();
  2109. }
  2110.  
  2111. public function GetCurrentlyHeldSwordEntity( out ent : CItemEntity ) : bool
  2112. {
  2113. var id : SItemUniqueId;
  2114.  
  2115. id = GetCurrentlyHeldSword();
  2116.  
  2117. if( IsIdValid( id ) )
  2118. {
  2119. ent = GetItemEntityUnsafe( id );
  2120.  
  2121. if( ent )
  2122. {
  2123. return true;
  2124. }
  2125. else
  2126. {
  2127. return false;
  2128. }
  2129. }
  2130. return false;
  2131. }
  2132.  
  2133. public function GetHeldWeaponsWithCategory( category : name, out items : array<SItemUniqueId> )
  2134. {
  2135. var i : int;
  2136.  
  2137. items = GetItemsByCategory( category );
  2138.  
  2139. for ( i = items.Size()-1; i >= 0; i -= 1)
  2140. {
  2141. if ( !IsItemHeld( items[i] ) )
  2142. {
  2143. items.EraseFast( i );
  2144. }
  2145. }
  2146. }
  2147.  
  2148. public function GetPotionItemBuffData(id : SItemUniqueId, out type : EEffectType, out customAbilityName : name) : bool
  2149. {
  2150. var size, i : int;
  2151. var arr : array<name>;
  2152.  
  2153. if(IsIdValid(id))
  2154. {
  2155. GetItemContainedAbilities( id, arr );
  2156. size = arr.Size();
  2157.  
  2158. for( i = 0; i < size; i += 1 )
  2159. {
  2160. if( IsEffectNameValid(arr[i]) )
  2161. {
  2162. EffectNameToType(arr[i], type, customAbilityName);
  2163. return true;
  2164. }
  2165. }
  2166. }
  2167.  
  2168. return false;
  2169. }
  2170.  
  2171.  
  2172. public function RecycleItem( id : SItemUniqueId, level : ECraftsmanLevel ) : array<SItemUniqueId>
  2173. {
  2174. var itemsAdded : array<SItemUniqueId>;
  2175. var currentAdded : array<SItemUniqueId>;
  2176.  
  2177. var parts : array<SItemParts>;
  2178. var i : int;
  2179.  
  2180. parts = GetItemRecyclingParts( id );
  2181.  
  2182. for ( i = 0; i < parts.Size(); i += 1 )
  2183. {
  2184. if ( ECL_Grand_Master == level || ECL_Arch_Master == level )
  2185. {
  2186. currentAdded = AddAnItem( parts[i].itemName, parts[i].quantity );
  2187. }
  2188. else if ( ECL_Master == level && parts[i].quantity > 1 )
  2189. {
  2190. currentAdded = AddAnItem( parts[i].itemName, RandRange( parts[i].quantity, 1 ) );
  2191. }
  2192. else
  2193. {
  2194. currentAdded = AddAnItem( parts[i].itemName, 1 );
  2195. }
  2196. itemsAdded.PushBack(currentAdded[0]);
  2197. }
  2198.  
  2199. RemoveItem(id);
  2200.  
  2201. return itemsAdded;
  2202. }
  2203.  
  2204.  
  2205.  
  2206.  
  2207.  
  2208.  
  2209. public function GetItemBuffs( id : SItemUniqueId, out buffs : array<SEffectInfo>) : int
  2210. {
  2211. var attrs, abs, absFast : array< name >;
  2212. var i, k : int;
  2213. var type : EEffectType;
  2214. var abilityName : name;
  2215. var buff : SEffectInfo;
  2216. var dm : CDefinitionsManagerAccessor;
  2217.  
  2218. buffs.Clear();
  2219.  
  2220. if( !IsIdValid(id) )
  2221. return 0;
  2222.  
  2223.  
  2224. GetItemContainedAbilities(id, absFast);
  2225. if(absFast.Size() == 0)
  2226. return 0;
  2227.  
  2228. GetItemAbilities(id, abs);
  2229. dm = theGame.GetDefinitionsManager();
  2230. for(k=0; k<abs.Size(); k+=1)
  2231. {
  2232. dm.GetContainedAbilities(abs[k], attrs);
  2233. buff.applyChance = CalculateAttributeValue(GetItemAbilityAttributeValue(id, 'buff_apply_chance', abs[k])) * ArrayOfNamesCount(abs, abs[k]);
  2234.  
  2235. for( i = 0; i < attrs.Size(); i += 1 )
  2236. {
  2237. if( IsEffectNameValid(attrs[i]) )
  2238. {
  2239. EffectNameToType(attrs[i], type, abilityName);
  2240.  
  2241. buff.effectType = type;
  2242. buff.effectAbilityName = abilityName;
  2243.  
  2244. buffs.PushBack(buff);
  2245.  
  2246.  
  2247. if(absFast.Size() == 1)
  2248. return buffs.Size();
  2249. else
  2250. absFast.EraseFast(0);
  2251. }
  2252. }
  2253. }
  2254.  
  2255. return buffs.Size();
  2256. }
  2257.  
  2258.  
  2259. public function DropItemInBag( item : SItemUniqueId, quantity : int )
  2260. {
  2261. var entities : array<CGameplayEntity>;
  2262. var i : int;
  2263. var owner : CActor;
  2264. var bag : W3ActorRemains;
  2265. var template : CEntityTemplate;
  2266. var bagtags : array <name>;
  2267. var bagPosition : Vector;
  2268. var tracedPosition, tracedNormal : Vector;
  2269.  
  2270. if(ItemHasTag(item, 'NoDrop'))
  2271. return;
  2272.  
  2273. owner = (CActor)GetEntity();
  2274. FindGameplayEntitiesInRange(entities, owner, 0.5, 100);
  2275.  
  2276. for(i=0; i<entities.Size(); i+=1)
  2277. {
  2278. bag = (W3ActorRemains)entities[i];
  2279.  
  2280. if(bag)
  2281. break;
  2282. }
  2283.  
  2284.  
  2285. if(!bag)
  2286. {
  2287. template = (CEntityTemplate)LoadResource("lootbag");
  2288. bagtags.PushBack('lootbag');
  2289.  
  2290.  
  2291. bagPosition = owner.GetWorldPosition();
  2292. if ( theGame.GetWorld().StaticTrace( bagPosition, bagPosition + Vector( 0.0f, 0.0f, -10.0f, 0.0f ), tracedPosition, tracedNormal ) )
  2293. {
  2294. bagPosition = tracedPosition;
  2295. }
  2296. bag = (W3ActorRemains)theGame.CreateEntity(template, bagPosition, owner.GetWorldRotation(), true, false, false, PM_Persist,bagtags);
  2297. }
  2298.  
  2299.  
  2300. GiveItemTo(bag.GetInventory(), item, quantity, false);
  2301.  
  2302.  
  2303. if(bag.GetInventory().IsEmpty())
  2304. {
  2305. delete bag;
  2306. return;
  2307. }
  2308.  
  2309. bag.LootDropped();
  2310. theTelemetry.LogWithLabelAndValue(TE_INV_ITEM_DROPPED, GetItemName(item), quantity);
  2311.  
  2312.  
  2313. if( thePlayer.IsSwimming() )
  2314. {
  2315. bag.PlayPropertyAnimation( 'float', 0 );
  2316. }
  2317. }
  2318.  
  2319.  
  2320.  
  2321.  
  2322.  
  2323.  
  2324. public final function AddRepairObjectItemBonuses(buffArmor : bool, buffSwords : bool, ammoArmor : int, ammoWeapon : int) : bool
  2325. {
  2326. var upgradedSomething, isArmor : bool;
  2327. var i, ammo, currAmmo : int;
  2328. var items, items2 : array<SItemUniqueId>;
  2329.  
  2330.  
  2331. if(buffArmor)
  2332. {
  2333. items = GetItemsByTag(theGame.params.TAG_ARMOR);
  2334. }
  2335. if(buffSwords)
  2336. {
  2337. items2 = GetItemsByTag(theGame.params.TAG_PLAYER_STEELSWORD);
  2338. ArrayOfIdsAppend(items, items2);
  2339. items2.Clear();
  2340. items2 = GetItemsByTag(theGame.params.TAG_PLAYER_SILVERSWORD);
  2341. ArrayOfIdsAppend(items, items2);
  2342. }
  2343.  
  2344. upgradedSomething = false;
  2345.  
  2346. for(i=0; i<items.Size(); i+=1)
  2347. {
  2348.  
  2349. if(IsItemAnyArmor(items[i]))
  2350. {
  2351. isArmor = true;
  2352. ammo = ammoArmor;
  2353. }
  2354. else
  2355. {
  2356. isArmor = false;
  2357. ammo = ammoWeapon;
  2358. }
  2359.  
  2360.  
  2361. currAmmo = GetItemModifierInt(items[i], 'repairObjectBonusAmmo', 0);
  2362.  
  2363.  
  2364. if(ammo > currAmmo)
  2365. {
  2366. SetItemModifierInt(items[i], 'repairObjectBonusAmmo', ammo);
  2367. upgradedSomething = true;
  2368.  
  2369.  
  2370. if(currAmmo == 0)
  2371. {
  2372. if(isArmor)
  2373. AddItemCraftedAbility(items[i], theGame.params.REPAIR_OBJECT_BONUS_ARMOR_ABILITY, false);
  2374. else
  2375. AddItemCraftedAbility(items[i], theGame.params.REPAIR_OBJECT_BONUS_WEAPON_ABILITY, false);
  2376. }
  2377. }
  2378. }
  2379.  
  2380. return upgradedSomething;
  2381. }
  2382.  
  2383. public final function ReduceItemRepairObjectBonusCharge(item : SItemUniqueId)
  2384. {
  2385. var currAmmo : int;
  2386.  
  2387. currAmmo = GetItemModifierInt(item, 'repairObjectBonusAmmo', 0);
  2388.  
  2389. if(currAmmo > 0)
  2390. {
  2391. SetItemModifierInt(item, 'repairObjectBonusAmmo', currAmmo - 1);
  2392.  
  2393. if(currAmmo == 1)
  2394. {
  2395. if(IsItemAnyArmor(item))
  2396. RemoveItemCraftedAbility(item, theGame.params.REPAIR_OBJECT_BONUS_ARMOR_ABILITY);
  2397. else
  2398. RemoveItemCraftedAbility(item, theGame.params.REPAIR_OBJECT_BONUS_WEAPON_ABILITY);
  2399. }
  2400. }
  2401. }
  2402.  
  2403.  
  2404. public final function GetRepairObjectBonusValueForArmor(armor : SItemUniqueId) : SAbilityAttributeValue
  2405. {
  2406. var retVal, bonusValue, baseArmor : SAbilityAttributeValue;
  2407.  
  2408. if(GetItemModifierInt(armor, 'repairObjectBonusAmmo', 0) > 0)
  2409. {
  2410. bonusValue = GetItemAttributeValue(armor, theGame.params.REPAIR_OBJECT_BONUS);
  2411. baseArmor = GetItemAttributeValue(armor, theGame.params.ARMOR_VALUE_NAME);
  2412.  
  2413. baseArmor.valueMultiplicative += 1;
  2414. retVal.valueAdditive = bonusValue.valueAdditive + CalculateAttributeValue(baseArmor) * bonusValue.valueMultiplicative;
  2415. }
  2416.  
  2417. return retVal;
  2418. }
  2419.  
  2420.  
  2421.  
  2422.  
  2423.  
  2424.  
  2425. public function CanItemHaveOil(id : SItemUniqueId) : bool
  2426. {
  2427. return IsItemSteelSwordUsableByPlayer(id) || IsItemSilverSwordUsableByPlayer(id);
  2428. }
  2429.  
  2430. public final function RemoveAllOilsFromItem( id : SItemUniqueId )
  2431. {
  2432. var i : int;
  2433. var oils : array< W3Effect_Oil >;
  2434. var actor : CActor;
  2435.  
  2436. actor = ( CActor ) GetEntity();
  2437. oils = GetOilsAppliedOnItem( id );
  2438. for( i = oils.Size() - 1; i >= 0; i -= 1 )
  2439. {
  2440. actor.RemoveEffect( oils[ i ] );
  2441. }
  2442. }
  2443.  
  2444. public final function GetActiveOilsAppliedOnItemCount( id : SItemUniqueId ) : int
  2445. {
  2446. var oils : array< W3Effect_Oil >;
  2447. var i, count : int;
  2448.  
  2449. count = 0;
  2450. oils = GetOilsAppliedOnItem( id );
  2451. for( i=0; i<oils.Size(); i+=1 )
  2452. {
  2453. if( oils[ i ].GetAmmoCurrentCount() > 0 )
  2454. {
  2455. count += 1;
  2456. }
  2457. }
  2458. return count;
  2459. }
  2460.  
  2461. public final function RemoveOldestOilFromItem( id : SItemUniqueId )
  2462. {
  2463. var buffToRemove : W3Effect_Oil;
  2464. var actor : CActor;
  2465.  
  2466. actor = ( CActor ) GetEntity();
  2467. if(! actor )
  2468. return;
  2469.  
  2470. buffToRemove = GetOldestOilAppliedOnItem(id, false);
  2471.  
  2472. if(buffToRemove)
  2473. {
  2474. actor.RemoveEffect( buffToRemove );
  2475. }
  2476. }
  2477.  
  2478. public final function GetOilsAppliedOnItem( id : SItemUniqueId ) : array< W3Effect_Oil >
  2479. {
  2480. var i : int;
  2481. var oils : array< CBaseGameplayEffect >;
  2482. var buff : W3Effect_Oil;
  2483. var ret : array < W3Effect_Oil >;
  2484. var actor : CActor;
  2485.  
  2486. actor = ( CActor ) GetEntity();
  2487. if(! actor )
  2488. return ret;
  2489.  
  2490. oils = actor.GetBuffs( EET_Oil );
  2491. for( i = oils.Size() - 1; i >= 0; i -= 1 )
  2492. {
  2493. buff = ( W3Effect_Oil ) oils[ i ];
  2494. if(buff && buff.GetSwordItemId() == id )
  2495. {
  2496. ret.PushBack( buff );
  2497. }
  2498. }
  2499.  
  2500. return ret;
  2501. }
  2502.  
  2503. public final function GetNewestOilAppliedOnItem( id : SItemUniqueId, onlyShowable : bool ) : W3Effect_Oil
  2504. {
  2505. return GetOilAppliedOnItemInternal( id, onlyShowable, true );
  2506. }
  2507.  
  2508. public final function GetOldestOilAppliedOnItem( id : SItemUniqueId, onlyShowable : bool ) : W3Effect_Oil
  2509. {
  2510. return GetOilAppliedOnItemInternal( id, onlyShowable, false );
  2511. }
  2512.  
  2513. private final function GetOilAppliedOnItemInternal( id : SItemUniqueId, onlyShowable : bool, newest : bool ) : W3Effect_Oil
  2514. {
  2515. var oils : array< W3Effect_Oil >;
  2516. var i, lastIndex : int;
  2517.  
  2518. oils = GetOilsAppliedOnItem( id );
  2519. lastIndex = -1;
  2520.  
  2521. for( i=0; i<oils.Size(); i+=1 )
  2522. {
  2523. if( onlyShowable && !oils[i].GetShowOnHUD() )
  2524. {
  2525. continue;
  2526. }
  2527.  
  2528. if( lastIndex == -1 )
  2529. {
  2530. lastIndex = i;
  2531. }
  2532. else if( newest && oils[i].GetQueueTimer() < oils[lastIndex].GetQueueTimer() )
  2533. {
  2534. lastIndex = i;
  2535. }
  2536. else if( !newest && oils[i].GetQueueTimer() > oils[lastIndex].GetQueueTimer() )
  2537. {
  2538. lastIndex = i;
  2539. }
  2540. }
  2541.  
  2542. if( lastIndex == -1 )
  2543. {
  2544. return NULL;
  2545. }
  2546.  
  2547. return oils[lastIndex];
  2548. }
  2549.  
  2550. public final function ItemHasAnyActiveOilApplied( id : SItemUniqueId ) : bool
  2551. {
  2552. return GetActiveOilsAppliedOnItemCount( id );
  2553. }
  2554.  
  2555. public final function ItemHasActiveOilApplied( id : SItemUniqueId, monsterCategory : EMonsterCategory ) : bool
  2556. {
  2557. var i : int;
  2558. var oils : array< W3Effect_Oil >;
  2559.  
  2560. oils = GetOilsAppliedOnItem( id );
  2561. for( i=0; i<oils.Size(); i+=1 )
  2562. {
  2563. if( oils[ i ].GetMonsterCategory() == monsterCategory && oils[ i ].GetAmmoCurrentCount() > 0 )
  2564. {
  2565. return true;
  2566. }
  2567. }
  2568.  
  2569. return false;
  2570. }
  2571.  
  2572.  
  2573.  
  2574.  
  2575.  
  2576. public final function GetParamsForRunewordTooltip(runewordName : name, out i : array<int>, out f : array<float>, out s : array<string>)
  2577. {
  2578. var min, max : SAbilityAttributeValue;
  2579. var val : float;
  2580. var attackRangeBase, attackRangeExt : CAIAttackRange;
  2581.  
  2582. i.Clear();
  2583. f.Clear();
  2584. s.Clear();
  2585.  
  2586. switch(runewordName)
  2587. {
  2588. case 'Glyphword 5':
  2589. theGame.GetDefinitionsManager().GetAbilityAttributeValue('Glyphword 5 _Stats', 'glyphword5_chance', min, max);
  2590. i.PushBack( RoundMath( CalculateAttributeValue(min) * 100) );
  2591. break;
  2592. case 'Glyphword 6' :
  2593. theGame.GetDefinitionsManager().GetAbilityAttributeValue('Glyphword 6 _Stats', 'glyphword6_stamina_drain_perc', min, max);
  2594. i.PushBack( RoundMath( CalculateAttributeValue(min) * 100) );
  2595. break;
  2596. case 'Glyphword 12' :
  2597. theGame.GetDefinitionsManager().GetAbilityAttributeValue('Glyphword 12 _Stats', 'glyphword12_range', min, max);
  2598. val = CalculateAttributeValue(min);
  2599. s.PushBack( NoTrailZeros(val) );
  2600.  
  2601. theGame.GetDefinitionsManager().GetAbilityAttributeValue('Glyphword 12 _Stats', 'glyphword12_chance', min, max);
  2602. i.PushBack( RoundMath( min.valueAdditive * 100) );
  2603. break;
  2604. case 'Glyphword 17' :
  2605. theGame.GetDefinitionsManager().GetAbilityAttributeValue('Glyphword 17 _Stats', 'quen_apply_chance', min, max);
  2606. val = CalculateAttributeValue(min);
  2607. i.PushBack( RoundMath(val * 100) );
  2608. break;
  2609. case 'Glyphword 14' :
  2610. case 'Glyphword 18' :
  2611. theGame.GetDefinitionsManager().GetAbilityAttributeValue('Glyphword 18 _Stats', 'increas_duration', min, max);
  2612. val = CalculateAttributeValue(min);
  2613. s.PushBack( NoTrailZeros(val) );
  2614. break;
  2615.  
  2616. case 'Runeword 2' :
  2617. attackRangeBase = theGame.GetAttackRangeForEntity(GetWitcherPlayer(), 'specialattacklight');
  2618. attackRangeExt = theGame.GetAttackRangeForEntity(GetWitcherPlayer(), 'runeword2_light');
  2619. s.PushBack( NoTrailZeros(attackRangeExt.rangeMax - attackRangeBase.rangeMax) );
  2620.  
  2621. attackRangeBase = theGame.GetAttackRangeForEntity(GetWitcherPlayer(), 'slash_long');
  2622. attackRangeExt = theGame.GetAttackRangeForEntity(GetWitcherPlayer(), 'runeword2_heavy');
  2623. s.PushBack( NoTrailZeros(attackRangeExt.rangeMax - attackRangeBase.rangeMax) );
  2624.  
  2625. break;
  2626. case 'Runeword 4' :
  2627. theGame.GetDefinitionsManager().GetAbilityAttributeValue('Runeword 4 _Stats', 'max_bonus', min, max);
  2628. i.PushBack( RoundMath(max.valueMultiplicative * 100) );
  2629. break;
  2630. case 'Runeword 6' :
  2631. theGame.GetDefinitionsManager().GetAbilityAttributeValue( 'Runeword 6 _Stats', 'runeword6_duration_bonus', min, max );
  2632. i.PushBack( RoundMath(min.valueMultiplicative * 100) );
  2633. break;
  2634. case 'Runeword 7' :
  2635. theGame.GetDefinitionsManager().GetAbilityAttributeValue( 'Runeword 7 _Stats', 'stamina', min, max );
  2636. i.PushBack( RoundMath(min.valueMultiplicative * 100) );
  2637. break;
  2638. case 'Runeword 10' :
  2639. theGame.GetDefinitionsManager().GetAbilityAttributeValue( 'Runeword 10 _Stats', 'stamina_runeword_gain', min, max );
  2640. i.PushBack( RoundMath(min.valueMultiplicative * 100) );
  2641. break;
  2642. case 'Runeword 11' :
  2643. theGame.GetDefinitionsManager().GetAbilityAttributeValue( 'Runeword 11 _Stats', 'duration', min, max );
  2644. s.PushBack( NoTrailZeros(min.valueAdditive) );
  2645. break;
  2646. case 'Runeword 12' :
  2647. theGame.GetDefinitionsManager().GetAbilityAttributeValue( 'Runeword 12 _Stats', 'focus_runeword_gain', min, max );
  2648. f.PushBack(min.valueAdditive);
  2649. f.PushBack(max.valueAdditive);
  2650. break;
  2651. default:
  2652. break;
  2653. }
  2654. }
  2655.  
  2656. public final function GetPotionAttributesForTooltip(potionId : SItemUniqueId, out tips : array<SAttributeTooltip>):void
  2657. {
  2658. var i, j, settingsSize : int;
  2659. var buffType : EEffectType;
  2660. var abilityName : name;
  2661. var abs, attrs : array<name>;
  2662. var val : SAbilityAttributeValue;
  2663. var newAttr : SAttributeTooltip;
  2664. var attributeString : string;
  2665.  
  2666.  
  2667. if(!( IsItemPotion(potionId) || IsItemFood(potionId) ) )
  2668. return;
  2669.  
  2670.  
  2671. GetItemContainedAbilities(potionId, abs);
  2672. for(i=0; i<abs.Size(); i+=1)
  2673. {
  2674. EffectNameToType(abs[i], buffType, abilityName);
  2675.  
  2676.  
  2677. if(buffType == EET_Undefined)
  2678. continue;
  2679.  
  2680.  
  2681. theGame.GetDefinitionsManager().GetAbilityAttributes(abs[i], attrs);
  2682. break;
  2683. }
  2684.  
  2685.  
  2686. attrs.Remove('duration');
  2687. attrs.Remove('level');
  2688.  
  2689. if(buffType == EET_Cat)
  2690. {
  2691.  
  2692. attrs.Remove('highlightObjectsRange');
  2693. }
  2694. else if(buffType == EET_GoldenOriole)
  2695. {
  2696.  
  2697. attrs.Remove('poison_resistance_perc');
  2698. }
  2699. else if(buffType == EET_MariborForest)
  2700. {
  2701.  
  2702. attrs.Remove('focus_on_drink');
  2703. }
  2704. else if(buffType == EET_KillerWhale)
  2705. {
  2706.  
  2707. attrs.Remove('swimmingStamina');
  2708. attrs.Remove('vision_strength');
  2709. }
  2710. else if(buffType == EET_Thunderbolt)
  2711. {
  2712.  
  2713. attrs.Remove('critical_hit_chance');
  2714. }
  2715. else if(buffType == EET_WhiteRaffardDecoction)
  2716. {
  2717. val = GetItemAttributeValue(potionId, 'level');
  2718. if(val.valueAdditive == 3)
  2719. attrs.Insert(0, 'duration');
  2720. }
  2721. else if(buffType == EET_Mutagen20)
  2722. {
  2723. attrs.Remove('burning_DoT_damage_resistance_perc');
  2724. attrs.Remove('poison_DoT_damage_resistance_perc');
  2725. attrs.Remove('bleeding_DoT_damage_resistance_perc');
  2726. }
  2727. else if(buffType == EET_Mutagen27)
  2728. {
  2729. attrs.Remove('mutagen27_max_stack');
  2730. }
  2731. else if(buffType == EET_Mutagen18)
  2732. {
  2733. attrs.Remove('mutagen18_max_stack');
  2734. }
  2735. else if(buffType == EET_Mutagen19)
  2736. {
  2737. attrs.Remove('max_hp_perc_trigger');
  2738. }
  2739. else if(buffType == EET_Mutagen21)
  2740. {
  2741. attrs.Remove('healingRatio');
  2742. }
  2743. else if(buffType == EET_Mutagen22)
  2744. {
  2745. attrs.Remove('mutagen22_max_stack');
  2746. }
  2747. else if(buffType == EET_Mutagen02)
  2748. {
  2749. attrs.Remove('resistGainRate');
  2750. }
  2751. else if(buffType == EET_Mutagen04)
  2752. {
  2753. attrs.Remove('staminaCostPerc');
  2754. attrs.Remove('healthReductionPerc');
  2755. }
  2756. else if(buffType == EET_Mutagen08)
  2757. {
  2758. attrs.Remove('resistGainRate');
  2759. }
  2760. else if(buffType == EET_Mutagen10)
  2761. {
  2762. attrs.Remove('mutagen10_max_stack');
  2763. }
  2764. else if(buffType == EET_Mutagen14)
  2765. {
  2766. attrs.Remove('mutagen14_max_stack');
  2767. }
  2768.  
  2769.  
  2770. for(j=0; j<attrs.Size(); j+=1)
  2771. {
  2772. val = GetItemAbilityAttributeValue(potionId, attrs[j], abs[i]);
  2773.  
  2774. newAttr.originName = attrs[j];
  2775. newAttr.attributeName = GetAttributeNameLocStr(attrs[j], false);
  2776.  
  2777. if(buffType == EET_MariborForest && attrs[j] == 'focus_gain')
  2778. {
  2779. newAttr.value = val.valueAdditive;
  2780. newAttr.percentageValue = false;
  2781. }
  2782. // FCR3 --
  2783. else if(buffType == EET_Cat && attrs[j] == 'critical_hit_chance')
  2784. {
  2785. newAttr.value = val.valueAdditive;
  2786. newAttr.percentageValue = true;
  2787. }
  2788. // -- FCR3
  2789. else if(val.valueMultiplicative != 0)
  2790. {
  2791. if(buffType == EET_Mutagen26)
  2792. {
  2793.  
  2794. newAttr.value = val.valueAdditive;
  2795. newAttr.percentageValue = false;
  2796. tips.PushBack(newAttr);
  2797.  
  2798. newAttr.value = val.valueMultiplicative;
  2799. newAttr.percentageValue = true;
  2800.  
  2801. attrs.Erase(1);
  2802. }
  2803. else if(buffType == EET_Mutagen07)
  2804. {
  2805.  
  2806. attrs.Erase(1);
  2807. newAttr.value = val.valueBase;
  2808. newAttr.percentageValue = true;
  2809. }
  2810. else
  2811. {
  2812. newAttr.value = val.valueMultiplicative;
  2813. newAttr.percentageValue = true;
  2814. }
  2815. }
  2816. else if(val.valueAdditive != 0)
  2817. {
  2818. if(buffType == EET_Thunderbolt)
  2819. {
  2820. newAttr.value = val.valueAdditive * 100;
  2821. newAttr.percentageValue = true;
  2822. }
  2823. else if(buffType == EET_Blizzard)
  2824. {
  2825. newAttr.value = 1 - val.valueAdditive;
  2826. newAttr.percentageValue = true;
  2827. }
  2828. else if(buffType == EET_Mutagen01 || buffType == EET_Mutagen15 || buffType == EET_Mutagen28 || buffType == EET_Mutagen27)
  2829. {
  2830. newAttr.value = val.valueAdditive;
  2831. newAttr.percentageValue = true;
  2832. }
  2833. else
  2834. {
  2835. newAttr.value = val.valueAdditive;
  2836. newAttr.percentageValue = false;
  2837. }
  2838. }
  2839. else if(buffType == EET_GoldenOriole)
  2840. {
  2841. newAttr.value = val.valueBase;
  2842. newAttr.percentageValue = true;
  2843. }
  2844. else
  2845. {
  2846. newAttr.value = val.valueBase;
  2847. newAttr.percentageValue = false;
  2848. }
  2849.  
  2850. tips.PushBack(newAttr);
  2851. }
  2852. }
  2853.  
  2854.  
  2855. public function GetItemRelativeTooltipType(id :SItemUniqueId, invOther : CInventoryComponent, idOther : SItemUniqueId) : ECompareType
  2856. {
  2857.  
  2858. if( (GetItemCategory(id) == invOther.GetItemCategory(idOther)) ||
  2859. ItemHasTag(id, 'PlayerSteelWeapon') && invOther.ItemHasTag(idOther, 'PlayerSteelWeapon') ||
  2860. ItemHasTag(id, 'PlayerSilverWeapon') && invOther.ItemHasTag(idOther, 'PlayerSilverWeapon') ||
  2861. ItemHasTag(id, 'PlayerSecondaryWeapon') && invOther.ItemHasTag(idOther, 'PlayerSecondaryWeapon')
  2862. )
  2863. {
  2864. return ECT_Compare;
  2865. }
  2866. return ECT_Incomparable;
  2867. }
  2868.  
  2869.  
  2870. private function FormatFloatForTooltip(fValue : float) : string
  2871. {
  2872. var valueInt, valueDec : int;
  2873. var strValue : string;
  2874.  
  2875. if(fValue < 0)
  2876. {
  2877. valueInt = CeilF(fValue);
  2878. valueDec = RoundMath((fValue - valueInt)*(-100));
  2879. }
  2880. else
  2881. {
  2882. valueInt = FloorF(fValue);
  2883. valueDec = RoundMath((fValue - valueInt)*(100));
  2884. }
  2885. strValue = valueInt+".";
  2886. if(valueDec < 10)
  2887. strValue += "0"+valueDec;
  2888. else
  2889. strValue += ""+valueDec;
  2890.  
  2891. return strValue;
  2892. }
  2893.  
  2894. public function SetPriceMultiplier( mult : float )
  2895. {
  2896. priceMult = mult;
  2897. }
  2898.  
  2899.  
  2900. public function GetMerchantPriceModifier( shopNPC : CNewNPC, item : SItemUniqueId ) : float
  2901. {
  2902. var areaPriceMult : float;
  2903. var itemPriceMult : float;
  2904. var importPriceMult : float;
  2905. var finalPriceMult : float;
  2906. var tag : name;
  2907. var zoneName : EZoneName;
  2908.  
  2909. zoneName = theGame.GetCurrentZone();
  2910.  
  2911. switch ( zoneName )
  2912. {
  2913. case ZN_NML_CrowPerch : areaPriceMult = CalculateAttributeValue(thePlayer.GetAttributeValue('crow_perch_price_mult'));
  2914. case ZN_NML_SpitfireBluff : areaPriceMult = CalculateAttributeValue(thePlayer.GetAttributeValue('spitfire_bluff_price_mult'));
  2915. case ZN_NML_TheMire : areaPriceMult = CalculateAttributeValue(thePlayer.GetAttributeValue('the_mire_price_mult'));
  2916. case ZN_NML_Mudplough : areaPriceMult = CalculateAttributeValue(thePlayer.GetAttributeValue('mudplough_price_mult'));
  2917. case ZN_NML_Grayrocks : areaPriceMult = CalculateAttributeValue(thePlayer.GetAttributeValue('grayrocks_price_mult'));
  2918. case ZN_NML_TheDescent : areaPriceMult = CalculateAttributeValue(thePlayer.GetAttributeValue('the_descent_price_mult'));
  2919. case ZN_NML_CrookbackBog : areaPriceMult = CalculateAttributeValue(thePlayer.GetAttributeValue('crookback_bog_price_mult'));
  2920. case ZN_NML_BaldMountain : areaPriceMult = CalculateAttributeValue(thePlayer.GetAttributeValue('bald_mountain_price_mult'));
  2921. case ZN_NML_Novigrad : areaPriceMult = CalculateAttributeValue(thePlayer.GetAttributeValue('novigrad_price_mult'));
  2922. case ZN_NML_Homestead : areaPriceMult = CalculateAttributeValue(thePlayer.GetAttributeValue('homestead_price_mult'));
  2923. case ZN_NML_Gustfields : areaPriceMult = CalculateAttributeValue(thePlayer.GetAttributeValue('gustfields_price_mult'));
  2924. case ZN_NML_Oxenfurt : areaPriceMult = CalculateAttributeValue(thePlayer.GetAttributeValue('oxenfurt_price_mult'));
  2925. case ZN_Undefined : areaPriceMult = 1;
  2926. }
  2927.  
  2928. if (ItemHasTag(item,'weapon')) { itemPriceMult = CalculateAttributeValue(shopNPC.GetAttributeValue('weapon_price_mult')); }
  2929. else if (ItemHasTag(item,'armor')) { itemPriceMult = CalculateAttributeValue(shopNPC.GetAttributeValue('armor_price_mult')); }
  2930. else if (ItemHasTag(item,'crafting')) { itemPriceMult = CalculateAttributeValue(shopNPC.GetAttributeValue('crafting_price_mult')); }
  2931. else if (ItemHasTag(item,'alchemy')) { itemPriceMult = CalculateAttributeValue(shopNPC.GetAttributeValue('alchemy_price_mult')); }
  2932. else if (ItemHasTag(item,'alcohol')) { itemPriceMult = CalculateAttributeValue(shopNPC.GetAttributeValue('alcohol_price_mult')); }
  2933. else if (ItemHasTag(item,'food')) { itemPriceMult = CalculateAttributeValue(shopNPC.GetAttributeValue('food_price_mult')); }
  2934. else if (ItemHasTag(item,'fish')) { itemPriceMult = CalculateAttributeValue(shopNPC.GetAttributeValue('fish_price_mult')); }
  2935. else if (ItemHasTag(item,'books')) { itemPriceMult = CalculateAttributeValue(shopNPC.GetAttributeValue('books_price_mult')); }
  2936. else if (ItemHasTag(item,'valuables')) { itemPriceMult = CalculateAttributeValue(shopNPC.GetAttributeValue('valuables_price_mult')); }
  2937. else if (ItemHasTag(item,'junk')) { itemPriceMult = CalculateAttributeValue(shopNPC.GetAttributeValue('junk_price_mult')); }
  2938. else if (ItemHasTag(item,'orens')) { itemPriceMult = CalculateAttributeValue(shopNPC.GetAttributeValue('orens_price_mult')); }
  2939. else if (ItemHasTag(item,'florens')) { itemPriceMult = CalculateAttributeValue(shopNPC.GetAttributeValue('florens_price_mult')); }
  2940. else { itemPriceMult = 1; }
  2941.  
  2942. if (ItemHasTag(item,'novigrad')) { importPriceMult = CalculateAttributeValue(shopNPC.GetAttributeValue('novigrad_price_mult')); }
  2943. else if (ItemHasTag(item,'nilfgard')) { importPriceMult = CalculateAttributeValue(shopNPC.GetAttributeValue('nilfgard_price_mult')); }
  2944. else if (ItemHasTag(item,'nomansland')) { importPriceMult = CalculateAttributeValue(shopNPC.GetAttributeValue('nomansland_price_mult')); }
  2945. else if (ItemHasTag(item,'skellige')) { importPriceMult = CalculateAttributeValue(shopNPC.GetAttributeValue('skellige_price_mult')); }
  2946. else if (ItemHasTag(item,'nonhuman')) { importPriceMult = CalculateAttributeValue(shopNPC.GetAttributeValue('nonhuman_price_mult')); }
  2947. else { importPriceMult = 1; }
  2948.  
  2949. finalPriceMult = areaPriceMult*itemPriceMult*importPriceMult*priceMult;
  2950. return finalPriceMult;
  2951. }
  2952.  
  2953. public function SetRepairPriceMultiplier( mult : float )
  2954. {
  2955. priceRepairMult = mult;
  2956. }
  2957.  
  2958.  
  2959. public function GetRepairPriceModifier( repairNPC : CNewNPC ) : float
  2960. {
  2961. return priceRepairMult;
  2962. }
  2963.  
  2964. public function GetRepairPrice( item : SItemUniqueId ) : float
  2965. {
  2966. var currDiff : float;
  2967. currDiff = GetItemMaxDurability(item) - GetItemDurability(item);
  2968.  
  2969. return priceRepair * currDiff;
  2970. }
  2971.  
  2972.  
  2973. public function GetTooltipData(itemId : SItemUniqueId, out localizedName : string, out localizedDescription : string, out price : int, out localizedCategory : string,
  2974. out itemStats : array<SAttributeTooltip>, out localizedFluff : string)
  2975. {
  2976. if( !IsIdValid(itemId) )
  2977. {
  2978. return;
  2979. }
  2980. localizedName = GetItemLocalizedNameByUniqueID(itemId);
  2981. localizedDescription = GetItemLocalizedDescriptionByUniqueID(itemId);
  2982. localizedFluff = "IMPLEMENT ME - fluff text";
  2983. price = GetItemPriceModified( itemId, false );
  2984. localizedCategory = GetItemCategoryLocalisedString(GetItemCategory(itemId));
  2985. GetItemStats(itemId, itemStats);
  2986. }
  2987.  
  2988.  
  2989. public function GetItemBaseStats(itemId : SItemUniqueId, out itemStats : array<SAttributeTooltip>)
  2990. {
  2991. var attributes : array<name>;
  2992.  
  2993. var dm : CDefinitionsManagerAccessor;
  2994. var oilAbilities, oilAttributes : array<name>;
  2995. var weights : array<float>;
  2996. var i, j : int;
  2997. var tmpI, tmpJ : int;
  2998.  
  2999. var idx : int;
  3000. var oilStatsCount : int;
  3001. var oilName : name;
  3002. var oilStats : array<SAttributeTooltip>;
  3003. var oilStatFirst : SAttributeTooltip;
  3004. var oils : array< W3Effect_Oil >;
  3005.  
  3006. GetItemBaseAttributes(itemId, attributes);
  3007.  
  3008.  
  3009. oils = GetOilsAppliedOnItem( itemId );
  3010. dm = theGame.GetDefinitionsManager();
  3011. for( i=0; i<oils.Size(); i+=1 )
  3012. {
  3013. oilName = oils[ i ].GetOilItemName();
  3014.  
  3015. oilAbilities.Clear();
  3016. weights.Clear();
  3017. dm.GetItemAbilitiesWithWeights(oilName, GetEntity() == thePlayer, oilAbilities, weights, tmpI, tmpJ);
  3018.  
  3019. oilAttributes.Clear();
  3020. oilAttributes = dm.GetAbilitiesAttributes(oilAbilities);
  3021.  
  3022. oilStatsCount = oilAttributes.Size();
  3023. for (idx = 0; idx < oilStatsCount; idx+=1)
  3024. {
  3025. attributes.Remove(oilAttributes[idx]);
  3026. }
  3027. }
  3028.  
  3029. GetItemTooltipAttributes(itemId, attributes, itemStats);
  3030. }
  3031.  
  3032.  
  3033. public function GetItemStats(itemId : SItemUniqueId, out itemStats : array<SAttributeTooltip>)
  3034. {
  3035. var attributes : array<name>;
  3036.  
  3037. GetItemAttributes(itemId, attributes);
  3038. GetItemTooltipAttributes(itemId, attributes, itemStats);
  3039. }
  3040.  
  3041. private function GetItemTooltipAttributes(itemId : SItemUniqueId, attributes : array<name>, out itemStats : array<SAttributeTooltip>):void
  3042. {
  3043. var itemCategory:name;
  3044. var i, j, settingsSize : int;
  3045. var attributeString : string;
  3046. var attributeColor : string;
  3047. var attributeName : name;
  3048. var isPercentageValue : string;
  3049. var primaryStatLabel : string;
  3050. var statLabel : string;
  3051.  
  3052. var stat : SAttributeTooltip;
  3053. var attributeVal : SAbilityAttributeValue;
  3054.  
  3055. settingsSize = theGame.tooltipSettings.GetNumRows();
  3056. itemStats.Clear();
  3057. itemCategory = GetItemCategory(itemId);
  3058. for(i=0; i<settingsSize; i+=1)
  3059. {
  3060.  
  3061. attributeString = theGame.tooltipSettings.GetValueAt(0,i);
  3062. if(StrLen(attributeString) <= 0)
  3063. continue;
  3064.  
  3065. attributeName = '';
  3066.  
  3067.  
  3068. for(j=0; j<attributes.Size(); j+=1)
  3069. {
  3070. if(NameToString(attributes[j]) == attributeString)
  3071. {
  3072. attributeName = attributes[j];
  3073. break;
  3074. }
  3075. }
  3076. if(!IsNameValid(attributeName))
  3077. continue;
  3078.  
  3079.  
  3080. if(itemCategory == 'silversword' && attributeName == 'SlashingDamage') continue;
  3081. if(itemCategory == 'steelsword' && attributeName == 'SilverDamage') continue;
  3082.  
  3083.  
  3084. attributeColor = theGame.tooltipSettings.GetValueAt(1,i);
  3085.  
  3086. isPercentageValue = theGame.tooltipSettings.GetValueAt(2,i);
  3087.  
  3088.  
  3089. attributeVal = GetItemAttributeValue(itemId, attributeName);
  3090. stat.attributeColor = attributeColor;
  3091. stat.percentageValue = isPercentageValue;
  3092. stat.primaryStat = IsPrimaryStatById(itemId, attributeName, primaryStatLabel);
  3093. stat.value = 0;
  3094. stat.originName = attributeName;
  3095. if(attributeVal.valueBase != 0)
  3096. {
  3097. statLabel = GetAttributeNameLocStr(attributeName, false);
  3098. stat.value = attributeVal.valueBase;
  3099. }
  3100. if(attributeVal.valueMultiplicative != 0)
  3101. {
  3102.  
  3103.  
  3104. statLabel = GetAttributeNameLocStr(attributeName, false);
  3105. stat.value = attributeVal.valueMultiplicative;
  3106. stat.percentageValue = true;
  3107. }
  3108. if(attributeVal.valueAdditive != 0)
  3109. {
  3110. statLabel = GetAttributeNameLocStr(attributeName, false);
  3111. stat.value = attributeVal.valueAdditive;
  3112. }
  3113. if (stat.value != 0)
  3114. {
  3115. stat.attributeName = statLabel;
  3116.  
  3117. itemStats.PushBack(stat);
  3118. }
  3119. }
  3120. }
  3121.  
  3122.  
  3123. public function GetItemStatsFromName(itemName : name, out itemStats : array<SAttributeTooltip>)
  3124. {
  3125. var itemCategory : name;
  3126. var i, j, settingsSize : int;
  3127. var attributeString : string;
  3128. var attributeColor : string;
  3129. var attributeName : name;
  3130. var isPercentageValue : string;
  3131. var attributes, itemAbilities, tmpArray : array<name>;
  3132. var weights : array<float>;
  3133. var stat : SAttributeTooltip;
  3134. var attributeVal, min, max : SAbilityAttributeValue;
  3135. var dm : CDefinitionsManagerAccessor;
  3136. var primaryStatLabel : string;
  3137. var statLabel : string;
  3138.  
  3139. settingsSize = theGame.tooltipSettings.GetNumRows();
  3140. dm = theGame.GetDefinitionsManager();
  3141. dm.GetItemAbilitiesWithWeights(itemName, GetEntity() == thePlayer, itemAbilities, weights, i, j);
  3142. attributes = dm.GetAbilitiesAttributes(itemAbilities);
  3143.  
  3144. itemStats.Clear();
  3145. itemCategory = dm.GetItemCategory(itemName);
  3146. for(i=0; i<settingsSize; i+=1)
  3147. {
  3148.  
  3149. attributeString = theGame.tooltipSettings.GetValueAt(0,i);
  3150. if(StrLen(attributeString) <= 0)
  3151. continue;
  3152.  
  3153. attributeName = '';
  3154.  
  3155.  
  3156. for(j=0; j<attributes.Size(); j+=1)
  3157. {
  3158. if(NameToString(attributes[j]) == attributeString)
  3159. {
  3160. attributeName = attributes[j];
  3161. break;
  3162. }
  3163. }
  3164. if(!IsNameValid(attributeName))
  3165. continue;
  3166.  
  3167.  
  3168. if(itemCategory == 'silversword' && attributeName == 'SlashingDamage') continue;
  3169. if(itemCategory == 'steelsword' && attributeName == 'SilverDamage') continue;
  3170.  
  3171.  
  3172. attributeColor = theGame.tooltipSettings.GetValueAt(1,i);
  3173.  
  3174. isPercentageValue = theGame.tooltipSettings.GetValueAt(2,i);
  3175.  
  3176.  
  3177. dm.GetAbilitiesAttributeValue(itemAbilities, attributeName, min, max);
  3178. attributeVal = GetAttributeRandomizedValue(min, max);
  3179.  
  3180. stat.attributeColor = attributeColor;
  3181. stat.percentageValue = isPercentageValue;
  3182.  
  3183. stat.primaryStat = IsPrimaryStat(itemCategory, attributeName, primaryStatLabel);
  3184.  
  3185. stat.value = 0;
  3186. stat.originName = attributeName;
  3187.  
  3188. if(attributeVal.valueBase != 0)
  3189. {
  3190. stat.value = attributeVal.valueBase;
  3191. }
  3192. if(attributeVal.valueMultiplicative != 0)
  3193. {
  3194. stat.value = attributeVal.valueMultiplicative;
  3195. stat.percentageValue = true;
  3196. }
  3197. if(attributeVal.valueAdditive != 0)
  3198. {
  3199. statLabel = GetAttributeNameLocStr(attributeName, false);
  3200. stat.value = attributeVal.valueBase + attributeVal.valueAdditive;
  3201. }
  3202.  
  3203. if (attributeName == 'toxicity_offset')
  3204. {
  3205. statLabel = GetAttributeNameLocStr('toxicity', false);
  3206. stat.percentageValue = false;
  3207. }
  3208. else
  3209. {
  3210. statLabel = GetAttributeNameLocStr(attributeName, false);
  3211. }
  3212.  
  3213. if (stat.value != 0)
  3214. {
  3215. stat.attributeName = statLabel;
  3216.  
  3217. itemStats.PushBack(stat);
  3218. }
  3219.  
  3220.  
  3221. }
  3222. }
  3223.  
  3224. public function IsThereItemOnSlot(slot : EEquipmentSlots) : bool
  3225. {
  3226. var player : W3PlayerWitcher;
  3227.  
  3228. player = ((W3PlayerWitcher)GetEntity());
  3229. if(player)
  3230. {
  3231. return player.IsAnyItemEquippedOnSlot(slot);
  3232. }
  3233. else
  3234. {
  3235. return false;
  3236. }
  3237. }
  3238.  
  3239. public function GetItemEquippedOnSlot(slot : EEquipmentSlots, out item : SItemUniqueId) : bool
  3240. {
  3241. var player : W3PlayerWitcher;
  3242.  
  3243. player = ((W3PlayerWitcher)GetEntity());
  3244. if(player)
  3245. {
  3246. return player.GetItemEquippedOnSlot(slot, item);
  3247. }
  3248. else
  3249. {
  3250. return false;
  3251. }
  3252. }
  3253.  
  3254. public function IsItemExcluded ( itemID : SItemUniqueId, excludedItems : array < SItemNameProperty > ) : bool
  3255. {
  3256. var i : int;
  3257. var currItemName : name;
  3258.  
  3259. currItemName = GetItemName( itemID );
  3260.  
  3261. for ( i = 0; i < excludedItems.Size(); i+=1 )
  3262. {
  3263. if ( currItemName == excludedItems[i].itemName )
  3264. {
  3265. return true;
  3266. }
  3267. }
  3268. return false;
  3269. }
  3270.  
  3271.  
  3272. public function GetItemPrimaryStat(itemId : SItemUniqueId, out attributeLabel : string, out attributeVal : float ) : void
  3273. {
  3274. var attributeName : name;
  3275. var attributeValue:SAbilityAttributeValue;
  3276.  
  3277. GetItemPrimaryStatImplById(itemId, attributeLabel, attributeVal, attributeName);
  3278.  
  3279. attributeValue = GetItemAttributeValue(itemId, attributeName);
  3280.  
  3281. if(attributeValue.valueBase != 0)
  3282. {
  3283. attributeVal = attributeValue.valueBase;
  3284. }
  3285. if(attributeValue.valueMultiplicative != 0)
  3286. {
  3287. attributeVal = attributeValue.valueMultiplicative;
  3288. }
  3289. if(attributeValue.valueAdditive != 0)
  3290. {
  3291. attributeVal = attributeValue.valueAdditive;
  3292. }
  3293. }
  3294.  
  3295. public function GetItemStatByName(itemName : name, statName : name, out resultValue : float) : void
  3296. {
  3297. var dm : CDefinitionsManagerAccessor;
  3298. var attributes, itemAbilities : array<name>;
  3299. var min, max, attributeValue : SAbilityAttributeValue;
  3300. var tmpInt : int;
  3301. var tmpArray : array<float>;
  3302.  
  3303. dm = theGame.GetDefinitionsManager();
  3304. dm.GetItemAbilitiesWithWeights(itemName, GetEntity() == thePlayer, itemAbilities, tmpArray, tmpInt, tmpInt);
  3305. attributes = dm.GetAbilitiesAttributes(itemAbilities);
  3306.  
  3307. dm.GetAbilitiesAttributeValue(itemAbilities, statName, min, max);
  3308. attributeValue = GetAttributeRandomizedValue(min, max);
  3309.  
  3310. if(attributeValue.valueBase != 0)
  3311. {
  3312. resultValue = attributeValue.valueBase;
  3313. }
  3314. if(attributeValue.valueMultiplicative != 0)
  3315. {
  3316. resultValue = attributeValue.valueMultiplicative;
  3317. }
  3318. if(attributeValue.valueAdditive != 0)
  3319. {
  3320. resultValue = attributeValue.valueAdditive;
  3321. }
  3322. }
  3323.  
  3324. public function GetItemPrimaryStatFromName(itemName : name, out attributeLabel : string, out attributeVal : float, out primAttrName : name) : void
  3325. {
  3326. var dm : CDefinitionsManagerAccessor;
  3327. var attributeName : name;
  3328. var attributes, itemAbilities : array<name>;
  3329. var attributeValue, min, max : SAbilityAttributeValue;
  3330.  
  3331. var tmpInt : int;
  3332. var tmpArray : array<float>;
  3333.  
  3334. dm = theGame.GetDefinitionsManager();
  3335.  
  3336. GetItemPrimaryStatImpl(dm.GetItemCategory(itemName), attributeLabel, attributeVal, attributeName);
  3337. dm.GetItemAbilitiesWithWeights(itemName, GetEntity() == thePlayer, itemAbilities, tmpArray, tmpInt, tmpInt);
  3338. attributes = dm.GetAbilitiesAttributes(itemAbilities);
  3339. for (tmpInt = 0; tmpInt < attributes.Size(); tmpInt += 1)
  3340. if (attributes[tmpInt] == attributeName)
  3341. {
  3342. dm.GetAbilitiesAttributeValue(itemAbilities, attributeName, min, max);
  3343. attributeValue = GetAttributeRandomizedValue(min, max);
  3344. primAttrName = attributeName;
  3345. break;
  3346. }
  3347.  
  3348. if(attributeValue.valueBase != 0)
  3349. {
  3350. attributeVal = attributeValue.valueBase;
  3351. }
  3352. if(attributeValue.valueMultiplicative != 0)
  3353. {
  3354. attributeVal = attributeValue.valueMultiplicative;
  3355. }
  3356. if(attributeValue.valueAdditive != 0)
  3357. {
  3358. attributeVal = attributeValue.valueAdditive;
  3359. }
  3360.  
  3361. }
  3362.  
  3363. public function IsPrimaryStatById(itemId : SItemUniqueId, attributeName : name, out attributeLabel : string) : bool
  3364. {
  3365. var attrValue : float;
  3366. var attrName : name;
  3367.  
  3368. GetItemPrimaryStatImplById(itemId, attributeLabel, attrValue, attrName);
  3369. return attrName == attributeName;
  3370. }
  3371.  
  3372. private function GetItemPrimaryStatImplById(itemId : SItemUniqueId, out attributeLabel : string, out attributeVal : float, out attributeName : name ) : void
  3373. {
  3374. var itemOnSlot : SItemUniqueId;
  3375. var categoryName : name;
  3376. var abList : array<name>;
  3377.  
  3378. attributeName = '';
  3379. attributeLabel = "";
  3380. categoryName = GetItemCategory(itemId);
  3381.  
  3382.  
  3383. if (categoryName == 'bolt' || categoryName == 'petard')
  3384. {
  3385. GetItemAttributes(itemId, abList);
  3386. if (abList.Contains('FireDamage'))
  3387. {
  3388. attributeName = 'FireDamage';
  3389. }
  3390. else if (abList.Contains('PiercingDamage'))
  3391. {
  3392. attributeName = 'PiercingDamage';
  3393. }
  3394. else if (abList.Contains('PiercingDamage'))
  3395. {
  3396. attributeName = 'PiercingDamage';
  3397. }
  3398. else if (abList.Contains('PoisonDamage'))
  3399. {
  3400. attributeName = 'PoisonDamage';
  3401. }
  3402. else if (abList.Contains('BludgeoningDamage'))
  3403. {
  3404. attributeName = 'BludgeoningDamage';
  3405. }
  3406. else
  3407. {
  3408. attributeName = 'PhysicalDamage';
  3409. }
  3410. attributeLabel = GetAttributeNameLocStr(attributeName, false);
  3411. }
  3412. else if (categoryName == 'secondary')
  3413. {
  3414. GetItemAttributes(itemId, abList);
  3415. if (abList.Contains('BludgeoningDamage'))
  3416. {
  3417. attributeName = 'BludgeoningDamage';
  3418. }
  3419. else
  3420. {
  3421. attributeName = 'PhysicalDamage';
  3422. }
  3423. attributeLabel = GetAttributeNameLocStr(attributeName, false);
  3424. }
  3425. else if (categoryName == 'steelsword')
  3426. {
  3427. GetItemAttributes(itemId, abList);
  3428. if (abList.Contains('SlashingDamage'))
  3429. {
  3430. attributeName = 'SlashingDamage';
  3431. attributeLabel = GetLocStringByKeyExt("panel_inventory_tooltip_damage");
  3432. }
  3433. else if (abList.Contains('BludgeoningDamage'))
  3434. {
  3435. attributeName = 'BludgeoningDamage';
  3436. }
  3437. else if (abList.Contains('PiercingDamage'))
  3438. {
  3439. attributeName = 'PiercingDamage';
  3440. }
  3441. else
  3442. {
  3443. attributeName = 'PhysicalDamage';
  3444. }
  3445. if (attributeLabel == "")
  3446. {
  3447. attributeLabel = GetAttributeNameLocStr(attributeName, false);
  3448. }
  3449. }
  3450. else
  3451. {
  3452. GetItemPrimaryStatImpl(categoryName, attributeLabel, attributeVal, attributeName);
  3453. }
  3454. }
  3455.  
  3456. public function IsPrimaryStat(categoryName : name, attributeName : name, out attributeLabel : string) : bool
  3457. {
  3458. var attrValue : float;
  3459. var attrName : name;
  3460.  
  3461. GetItemPrimaryStatImpl(categoryName, attributeLabel, attrValue, attrName);
  3462. return attrName == attributeName;
  3463. }
  3464.  
  3465. private function GetItemPrimaryStatImpl(categoryName : name, out attributeLabel : string, out attributeVal : float, out attributeName : name ) : void
  3466. {
  3467. attributeName = '';
  3468. attributeLabel = "";
  3469. switch (categoryName)
  3470. {
  3471. case 'steelsword':
  3472. attributeName = 'SlashingDamage';
  3473. attributeLabel = GetLocStringByKeyExt("panel_inventory_tooltip_damage");
  3474. break;
  3475. case 'silversword':
  3476. attributeName = 'SilverDamage';
  3477. attributeLabel = GetLocStringByKeyExt("panel_inventory_tooltip_damage");
  3478. break;
  3479. case 'armor':
  3480. case 'gloves':
  3481. case 'gloves':
  3482. case 'boots':
  3483. case 'pants':
  3484. attributeName = 'armor';
  3485. break;
  3486. case 'potion':
  3487. case 'oil':
  3488.  
  3489. break;
  3490. case 'bolt':
  3491. case 'petard':
  3492. attributeName = 'PhysicalDamage';
  3493. break;
  3494. case 'crossbow':
  3495. default:
  3496. attributeLabel = "";
  3497. attributeVal = 0;
  3498. return;
  3499. break;
  3500. }
  3501.  
  3502. if (attributeLabel == "")
  3503. {
  3504. attributeLabel = GetAttributeNameLocStr(attributeName, false);
  3505. }
  3506. }
  3507.  
  3508. public function CanBeCompared(itemId : SItemUniqueId) : bool
  3509. {
  3510. var wplayer : W3PlayerWitcher;
  3511. var itemSlot : EEquipmentSlots;
  3512. var equipedItem : SItemUniqueId;
  3513. var horseManager : W3HorseManager;
  3514.  
  3515. var isArmorOrWeapon : bool;
  3516.  
  3517. if (IsItemHorseItem(itemId))
  3518. {
  3519. horseManager = GetWitcherPlayer().GetHorseManager();
  3520.  
  3521. if (!horseManager)
  3522. {
  3523. return false;
  3524. }
  3525.  
  3526. if (horseManager.IsItemEquipped(itemId))
  3527. {
  3528. return false;
  3529. }
  3530.  
  3531. itemSlot = GetHorseSlotForItem(itemId);
  3532. equipedItem = horseManager.GetItemInSlot(itemSlot);
  3533. if (!horseManager.GetInventoryComponent().IsIdValid(equipedItem))
  3534. {
  3535. return false;
  3536. }
  3537. }
  3538. else
  3539. {
  3540. isArmorOrWeapon = IsItemAnyArmor(itemId) || IsItemWeapon(itemId);
  3541. if (!isArmorOrWeapon)
  3542. {
  3543. return false;
  3544. }
  3545.  
  3546. wplayer = GetWitcherPlayer();
  3547. if (wplayer.IsItemEquipped(itemId))
  3548. {
  3549. return false;
  3550. }
  3551.  
  3552. itemSlot = GetSlotForItemId(itemId);
  3553. wplayer.GetItemEquippedOnSlot(itemSlot, equipedItem);
  3554. if (!wplayer.inv.IsIdValid(equipedItem))
  3555. {
  3556. return false;
  3557. }
  3558. }
  3559.  
  3560. return true;
  3561. }
  3562.  
  3563. public function GetHorseSlotForItem(id : SItemUniqueId) : EEquipmentSlots
  3564. {
  3565. var tags : array<name>;
  3566.  
  3567. GetItemTags(id, tags);
  3568.  
  3569. if(tags.Contains('Saddle')) return EES_HorseSaddle;
  3570. else if(tags.Contains('HorseBag')) return EES_HorseBag;
  3571. else if(tags.Contains('Trophy')) return EES_HorseTrophy;
  3572. else if(tags.Contains('Blinders')) return EES_HorseBlinders;
  3573. else return EES_InvalidSlot;
  3574. }
  3575.  
  3576.  
  3577.  
  3578.  
  3579.  
  3580. public final function SingletonItemRefillAmmo( id : SItemUniqueId, optional alchemyTableUsed : bool )
  3581. {
  3582. var l_bed : W3WitcherBed;
  3583. var refilledByBed : bool;
  3584.  
  3585. refilledByBed = false;
  3586.  
  3587.  
  3588. if( FactsQuerySum( "PlayerInsideOuterWitcherHouse" ) >= 1 && FactsQuerySum( "AlchemyTableExists" ) >= 1 && !IsItemMutagenPotion( id ) )
  3589. {
  3590. l_bed = (W3WitcherBed)theGame.GetEntityByTag( 'witcherBed' );
  3591.  
  3592. if( l_bed.GetWasUsed() || alchemyTableUsed )
  3593. {
  3594. SetItemModifierInt( id, 'ammo_current', SingletonItemGetMaxAmmo(id) + theGame.params.QUANTITY_INCREASED_BY_ALCHEMY_TABLE ) ;
  3595. refilledByBed = true;
  3596. if( !l_bed.GetWereItemsRefilled() )
  3597. {
  3598. l_bed.SetWereItemsRefilled( true );
  3599. }
  3600. }
  3601. }
  3602.  
  3603.  
  3604. if( !refilledByBed && SingletonItemGetAmmo( id ) < SingletonItemGetMaxAmmo( id ) )
  3605. {
  3606. SetItemModifierInt(id, 'ammo_current', SingletonItemGetMaxAmmo(id));
  3607. }
  3608.  
  3609. theGame.GetGlobalEventsManager().OnScriptedEvent( SEC_OnAmmoChanged );
  3610. }
  3611.  
  3612. public function SingletonItemSetAmmo(id : SItemUniqueId, quantity : int)
  3613. {
  3614. var amount : int;
  3615.  
  3616. if(ItemHasTag(id, theGame.params.TAG_INFINITE_AMMO))
  3617. {
  3618. amount = -1;
  3619. }
  3620. else
  3621. {
  3622. amount = Clamp(quantity, 0, SingletonItemGetMaxAmmo(id));
  3623. }
  3624.  
  3625. SetItemModifierInt(id, 'ammo_current', amount);
  3626. theGame.GetGlobalEventsManager().OnScriptedEvent( SEC_OnAmmoChanged );
  3627. }
  3628.  
  3629. public function SingletonItemAddAmmo(id : SItemUniqueId, quantity : int)
  3630. {
  3631. var ammo : int;
  3632.  
  3633. if(quantity <= 0)
  3634. return;
  3635.  
  3636. ammo = GetItemModifierInt(id, 'ammo_current');
  3637.  
  3638. if(ammo == -1)
  3639. return;
  3640.  
  3641. ammo = Clamp(ammo + quantity, 0, SingletonItemGetMaxAmmo(id));
  3642. SetItemModifierInt(id, 'ammo_current', ammo);
  3643. theGame.GetGlobalEventsManager().OnScriptedEvent( SEC_OnAmmoChanged );
  3644. }
  3645.  
  3646. public function SingletonItemsRefillAmmo( optional alchemyTableUsed : bool ) : bool
  3647. {
  3648. var i : int;
  3649. var singletonItems : array<SItemUniqueId>;
  3650. var alco : SItemUniqueId;
  3651. var arrStr : array<string>;
  3652. var witcher : W3PlayerWitcher;
  3653. var itemLabel : string;
  3654.  
  3655. witcher = GetWitcherPlayer();
  3656. if(GetEntity() == witcher && HasNotFilledSingletonItem( alchemyTableUsed ) )
  3657. {
  3658. alco = witcher.GetAlcoholForAlchemicalItemsRefill();
  3659.  
  3660. if(!IsIdValid(alco))
  3661. {
  3662.  
  3663. theGame.GetGuiManager().ShowNotification(GetLocStringByKeyExt("message_common_alchemy_items_cannot_refill"));
  3664. theSound.SoundEvent("gui_global_denied");
  3665.  
  3666. return false;
  3667. }
  3668. else
  3669. {
  3670.  
  3671. arrStr.PushBack(GetItemName(alco));
  3672. itemLabel = GetLocStringByKeyExt(GetItemLocalizedNameByUniqueID(alco));
  3673. theGame.GetGuiManager().ShowNotification( itemLabel + " - " + GetLocStringByKeyExtWithParams("message_common_alchemy_items_refilled", , , arrStr));
  3674. theSound.SoundEvent("gui_alchemy_brew");
  3675.  
  3676. if(!ItemHasTag(alco, theGame.params.TAG_INFINITE_USE))
  3677. RemoveItem(alco);
  3678. }
  3679. }
  3680.  
  3681. singletonItems = GetSingletonItems();
  3682. for(i=0; i<singletonItems.Size(); i+=1)
  3683. {
  3684. SingletonItemRefillAmmo( singletonItems[i], alchemyTableUsed );
  3685. }
  3686.  
  3687. return true;
  3688. }
  3689.  
  3690. public function SingletonItemsRefillAmmoNoAlco(optional dontUpdateUI : bool)
  3691. {
  3692. var i : int;
  3693. var singletonItems : array<SItemUniqueId>;
  3694. var alco : SItemUniqueId;
  3695. var arrStr : array<string>;
  3696. var witcher : W3PlayerWitcher;
  3697. var itemLabel : string;
  3698.  
  3699. witcher = GetWitcherPlayer();
  3700. if(!dontUpdateUI && GetEntity() == witcher && HasNotFilledSingletonItem())
  3701. {
  3702.  
  3703. arrStr.PushBack(GetItemName(alco));
  3704. itemLabel = GetLocStringByKeyExt(GetItemLocalizedNameByUniqueID(alco));
  3705. theGame.GetGuiManager().ShowNotification( itemLabel + " - " + GetLocStringByKeyExtWithParams("message_common_alchemy_items_refilled", , , arrStr));
  3706. theSound.SoundEvent("gui_alchemy_brew");
  3707. }
  3708.  
  3709. singletonItems = GetSingletonItems();
  3710. for(i=0; i<singletonItems.Size(); i+=1)
  3711. {
  3712. SingletonItemRefillAmmo(singletonItems[i]);
  3713. }
  3714. }
  3715.  
  3716.  
  3717. private final function HasNotFilledSingletonItem( optional alchemyTableUsed : bool ) : bool
  3718. {
  3719. var i : int;
  3720. var singletonItems : array<SItemUniqueId>;
  3721. var hasLab : bool;
  3722. var l_bed : W3WitcherBed;
  3723.  
  3724.  
  3725. hasLab = false;
  3726. if( FactsQuerySum( "PlayerInsideOuterWitcherHouse" ) >= 1 && FactsQuerySum( "AlchemyTableExists" ) >= 1 )
  3727. {
  3728. l_bed = (W3WitcherBed)theGame.GetEntityByTag( 'witcherBed' );
  3729. if( l_bed.GetWasUsed() || alchemyTableUsed )
  3730. {
  3731. hasLab = true;
  3732. }
  3733. }
  3734.  
  3735. singletonItems = GetSingletonItems();
  3736. for(i=0; i<singletonItems.Size(); i+=1)
  3737. {
  3738. if( hasLab && !IsItemMutagenPotion( singletonItems[i] ) )
  3739. {
  3740. if(SingletonItemGetAmmo(singletonItems[i]) <= SingletonItemGetMaxAmmo(singletonItems[i]))
  3741. {
  3742. return true;
  3743. }
  3744. }
  3745. else if(SingletonItemGetAmmo(singletonItems[i]) < SingletonItemGetMaxAmmo(singletonItems[i]))
  3746. {
  3747. return true;
  3748. }
  3749. }
  3750.  
  3751. return false;
  3752. }
  3753.  
  3754. public function SingletonItemRemoveAmmo(itemID : SItemUniqueId, optional quantity : int)
  3755. {
  3756. var ammo : int;
  3757.  
  3758. if(!IsItemSingletonItem(itemID) || ItemHasTag(itemID, theGame.params.TAG_INFINITE_AMMO))
  3759. return;
  3760.  
  3761. if(quantity <= 0)
  3762. quantity = 1;
  3763.  
  3764. ammo = GetItemModifierInt(itemID, 'ammo_current');
  3765. ammo = Max(0, ammo - quantity);
  3766. SetItemModifierInt(itemID, 'ammo_current', ammo);
  3767.  
  3768.  
  3769. if(ammo == 0 && ShouldProcessTutorial('TutorialAlchemyRefill') && FactsQuerySum("q001_nightmare_ended") > 0)
  3770. {
  3771. FactsAdd('tut_alch_refill', 1);
  3772. }
  3773. theGame.GetGlobalEventsManager().OnScriptedEvent( SEC_OnAmmoChanged );
  3774. }
  3775.  
  3776. public function SingletonItemGetAmmo(itemID : SItemUniqueId) : int
  3777. {
  3778. if(!IsItemSingletonItem(itemID))
  3779. return 0;
  3780.  
  3781. return GetItemModifierInt(itemID, 'ammo_current');
  3782. }
  3783.  
  3784. public function SingletonItemGetMaxAmmo(itemID : SItemUniqueId) : int
  3785. {
  3786. var ammo, i : int;
  3787. var perk20Bonus, min, max : SAbilityAttributeValue;
  3788. var atts : array<name>;
  3789. var canUseSkill : bool;
  3790.  
  3791. ammo = RoundMath(CalculateAttributeValue(GetItemAttributeValue(itemID, 'ammo')));
  3792.  
  3793. if( !ItemHasTag( itemID, 'NoAdditionalAmmo' ) )
  3794. {
  3795. if(GetEntity() == GetWitcherPlayer() && ammo > 0)
  3796. {
  3797. if(IsItemBomb(itemID) && thePlayer.CanUseSkill(S_Alchemy_s08) )
  3798. {
  3799. ammo += thePlayer.GetSkillLevel(S_Alchemy_s08);
  3800. }
  3801.  
  3802. if(thePlayer.HasBuff(EET_Mutagen03) && (IsItemBomb(itemID) || (!IsItemMutagenPotion(itemID) && IsItemPotion(itemID))) )
  3803. {
  3804. ammo += 1;
  3805. }
  3806.  
  3807. if( GetWitcherPlayer().IsSetBonusActive( EISB_RedWolf_2 ) && !IsItemMutagenPotion(itemID) )
  3808. {
  3809. theGame.GetDefinitionsManager().GetAbilityAttributeValue( GetSetBonusAbility( EISB_RedWolf_2 ), 'amount', min, max);
  3810. ammo += (int)min.valueAdditive;
  3811. }
  3812.  
  3813.  
  3814. if( IsItemBomb( itemID ) && thePlayer.CanUseSkill( S_Perk_20 ) && GetItemName( itemID ) != 'Snow Ball' )
  3815. {
  3816. GetItemAttributes( itemID, atts );
  3817. canUseSkill = thePlayer.CanUseSkill( S_Alchemy_s10 );
  3818. perk20Bonus = GetWitcherPlayer().GetSkillAttributeValue( S_Perk_20, 'stack_multiplier', false, false );
  3819.  
  3820. for( i=0 ; i<atts.Size() ; i+=1 )
  3821. {
  3822. if( canUseSkill || IsDamageTypeNameValid( atts[i] ) )
  3823. {
  3824. ammo = RoundMath( ammo * perk20Bonus.valueMultiplicative );
  3825. break;
  3826. }
  3827. }
  3828. }
  3829. }
  3830. }
  3831.  
  3832. return ammo;
  3833. }
  3834.  
  3835. public function ManageSingletonItemsBonus()
  3836. {
  3837. var l_items : array<SItemUniqueId>;
  3838. var l_i : int;
  3839. var l_haveBombOrPot : bool;
  3840.  
  3841. l_items = GetSingletonItems();
  3842.  
  3843. for( l_i = 0 ; l_i < l_items.Size() ; l_i += 1 )
  3844. {
  3845. if( IsItemPotion( l_items[ l_i ] ) || IsItemBomb( l_items[ l_i ] ) )
  3846. {
  3847. l_haveBombOrPot = true;
  3848. if( SingletonItemGetMaxAmmo( l_items[ l_i ] ) >= SingletonItemGetAmmo( l_items[ l_i ] ) )
  3849. {
  3850. if( SingletonItemsRefillAmmo( true ) )
  3851. {
  3852. theGame.GetGuiManager().ShowNotification( GetLocStringByKeyExt( "message_common_alchemy_table_buff_applied" ),, true );
  3853. }
  3854.  
  3855. return;
  3856. }
  3857. }
  3858. }
  3859.  
  3860. if( !l_haveBombOrPot )
  3861. {
  3862. theGame.GetGuiManager().ShowNotification( GetLocStringByKeyExt( "message_common_alchemy_table_buff_no_items" ),, true );
  3863. return;
  3864. }
  3865.  
  3866. theGame.GetGuiManager().ShowNotification( GetLocStringByKeyExt( "message_common_alchemy_table_buff_already_on" ),, true );
  3867. }
  3868.  
  3869.  
  3870.  
  3871.  
  3872.  
  3873. public final function IsItemSteelSwordUsableByPlayer(item : SItemUniqueId) : bool
  3874. {
  3875. return ItemHasTag(item, theGame.params.TAG_PLAYER_STEELSWORD) && !ItemHasTag(item, 'SecondaryWeapon');
  3876. }
  3877.  
  3878. public final function IsItemSilverSwordUsableByPlayer(item : SItemUniqueId) : bool
  3879. {
  3880. return ItemHasTag(item, theGame.params.TAG_PLAYER_SILVERSWORD) && !ItemHasTag(item, 'SecondaryWeapon');
  3881. }
  3882.  
  3883. public final function IsItemFists(item : SItemUniqueId) : bool {return GetItemCategory(item) == 'fist';}
  3884. public final function IsItemWeapon(item : SItemUniqueId) : bool {return ItemHasTag(item, 'Weapon') || ItemHasTag(item, 'WeaponTab');}
  3885. public final function IsItemCrossbow(item : SItemUniqueId) : bool {return GetItemCategory(item) == 'crossbow';}
  3886. public final function IsItemChestArmor(item : SItemUniqueId) : bool {return GetItemCategory(item) == 'armor';}
  3887. public final function IsItemBody(item : SItemUniqueId) : bool {return ItemHasTag(item, 'Body');}
  3888. public final function IsRecipeOrSchematic( item : SItemUniqueId ) : bool {return GetItemCategory(item) == 'alchemy_recipe' || GetItemCategory(item) == 'crafting_schematic'; }
  3889. public final function IsItemBoots(item : SItemUniqueId) : bool {return GetItemCategory(item) == 'boots';}
  3890. public final function IsItemGloves(item : SItemUniqueId) : bool {return GetItemCategory(item) == 'gloves';}
  3891. public final function IsItemPants(item : SItemUniqueId) : bool {return GetItemCategory(item) == 'trousers' || GetItemCategory(item) == 'pants';}
  3892. public final function IsItemTrophy(item : SItemUniqueId) : bool {return GetItemCategory(item) == 'trophy';}
  3893. public final function IsItemMask(item : SItemUniqueId) : bool {return GetItemCategory(item) == 'mask';}
  3894. public final function IsItemBomb(item : SItemUniqueId) : bool {return GetItemCategory(item) == 'petard';}
  3895. public final function IsItemBolt(item : SItemUniqueId) : bool {return GetItemCategory(item) == 'bolt';}
  3896. public final function IsItemUpgrade(item : SItemUniqueId) : bool {return GetItemCategory(item) == 'upgrade';}
  3897. public final function IsItemTool(item : SItemUniqueId) : bool {return GetItemCategory(item) == 'tool';}
  3898. public final function IsItemPotion(item : SItemUniqueId) : bool {return ItemHasTag(item, 'Potion');}
  3899. public final function IsItemOil(item : SItemUniqueId) : bool {return ItemHasTag(item, 'SilverOil') || ItemHasTag(item, 'SteelOil');}
  3900. public final function IsItemAnyArmor(item : SItemUniqueId) : bool {return ItemHasTag(item, theGame.params.TAG_ARMOR);}
  3901. public final function IsItemUpgradeable(item : SItemUniqueId) : bool {return ItemHasTag(item, theGame.params.TAG_ITEM_UPGRADEABLE);}
  3902. public final function IsItemIngredient(item : SItemUniqueId) : bool {return ItemHasTag(item, 'AlchemyIngredient') || ItemHasTag(item, 'CraftingIngredient');}
  3903. public final function IsItemDismantleKit(item : SItemUniqueId) : bool {return ItemHasTag(item, 'DismantleKit');}
  3904. public final function IsItemHorseBag(item : SItemUniqueId) : bool {return ItemHasTag(item, 'HorseBag');}
  3905. public final function IsItemReadable(item : SItemUniqueId) : bool {return ItemHasTag(item, 'ReadableItem');}
  3906. public final function IsItemAlchemyItem(item : SItemUniqueId) : bool {return IsItemOil(item) || IsItemPotion(item) || IsItemBomb(item); }
  3907. public final function IsItemSingletonItem(item : SItemUniqueId) : bool {return ItemHasTag(item, theGame.params.TAG_ITEM_SINGLETON);}
  3908. public final function IsItemQuest(item : SItemUniqueId) : bool {return ItemHasTag(item, 'Quest');}
  3909. public final function IsItemFood(item : SItemUniqueId) : bool {return ItemHasTag(item, 'Edibles') || ItemHasTag(item, 'Drinks');}
  3910. public final function IsItemSecondaryWeapon(item : SItemUniqueId) : bool {return ItemHasTag(item, 'SecondaryWeapon');}
  3911. public final function IsItemHorseItem(item: SItemUniqueId) : bool {return ItemHasTag(item, 'Saddle') || ItemHasTag(item, 'HorseBag') || ItemHasTag(item, 'Trophy') || ItemHasTag(item, 'Blinders'); }
  3912. public final function IsItemSaddle(item: SItemUniqueId) : bool {return ItemHasTag(item, 'Saddle');}
  3913. public final function IsItemBlinders(item: SItemUniqueId) : bool {return ItemHasTag(item, 'Blinders');}
  3914. public final function IsItemDye( item : SItemUniqueId ) : bool { return ItemHasTag( item, 'mod_dye' ); }
  3915. public final function IsItemUsable( item : SItemUniqueId ) : bool { return GetItemCategory( item ) == 'usable'; }
  3916. public final function IsItemJunk( item : SItemUniqueId ) : bool { return ItemHasTag( item,'junk' ) || GetItemCategory( item ) == 'junk' ; }
  3917. public final function IsItemAlchemyIngredient(item : SItemUniqueId) : bool { return ItemHasTag( item, 'AlchemyIngredient' ); }
  3918. public final function IsItemCraftingIngredient(item : SItemUniqueId) : bool { return ItemHasTag( item, 'CraftingIngredient' ); }
  3919. public final function IsItemArmorReapairKit(item : SItemUniqueId) : bool { return ItemHasTag( item, 'ArmorReapairKit' ); }
  3920. public final function IsItemWeaponReapairKit(item : SItemUniqueId) : bool { return ItemHasTag( item, 'WeaponReapairKit' ); }
  3921. public final function IsQuickSlotItem( item : SItemUniqueId ) : bool { return ItemHasTag( item, 'QuickSlot' ); }
  3922.  
  3923. public final function IsItemNew( item : SItemUniqueId ) : bool
  3924. {
  3925. var uiData : SInventoryItemUIData;
  3926.  
  3927. uiData = GetInventoryItemUIData( item );
  3928. return uiData.isNew;
  3929. }
  3930.  
  3931. public final function IsItemMutagenPotion(item : SItemUniqueId) : bool
  3932. {
  3933. return IsItemPotion(item) && ItemHasTag(item, 'Mutagen');
  3934. }
  3935.  
  3936. public final function CanItemBeColored( item : SItemUniqueId) : bool
  3937. {
  3938. if ( RoundMath( CalculateAttributeValue( GetItemAttributeValue( item, 'quality' ) ) ) == 5 )
  3939. {
  3940. return true;
  3941. }
  3942. return false;
  3943. }
  3944.  
  3945. public final function IsItemSetItem(item : SItemUniqueId) : bool
  3946. {
  3947. return
  3948. ItemHasTag(item, theGame.params.ITEM_SET_TAG_BEAR) ||
  3949. ItemHasTag(item, theGame.params.ITEM_SET_TAG_GRYPHON) ||
  3950. ItemHasTag(item, theGame.params.ITEM_SET_TAG_LYNX) ||
  3951. ItemHasTag(item, theGame.params.ITEM_SET_TAG_WOLF) ||
  3952. ItemHasTag(item, theGame.params.ITEM_SET_TAG_RED_WOLF) ||
  3953. ItemHasTag( item, theGame.params.ITEM_SET_TAG_VAMPIRE ) ||
  3954. ItemHasTag(item, theGame.params.ITEM_SET_TAG_VIPER);
  3955. }
  3956.  
  3957. public function GetArmorType(item : SItemUniqueId) : EArmorType
  3958. {
  3959. var isItemEquipped : bool;
  3960.  
  3961. isItemEquipped = GetWitcherPlayer().IsItemEquipped(item);
  3962.  
  3963.  
  3964. if( thePlayer.HasAbility('Glyphword 2 _Stats', true) && isItemEquipped )
  3965. {return EAT_Light;}
  3966. if( thePlayer.HasAbility('Glyphword 3 _Stats', true) && isItemEquipped )
  3967. {return EAT_Medium;}
  3968. if( thePlayer.HasAbility('Glyphword 4 _Stats', true) && isItemEquipped )
  3969. {return EAT_Heavy;}
  3970.  
  3971. if(ItemHasTag(item, 'LightArmor'))
  3972. return EAT_Light;
  3973. else if(ItemHasTag(item, 'MediumArmor'))
  3974. return EAT_Medium;
  3975. else if(ItemHasTag(item, 'HeavyArmor'))
  3976. return EAT_Heavy;
  3977.  
  3978. return EAT_Undefined;
  3979. }
  3980.  
  3981. public final function GetAlchemyCraftableItems() : array<SItemUniqueId>
  3982. {
  3983. var items : array<SItemUniqueId>;
  3984. var i : int;
  3985.  
  3986. GetAllItems(items);
  3987.  
  3988. for(i=items.Size()-1; i>=0; i-=1)
  3989. {
  3990. if(!IsItemPotion(items[i]) && !IsItemBomb(items[i]) && !IsItemOil(items[i]))
  3991. items.EraseFast(i);
  3992. }
  3993.  
  3994. return items;
  3995. }
  3996.  
  3997. public function IsItemEncumbranceItem(item : SItemUniqueId) : bool
  3998. {
  3999. if(ItemHasTag(item, theGame.params.TAG_ENCUMBRANCE_ITEM_FORCE_YES))
  4000. return true;
  4001.  
  4002. if(ItemHasTag(item, theGame.params.TAG_ENCUMBRANCE_ITEM_FORCE_NO))
  4003. return false;
  4004.  
  4005.  
  4006. if (
  4007. IsRecipeOrSchematic( item )
  4008. || IsItemBody( item )
  4009.  
  4010.  
  4011.  
  4012.  
  4013.  
  4014.  
  4015.  
  4016.  
  4017.  
  4018.  
  4019.  
  4020.  
  4021. )
  4022. return false;
  4023.  
  4024. return true;
  4025. }
  4026.  
  4027. public function GetItemEncumbrance(item : SItemUniqueId) : float
  4028. {
  4029. var itemCategory : name;
  4030. if ( IsItemEncumbranceItem( item ) )
  4031. {
  4032. itemCategory = GetItemCategory( item );
  4033. if ( itemCategory == 'quest' || itemCategory == 'key' )
  4034. {
  4035. return 0.01 * GetItemQuantity( item );
  4036. }
  4037. else if ( itemCategory == 'usable' || itemCategory == 'upgrade' || itemCategory == 'junk' )
  4038. {
  4039. return 0.01 + GetItemWeight( item ) * GetItemQuantity( item ) * 0.2;
  4040. }
  4041. else if ( IsItemAlchemyItem( item ) || IsItemIngredient( item ) || IsItemFood( item ) || IsItemReadable( item ) )
  4042. {
  4043. return 0.0;
  4044. }
  4045. else
  4046. {
  4047. return 0.01 + GetItemWeight( item ) * GetItemQuantity( item ) * 0.5;
  4048. }
  4049. }
  4050. return 0;
  4051. }
  4052.  
  4053. public function GetFilterTypeByItem( item : SItemUniqueId ) : EInventoryFilterType
  4054. {
  4055. var filterType : EInventoryFilterType;
  4056.  
  4057. if( ItemHasTag( item, 'Quest' ) )
  4058. {
  4059. return IFT_QuestItems;
  4060. }
  4061. else if( IsItemIngredient( item ) )
  4062. {
  4063. return IFT_Ingredients;
  4064. }
  4065. else if( IsItemAlchemyItem(item) )
  4066. {
  4067. return IFT_AlchemyItems;
  4068. }
  4069. else if( IsItemAnyArmor(item) )
  4070. {
  4071. return IFT_Armors;
  4072. }
  4073. else if( IsItemWeapon( item ) )
  4074. {
  4075. return IFT_Weapons;
  4076. }
  4077. else
  4078. {
  4079. return IFT_Default;
  4080. }
  4081. }
  4082.  
  4083.  
  4084. public function IsItemQuickslotItem(item : SItemUniqueId) : bool
  4085. {
  4086. return IsSlotQuickslot( GetSlotForItemId(item) );
  4087. }
  4088.  
  4089. public function GetCrossbowAmmo(id : SItemUniqueId) : int
  4090. {
  4091. if(!IsItemCrossbow(id))
  4092. return -1;
  4093.  
  4094. return (int)CalculateAttributeValue(GetItemAttributeValue(id, 'ammo'));
  4095. }
  4096.  
  4097.  
  4098.  
  4099. public function GetSlotForItemId(item : SItemUniqueId) : EEquipmentSlots
  4100. {
  4101. var tags : array<name>;
  4102. var player : W3PlayerWitcher;
  4103. var slot : EEquipmentSlots;
  4104.  
  4105. player = ((W3PlayerWitcher)GetEntity());
  4106.  
  4107. GetItemTags(item, tags);
  4108. slot = GetSlotForItem( GetItemCategory(item), tags, player );
  4109.  
  4110. if(!player)
  4111. return slot;
  4112.  
  4113. if(IsMultipleSlot(slot))
  4114. {
  4115. if(slot == EES_Petard1 && player.IsAnyItemEquippedOnSlot(slot))
  4116. {
  4117. if(!player.IsAnyItemEquippedOnSlot(EES_Petard2))
  4118. slot = EES_Petard2;
  4119. }
  4120. else if(slot == EES_Quickslot1 && player.IsAnyItemEquippedOnSlot(slot))
  4121. {
  4122. if(!player.IsAnyItemEquippedOnSlot(EES_Quickslot2))
  4123. slot = EES_Quickslot2;
  4124. }
  4125. else if(slot == EES_Potion1 && player.IsAnyItemEquippedOnSlot(EES_Potion1))
  4126. {
  4127. if(!player.IsAnyItemEquippedOnSlot(EES_Potion2))
  4128. {
  4129. slot = EES_Potion2;
  4130. }
  4131. else
  4132. {
  4133. if(!player.IsAnyItemEquippedOnSlot(EES_Potion3))
  4134. {
  4135. slot = EES_Potion3;
  4136. }
  4137. else
  4138. {
  4139. if(!player.IsAnyItemEquippedOnSlot(EES_Potion4))
  4140. {
  4141. slot = EES_Potion4;
  4142. }
  4143. }
  4144. }
  4145. }
  4146. else if(slot == EES_PotionMutagen1 && player.IsAnyItemEquippedOnSlot(slot))
  4147. {
  4148. if(!player.IsAnyItemEquippedOnSlot(EES_PotionMutagen2))
  4149. {
  4150. slot = EES_PotionMutagen2;
  4151. }
  4152. else
  4153. {
  4154. if(!player.IsAnyItemEquippedOnSlot(EES_PotionMutagen3))
  4155. {
  4156. slot = EES_PotionMutagen3;
  4157. }
  4158. else
  4159. {
  4160. if(!player.IsAnyItemEquippedOnSlot(EES_PotionMutagen4))
  4161. {
  4162. slot = EES_PotionMutagen4;
  4163. }
  4164. }
  4165. }
  4166. }
  4167. else if(slot == EES_SkillMutagen1 && player.IsAnyItemEquippedOnSlot(slot))
  4168. {
  4169. if(!player.IsAnyItemEquippedOnSlot(EES_SkillMutagen2))
  4170. {
  4171. slot = EES_SkillMutagen2;
  4172. }
  4173. else
  4174. {
  4175. if(!player.IsAnyItemEquippedOnSlot(EES_SkillMutagen3))
  4176. {
  4177. slot = EES_SkillMutagen3;
  4178. }
  4179. else
  4180. {
  4181. if(!player.IsAnyItemEquippedOnSlot(EES_SkillMutagen4))
  4182. {
  4183. slot = EES_SkillMutagen4;
  4184. }
  4185. }
  4186. }
  4187. }
  4188. }
  4189.  
  4190. return slot;
  4191. }
  4192.  
  4193.  
  4194.  
  4195. public function GetAllWeapons() : array<SItemUniqueId>
  4196. {
  4197. return GetItemsByTag('Weapon');
  4198. }
  4199.  
  4200.  
  4201. public function GetSpecifiedPlayerItemsQuest(steelSword, silverSword, armor, boots, gloves, pants, trophy, mask, bombs, crossbow, secondaryWeapon, equippedOnly : bool) : array<SItemUniqueId>
  4202. {
  4203. var items, allItems : array<SItemUniqueId>;
  4204. var i : int;
  4205.  
  4206. GetAllItems(allItems);
  4207.  
  4208. for(i=0; i<allItems.Size(); i+=1)
  4209. {
  4210. if(
  4211. (steelSword && IsItemSteelSwordUsableByPlayer(allItems[i])) ||
  4212. (silverSword && IsItemSilverSwordUsableByPlayer(allItems[i])) ||
  4213. (armor && IsItemChestArmor(allItems[i])) ||
  4214. (boots && IsItemBoots(allItems[i])) ||
  4215. (gloves && IsItemGloves(allItems[i])) ||
  4216. (pants && IsItemPants(allItems[i])) ||
  4217. (trophy && IsItemTrophy(allItems[i])) ||
  4218. (mask && IsItemMask(allItems[i])) ||
  4219. (bombs && IsItemBomb(allItems[i])) ||
  4220. (crossbow && (IsItemCrossbow(allItems[i]) || IsItemBolt(allItems[i]))) ||
  4221. (secondaryWeapon && IsItemSecondaryWeapon(allItems[i]))
  4222. )
  4223. {
  4224. if(!equippedOnly || (equippedOnly && ((W3PlayerWitcher)GetEntity()) && GetWitcherPlayer().IsItemEquipped(allItems[i])) )
  4225. {
  4226. if(!ItemHasTag(allItems[i], 'NoDrop'))
  4227. items.PushBack(allItems[i]);
  4228. }
  4229. }
  4230. }
  4231.  
  4232. return items;
  4233. }
  4234.  
  4235.  
  4236. event OnItemAboutToGive( itemId : SItemUniqueId, quantity : int )
  4237. {
  4238. if(GetEntity() == GetWitcherPlayer())
  4239. {
  4240. if( IsItemSteelSwordUsableByPlayer( itemId ) || IsItemSilverSwordUsableByPlayer( itemId ) )
  4241. {
  4242. RemoveAllOilsFromItem( itemId );
  4243. }
  4244. }
  4245. }
  4246.  
  4247.  
  4248. event OnItemRemoved( itemId : SItemUniqueId, quantity : int )
  4249. {
  4250. var ent : CGameplayEntity;
  4251. var crossbows : array<SItemUniqueId>;
  4252. var witcher : W3PlayerWitcher;
  4253. var refill : W3RefillableContainer;
  4254.  
  4255. witcher = GetWitcherPlayer();
  4256.  
  4257. if(GetEntity() == witcher)
  4258. {
  4259.  
  4260.  
  4261.  
  4262.  
  4263.  
  4264. if(IsItemCrossbow(itemId) && HasInfiniteBolts())
  4265. {
  4266. crossbows = GetItemsByCategory('crossbow');
  4267. crossbows.Remove(itemId);
  4268.  
  4269. if(crossbows.Size() == 0)
  4270. {
  4271. RemoveItemByName('Bodkin Bolt', GetItemQuantityByName('Bodkin Bolt'));
  4272. RemoveItemByName('Harpoon Bolt', GetItemQuantityByName('Harpoon Bolt'));
  4273. }
  4274. }
  4275. else if(IsItemBolt(itemId) && witcher.IsItemEquipped(itemId) && witcher.inv.GetItemQuantity(itemId) == quantity)
  4276. {
  4277.  
  4278. witcher.UnequipItem(itemId);
  4279. }
  4280.  
  4281.  
  4282. if(IsItemCrossbow(itemId) && witcher.IsItemEquipped(itemId) && witcher.rangedWeapon)
  4283. {
  4284. witcher.rangedWeapon.ClearDeployedEntity(true);
  4285. witcher.rangedWeapon = NULL;
  4286. }
  4287. if( GetItemCategory(itemId) == 'usable' )
  4288. {
  4289. if(witcher.IsHoldingItemInLHand() && itemId == witcher.currentlyEquipedItemL )
  4290. {
  4291. witcher.HideUsableItem(true);
  4292. }
  4293. }
  4294. if( IsItemSteelSwordUsableByPlayer( itemId ) || IsItemSilverSwordUsableByPlayer( itemId ) )
  4295. {
  4296. RemoveAllOilsFromItem( itemId );
  4297. }
  4298.  
  4299.  
  4300. if(witcher.IsItemEquipped(itemId) && quantity >= witcher.inv.GetItemQuantity(itemId))
  4301. witcher.UnequipItem(itemId);
  4302. }
  4303.  
  4304.  
  4305. if(GetEntity() == thePlayer && IsItemWeapon(itemId) && (IsItemHeld(itemId) || IsItemMounted(itemId) ))
  4306. {
  4307. thePlayer.OnHolsteredItem(GetItemCategory(itemId),'r_weapon');
  4308. }
  4309.  
  4310.  
  4311. ent = (CGameplayEntity)GetEntity();
  4312. if(ent)
  4313. ent.OnItemTaken( itemId, quantity );
  4314.  
  4315.  
  4316. if(IsLootRenewable())
  4317. {
  4318. refill = (W3RefillableContainer)GetEntity();
  4319. if(refill)
  4320. refill.AddTimer('Refill', 20, true);
  4321. }
  4322. }
  4323.  
  4324.  
  4325. function GenerateItemLevel( item : SItemUniqueId, rewardItem : bool )
  4326. {
  4327. //var stat : SAbilityAttributeValue;
  4328. var stat, statAutogen : SAbilityAttributeValue; // FCR3
  4329. var playerLevel : int;
  4330. var lvl, i : int;
  4331. var quality : int;
  4332. var ilMin, ilMax : int;
  4333. var enemyLevel : int; // FCR3
  4334.  
  4335. playerLevel = GetWitcherPlayer().GetLevel();
  4336.  
  4337. lvl = playerLevel - 1;
  4338.  
  4339.  
  4340. if ( ( W3MerchantNPC )GetEntity() )
  4341. {
  4342. lvl = RoundF( playerLevel + RandRangeF( 2, 0 ) );
  4343. AddItemTag( item, 'AutogenUseLevelRange' );
  4344. }
  4345. else if ( rewardItem )
  4346. {
  4347. //lvl = RoundF( playerLevel + RandRangeF( 1, 0 ) );
  4348. lvl = RoundF( playerLevel + RandRangeF( 3, 1 ) ); // FCR3
  4349. }
  4350. else if ( ItemHasTag( item, 'AutogenUseLevelRange') )
  4351. {
  4352. quality = RoundMath( CalculateAttributeValue( GetItemAttributeValue( item, 'quality' ) ) );
  4353. ilMin = RoundMath(CalculateAttributeValue( GetItemAttributeValue( item, 'item_level_min' ) ));
  4354. ilMax = RoundMath(CalculateAttributeValue( GetItemAttributeValue( item, 'item_level_max' ) ));
  4355.  
  4356. if ( !ItemHasTag( item, 'AutogenForceLevel') )
  4357. lvl += RoundMath(RandRangeF( 1, -1 ));
  4358.  
  4359. // FCR3 --
  4360. if ( !lvlCheck2 )
  4361. {
  4362. FindGameplayEntitiesInSphere( enemies, GetEntity().GetWorldPosition(), 30, 999, '', FLAG_Attitude_Hostile, thePlayer );
  4363. if ( enemies.Size() > 0 )
  4364. {
  4365. if ( lastEnemyCount != enemies.Size() )
  4366. {
  4367. lastEnemyCount = enemies.Size();
  4368. for( i = lastEnemyCount - 1; i >= 0; i -= 1 )
  4369. {
  4370. enemyLevel = ((CNewNPC)enemies[i]).GetLevel();
  4371. if ( highestEnemyLevel < enemyLevel )
  4372. {
  4373. highestEnemyLevel = enemyLevel;
  4374. }
  4375. }
  4376.  
  4377. if ( highestEnemyLevel > lvl )
  4378. {
  4379. lvl = highestEnemyLevel;
  4380. }
  4381. else
  4382. {
  4383. lvl += 1;
  4384. }
  4385. }
  4386. lvlCheck2 = true;
  4387. }
  4388. }
  4389.  
  4390. //lvl += 1;
  4391. // -- FCR3
  4392.  
  4393. if ( FactsQuerySum("NewGamePlus") > 0 )
  4394. {
  4395. if ( lvl < ilMin + theGame.params.GetNewGamePlusLevel() ) lvl = ilMin + theGame.params.GetNewGamePlusLevel();
  4396. if ( lvl > ilMax + theGame.params.GetNewGamePlusLevel() ) lvl = ilMax + theGame.params.GetNewGamePlusLevel();
  4397. }
  4398. else
  4399. {
  4400. if ( lvl < ilMin ) lvl = ilMin;
  4401. if ( lvl > ilMax ) lvl = ilMax;
  4402. }
  4403.  
  4404. if ( quality == 5 ) lvl += 2;
  4405. if ( quality == 4 ) lvl += 1;
  4406. if ( (quality == 5 || quality == 4) && ItemHasTag(item, 'EP1') ) lvl += 1;
  4407. }
  4408. else if ( !ItemHasTag( item, 'AutogenForceLevel') )
  4409. {
  4410. quality = RoundMath( CalculateAttributeValue( GetItemAttributeValue( item, 'quality' ) ) );
  4411.  
  4412. if ( quality == 5 )
  4413. {
  4414. lvl = RoundF( playerLevel + RandRangeF( 2, 0 ) );
  4415. }
  4416. else if ( quality == 4 )
  4417. {
  4418. lvl = RoundF( playerLevel + RandRangeF( 1, -2 ) );
  4419. }
  4420. else if ( quality == 3 )
  4421. {
  4422. lvl = RoundF( playerLevel + RandRangeF( -1, -3 ) );
  4423.  
  4424. if ( RandF() > 0.9 )
  4425. {
  4426. lvl = playerLevel;
  4427. }
  4428. }
  4429. else if ( quality == 2 )
  4430. {
  4431. lvl = RoundF( playerLevel + RandRangeF( -2, -5 ) );
  4432.  
  4433. if ( RandF() > 0.95 )
  4434. {
  4435. lvl = playerLevel;
  4436. }
  4437. }
  4438. else
  4439. {
  4440. lvl = RoundF( playerLevel + RandRangeF( -2, -8 ) );
  4441.  
  4442. if ( RandF() == 0 )
  4443. {
  4444. lvl = playerLevel;
  4445. }
  4446. }
  4447.  
  4448. // FCR3 --
  4449. FindGameplayEntitiesInSphere( enemies, GetEntity().GetWorldPosition(), 30, 999, '', FLAG_Attitude_Hostile, thePlayer );
  4450. if ( lastEnemyCount != enemies.Size() )
  4451. {
  4452. lastEnemyCount = enemies.Size();
  4453. for( i = lastEnemyCount - 1; i >= 0; i -= 1 )
  4454. {
  4455. enemyLevel = ((CNewNPC)enemies[i]).GetLevel();
  4456. if ( highestEnemyLevel < enemyLevel )
  4457. {
  4458. highestEnemyLevel = enemyLevel;
  4459. }
  4460. }
  4461.  
  4462. if ( highestEnemyLevel > lvl )
  4463. {
  4464. lvl = highestEnemyLevel;
  4465.  
  4466. if ( quality == 5 )
  4467. {
  4468. lvl += 2;
  4469. }
  4470. else if ( quality == 4 )
  4471. {
  4472. lvl += 1;
  4473. }
  4474. else if ( quality == 3 )
  4475. {
  4476. if ( RandF() < 0.9 )
  4477. {
  4478. lvl -= 1;
  4479. }
  4480. }
  4481. else if ( quality == 2 )
  4482. {
  4483. if ( RandF() < 0.95 )
  4484. {
  4485. lvl -= 2;
  4486. }
  4487. }
  4488. else
  4489. {
  4490. lvl -= 2;
  4491. }
  4492. }
  4493. }
  4494. // -- FCR3
  4495. }
  4496.  
  4497. // FCR3 --
  4498. if ( GetItemCategory( item ) == 'bolt' )
  4499. {
  4500. lvl = playerLevel;
  4501. if ( quality == 5 )
  4502. {
  4503. lvl += 14;
  4504. }
  4505. else if ( quality == 4 )
  4506. {
  4507. lvl += 10;
  4508. }
  4509. else if ( quality == 3 )
  4510. {
  4511. lvl += 6;
  4512. }
  4513. else if ( quality == 2 )
  4514. {
  4515. lvl += 4;
  4516. }
  4517. }
  4518. // -- FCR3
  4519.  
  4520. if ( highestEnemyLevel > lvl )
  4521. {
  4522. lvl = highestEnemyLevel;
  4523.  
  4524. if ( quality == 5 )
  4525. {
  4526. lvl += 2;
  4527. }
  4528. else if ( quality == 4 )
  4529. {
  4530. lvl += 1;
  4531. }
  4532. else if ( quality == 3 )
  4533. {
  4534. if ( RandF() < 0.9 )
  4535. {
  4536. lvl -= 1;
  4537. }
  4538. }
  4539. else if ( quality == 2 )
  4540. {
  4541. if ( RandF() < 0.95 )
  4542. {
  4543. lvl -= 2;
  4544. }
  4545. }
  4546. else
  4547. {
  4548. lvl -= 2;
  4549. }
  4550. }
  4551. }
  4552. // -- FCR3
  4553. }
  4554.  
  4555. // FCR3 --
  4556. if ( GetItemCategory( item ) == 'bolt' )
  4557. {
  4558. lvl = playerLevel;
  4559. if ( quality == 5 )
  4560. {
  4561. lvl += 14;
  4562. }
  4563. else if ( quality == 4 )
  4564. {
  4565. lvl += 10;
  4566. }
  4567. else if ( quality == 3 )
  4568. {
  4569. lvl += 6;
  4570. }
  4571. else if ( quality == 2 )
  4572. {
  4573. lvl += 4;
  4574. }
  4575. }
  4576. // -- FCR3
  4577.  
  4578. if (FactsQuerySum("StandAloneEP1") > 0)
  4579. lvl = GetWitcherPlayer().GetLevel() - 1;
  4580.  
  4581.  
  4582. //if ( FactsQuerySum("NewGamePlus") > 0 && !ItemHasTag( item, 'AutogenUseLevelRange') )
  4583. if ( FactsQuerySum("NewGamePlus") > 0 && !ItemHasTag( item, 'AutogenUseLevelRange') && GetItemCategory( item ) != 'bolt' ) // FCR3
  4584. {
  4585. if ( quality == 5 ) lvl += 2;
  4586. if ( quality == 4 ) lvl += 1;
  4587. }
  4588.  
  4589. if ( lvl < 1 ) lvl = 1;
  4590. if ( lvl > GetWitcherPlayer().GetMaxLevel() ) lvl = GetWitcherPlayer().GetMaxLevel();
  4591.  
  4592.  
  4593.  
  4594. if ( ItemHasTag( item, 'PlayerSteelWeapon' ) && !( ItemHasAbility( item, 'autogen_steel_base' ) || ItemHasAbility( item, 'autogen_fixed_steel_base' ) ) )
  4595. {
  4596. if ( ItemHasTag(item, 'AutogenUseLevelRange') && ItemHasAbility(item, 'autogen_fixed_steel_base') )
  4597. return;
  4598.  
  4599. if ( ItemHasTag(item, 'AutogenUseLevelRange') )
  4600. AddItemCraftedAbility(item, 'autogen_fixed_steel_base' );
  4601. else
  4602. AddItemCraftedAbility(item, 'autogen_steel_base' );
  4603.  
  4604. for( i=0; i<lvl; i+=1 )
  4605. {
  4606. if (FactsQuerySum("StandAloneEP1") > 0)
  4607. {
  4608. AddItemCraftedAbility(item, 'autogen_fixed_steel_dmg', true );
  4609. continue;
  4610. }
  4611.  
  4612. if ( ItemHasTag( item, 'AutogenForceLevel') || ItemHasTag(item, 'AutogenUseLevelRange') || FactsQuerySum("NewGamePlus") > 0 )
  4613. AddItemCraftedAbility(item, 'autogen_fixed_steel_dmg', true );
  4614. else
  4615. AddItemCraftedAbility(item, 'autogen_steel_dmg', true );
  4616. }
  4617. }
  4618. else if ( ItemHasTag( item, 'PlayerSilverWeapon' ) && !( ItemHasAbility( item, 'autogen_silver_base' ) || ItemHasAbility( item, 'autogen_fixed_silver_base' ) ) )
  4619. {
  4620. if ( ItemHasTag(item, 'AutogenUseLevelRange') && ItemHasAbility(item, 'autogen_fixed_silver_base') )
  4621. return;
  4622.  
  4623. if ( ItemHasTag(item, 'AutogenUseLevelRange') )
  4624. AddItemCraftedAbility(item, 'autogen_fixed_silver_base' );
  4625. else
  4626. AddItemCraftedAbility(item, 'autogen_silver_base' );
  4627.  
  4628. for( i=0; i<lvl; i+=1 )
  4629. {
  4630. if (FactsQuerySum("StandAloneEP1") > 0)
  4631. {
  4632. AddItemCraftedAbility(item, 'autogen_fixed_silver_dmg', true );
  4633. continue;
  4634. }
  4635.  
  4636. if ( ItemHasTag( item, 'AutogenForceLevel') || ItemHasTag(item, 'AutogenUseLevelRange') || FactsQuerySum("NewGamePlus") > 0 )
  4637. AddItemCraftedAbility(item, 'autogen_fixed_silver_dmg', true );
  4638. else
  4639. AddItemCraftedAbility(item, 'autogen_silver_dmg', true );
  4640. }
  4641. }
  4642. else if ( GetItemCategory( item ) == 'armor' && !( ItemHasAbility( item, 'autogen_armor_base' ) || ItemHasAbility( item, 'autogen_fixed_armor_base' ) ) )
  4643. {
  4644. if ( ItemHasTag(item, 'AutogenUseLevelRange') && ItemHasAbility(item, 'autogen_fixed_armor_base') )
  4645. return;
  4646.  
  4647. if ( ItemHasTag(item, 'AutogenUseLevelRange') )
  4648. AddItemCraftedAbility(item, 'autogen_fixed_armor_base' );
  4649. else
  4650. AddItemCraftedAbility(item, 'autogen_armor_base' );
  4651.  
  4652. for( i=0; i<lvl; i+=1 )
  4653. {
  4654. if (FactsQuerySum("StandAloneEP1") > 0)
  4655. {
  4656. AddItemCraftedAbility(item, 'autogen_fixed_armor_armor', true );
  4657. continue;
  4658. }
  4659.  
  4660. if ( ItemHasTag( item, 'AutogenForceLevel') || ItemHasTag( item, 'AutogenUseLevelRange') || FactsQuerySum("NewGamePlus") > 0 )
  4661. AddItemCraftedAbility(item, 'autogen_fixed_armor_armor', true );
  4662. else
  4663. AddItemCraftedAbility(item, 'autogen_armor_armor', true );
  4664. }
  4665. }
  4666. else if ( ( GetItemCategory( item ) == 'boots' || GetItemCategory( item ) == 'pants' ) && !( ItemHasAbility( item, 'autogen_pants_base' ) || ItemHasAbility( item, 'autogen_fixed_pants_base' ) ) )
  4667. {
  4668. if ( ItemHasTag(item, 'AutogenUseLevelRange') && ItemHasAbility(item, 'autogen_fixed_pants_base') )
  4669. return;
  4670.  
  4671. if ( ItemHasTag(item, 'AutogenUseLevelRange') )
  4672. AddItemCraftedAbility(item, 'autogen_fixed_pants_base' );
  4673. else
  4674. AddItemCraftedAbility(item, 'autogen_pants_base' );
  4675.  
  4676. for( i=0; i<lvl; i+=1 )
  4677. {
  4678. if (FactsQuerySum("StandAloneEP1") > 0)
  4679. {
  4680. AddItemCraftedAbility(item, 'autogen_fixed_pants_armor', true );
  4681. continue;
  4682. }
  4683.  
  4684. if ( ItemHasTag( item, 'AutogenForceLevel') || ItemHasTag( item, 'AutogenUseLevelRange') || FactsQuerySum("NewGamePlus") > 0 )
  4685. AddItemCraftedAbility(item, 'autogen_fixed_pants_armor', true );
  4686. else
  4687. AddItemCraftedAbility(item, 'autogen_pants_armor', true );
  4688. }
  4689. }
  4690. else if ( GetItemCategory( item ) == 'gloves' && !( ItemHasAbility( item, 'autogen_gloves_base' ) || ItemHasAbility( item, 'autogen_fixed_gloves_base' ) ) )
  4691. {
  4692. if ( ItemHasTag(item, 'AutogenUseLevelRange') && ItemHasAbility(item, 'autogen_fixed_gloves_base') )
  4693. return;
  4694.  
  4695. if ( ItemHasTag(item, 'AutogenUseLevelRange') )
  4696. AddItemCraftedAbility(item, 'autogen_fixed_gloves_base' );
  4697. else
  4698. AddItemCraftedAbility(item, 'autogen_gloves_base' );
  4699.  
  4700. for( i=0; i<lvl; i+=1 )
  4701. {
  4702. if (FactsQuerySum("StandAloneEP1") > 0)
  4703. {
  4704. AddItemCraftedAbility(item, 'autogen_fixed_gloves_armor', true );
  4705. continue;
  4706. }
  4707.  
  4708. if ( ItemHasTag( item, 'AutogenForceLevel') || ItemHasTag(item, 'AutogenUseLevelRange') || FactsQuerySum("NewGamePlus") > 0 )
  4709. AddItemCraftedAbility(item, 'autogen_fixed_gloves_armor', true );
  4710. else
  4711. AddItemCraftedAbility(item, 'autogen_gloves_armor', true );
  4712. }
  4713. }
  4714. // FCR3 --
  4715. // scale existing damage values on bolts with player level
  4716. // infinite bolts are replaced with updated version on each levelup
  4717. else if ( GetItemCategory( item ) == 'bolt' )
  4718. {
  4719. // FCR3 --
  4720. if ( ItemHasTag(item, 'BoltUpscaled') )
  4721. return;
  4722. // -- FCR3
  4723. for( i=0; i<lvl; i+=1 )
  4724. {
  4725. stat = GetItemAttributeValue(item, 'PiercingDamage');
  4726. statAutogen = GetItemAttributeValue(item, 'bolt_piercing_dmg');
  4727. if ( stat.valueAdditive > 0 && statAutogen.valueAdditive <= 0 )
  4728. AddItemCraftedAbility(item, 'bolt_piercing_dmg', true );
  4729.  
  4730. stat = GetItemAttributeValue(item, 'SilverDamage');
  4731. statAutogen = GetItemAttributeValue(item, 'bolt_silver_dmg');
  4732. if ( stat.valueAdditive > 0 && statAutogen.valueAdditive <= 0 )
  4733. AddItemCraftedAbility(item, 'bolt_silver_dmg', true );
  4734.  
  4735. stat = GetItemAttributeValue(item, 'BludgeoningDamage');
  4736. statAutogen = GetItemAttributeValue(item, 'bolt_bludgeoning_dmg');
  4737. if ( stat.valueAdditive > 0 && statAutogen.valueAdditive <= 0 )
  4738. AddItemCraftedAbility(item, 'bolt_bludgeoning_dmg', true );
  4739.  
  4740. stat = GetItemAttributeValue(item, 'FireDamage');
  4741. statAutogen = GetItemAttributeValue(item, 'bolt_fire_dmg');
  4742. if ( stat.valueAdditive > 0 && statAutogen.valueAdditive <= 0 )
  4743. AddItemCraftedAbility(item, 'bolt_fire_dmg', true );
  4744. }
  4745.  
  4746. AddItemTag( item, 'BoltUpscaled' ); // FCR3
  4747. }
  4748. // -- FCR3
  4749. }
  4750.  
  4751.  
  4752. event OnItemAdded(data : SItemChangedData)
  4753. {
  4754. var i, j : int;
  4755. var ent : CGameplayEntity;
  4756. var allCardsNames, foundCardsNames : array<name>;
  4757. var allStringNamesOfCards : array<string>;
  4758. var foundCardsStringNames : array<string>;
  4759. var gwintCards : array<SItemUniqueId>;
  4760. var itemName : name;
  4761. var witcher : W3PlayerWitcher;
  4762. var itemCategory : name;
  4763. var dm : CDefinitionsManagerAccessor;
  4764. var locKey : string;
  4765. var leaderCardsHack : array<name>;
  4766.  
  4767. var hud : CR4ScriptedHud;
  4768. var journalUpdateModule : CR4HudModuleJournalUpdate;
  4769. var itemId : SItemUniqueId;
  4770.  
  4771. var isItemShematic : bool;
  4772.  
  4773. var ngp : bool;
  4774.  
  4775.  
  4776. // FCR3 --
  4777. lvlCheck1 = false;
  4778. lvlCheck2 = false;
  4779. emptyCheck = false;
  4780. empty = false;
  4781. // -- FCR3
  4782.  
  4783. ent = (CGameplayEntity)GetEntity();
  4784.  
  4785. itemId = data.ids[0];
  4786.  
  4787. // FCR3 --
  4788. if ( ent == thePlayer )
  4789. {
  4790. AddItemTag( itemId, 'PlayerOwned' );
  4791. }
  4792. // -- FCR3
  4793.  
  4794. if( data.informGui )
  4795. {
  4796. recentlyAddedItems.PushBack( itemId );
  4797. if( ItemHasTag( itemId, 'FocusObject' ) )
  4798. {
  4799. GetWitcherPlayer().GetMedallion().Activate( true, 3.0);
  4800. }
  4801. }
  4802.  
  4803.  
  4804. //if ( ItemHasTag(itemId, 'Autogen') )
  4805. if ( ItemHasTag(itemId, 'Autogen') || GetItemCategory( itemId ) == 'bolt' ) // FCR3
  4806. {
  4807. GenerateItemLevel( itemId, false );
  4808. }
  4809.  
  4810. witcher = GetWitcherPlayer();
  4811.  
  4812.  
  4813. if(ent == witcher || ((W3MerchantNPC)ent) )
  4814. {
  4815. ngp = FactsQuerySum("NewGamePlus") > 0;
  4816. for(i=0; i<data.ids.Size(); i+=1)
  4817. {
  4818.  
  4819. if ( GetItemModifierInt(data.ids[i], 'ItemQualityModified') <= 0 )
  4820. AddRandomEnhancementToItem(data.ids[i]);
  4821.  
  4822. if ( ngp )
  4823. SetItemModifierInt(data.ids[i], 'DoNotAdjustNGPDLC', 1);
  4824.  
  4825. itemName = GetItemName(data.ids[i]);
  4826.  
  4827. if ( ngp && GetItemModifierInt(data.ids[i], 'NGPItemAdjusted') <= 0 && !ItemHasTag(data.ids[i], 'Autogen') )
  4828. {
  4829. IncreaseNGPItemlevel(data.ids[i]);
  4830. }
  4831.  
  4832. }
  4833. }
  4834. if(ent == witcher)
  4835. {
  4836. for(i=0; i<data.ids.Size(); i+=1)
  4837. {
  4838.  
  4839. if( ItemHasTag( itemId, theGame.params.GWINT_CARD_ACHIEVEMENT_TAG ) || !FactsDoesExist( "fix_for_gwent_achievement_bug_121588" ) )
  4840. {
  4841.  
  4842. leaderCardsHack.PushBack('gwint_card_emhyr_gold');
  4843. leaderCardsHack.PushBack('gwint_card_emhyr_silver');
  4844. leaderCardsHack.PushBack('gwint_card_emhyr_bronze');
  4845. leaderCardsHack.PushBack('gwint_card_foltest_gold');
  4846. leaderCardsHack.PushBack('gwint_card_foltest_silver');
  4847. leaderCardsHack.PushBack('gwint_card_foltest_bronze');
  4848. leaderCardsHack.PushBack('gwint_card_francesca_gold');
  4849. leaderCardsHack.PushBack('gwint_card_francesca_silver');
  4850. leaderCardsHack.PushBack('gwint_card_francesca_bronze');
  4851. leaderCardsHack.PushBack('gwint_card_eredin_gold');
  4852. leaderCardsHack.PushBack('gwint_card_eredin_silver');
  4853. leaderCardsHack.PushBack('gwint_card_eredin_bronze');
  4854.  
  4855. dm = theGame.GetDefinitionsManager();
  4856.  
  4857. allCardsNames = theGame.GetDefinitionsManager().GetItemsWithTag(theGame.params.GWINT_CARD_ACHIEVEMENT_TAG);
  4858.  
  4859.  
  4860. gwintCards = GetItemsByTag(theGame.params.GWINT_CARD_ACHIEVEMENT_TAG);
  4861.  
  4862.  
  4863. allStringNamesOfCards.PushBack('gwint_name_emhyr');
  4864. allStringNamesOfCards.PushBack('gwint_name_emhyr');
  4865. allStringNamesOfCards.PushBack('gwint_name_emhyr');
  4866. allStringNamesOfCards.PushBack('gwint_name_foltest');
  4867. allStringNamesOfCards.PushBack('gwint_name_foltest');
  4868. allStringNamesOfCards.PushBack('gwint_name_foltest');
  4869. allStringNamesOfCards.PushBack('gwint_name_francesca');
  4870. allStringNamesOfCards.PushBack('gwint_name_francesca');
  4871. allStringNamesOfCards.PushBack('gwint_name_francesca');
  4872. allStringNamesOfCards.PushBack('gwint_name_eredin');
  4873. allStringNamesOfCards.PushBack('gwint_name_eredin');
  4874. allStringNamesOfCards.PushBack('gwint_name_eredin');
  4875.  
  4876.  
  4877. for(j=0; j<allCardsNames.Size(); j+=1)
  4878. {
  4879. itemName = allCardsNames[j];
  4880. locKey = dm.GetItemLocalisationKeyName(allCardsNames[j]);
  4881. if (!allStringNamesOfCards.Contains(locKey))
  4882. {
  4883. allStringNamesOfCards.PushBack(locKey);
  4884. }
  4885. }
  4886.  
  4887.  
  4888. if(gwintCards.Size() >= allStringNamesOfCards.Size())
  4889. {
  4890. foundCardsNames.Clear();
  4891. for(j=0; j<gwintCards.Size(); j+=1)
  4892. {
  4893. itemName = GetItemName(gwintCards[j]);
  4894. locKey = dm.GetItemLocalisationKeyName(itemName);
  4895.  
  4896. if(!foundCardsStringNames.Contains(locKey) || leaderCardsHack.Contains(itemName))
  4897. {
  4898. foundCardsStringNames.PushBack(locKey);
  4899. }
  4900. }
  4901.  
  4902. if(foundCardsStringNames.Size() >= allStringNamesOfCards.Size())
  4903. {
  4904. theGame.GetGamerProfile().AddAchievement(EA_GwintCollector);
  4905. FactsAdd("gwint_all_cards_collected", 1, -1);
  4906. }
  4907. }
  4908.  
  4909. if(!FactsDoesExist("fix_for_gwent_achievement_bug_121588"))
  4910. FactsAdd("fix_for_gwent_achievement_bug_121588", 1, -1);
  4911. }
  4912.  
  4913. itemCategory = GetItemCategory( itemId );
  4914. isItemShematic = itemCategory == 'alchemy_recipe' || itemCategory == 'crafting_schematic';
  4915.  
  4916. if( isItemShematic )
  4917. {
  4918. ReadSchematicsAndRecipes( itemId );
  4919. }
  4920.  
  4921.  
  4922. if( ItemHasTag( data.ids[i], 'GwintCard'))
  4923. {
  4924. witcher.AddGwentCard(GetItemName(data.ids[i]), data.quantity);
  4925. }
  4926.  
  4927.  
  4928.  
  4929. if( !isItemShematic && ( this.ItemHasTag( itemId, 'ReadableItem' ) || this.ItemHasTag( itemId, 'Painting' ) ) && !this.ItemHasTag( itemId, 'NoNotification' ) )
  4930. {
  4931. hud = (CR4ScriptedHud)theGame.GetHud();
  4932. if( hud )
  4933. {
  4934. journalUpdateModule = (CR4HudModuleJournalUpdate)hud.GetHudModule( "JournalUpdateModule" );
  4935. if( journalUpdateModule )
  4936. {
  4937. journalUpdateModule.AddQuestBookInfo( itemId );
  4938. }
  4939. }
  4940. }
  4941. }
  4942. }
  4943.  
  4944.  
  4945. if( IsItemSingletonItem( itemId ) )
  4946. {
  4947. for(i=0; i<data.ids.Size(); i+=1)
  4948. {
  4949. if(!GetItemModifierInt(data.ids[i], 'is_initialized', 0))
  4950. {
  4951. SingletonItemRefillAmmo(data.ids[i]);
  4952. SetItemModifierInt(data.ids[i], 'is_initialized', 1);
  4953. }
  4954. }
  4955. }
  4956.  
  4957.  
  4958. if(ent)
  4959. ent.OnItemGiven(data);
  4960. }
  4961.  
  4962. public function AddRandomEnhancementToItem(item : SItemUniqueId)
  4963. {
  4964. var itemCategory : name;
  4965. var itemQuality : int;
  4966. var ability : name;
  4967. var ent : CGameplayEntity;
  4968.  
  4969.  
  4970.  
  4971.  
  4972. if( ItemHasTag(item, 'DoNotEnhance') )
  4973. {
  4974. SetItemModifierInt(item, 'ItemQualityModified', 1);
  4975. return;
  4976. }
  4977.  
  4978. itemCategory = GetItemCategory(item);
  4979. itemQuality = RoundMath(CalculateAttributeValue(GetItemAttributeValue(item, 'quality' )));
  4980.  
  4981. if ( itemCategory == 'armor' )
  4982. {
  4983. switch ( itemQuality )
  4984. {
  4985. case 2 :
  4986. ability = 'quality_masterwork_armor';
  4987. AddItemCraftedAbility(item, theGame.params.GetRandomMasterworkArmorAbility(), true);
  4988. break;
  4989. case 3 :
  4990. ability = 'quality_magical_armor';
  4991. if ( ItemHasTag(item, 'EP1') )
  4992. {
  4993. AddItemCraftedAbility(item, theGame.params.GetRandomMagicalArmorAbility(), true);
  4994. break;
  4995. }
  4996.  
  4997. if ( RandF() > 0.5 )
  4998. AddItemCraftedAbility(item, theGame.params.GetRandomMagicalArmorAbility(), true);
  4999. else
  5000. AddItemCraftedAbility(item, theGame.params.GetRandomMasterworkArmorAbility(), true);
  5001.  
  5002. if ( RandF() > 0.5 )
  5003. AddItemCraftedAbility(item, theGame.params.GetRandomMagicalArmorAbility(), true);
  5004. else
  5005. AddItemCraftedAbility(item, theGame.params.GetRandomMasterworkArmorAbility(), true);
  5006. break;
  5007. default : break;
  5008. }
  5009. }
  5010. else if ( itemCategory == 'gloves' )
  5011. {
  5012. switch ( itemQuality )
  5013. {
  5014. case 2 :
  5015. ability = 'quality_masterwork_gloves';
  5016. AddItemCraftedAbility(item, theGame.params.GetRandomMasterworkGlovesAbility(), true);
  5017. break;
  5018. case 3 :
  5019. ability = 'quality_magical_gloves';
  5020. if ( ItemHasTag(item, 'EP1') )
  5021. {
  5022. AddItemCraftedAbility(item, theGame.params.GetRandomMagicalArmorAbility(), true);
  5023. break;
  5024. }
  5025.  
  5026. if ( RandF() > 0.5 )
  5027. AddItemCraftedAbility(item, theGame.params.GetRandomMagicalGlovesAbility(), true);
  5028. else
  5029. AddItemCraftedAbility(item, theGame.params.GetRandomMasterworkGlovesAbility(), true);
  5030.  
  5031. if ( RandF() > 0.5 )
  5032. AddItemCraftedAbility(item, theGame.params.GetRandomMagicalGlovesAbility(), true);
  5033. else
  5034. AddItemCraftedAbility(item, theGame.params.GetRandomMasterworkGlovesAbility(), true);
  5035. break;
  5036. default : break;
  5037. }
  5038. }
  5039. else if ( itemCategory == 'pants' )
  5040. {
  5041. switch ( itemQuality )
  5042. {
  5043. case 2 :
  5044. ability = 'quality_masterwork_pants';
  5045. AddItemCraftedAbility(item, theGame.params.GetRandomMasterworkPantsAbility(), true);
  5046. break;
  5047. case 3 :
  5048. ability = 'quality_magical_pants';
  5049. if ( ItemHasTag(item, 'EP1') )
  5050. {
  5051. AddItemCraftedAbility(item, theGame.params.GetRandomMagicalArmorAbility(), true);
  5052. break;
  5053. }
  5054.  
  5055. if ( RandF() > 0.5 )
  5056. AddItemCraftedAbility(item, theGame.params.GetRandomMagicalPantsAbility(), true);
  5057. else
  5058. AddItemCraftedAbility(item, theGame.params.GetRandomMasterworkPantsAbility(), true);
  5059.  
  5060. if ( RandF() > 0.5 )
  5061. AddItemCraftedAbility(item, theGame.params.GetRandomMagicalPantsAbility(), true);
  5062. else
  5063. AddItemCraftedAbility(item, theGame.params.GetRandomMasterworkPantsAbility(), true);
  5064. break;
  5065. default : break;
  5066. }
  5067. }
  5068. else if ( itemCategory == 'boots' )
  5069. {
  5070. switch ( itemQuality )
  5071. {
  5072. case 2 :
  5073. ability = 'quality_masterwork_boots';
  5074. AddItemCraftedAbility(item, theGame.params.GetRandomMasterworkBootsAbility(), true);
  5075. break;
  5076. case 3 :
  5077. ability = 'quality_magical_boots';
  5078. if ( ItemHasTag(item, 'EP1') )
  5079. {
  5080. AddItemCraftedAbility(item, theGame.params.GetRandomMagicalArmorAbility(), true);
  5081. break;
  5082. }
  5083.  
  5084. if ( RandF() > 0.5 )
  5085. AddItemCraftedAbility(item, theGame.params.GetRandomMagicalBootsAbility(), true);
  5086. else
  5087. AddItemCraftedAbility(item, theGame.params.GetRandomMasterworkBootsAbility(), true);
  5088.  
  5089. if ( RandF() > 0.5 )
  5090. AddItemCraftedAbility(item, theGame.params.GetRandomMagicalBootsAbility(), true);
  5091. else
  5092. AddItemCraftedAbility(item, theGame.params.GetRandomMasterworkBootsAbility(), true);
  5093. break;
  5094. default : break;
  5095. }
  5096. }
  5097. else if ( itemCategory == 'steelsword' )
  5098. {
  5099. switch ( itemQuality )
  5100. {
  5101. case 2 :
  5102. ability = 'quality_masterwork_steelsword';
  5103. AddItemCraftedAbility(item, theGame.params.GetRandomMasterworkWeaponAbility(), true);
  5104. break;
  5105. case 3 :
  5106. ability = 'quality_magical_steelsword';
  5107. if ( ItemHasTag(item, 'EP1') )
  5108. {
  5109. AddItemCraftedAbility(item, theGame.params.GetRandomMagicalArmorAbility(), true);
  5110. break;
  5111. }
  5112.  
  5113. if ( RandF() > 0.5 )
  5114. AddItemCraftedAbility(item, theGame.params.GetRandomMagicalWeaponAbility(), true);
  5115. else
  5116. AddItemCraftedAbility(item, theGame.params.GetRandomMasterworkWeaponAbility(), true);
  5117.  
  5118. if ( RandF() > 0.5 )
  5119. AddItemCraftedAbility(item, theGame.params.GetRandomMagicalWeaponAbility(), true);
  5120. else
  5121. AddItemCraftedAbility(item, theGame.params.GetRandomMasterworkWeaponAbility(), true);
  5122. break;
  5123. default : break;
  5124. }
  5125. }
  5126. else if ( itemCategory == 'silversword' )
  5127. {
  5128. switch ( itemQuality )
  5129. {
  5130. case 2 :
  5131. ability = 'quality_masterwork_silversword';
  5132. AddItemCraftedAbility(item, theGame.params.GetRandomMasterworkWeaponAbility(), true);
  5133. break;
  5134. case 3 :
  5135. ability = 'quality_magical_silversword';
  5136. if ( ItemHasTag(item, 'EP1') )
  5137. {
  5138. AddItemCraftedAbility(item, theGame.params.GetRandomMagicalArmorAbility(), true);
  5139. break;
  5140. }
  5141.  
  5142. if ( RandF() > 0.5 )
  5143. AddItemCraftedAbility(item, theGame.params.GetRandomMagicalWeaponAbility(), true);
  5144. else
  5145. AddItemCraftedAbility(item, theGame.params.GetRandomMasterworkWeaponAbility(), true);
  5146.  
  5147. if ( RandF() > 0.5 )
  5148. AddItemCraftedAbility(item, theGame.params.GetRandomMagicalWeaponAbility(), true);
  5149. else
  5150. AddItemCraftedAbility(item, theGame.params.GetRandomMasterworkWeaponAbility(), true);
  5151. break;
  5152.  
  5153. default : break;
  5154. }
  5155. }
  5156.  
  5157. if(IsNameValid(ability))
  5158. {
  5159. AddItemCraftedAbility(item, ability, false);
  5160. SetItemModifierInt(item, 'ItemQualityModified', 1);
  5161. }
  5162. }
  5163.  
  5164. public function IncreaseNGPItemlevel(item : SItemUniqueId)
  5165. {
  5166. var i, diff : int;
  5167.  
  5168. diff = theGame.params.NewGamePlusLevelDifference();
  5169.  
  5170. if (diff > 0)
  5171. {
  5172. if ( ItemHasTag( item, 'PlayerSteelWeapon' ) )
  5173. {
  5174. for( i=0; i<diff; i+=1 )
  5175. {
  5176. AddItemCraftedAbility(item, 'autogen_fixed_steel_dmg', true );
  5177. }
  5178. }
  5179. else if ( ItemHasTag( item, 'PlayerSilverWeapon' ) )
  5180. {
  5181. for( i=0; i<diff; i+=1 )
  5182. {
  5183. AddItemCraftedAbility(item, 'autogen_fixed_silver_dmg', true );
  5184. }
  5185. }
  5186. else if ( IsItemChestArmor(item) )
  5187. {
  5188. for( i=0; i<diff; i+=1 )
  5189. {
  5190. AddItemCraftedAbility(item, 'autogen_fixed_armor_armor', true );
  5191. }
  5192. }
  5193. else if ( IsItemBoots(item) || IsItemPants(item) )
  5194. {
  5195. for( i=0; i<diff; i+=1 )
  5196. {
  5197. AddItemCraftedAbility(item, 'autogen_fixed_pants_armor', true );
  5198. }
  5199. }
  5200. else if ( IsItemGloves(item) )
  5201. {
  5202. for( i=0; i<diff; i+=1 )
  5203. {
  5204. AddItemCraftedAbility(item, 'autogen_fixed_gloves_armor', true );
  5205. }
  5206. }
  5207. }
  5208.  
  5209. SetItemModifierInt(item, 'NGPItemAdjusted', 1);
  5210. }
  5211.  
  5212. public function GetItemQuality( itemId : SItemUniqueId ) : int
  5213. {
  5214. var itemQuality : float;
  5215. var itemQualityAtribute : SAbilityAttributeValue;
  5216. var excludedTags : array<name>;
  5217. var tempItemQualityAtribute : SAbilityAttributeValue;
  5218.  
  5219.  
  5220. excludedTags.PushBack(theGame.params.OIL_ABILITY_TAG);
  5221. itemQualityAtribute = GetItemAttributeValue( itemId, 'quality', excludedTags, true );
  5222.  
  5223. itemQuality = itemQualityAtribute.valueAdditive;
  5224. if( itemQuality == 0 )
  5225. {
  5226. itemQuality = 1;
  5227. }
  5228. return RoundMath(itemQuality);
  5229. }
  5230.  
  5231. public function GetItemQualityFromName( itemName : name, out min : int, out max : int)
  5232. {
  5233. var dm : CDefinitionsManagerAccessor;
  5234. var attributeName : name;
  5235. var attributes, itemAbilities : array<name>;
  5236. var attributeMin, attributeMax : SAbilityAttributeValue;
  5237.  
  5238. var tmpInt : int;
  5239. var tmpArray : array<float>;
  5240.  
  5241. dm = theGame.GetDefinitionsManager();
  5242.  
  5243. dm.GetItemAbilitiesWithWeights(itemName, GetEntity() == thePlayer, itemAbilities, tmpArray, tmpInt, tmpInt);
  5244. attributes = dm.GetAbilitiesAttributes(itemAbilities);
  5245. for (tmpInt = 0; tmpInt < attributes.Size(); tmpInt += 1)
  5246. {
  5247. if (attributes[tmpInt] == 'quality')
  5248. {
  5249. dm.GetAbilitiesAttributeValue(itemAbilities, 'quality', attributeMin, attributeMax);
  5250. min = RoundMath(CalculateAttributeValue(attributeMin));
  5251. max = RoundMath(CalculateAttributeValue(attributeMax));
  5252. break;
  5253. }
  5254. }
  5255. }
  5256.  
  5257. public function GetRecentlyAddedItems() : array<SItemUniqueId>
  5258. {
  5259. return recentlyAddedItems;
  5260. }
  5261.  
  5262. public function GetRecentlyAddedItemsListSize() : int
  5263. {
  5264. return recentlyAddedItems.Size();
  5265. }
  5266.  
  5267. public function RemoveItemFromRecentlyAddedList( itemId : SItemUniqueId ) : bool
  5268. {
  5269. var i : int;
  5270.  
  5271. for( i = 0; i < recentlyAddedItems.Size(); i += 1 )
  5272. {
  5273. if( recentlyAddedItems[i] == itemId )
  5274. {
  5275. recentlyAddedItems.EraseFast( i );
  5276. return true;
  5277. }
  5278. }
  5279.  
  5280. return false;
  5281. }
  5282.  
  5283.  
  5284.  
  5285.  
  5286. import final function NotifyScriptedListeners( notify : bool );
  5287.  
  5288. var listeners : array< IInventoryScriptedListener >;
  5289.  
  5290. function AddListener( listener : IInventoryScriptedListener )
  5291. {
  5292. if ( listeners.FindFirst( listener ) == -1 )
  5293. {
  5294. listeners.PushBack( listener );
  5295. if ( listeners.Size() == 1 )
  5296. {
  5297. NotifyScriptedListeners( true );
  5298. }
  5299. }
  5300. }
  5301.  
  5302. function RemoveListener( listener : IInventoryScriptedListener )
  5303. {
  5304. if ( listeners.Remove( listener ) )
  5305. {
  5306. if ( listeners.Size() == 0 )
  5307. {
  5308. NotifyScriptedListeners( false );
  5309. }
  5310. }
  5311. }
  5312.  
  5313. event OnInventoryScriptedEvent( eventType : EInventoryEventType, itemId : SItemUniqueId, quantity : int, fromAssociatedInventory : bool )
  5314. {
  5315. var i, size : int;
  5316.  
  5317. size = listeners.Size();
  5318. for (i=size-1; i>=0; i-=1 )
  5319. {
  5320. listeners[i].OnInventoryScriptedEvent( eventType, itemId, quantity, fromAssociatedInventory );
  5321. }
  5322.  
  5323.  
  5324. if(GetEntity() == GetWitcherPlayer() && (eventType == IET_ItemRemoved || eventType == IET_ItemQuantityChanged) )
  5325. GetWitcherPlayer().UpdateEncumbrance();
  5326. }
  5327.  
  5328.  
  5329.  
  5330.  
  5331. public final function GetMutationResearchPoints( color : ESkillColor, item : SItemUniqueId ) : int
  5332. {
  5333. var val : SAbilityAttributeValue;
  5334. var colorAttribute : name;
  5335.  
  5336.  
  5337. if( color == SC_None || color == SC_Yellow || !IsIdValid( item ) )
  5338. {
  5339. return 0;
  5340. }
  5341.  
  5342.  
  5343. switch( color )
  5344. {
  5345. case SC_Red:
  5346. colorAttribute = 'mutation_research_points_red';
  5347. break;
  5348. case SC_Blue:
  5349. colorAttribute = 'mutation_research_points_blue';
  5350. break;
  5351. case SC_Green:
  5352. colorAttribute = 'mutation_research_points_green';
  5353. break;
  5354. }
  5355.  
  5356.  
  5357. val = GetItemAttributeValue( item, colorAttribute );
  5358.  
  5359. return ( int )val.valueAdditive;
  5360. }
  5361.  
  5362. public function GetSkillMutagenColor(item : SItemUniqueId) : ESkillColor
  5363. {
  5364. var abs : array<name>;
  5365.  
  5366.  
  5367. if(!ItemHasTag(item, 'MutagenIngredient'))
  5368. return SC_None;
  5369.  
  5370. GetItemAbilities(item, abs);
  5371.  
  5372. if(abs.Contains('mutagen_color_green')) return SC_Green;
  5373. if(abs.Contains('mutagen_color_blue')) return SC_Blue;
  5374. if(abs.Contains('mutagen_color_red')) return SC_Red;
  5375. if(abs.Contains('lesser_mutagen_color_green')) return SC_Green;
  5376. if(abs.Contains('lesser_mutagen_color_blue')) return SC_Blue;
  5377. if(abs.Contains('lesser_mutagen_color_red')) return SC_Red;
  5378. if(abs.Contains('greater_mutagen_color_green')) return SC_Green;
  5379. if(abs.Contains('greater_mutagen_color_blue')) return SC_Blue;
  5380. if(abs.Contains('greater_mutagen_color_red')) return SC_Red;
  5381.  
  5382. return SC_None;
  5383. }
  5384.  
  5385.  
  5386.  
  5387.  
  5388.  
  5389.  
  5390.  
  5391.  
  5392.  
  5393. import final function GetItemEnhancementSlotsCount( itemId : SItemUniqueId ) : int;
  5394. import final function GetItemEnhancementItems( itemId : SItemUniqueId, out names : array< name > );
  5395. import final function GetItemEnhancementCount( itemId : SItemUniqueId ) : int;
  5396. import final function GetItemColor( itemId : SItemUniqueId ) : name;
  5397. import final function IsItemColored( itemId : SItemUniqueId ) : bool;
  5398. import final function SetPreviewColor( itemId : SItemUniqueId, colorId : int );
  5399. import final function ClearPreviewColor( itemId : SItemUniqueId ) : bool;
  5400. import final function ColorItem( itemId : SItemUniqueId, dyeId : SItemUniqueId );
  5401. import final function ClearItemColor( itemId : SItemUniqueId ) : bool;
  5402. import final function EnchantItem( enhancedItemId : SItemUniqueId, enchantmentName : name, enchantmentStat : name ) : bool;
  5403. import final function GetEnchantment( enhancedItemId : SItemUniqueId ) : name;
  5404. import final function IsItemEnchanted( enhancedItemId : SItemUniqueId ) : bool;
  5405. import final function UnenchantItem( enhancedItemId : SItemUniqueId ) : bool;
  5406. import private function EnhanceItem( enhancedItemId : SItemUniqueId, extensionItemId : SItemUniqueId ) : bool;
  5407. import private function RemoveItemEnhancementByIndex( enhancedItemId : SItemUniqueId, slotIndex : int ) : bool;
  5408. import private function RemoveItemEnhancementByName( enhancedItemId : SItemUniqueId, extensionItemName : name ) : bool;
  5409. import final function PreviewItemAttributeAfterUpgrade( baseItemId : SItemUniqueId, upgradeItemId : SItemUniqueId, attributeName : name, optional baseInventory : CInventoryComponent, optional upgradeInventory : CInventoryComponent ) : SAbilityAttributeValue;
  5410. import final function HasEnhancementItemTag( enhancedItemId : SItemUniqueId, slotIndex : int, tag : name ) : bool;
  5411.  
  5412.  
  5413. function NotifyEnhancedItem( enhancedItemId : SItemUniqueId )
  5414. {
  5415. var weapons : array<SItemUniqueId>;
  5416. var sword : CWitcherSword;
  5417. var i : int;
  5418.  
  5419. sword = (CWitcherSword) GetItemEntityUnsafe( enhancedItemId );
  5420. sword.UpdateEnhancements( this );
  5421. }
  5422.  
  5423. function EnhanceItemScript( enhancedItemId : SItemUniqueId, extensionItemId : SItemUniqueId ) : bool
  5424. {
  5425. var i : int;
  5426. var enhancements : array<name>;
  5427. var runeword : Runeword;
  5428.  
  5429. if ( EnhanceItem( enhancedItemId, extensionItemId ) )
  5430. {
  5431. NotifyEnhancedItem( enhancedItemId );
  5432.  
  5433. GetItemEnhancementItems( enhancedItemId, enhancements );
  5434. if ( theGame.runewordMgr.GetRuneword( enhancements, runeword ) )
  5435. {
  5436. for ( i = 0; i < runeword.abilities.Size(); i+=1 )
  5437. {
  5438. AddItemBaseAbility( enhancedItemId, runeword.abilities[i] );
  5439. }
  5440. }
  5441. return true;
  5442. }
  5443. return false;
  5444. }
  5445.  
  5446. function RemoveItemEnhancementByIndexScript( enhancedItemId : SItemUniqueId, slotIndex : int ) : bool
  5447. {
  5448. var i : int;
  5449. var enhancements : array<name>;
  5450. var runeword : Runeword;
  5451. var hasRuneword : bool;
  5452. var names : array< name >;
  5453.  
  5454. GetItemEnhancementItems( enhancedItemId, enhancements );
  5455. hasRuneword = theGame.runewordMgr.GetRuneword( enhancements, runeword );
  5456.  
  5457. GetItemEnhancementItems( enhancedItemId, names );
  5458.  
  5459. if ( RemoveItemEnhancementByIndex( enhancedItemId, slotIndex ) )
  5460. {
  5461. NotifyEnhancedItem( enhancedItemId );
  5462.  
  5463.  
  5464.  
  5465. if ( hasRuneword )
  5466. {
  5467.  
  5468. for ( i = 0; i < runeword.abilities.Size(); i+=1 )
  5469. {
  5470. RemoveItemBaseAbility( enhancedItemId, runeword.abilities[i] );
  5471. }
  5472. }
  5473. return true;
  5474. }
  5475. return false;
  5476. }
  5477.  
  5478.  
  5479. function RemoveItemEnhancementByNameScript( enhancedItemId : SItemUniqueId, extensionItemName : name ) : bool
  5480. {
  5481. var i : int;
  5482. var enhancements : array<name>;
  5483. var runeword : Runeword;
  5484. var hasRuneword : bool;
  5485.  
  5486. GetItemEnhancementItems( enhancedItemId, enhancements );
  5487. hasRuneword = theGame.runewordMgr.GetRuneword( enhancements, runeword );
  5488.  
  5489.  
  5490. if ( RemoveItemEnhancementByName( enhancedItemId, extensionItemName ) )
  5491. {
  5492. NotifyEnhancedItem( enhancedItemId );
  5493.  
  5494.  
  5495. AddAnItem( extensionItemName, 1, true, true );
  5496. if ( hasRuneword )
  5497. {
  5498.  
  5499. for ( i = 0; i < runeword.abilities.Size(); i+=1 )
  5500. {
  5501. RemoveItemBaseAbility( enhancedItemId, runeword.abilities[i] );
  5502. }
  5503. }
  5504. return true;
  5505. }
  5506. return false;
  5507. }
  5508.  
  5509. function RemoveAllItemEnhancements( enhancedItemId : SItemUniqueId )
  5510. {
  5511. var count, i : int;
  5512.  
  5513. count = GetItemEnhancementCount( enhancedItemId );
  5514. for ( i = count - 1; i >= 0; i-=1 )
  5515. {
  5516. RemoveItemEnhancementByIndexScript( enhancedItemId, i );
  5517. }
  5518. }
  5519.  
  5520. function GetHeldAndMountedItems( out items : array< SItemUniqueId > )
  5521. {
  5522. var allItems : array< SItemUniqueId >;
  5523. var i : int;
  5524. var itemName : name;
  5525.  
  5526. GetAllItems( allItems );
  5527.  
  5528. items.Clear();
  5529. for( i = 0; i < allItems.Size(); i += 1 )
  5530. {
  5531. if ( IsItemHeld( allItems[ i ] ) || IsItemMounted( allItems[ i ] ) )
  5532. {
  5533. items.PushBack( allItems[ i ] );
  5534. }
  5535. }
  5536. }
  5537.  
  5538.  
  5539. public function GetHasValidDecorationItems( items : array<SItemUniqueId>, decoration : W3HouseDecorationBase ) : bool
  5540. {
  5541. var i, size : int;
  5542.  
  5543. size = items.Size();
  5544.  
  5545.  
  5546. if(size == 0 )
  5547. {
  5548. LogChannel( 'houseDecorations', "No items with valid tag were found!" );
  5549. return false;
  5550. }
  5551.  
  5552.  
  5553. for( i=0; i < size; i+= 1 )
  5554. {
  5555.  
  5556. if( GetWitcherPlayer().IsItemEquipped( items[i] ) )
  5557. {
  5558. LogChannel( 'houseDecorations', "Found item is equipped, erasing..." );
  5559. continue;
  5560. }
  5561.  
  5562.  
  5563. if( IsItemQuest( items[i] ) && decoration.GetAcceptQuestItems() == false )
  5564. {
  5565. LogChannel( 'houseDecorations', "Found item is quest item, and quest items are not accepted, erasing..." );
  5566. continue;
  5567. }
  5568.  
  5569.  
  5570. if( decoration.GetItemHasForbiddenTag( items[i] ) )
  5571. {
  5572. LogChannel( 'houseDecorations', "Found item has a forbidden tag, erasing..." );
  5573. continue;
  5574. }
  5575.  
  5576. LogChannel( 'houseDecorations', "Item checks out: "+ GetItemName( items[i] ) );
  5577. return true;
  5578. }
  5579. LogChannel( 'houseDecorations', "No valid items were found!" );
  5580.  
  5581. return false;
  5582. }
  5583.  
  5584.  
  5585. function GetMissingCards() : array< name >
  5586. {
  5587. var defMgr : CDefinitionsManagerAccessor = theGame.GetDefinitionsManager();
  5588. var allCardNames : array< name > = defMgr.GetItemsWithTag(theGame.params.GWINT_CARD_ACHIEVEMENT_TAG);
  5589. var playersCards : array< SItemUniqueId > = GetItemsByTag(theGame.params.GWINT_CARD_ACHIEVEMENT_TAG);
  5590. var playersCardLocs : array< string >;
  5591. var missingCardLocs : array< string >;
  5592. var missingCards : array< name >;
  5593. var i, j : int;
  5594. var found : bool;
  5595.  
  5596.  
  5597. for ( i = 0; i < allCardNames.Size(); i+=1 )
  5598. {
  5599. found = false;
  5600.  
  5601. for ( j = 0; j < playersCards.Size(); j+=1 )
  5602. {
  5603. if ( allCardNames[i] == GetItemName( playersCards[j] ) )
  5604. {
  5605. found = true;
  5606. playersCardLocs.PushBack( defMgr.GetItemLocalisationKeyName ( allCardNames[i] ) );
  5607. break;
  5608. }
  5609. }
  5610.  
  5611. if ( !found )
  5612. {
  5613. missingCardLocs.PushBack( defMgr.GetItemLocalisationKeyName( allCardNames[i] ) );
  5614. missingCards.PushBack( allCardNames[i] );
  5615. }
  5616. }
  5617.  
  5618. if( missingCardLocs.Size() < 2 )
  5619. {
  5620. return missingCards;
  5621. }
  5622.  
  5623.  
  5624. for ( i = missingCardLocs.Size()-1 ; i >= 0 ; i-=1 )
  5625. {
  5626. for ( j = 0 ; j < playersCardLocs.Size() ; j+=1 )
  5627. {
  5628. if ( missingCardLocs[i] == playersCardLocs[j]
  5629. && missingCardLocs[i] != "gwint_name_emhyr" && missingCardLocs[i] != "gwint_name_foltest"
  5630. && missingCardLocs[i] != "gwint_name_francesca" && missingCardLocs[i] != "gwint_name_eredin" )
  5631. {
  5632. missingCardLocs.EraseFast( i );
  5633. missingCards.EraseFast( i );
  5634. break;
  5635. }
  5636. }
  5637. }
  5638.  
  5639. return missingCards;
  5640. }
  5641.  
  5642. public function FindCardSources( missingCards : array< name > ) : array< SCardSourceData >
  5643. {
  5644. var sourceCSV : C2dArray;
  5645. var sourceTable : array< SCardSourceData >;
  5646. var sourceRemaining : array< SCardSourceData >;
  5647. var sourceCount, i, j : int;
  5648.  
  5649. if ( theGame.IsFinalBuild() )
  5650. {
  5651. sourceCSV = LoadCSV("gameplay\globals\card_sources.csv");
  5652. }
  5653. else
  5654. {
  5655. sourceCSV = LoadCSV("qa\card_sources.csv");
  5656. }
  5657.  
  5658. sourceCount = sourceCSV.GetNumRows();
  5659. sourceTable.Resize(sourceCount);
  5660.  
  5661. for ( i = 0 ; i < sourceCount ; i+=1 )
  5662. {
  5663. sourceTable[i].cardName = sourceCSV.GetValueAsName("CardName",i);
  5664. sourceTable[i].source = sourceCSV.GetValue("Source",i);
  5665. sourceTable[i].originArea = sourceCSV.GetValue("OriginArea",i);
  5666. sourceTable[i].originQuest = sourceCSV.GetValue("OriginQuest",i);
  5667. sourceTable[i].details = sourceCSV.GetValue("Details",i);
  5668. sourceTable[i].coords = sourceCSV.GetValue("Coords",i);
  5669. }
  5670.  
  5671. for ( i = 0 ; i < missingCards.Size() ; i+=1 )
  5672. {
  5673. for ( j = 0 ; j < sourceCount ; j+=1 )
  5674. {
  5675. if ( sourceTable[j].cardName == missingCards[i] )
  5676. {
  5677. sourceRemaining.PushBack( sourceTable[j] );
  5678. }
  5679. }
  5680. }
  5681.  
  5682. return sourceRemaining;
  5683. }
  5684.  
  5685. public function GetGwentAlmanacContents() : string
  5686. {
  5687. var sourcesRemaining : array< SCardSourceData >;
  5688. var missingCards : array< string >;
  5689. var almanacContents : string;
  5690. var i : int;
  5691. var NML, Novigrad, Skellige, Prologue, Vizima, KaerMorhen, Random : int;
  5692.  
  5693. sourcesRemaining = FindCardSources( GetMissingCards() );
  5694.  
  5695. for ( i = 0 ; i < sourcesRemaining.Size() ; i+=1 )
  5696. {
  5697. switch ( sourcesRemaining[i].originArea )
  5698. {
  5699. case "NML":
  5700. NML += 1;
  5701. break;
  5702. case "Novigrad":
  5703. Novigrad += 1;
  5704. break;
  5705. case "Skellige":
  5706. Skellige += 1;
  5707. break;
  5708. case "Prologue":
  5709. Prologue += 1;
  5710. break;
  5711. case "Vizima":
  5712. Vizima += 1;
  5713. break;
  5714. case "KaerMorhen":
  5715. KaerMorhen += 1;
  5716. break;
  5717. case "Random":
  5718. Random += 1;
  5719. break;
  5720. default:
  5721. break;
  5722. }
  5723. }
  5724.  
  5725. if ( NML + Novigrad + Skellige + Prologue + Vizima + KaerMorhen + Random == 0 )
  5726. {
  5727. almanacContents = GetLocStringByKeyExt( "gwent_almanac_text" ) + "<br>";
  5728. almanacContents += GetLocStringByKeyExt( "gwent_almanac_completed_text" );
  5729. }
  5730. else
  5731. {
  5732. almanacContents = GetLocStringByKeyExt( "gwent_almanac_text" ) + "<br>";
  5733. if ( NML > 0 )
  5734. {
  5735. almanacContents += GetLocStringByKeyExt( "location_name_velen" ) + ": " + NML + "<br>";
  5736. }
  5737. if ( Novigrad > 0 )
  5738. {
  5739. almanacContents += GetLocStringByKeyExt( "map_location_novigrad" ) + ": " + Novigrad + "<br>";
  5740. }
  5741. if ( Skellige > 0 )
  5742. {
  5743. almanacContents += GetLocStringByKeyExt( "map_location_skellige" ) + ": " + Skellige + "<br>";
  5744. }
  5745. if ( Prologue > 0 )
  5746. {
  5747. almanacContents += GetLocStringByKeyExt( "map_location_prolog_village" ) + ": " + Prologue + "<br>";
  5748. }
  5749. if ( Vizima > 0 )
  5750. {
  5751. almanacContents += GetLocStringByKeyExt( "map_location_wyzima_castle" ) + ": " + Vizima + "<br>";
  5752. }
  5753. if ( KaerMorhen > 0 )
  5754. {
  5755. almanacContents += GetLocStringByKeyExt( "map_location_kaer_morhen" ) + ": " + KaerMorhen + "<br>";
  5756. }
  5757. almanacContents += GetLocStringByKeyExt( "gwent_source_random" ) + ": " + Random;
  5758. }
  5759.  
  5760. return almanacContents;
  5761. }
  5762.  
  5763. public function GetUnusedMutagensCount(itemName:name):int
  5764. {
  5765. var items : array<SItemUniqueId>;
  5766. var equippedOnSlot : EEquipmentSlots;
  5767. var availableCount : int;
  5768. var res, i : int = 0;
  5769.  
  5770. items = thePlayer.inv.GetItemsByName(itemName);
  5771.  
  5772. for(i=0; i<items.Size(); i+=1)
  5773. {
  5774. equippedOnSlot = GetWitcherPlayer().GetItemSlot( items[i] );
  5775.  
  5776. if(equippedOnSlot == EES_InvalidSlot)
  5777. {
  5778. availableCount = thePlayer.inv.GetItemQuantity( items[i] );
  5779. res = res + availableCount;
  5780. }
  5781. }
  5782.  
  5783. return res;
  5784. }
  5785.  
  5786. public function GetFirstUnusedMutagenByName( itemName : name ):SItemUniqueId
  5787. {
  5788. var items : array<SItemUniqueId>;
  5789. var equippedOnSlot : EEquipmentSlots;
  5790. var availableCount : int;
  5791. var res, i : int = 0;
  5792.  
  5793. items = thePlayer.inv.GetItemsByName(itemName);
  5794.  
  5795. for(i=0; i<items.Size(); i+=1)
  5796. {
  5797. equippedOnSlot = GetWitcherPlayer().GetItemSlot( items[i] );
  5798.  
  5799. if( equippedOnSlot == EES_InvalidSlot )
  5800. {
  5801. return items[i];
  5802. }
  5803. }
  5804.  
  5805. return GetInvalidUniqueId();
  5806. }
  5807.  
  5808. public function RemoveUnusedMutagensCountById( itemId:SItemUniqueId, count:int ):void
  5809. {
  5810. RemoveUnusedMutagensCount( thePlayer.inv.GetItemName( itemId ), count );
  5811. }
  5812.  
  5813. public function RemoveUnusedMutagensCount( itemName:name, count:int ):void
  5814. {
  5815. var items : array<SItemUniqueId>;
  5816. var curItem : SItemUniqueId;
  5817. var equippedOnSlot : EEquipmentSlots;
  5818.  
  5819. var i : int;
  5820. var itemRemoved : int;
  5821. var availableToRemoved : int;
  5822. var removedRes : bool;
  5823.  
  5824. itemRemoved = 0;
  5825. items = thePlayer.inv.GetItemsByName( itemName );
  5826.  
  5827. for( i=0; i < items.Size(); i+=1 )
  5828. {
  5829. curItem = items[ i ];
  5830. equippedOnSlot = GetWitcherPlayer().GetItemSlot( curItem );
  5831.  
  5832. if( equippedOnSlot == EES_InvalidSlot )
  5833. {
  5834. availableToRemoved = Min( thePlayer.inv.GetItemQuantity( curItem ), ( count - itemRemoved ) );
  5835. removedRes = thePlayer.inv.RemoveItem(items[i], availableToRemoved);
  5836.  
  5837. if (removedRes)
  5838. {
  5839. itemRemoved = itemRemoved + availableToRemoved;
  5840.  
  5841. if (itemRemoved >= count)
  5842. {
  5843. return;
  5844. }
  5845. }
  5846.  
  5847. }
  5848. }
  5849. }
  5850.  
  5851. }
  5852.  
  5853. exec function findMissingCards( optional card : name )
  5854. {
  5855. var inv : CInventoryComponent = thePlayer.GetInventory();
  5856. var sourcesRemaining : array< SCardSourceData >;
  5857. var missingCards : array< name >;
  5858. var i : int;
  5859. var sourceLogString : string;
  5860.  
  5861. if ( card != '' )
  5862. {
  5863. missingCards.PushBack( card );
  5864. }
  5865. else
  5866. {
  5867. missingCards = inv.GetMissingCards();
  5868. }
  5869.  
  5870. sourcesRemaining = inv.FindCardSources( missingCards );
  5871.  
  5872. for ( i = 0 ; i < sourcesRemaining.Size() ; i+=1 )
  5873. {
  5874. sourceLogString = sourcesRemaining[i].cardName + " is a " + sourcesRemaining[i].source ;
  5875. if ( sourcesRemaining[i].originArea == "Random" )
  5876. {
  5877. sourceLogString += " card from a random merchant.";
  5878. }
  5879. else
  5880. {
  5881. sourceLogString += " item in " + sourcesRemaining[i].originArea + " from ";
  5882.  
  5883. if ( sourcesRemaining[i].originQuest != "" )
  5884. {
  5885. sourceLogString += sourcesRemaining[i].originQuest + " , ";
  5886. }
  5887.  
  5888. sourceLogString += sourcesRemaining[i].details;
  5889. }
  5890. Log( sourceLogString );
  5891.  
  5892. if ( sourcesRemaining[i].coords != "" )
  5893. {
  5894. Log( sourcesRemaining[i].coords );
  5895. }
  5896. }
  5897. }
  5898.  
  5899. exec function slotTest()
  5900. {
  5901. var inv : CInventoryComponent = thePlayer.inv;
  5902. var weaponItemId : SItemUniqueId;
  5903. var upgradeItemId : SItemUniqueId;
  5904. var i : int;
  5905.  
  5906. LogChannel('SlotTest', "----------------------------------------------------------------");
  5907.  
  5908.  
  5909. inv.AddAnItem( 'Perun rune', 1);
  5910. inv.AddAnItem( 'Svarog rune', 1);
  5911.  
  5912.  
  5913. for ( i = 0; i < 2; i += 1 )
  5914. {
  5915.  
  5916. if ( !GetItem( inv, 'steelsword', weaponItemId ) ||
  5917. !GetItem( inv, 'upgrade', upgradeItemId ) )
  5918. {
  5919. return;
  5920. }
  5921.  
  5922.  
  5923. PrintItem( inv, weaponItemId );
  5924.  
  5925.  
  5926. if ( inv.EnhanceItemScript( weaponItemId, upgradeItemId ) )
  5927. {
  5928. LogChannel('SlotTest', "Enhanced item");
  5929. }
  5930. else
  5931. {
  5932. LogChannel('SlotTest', "Failed to enhance item!");
  5933. }
  5934. }
  5935.  
  5936.  
  5937. if ( !GetItem( inv, 'steelsword', weaponItemId ) )
  5938. {
  5939. return;
  5940. }
  5941.  
  5942.  
  5943. PrintItem( inv, weaponItemId );
  5944.  
  5945.  
  5946. if ( inv.RemoveItemEnhancementByNameScript( weaponItemId, 'Svarog rune' ) )
  5947. {
  5948. LogChannel('SlotTest', "Removed enhancement");
  5949. }
  5950. else
  5951. {
  5952. LogChannel('SlotTest', "Failed to remove enhancement!");
  5953. }
  5954.  
  5955.  
  5956. if ( !GetItem( inv, 'steelsword', weaponItemId ) )
  5957. {
  5958. return;
  5959. }
  5960.  
  5961.  
  5962. PrintItem( inv, weaponItemId );
  5963.  
  5964.  
  5965. if ( inv.RemoveItemEnhancementByIndexScript( weaponItemId, 0 ) )
  5966. {
  5967. LogChannel('SlotTest', "Removed enhancement");
  5968. }
  5969. else
  5970. {
  5971. LogChannel('SlotTest', "Failed to remove enhancement!");
  5972. }
  5973.  
  5974.  
  5975. if ( !GetItem( inv, 'steelsword', weaponItemId ) )
  5976. {
  5977. return;
  5978. }
  5979.  
  5980.  
  5981. PrintItem( inv, weaponItemId );
  5982. }
  5983.  
  5984. function GetItem( inv : CInventoryComponent, category : name, out itemId : SItemUniqueId ) : bool
  5985. {
  5986. var itemIds : array< SItemUniqueId >;
  5987.  
  5988. itemIds = inv.GetItemsByCategory( category );
  5989. if ( itemIds.Size() > 0 )
  5990. {
  5991. itemId = itemIds[ 0 ];
  5992. return true;
  5993. }
  5994. LogChannel( 'SlotTest', "Failed to get item with GetItemsByCategory( '" + category + "' )" );
  5995. return false;
  5996. }
  5997.  
  5998. function PrintItem( inv : CInventoryComponent, weaponItemId : SItemUniqueId )
  5999. {
  6000. var names : array< name >;
  6001. var tags : array< name >;
  6002. var i : int;
  6003. var line : string;
  6004. var attribute : SAbilityAttributeValue;
  6005.  
  6006. LogChannel('SlotTest', "Slots: " + inv.GetItemEnhancementCount( weaponItemId ) + "/" + inv.GetItemEnhancementSlotsCount( weaponItemId ) );
  6007. inv.GetItemEnhancementItems( weaponItemId, names );
  6008. if ( names.Size() > 0 )
  6009. {
  6010. for ( i = 0; i < names.Size(); i += 1 )
  6011. {
  6012. if ( i == 0 )
  6013. {
  6014. line += "[";
  6015. }
  6016. line += names[ i ];
  6017. if ( i < names.Size() - 1 )
  6018. {
  6019. line += ", ";
  6020. }
  6021. if ( i == names.Size() - 1 )
  6022. {
  6023. line += "]";
  6024. }
  6025. }
  6026. }
  6027. else
  6028. {
  6029. line += "[]";
  6030. }
  6031. LogChannel('SlotTest', "Upgrade item names " + line );
  6032.  
  6033. tags.PushBack('Upgrade');
  6034.  
  6035. attribute = inv.GetItemAttributeValue( weaponItemId, 'PhysicalDamage' );
  6036. LogChannel('SlotTest', "Attribute '" + 'PhysicalDamage' + "' " + attribute.valueBase + " " + attribute.valueMultiplicative + " " + attribute.valueAdditive );
  6037. attribute = inv.GetItemAttributeValue( weaponItemId, 'SilverDamage' );
  6038. LogChannel('SlotTest', "Attribute '" + 'SilverDamage' + "' " + attribute.valueBase + " " + attribute.valueMultiplicative + " " + attribute.valueAdditive );
  6039.  
  6040. attribute = inv.GetItemAttributeValue( weaponItemId, 'PhysicalDamage', tags, true );
  6041. LogChannel('SlotTest', "Attribute '" + 'PhysicalDamage' + "' " + attribute.valueBase + " " + attribute.valueMultiplicative + " " + attribute.valueAdditive );
  6042. attribute = inv.GetItemAttributeValue( weaponItemId, 'SilverDamage', tags, true );
  6043. LogChannel('SlotTest', "Attribute '" + 'SilverDamage' + "' " + attribute.valueBase + " " + attribute.valueMultiplicative + " " + attribute.valueAdditive );
  6044.  
  6045. attribute = inv.GetItemAttributeValue( weaponItemId, 'PhysicalDamage', tags );
  6046. LogChannel('SlotTest', "Attribute '" + 'PhysicalDamage' + "' " + attribute.valueBase + " " + attribute.valueMultiplicative + " " + attribute.valueAdditive );
  6047. attribute = inv.GetItemAttributeValue( weaponItemId, 'SilverDamage', tags );
  6048. LogChannel('SlotTest', "Attribute '" + 'SilverDamage' + "' " + attribute.valueBase + " " + attribute.valueMultiplicative + " " + attribute.valueAdditive );
  6049.  
  6050. }
  6051.  
  6052. function PlayItemEquipSound( itemCategory : name ) : void
  6053. {
  6054. switch( itemCategory )
  6055. {
  6056. case 'steelsword' :
  6057. theSound.SoundEvent("gui_inventory_steelsword_attach");
  6058. return;
  6059. case 'silversword' :
  6060. theSound.SoundEvent("gui_inventory_silversword_attach");
  6061. return;
  6062. case 'secondary' :
  6063. theSound.SoundEvent("gui_inventory_weapon_attach");
  6064. return;
  6065. case 'armor' :
  6066. theSound.SoundEvent("gui_inventory_armor_attach");
  6067. return;
  6068. case 'pants' :
  6069. theSound.SoundEvent("gui_inventory_pants_attach");
  6070. return;
  6071. case 'boots' :
  6072. theSound.SoundEvent("gui_inventory_boots_attach");
  6073. return;
  6074. case 'gloves' :
  6075. theSound.SoundEvent("gui_inventory_gauntlet_attach");
  6076. return;
  6077. case 'potion' :
  6078. theSound.SoundEvent("gui_inventory_potion_attach");
  6079. return;
  6080. case 'petard' :
  6081. theSound.SoundEvent("gui_inventory_bombs_attach");
  6082. return;
  6083. case 'ranged' :
  6084. theSound.SoundEvent("gui_inventory_ranged_attach");
  6085. return;
  6086. case 'herb' :
  6087. theSound.SoundEvent("gui_pick_up_herbs");
  6088. return;
  6089. case 'trophy' :
  6090. case 'horse_bag' :
  6091. theSound.SoundEvent("gui_inventory_horse_bage_attach");
  6092. return;
  6093. case 'horse_blinder' :
  6094. theSound.SoundEvent("gui_inventory_horse_blinder_attach");
  6095. return;
  6096. case 'horse_saddle' :
  6097. theSound.SoundEvent("gui_inventory_horse_saddle_attach");
  6098. return;
  6099. default :
  6100. theSound.SoundEvent("gui_inventory_other_attach");
  6101. return;
  6102. }
  6103. }
  6104.  
  6105. function PlayItemUnequipSound( itemCategory : name ) : void
  6106. {
  6107. switch( itemCategory )
  6108. {
  6109. case 'steelsword' :
  6110. theSound.SoundEvent("gui_inventory_steelsword_back");
  6111. return;
  6112. case 'silversword' :
  6113. theSound.SoundEvent("gui_inventory_silversword_back");
  6114. return;
  6115. case 'secondary' :
  6116. theSound.SoundEvent("gui_inventory_weapon_back");
  6117. return;
  6118. case 'armor' :
  6119. theSound.SoundEvent("gui_inventory_armor_back");
  6120. return;
  6121. case 'pants' :
  6122. theSound.SoundEvent("gui_inventory_pants_back");
  6123. return;
  6124. case 'boots' :
  6125. theSound.SoundEvent("gui_inventory_boots_back");
  6126. return;
  6127. case 'gloves' :
  6128. theSound.SoundEvent("gui_inventory_gauntlet_back");
  6129. return;
  6130. case 'petard' :
  6131. theSound.SoundEvent("gui_inventory_bombs_back");
  6132. return;
  6133. case 'potion' :
  6134. theSound.SoundEvent("gui_inventory_potion_back");
  6135. return;
  6136. case 'ranged' :
  6137. theSound.SoundEvent("gui_inventory_ranged_back");
  6138. return;
  6139. case 'trophy' :
  6140. case 'horse_bag' :
  6141. theSound.SoundEvent("gui_inventory_horse_bage_back");
  6142. return;
  6143. case 'horse_blinder' :
  6144. theSound.SoundEvent("gui_inventory_horse_blinder_back");
  6145. return;
  6146. case 'horse_saddle' :
  6147. theSound.SoundEvent("gui_inventory_horse_saddle_back");
  6148. return;
  6149. default :
  6150. theSound.SoundEvent("gui_inventory_other_back");
  6151. return;
  6152. }
  6153. }
  6154.  
  6155. function PlayItemConsumeSound( item : SItemUniqueId ) : void
  6156. {
  6157. if( thePlayer.GetInventory().ItemHasTag( item, 'Drinks' ) || thePlayer.GetInventory().ItemHasTag( item, 'Alcohol' ) )
  6158. {
  6159. theSound.SoundEvent('gui_inventory_drink');
  6160. }
  6161. else
  6162. {
  6163. theSound.SoundEvent('gui_inventory_eat');
  6164. }
  6165. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement