1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: Holds constants for the econ item system
//
//=============================================================================
#include "cbase.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
const char *g_szQualityStrings[] =
{
"Normal",
"rarity1", // Genuine
"rarity2", // Customized
"vintage", // Vintage has to stay at 3 for backwards compatibility
"rarity3", // Well-Designed
"rarity4", // Unusual
"Unique",
"community",
"developer",
"selfmade",
"customized",
"strange",
"completed",
"haunted",
"collectors",
"paintkitWeapon",
"default", // AE_RARITY_DEFAULT,
"common", // AE_RARITY_COMMON,
"uncommon", // AE_RARITY_UNCOMMON,
"rare", // AE_RARITY_RARE,
"mythical", // AE_RARITY_MYTHICAL,
"legendary", // AE_RARITY_LEGENDARY,
"ancient", // AE_RARITY_ANCIENT,
};
COMPILE_TIME_ASSERT( ARRAYSIZE( g_szQualityStrings ) == AE_MAX_TYPES );
const char *EconQuality_GetQualityString( EEconItemQuality eQuality )
{
// This is a runtime check and not an assert because we could theoretically bounce the GC with new
// qualities while the client is running.
if ( eQuality >= 0 && eQuality < AE_MAX_TYPES )
return g_szQualityStrings[ eQuality ];
return NULL;
}
EEconItemQuality EconQuality_GetQualityFromString( const char* pszQuality )
{
// Convert to lowercase
CUtlString strLoweredInput( pszQuality );
strLoweredInput.ToLower();
// Guaranteed with the compile time assert above that AE_MAX_TYPES is
// the size of the string qualities
for( int i = 0; i < AE_MAX_TYPES; ++i )
{
// Convert to lowercase
CUtlString strLoweredQuality( g_szQualityStrings[i] );
strLoweredQuality.ToLower();
if( !Q_stricmp( strLoweredInput.Get(), strLoweredQuality.Get() ) )
return EEconItemQuality(i);
}
return AE_UNDEFINED;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
const char *g_szQualityColorStrings[] =
{
"QualityColorNormal",
"QualityColorrarity1",
"QualityColorrarity2",
"QualityColorVintage",
"QualityColorrarity3",
"QualityColorrarity4", // AE_UNUSUAL
"QualityColorUnique",
"QualityColorCommunity",
"QualityColorDeveloper",
"QualityColorSelfMade",
"QualityColorSelfMadeCustomized",
"QualityColorStrange",
"QualityColorCompleted",
"QualityColorHaunted", // AE_HAUNTED
"QualityColorCollectors", // AE_COLLECTORS
"QualityColorPaintkitWeapon", // AE_PAINTKITWEAPON
"ItemRarityDefault" , // AE_RARITY_DEFAULT,
"ItemRarityCommon" , // AE_RARITY_COMMON,
"ItemRarityUncommon" , // AE_RARITY_UNCOMMON,
"ItemRarityRare" , // AE_RARITY_RARE,
"ItemRarityMythical" , // AE_RARITY_MYTHICAL,
"ItemRarityLegendary" , // AE_RARITY_LEGENDARY,
"ItemRarityAncient" , // AE_RARITY_ANCIENT,
};
COMPILE_TIME_ASSERT( ARRAYSIZE( g_szQualityColorStrings ) == AE_MAX_TYPES );
const char *EconQuality_GetColorString( EEconItemQuality eQuality )
{
if ( eQuality >= 0 && eQuality < AE_MAX_TYPES )
return g_szQualityColorStrings[ eQuality ];
return NULL;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
const char *g_szQualityLocalizationStrings[] =
{
"#Normal",
"#rarity1", // Genuine
"#rarity2",
"#vintage",
"#rarity3", // Artisan
"#rarity4", // Unusual
"#unique",
"#community",
"#developer",
"#selfmade",
"#customized",
"#strange",
"#completed",
"#haunted",
"#collectors",
"#paintkitWeapon",
"#Rarity_Default",
"#Rarity_Common",
"#Rarity_Uncommon",
"#Rarity_Rare",
"#Rarity_Mythical",
"#Rarity_Legendary",
"#Rarity_Ancient"
};
COMPILE_TIME_ASSERT( ARRAYSIZE( g_szQualityLocalizationStrings ) == AE_MAX_TYPES );
const char *EconQuality_GetLocalizationString( EEconItemQuality eQuality )
{
if ( eQuality >= 0 && eQuality < AE_MAX_TYPES )
return g_szQualityLocalizationStrings[ eQuality ];
return NULL;
}
//-----------------------------------------------------------------------------
// Purpose: Sort order for rarities
// Small Numbers sort to front
//-----------------------------------------------------------------------------
int g_nRarityScores[] =
{
15, // AE_NORMAL,
10, // AE_RARITY1, // Geniune
102, // AE_RARITY2, // Customized (unused)
11, // AE_VINTAGE,
101, // AE_RARITY3, // Artisan (unused)
0, // AE_UNUSUAL,
14, // AE_UNIQUE,
-1, // AE_COMMUNITY,
-3, // AE_DEVELOPER,
-2, // AE_SELFMADE,
100, // AE_CUSTOMIZED, // Unused
9, // AE_STRANGE,
103, // AE_COMPLETED, // Unused
13, // AE_HAUNTED
12, // AE_COLLECTORS
8, // AE_PAINTKITWEAPON
7, // AE_RARITY_DEFAULT,
6, // AE_RARITY_COMMON,
5, // AE_RARITY_UNCOMMON,
4, // AE_RARITY_RARE,
3, // AE_RARITY_MYTHICAL,
2, // AE_RARITY_LEGENDARY,
1, // AE_RARITY_ANCIENT,
};
COMPILE_TIME_ASSERT( ARRAYSIZE( g_nRarityScores ) == AE_MAX_TYPES );
//-----------------------------------------------------------------------------
int EconQuality_GetRarityScore( EEconItemQuality eQuality )
{
if ( eQuality >= 0 && eQuality < AE_MAX_TYPES )
return g_nRarityScores[ eQuality ];
return 0;
}
//-----------------------------------------------------------------------------
const char *g_pchWearAmountStrings[] =
{
"#TFUI_InvTooltip_None",
"#TFUI_InvTooltip_FactoryNew",
"#TFUI_InvTooltip_MinimalWear",
"#TFUI_InvTooltip_FieldTested",
"#TFUI_InvTooltip_WellWorn",
"#TFUI_InvTooltip_BattleScared"
};
//-----------------------------------------------------------------------------
int EconWear_ToIntCategory( float flWear )
{
if ( flWear <= 0.2f )
{
return 1;
}
else if ( flWear <= 0.4f )
{
return 2;
}
else if ( flWear <= 0.6f )
{
return 3;
}
else if ( flWear <= 0.8f )
{
return 4;
}
else if ( flWear <= 1.0f )
{
return 5;
}
return 3; // default wear
}
// -------------------------------------------------------------------------
// Shim to return a value for buckets. For strange we bucket all of them in to 1 non-instance data group
int EconStrange_ToStrangeBucket( float value )
{
return 0;
}
float EconStrange_FromStrangeBucket( int value )
{
return 0;
}
//-----------------------------------------------------------------------------
const char *GetWearLocalizationString( float flWear )
{
int nIndex = EconWear_ToIntCategory( flWear );
return g_pchWearAmountStrings[ nIndex ];
}
//-----------------------------------------------------------------------------
bool EconWear_IsValidValue( int nWear )
{
return nWear > 0 && nWear <= 5;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
CSchemaColorDefHandle g_AttribColorDefs[] =
{
CSchemaColorDefHandle( "desc_level" ), // ATTRIB_COL_LEVEL
CSchemaColorDefHandle( "desc_attrib_neutral" ), // ATTRIB_COL_NEUTRAL
CSchemaColorDefHandle( "desc_attrib_positive" ), // ATTRIB_COL_POSITIVE
CSchemaColorDefHandle( "desc_attrib_negative" ), // ATTRIB_COL_NEGATIVE
CSchemaColorDefHandle( "desc_itemset_name" ), // ATTRIB_COL_ITEMSET_NAME
CSchemaColorDefHandle( "desc_itemset_equipped" ), // ATTRIB_COL_ITEMSET_EQUIPPED
CSchemaColorDefHandle( "desc_itemset_missing" ), // ATTRIB_COL_ITEMSET_MISSING
CSchemaColorDefHandle( "desc_bundle" ), // ATTRIB_COL_BUNDLE_ITEM
CSchemaColorDefHandle( "desc_limited_use" ), // ATTRIB_COL_LIMITED_USE
CSchemaColorDefHandle( "desc_flags" ), // ATTRIB_COL_component_flags
CSchemaColorDefHandle( "desc_limited_quantity" ), // ATTRIB_COL_LIMITED_QUANTITY
CSchemaColorDefHandle( "desc_default" ), // ATTRIB_COL_RARITY_DEFAULT
CSchemaColorDefHandle( "desc_common" ), // ATTRIB_COL_RARITY_COMMON
CSchemaColorDefHandle( "desc_uncommon" ), // ATTRIB_COL_RARITY_UNCOMMON
CSchemaColorDefHandle( "desc_rare" ), // ATTRIB_COL_RARITY_RARE
CSchemaColorDefHandle( "desc_mythical" ), // ATTRIB_COL_RARITY_MYTHICAL
CSchemaColorDefHandle( "desc_legendary" ), // ATTRIB_COL_RARITY_LEGENDARY
CSchemaColorDefHandle( "desc_ancient" ), // ATTRIB_COL_RARITY_ANCIENT
CSchemaColorDefHandle( "desc_immortal" ), // ATTRIB_COL_RARITY_IMMORTAL
CSchemaColorDefHandle( "desc_arcana" ), // ATTRIB_COL_RARITY_ARCANA
CSchemaColorDefHandle( "desc_strange" ), // ATTRIB_COL_STRANGE
CSchemaColorDefHandle( "desc_unusual" ), // ATTRIB_COL_UNUSUAL
};
COMPILE_TIME_ASSERT( ARRAYSIZE( g_AttribColorDefs ) == NUM_ATTRIB_COLORS );
attrib_colors_t GetAttribColorIndexForName( const char* pszName )
{
for ( int i = 0; i < NUM_ATTRIB_COLORS; ++i )
{
if ( !Q_strcmp( g_AttribColorDefs[i].GetName(), pszName ) )
return (attrib_colors_t)i;
}
return (attrib_colors_t)0;
}
const char *GetColorNameForAttribColor( attrib_colors_t unAttribColor )
{
Assert( unAttribColor >= 0 );
Assert( unAttribColor < NUM_ATTRIB_COLORS );
return g_AttribColorDefs[unAttribColor]
? g_AttribColorDefs[unAttribColor]->GetColorName()
: "ItemAttribNeutral";
}
const char *GetHexColorForAttribColor( attrib_colors_t unAttribColor )
{
Assert( unAttribColor >= 0 );
Assert( unAttribColor < NUM_ATTRIB_COLORS );
return g_AttribColorDefs[unAttribColor]
? g_AttribColorDefs[unAttribColor]->GetHexColor()
: "#ebe2ca";
}
entityquality_t GetItemQualityFromString( const char *sQuality )
{
for ( int i = 0; i < AE_MAX_TYPES; i++ )
{
if ( !Q_strnicmp( sQuality, g_szQualityStrings[i], 16 ) )
return (entityquality_t)i;
}
return AE_NORMAL;
}
const char *g_szRecipeCategoryStrings[] =
{
"crafting", // RECIPE_CATEGORY_CRAFTINGITEMS = 0,
"commonitem", // RECIPE_CATEGORY_COMMONITEMS,
"rareitem", // RECIPE_CATEGORY_RAREITEMS,
"special", // RECIPE_CATEGORY_SPECIAL,
};
COMPILE_TIME_ASSERT( ARRAYSIZE( g_szRecipeCategoryStrings ) == NUM_RECIPE_CATEGORIES );
//-----------------------------------------------------------------------------
// Item acquisition.
//-----------------------------------------------------------------------------
// Strings shown to the local player in the pickup dialog
const char *g_pszItemPickupMethodStrings[] =
{
"#NewItemMethod_Dropped", // UNACK_ITEM_DROPPED = 1,
"#NewItemMethod_Crafted", // UNACK_ITEM_CRAFTED,
"#NewItemMethod_Traded", // UNACK_ITEM_TRADED,
"#NewItemMethod_Purchased", // UNACK_ITEM_PURCHASED,
"#NewItemMethod_FoundInCrate", // UNACK_ITEM_FOUND_IN_CRATE,
"#NewItemMethod_Gifted", // UNACK_ITEM_GIFTED,
"#NewItemMethod_Support", // UNACK_ITEM_SUPPORT,
"#NewItemMethod_Promotion", // UNACK_ITEM_PROMOTION,
"#NewItemMethod_Earned", // UNACK_ITEM_EARNED,
"#NewItemMethod_Refunded", // UNACK_ITEM_REFUNDED,
"#NewItemMethod_GiftWrapped", // UNACK_ITEM_GIFT_WRAPPED,
"#NewItemMethod_Foreign", // UNACK_ITEM_FOREIGN,
"#NewItemMethod_CollectionReward", // UNACK_ITEM_COLLECTION_REWARD
"#NewItemMethod_PreviewItem", // UNACK_ITEM_PREVIEW_ITEM
"#NewItemMethod_PreviewItemPurchased", // UNACK_ITEM_PREVIEW_ITEM_PURCHASED
"#NewItemMethod_PeriodicScoreReward",// UNACK_ITEM_PERIODIC_SCORE_REWARD
"#NewItemMethod_MvMBadgeCompletionReward",// UNACK_ITEM_MVM_MISSION_COMPLETION_REWARD
"#NewItemMethod_MvMSquadSurplusReward",// UNACK_ITEM_MVM_SQUAD_SURPLUS_REWARD
"#NewItemMethod_HolidayGift", // UNACK_ITEM_FOUND_HOLIDAY_GIFT
"#NewItemMethod_CommunityMarketPurchase", // UNACK_ITEM_COMMUNITY_MARKET_PURCHASE
"#NewItemMethod_RecipeOutput", // UNACK_ITEM_RECIPE_OUTPUT
NULL, // UNACK_ITEM_HIDDEN_QUEST_ITEM
"#NewItemMethod_QuestOutput", // UNACK_ITEM_QUEST_OUTPUT
"#NewItemMethod_QuestLoaner", // UNACK_ITEM_QUEST_LOANER
"#NewItemMethod_TradeUp", // UNACK_ITEM_TRADE_UP
"#NewItemMethod_QuestMerasmissionOutput", //UNACK_ITEM_QUEST_MERASMISSION_OUTPUT
"#NewItemMethod_ViralCompetitiveBetaPassSpread", //UNACK_ITEM_VIRAL_COMPETITIVE_BETA_PASS_SPREAD
#ifdef ENABLE_STORE_RENTAL_BACKEND
"#NewItemMethod_RentalPurchase", // UNACK_ITEM_RENTAL_PURCHASE
#endif
};
COMPILE_TIME_ASSERT( ARRAYSIZE( g_pszItemPickupMethodStrings ) == (UNACK_NUM_METHODS - 1) ); // -1 because UNACK_ITEM_DROPPED is index 1, not 0
const char *g_pszItemPickupMethodStringsUnloc[] =
{
"dropped", // UNACK_ITEM_DROPPED = 1,
"crafted", // UNACK_ITEM_CRAFTED,
"traded", // UNACK_ITEM_TRADED,
"purchased", // UNACK_ITEM_PURCHASED,
"found_in_crate", // UNACK_ITEM_FOUND_IN_CRATE,
"gifted", // UNACK_ITEM_GIFTED,
"support", // UNACK_ITEM_SUPPORT,
"promotion", // UNACK_ITEM_PROMOTION,
"earned", // UNACK_ITEM_EARNED,
"refunded", // UNACK_ITEM_REFUNDED,
"gift_wrapped", // UNACK_ITEM_GIFT_WRAPPED
"foreign", // UNACK_ITEM_FOREIGN
"collection_reward",// UNACK_ITEM_COLLECTION_REWARD
"preview_item", // UNACK_ITEM_PREVIEW_ITEM
"preview_item_purchased", // UNACK_ITEM_PREVIEW_ITEM_PURCHASED
"periodic_score_reward", // UNACK_ITEM_PERIODIC_SCORE_REWARD
"mvm_badge_completion_reward", // UNACK_ITEM_MVM_MISSION_COMPLETION_REWARD
"mvm_squad_surplus_reward", // UNACK_ITEM_MVM_SQUAD_SURPLUS_REWARD
"holiday_gift", // UNACK_ITEM_FOUND_HOLIDAY_GIFT
"market_purchase", // UNACK_ITEM_COMMUNITY_MARKET_PURCHASE
"recipe_output", // UNACK_ITEM_RECIPE_OUTPUT
"hidden_quest", // UNACK_ITEM_HIDDEN_QUEST_ITEM
"quest_output", // UNACK_ITEM_QUEST_OUTPUT
"trade_up", // UNACK_ITEM_TRADE_UP
"quest_output", // UNACK_ITEM_QUEST_MERASMISSION_OUTPUT
"viral_competitive_beta_pass", //UNACK_ITEM_VIRAL_COMPETITIVE_BETA_PASS_SPREAD
#ifdef ENABLE_STORE_RENTAL_BACKEND
"rental_purchase", // UNACK_ITEM_RENTAL_PURCHASE
#endif
};
COMPILE_TIME_ASSERT( ARRAYSIZE( g_pszItemPickupMethodStringsUnloc ) == (UNACK_NUM_METHODS - 1) );
// Strings shown to other players in the chat dialog
const char *g_pszItemFoundMethodStrings[] =
{
"#Item_Found", // UNACK_ITEM_DROPPED = 1,
"#Item_Crafted", // UNACK_ITEM_CRAFTED,
"#Item_Traded", // UNACK_ITEM_TRADED,
NULL, // UNACK_ITEM_PURCHASED,
"#Item_FoundInCrate", // UNACK_ITEM_FOUND_IN_CRATE,
"#Item_Gifted", // UNACK_ITEM_GIFTED,
NULL, // UNACK_ITEM_SUPPORT,
NULL, // UNACK_ITEM_PROMOTION
"#Item_Earned", // UNACK_ITEM_EARNED
"#Item_Refunded", // UNACK_ITEM_REFUNDED
"#Item_GiftWrapped", // UNACK_ITEM_GIFT_WRAPPED
"#Item_Foreign", // UNACK_ITEM_FOREIGN
"#Item_CollectionReward", // UNACK_ITEM_COLLECTION_REWARD
"#Item_PreviewItem", // UNACK_ITEM_PREVIEW_ITEM
"#Item_PreviewItemPurchased",// UNACK_ITEM_PREVIEW_ITEM_PURCHASED
"#Item_PeriodicScoreReward",// UNACK_ITEM_PERIODIC_SCORE_REWARD
"#Item_MvMBadgeCompletionReward",// UNACK_ITEM_MVM_MISSION_COMPLETION_REWARD
"#Item_MvMSquadSurplusReward",// UNACK_ITEM_MVM_SQUAD_SURPLUS_REWARD
"#Item_HolidayGift", // UNACK_ITEM_FOUND_HOLIDAY_GIFT
NULL, // UNACK_ITEM_COMMUNITY_MARKET_PURCHASE
"#Item_RecipeOutput", // UNACK_ITEM_RECIPE_OUTPUT
NULL, // UNACK_ITEM_HIDDEN_QUEST_ITEM
"#Item_QuestOutput", // UNACK_ITEM_QUEST_OUTPUT
NULL, // UNACK_ITEM_QUEST_LOANER
"#Item_TradeUp", // UNACK_ITEM_TRADE_UP
"#Item_QuestMerasmissionOutput", // UNACK_ITEM_QUEST_MERASMISSION_OUTPUT
"#Item_ViralCompetitiveBetaPassSpread", //UNACK_ITEM_VIRAL_COMPETITIVE_BETA_PASS_SPREAD
#ifdef ENABLE_STORE_RENTAL_BACKEND
NULL, // UNACK_ITEM_RENTAL_PURCHASE
#endif
};
COMPILE_TIME_ASSERT( ARRAYSIZE( g_pszItemFoundMethodStrings ) == (UNACK_NUM_METHODS - 1) );
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
struct strange_attr_set_t
{
strange_attr_set_t( const char *pScoreAttrName, const char *pTypeAttrName, const char *pRestrictionAttrName, const char *pRestrictionValueAttrName, bool bIsUserCustomizable )
: m_attrScore( pScoreAttrName )
, m_attrType( pTypeAttrName )
, m_attrRestriction( pRestrictionAttrName )
, m_attrRestrictionValue( pRestrictionValueAttrName )
, m_bIsUserCustomizable( bIsUserCustomizable )
{
//
}
CSchemaAttributeDefHandle m_attrScore;
CSchemaAttributeDefHandle m_attrType;
CSchemaAttributeDefHandle m_attrRestriction;
CSchemaAttributeDefHandle m_attrRestrictionValue;
bool m_bIsUserCustomizable;
};
strange_attr_set_t g_KillEaterAttr[] =
{
strange_attr_set_t( "kill eater", "kill eater score type", "strange restriction type 1", "strange restriction value 1", false ),
strange_attr_set_t( "kill eater 2", "kill eater score type 2", "strange restriction type 2", "strange restriction value 2", false ),
strange_attr_set_t( "kill eater 3", "kill eater score type 3", "strange restriction type 3", "strange restriction value 3", false ),
// assumption: all of the user-customizable attributes will follow all of the schema-specified attributes
strange_attr_set_t( "kill eater user 1", "kill eater user score type 1", "strange restriction user type 1", "strange restriction user value 1", true ),
strange_attr_set_t( "kill eater user 2", "kill eater user score type 2", "strange restriction user type 2", "strange restriction user value 2", true ),
strange_attr_set_t( "kill eater user 3", "kill eater user score type 3", "strange restriction user type 3", "strange restriction user value 3", true ),
};
int GetKillEaterAttrCount()
{
#ifdef DBGFLAG_ASSERT
// Verify our commented assumption that all of the non-user-customizable attributes will be followed by
// all of the user-customizable attributes.
bool bInUserCustomizableBlock = false;
for ( int i = 0; i < ARRAYSIZE( g_KillEaterAttr ); i++ )
{
if ( bInUserCustomizableBlock )
{
AssertMsg( g_KillEaterAttr[i].m_bIsUserCustomizable, "Ordering assumption for g_KillEaterAttr violated! User-customizable attributes should all be at the end of the list!" );
}
bInUserCustomizableBlock |= g_KillEaterAttr[i].m_bIsUserCustomizable;
}
#endif
return ARRAYSIZE( g_KillEaterAttr );
}
int GetKillEaterAttrCount_UserCustomizable()
{
int iCount = 0;
for ( int i = 0; i < GetKillEaterAttrCount(); i++ )
{
if ( GetKillEaterAttr_IsUserCustomizable( i ) )
{
iCount++;
}
}
return iCount;
}
const CEconItemAttributeDefinition *GetKillEaterAttr_Score( int i )
{
Assert( i >= 0 );
Assert( i < GetKillEaterAttrCount() );
const CEconItemAttributeDefinition *pAttrRes = g_KillEaterAttr[i].m_attrScore;
AssertMsg1( pAttrRes, "Missing Killeater attr score %s", g_KillEaterAttr[ i ].m_attrScore.GetName() );
return pAttrRes;
}
const CEconItemAttributeDefinition *GetKillEaterAttr_Type( int i )
{
Assert( i >= 0 );
Assert( i < GetKillEaterAttrCount() );
const CEconItemAttributeDefinition *pAttrRes = g_KillEaterAttr[i].m_attrType;
AssertMsg1( pAttrRes, "Missing Killeater attr type %s", g_KillEaterAttr[ i ].m_attrType.GetName() );
return pAttrRes;
}
const CEconItemAttributeDefinition *GetKillEaterAttr_Restriction( int i )
{
Assert( i >= 0 );
Assert( i < GetKillEaterAttrCount() );
const CEconItemAttributeDefinition *pAttrRes = g_KillEaterAttr[i].m_attrRestriction;
AssertMsg1( pAttrRes, "Missing Killeater attr restriction %s", g_KillEaterAttr[ i ].m_attrRestriction.GetName() );
return pAttrRes;
}
const CEconItemAttributeDefinition *GetKillEaterAttr_RestrictionValue( int i )
{
Assert( i >= 0 );
Assert( i < GetKillEaterAttrCount() );
const CEconItemAttributeDefinition *pAttrRes = g_KillEaterAttr[i].m_attrRestrictionValue;
AssertMsg1( pAttrRes, "Missing Killeater attr restriction value %s", g_KillEaterAttr[ i ].m_attrRestrictionValue.GetName() );
return pAttrRes;
}
bool GetKillEaterAttr_IsUserCustomizable( int i )
{
Assert( i >= 0 );
Assert( i < GetKillEaterAttrCount() );
return g_KillEaterAttr[i].m_bIsUserCustomizable;
}
bool GetKilleaterValueByEvent( const IEconItemInterface* pItem, const kill_eater_event_t& EEventType, uint32& value )
{
for ( int i = 0; i < GetKillEaterAttrCount(); i++ )
{
const CEconItemAttributeDefinition *pAttribKillEater = GetKillEaterAttr_Score( i );
const CEconItemAttributeDefinition *pAttribKillEaterScoreType = GetKillEaterAttr_Type( i );
Assert( pAttribKillEater && pAttribKillEaterScoreType );
if ( !pAttribKillEater || !pAttribKillEaterScoreType )
return false;
// make sure this item even has a kill count attribute we're looking for
uint32 unKillEaterAttrValue;
if ( !pItem->FindAttribute( pAttribKillEater, &unKillEaterAttrValue ) )
continue;
uint32 unKillEaterScoreTypeAttrValue = kKillEaterEvent_PlayerKill;
float fKillEaterScoreTypeAttrValue;
if ( FindAttribute_UnsafeBitwiseCast<attrib_value_t>( pItem, pAttribKillEaterScoreType, &fKillEaterScoreTypeAttrValue ) )
{
unKillEaterScoreTypeAttrValue = (uint32)fKillEaterScoreTypeAttrValue;
}
// this isn't the attribute we're trying to find
if ( EEventType != (kill_eater_event_t)unKillEaterScoreTypeAttrValue )
continue;
value = unKillEaterAttrValue;
return true;
}
return false;
}
// Does this thing have kill eater
bool BIsItemStrange( const IEconItemInterface *pItem )
{
// Go over the attributes of the item, if it has any strange attributes the item is strange and don't apply
uint32 unKillEaterAttr;
for ( int i = 0; i < GetKillEaterAttrCount(); i++ )
{
if ( pItem->FindAttribute( GetKillEaterAttr_Score( i ), &unKillEaterAttr ) )
{
return true;
}
}
return false;
}
//-----------------------------------------------------------------------------
// Purpose: Get a localization token that describes why an item is not usable
// in the trade-up crafting. Returns NULL if no reason. Can pass in
// another item to compare against, which causes extra consistency checks
//-----------------------------------------------------------------------------
const char* GetCollectionCraftingInvalidReason( const IEconItemInterface *pTestItem, const IEconItemInterface *pSourceItem )
{
if ( !pTestItem )
{
return "#TF_CollectionCrafting_NoItem";
}
// Needs to have a collection
const CEconItemCollectionDefinition* pTestCollection = pTestItem->GetItemDefinition()->GetItemCollectionDefinition();
if ( !pTestCollection )
{
return "#TF_CollectionCrafting_NoCollection";
}
// Make sure this item is a part of the collection it claims to be in
{
item_definition_index_t nThisDefIndex = pTestItem->GetItemDefIndex();
bool bFound = false;
for( int i=0; i < pTestCollection->m_iItemDefs.Count() && !bFound; ++i )
{
bFound |= pTestCollection->m_iItemDefs[i] == nThisDefIndex;
}
if ( !bFound )
{
return "#TF_CollectionCrafting_NoCollection";
}
}
// Needs rarity
uint8 nRarity = pTestItem->GetItemDefinition()->GetRarity();
if( nRarity == k_unItemRarity_Any )
{
return "#TF_CollectionCrafting_NoRarity";
}
// Can't use items with rarity at the "top" of a collection (what would they craft into?)
if ( nRarity == pTestCollection->GetMaxRarity() )
{
return "#TF_CollectionCrafting_MaxRarity";
}
// No self mades or community items
uint32 eQuality = pTestItem->GetQuality();
if ( eQuality == AE_SELFMADE || eQuality == AE_COMMUNITY )
{
return "#TF_CollectionCrafting_NoUnusual";
}
// This is how we test for unusuals. Don't let unusuals be crafted
static CSchemaAttributeDefHandle pAttrDef_ParticleEffect( "attach particle effect" );
if ( pTestItem->FindAttribute( pAttrDef_ParticleEffect ) )
{
return "#TF_CollectionCrafting_NoUnusual";
}
static CSchemaAttributeDefHandle pAttrDef_TauntUnusualAttr( "on taunt attach particle index" );
if ( pTestItem->FindAttribute( pAttrDef_TauntUnusualAttr ) )
{
return "#TF_CollectionCrafting_NoUnusual";
}
// Not allowed to be crafted?
if ( !pTestItem->IsUsableInCrafting() )
{
return "#TF_CollectionCrafting_NotCraftable";
}
// If another item was passed in, we have a few consistency checks to make
if ( pSourceItem )
{
// Need to have the same rarity
if ( nRarity != pSourceItem->GetItemDefinition()->GetRarity() )
{
return "#TF_CollectionCrafting_MismatchRarity";
}
// Need to have the same strangeness
if ( BIsItemStrange( pSourceItem ) != BIsItemStrange( pTestItem ) )
{
return "#TF_CollectionCrafting_MismatchStrange";
}
}
return NULL;
}
//-----------------------------------------------------------------------------
// Purpose: Get a localization token that describes why an item is not usable
// in the Halloween Offering. Returns NULL if no reason. Can pass in
// another item to compare against, which causes extra consistency checks
//-----------------------------------------------------------------------------
const char* GetHalloweenOfferingInvalidReason( const IEconItemInterface *pTestItem, const IEconItemInterface *pSourceItem )
{
// Must either be a Cosmetic
// Taunt
// Allowable Tool (Strange part, Paint, name tag, killstreak). Not crates, keys
// Marketable Weapon ie Strange, Genuine, Vintage, paintkit
// Cannot be Unusual
if ( !pTestItem )
{
return "#TF_CollectionCrafting_NoItem";
}
// No self mades or community items
uint32 eQuality = pTestItem->GetQuality();
if ( eQuality == AE_SELFMADE || eQuality == AE_COMMUNITY )
{
return "#TF_CollectionCrafting_NoUnusual";
}
// This is how we test for unusuals. Don't let unusuals be crafted
static CSchemaAttributeDefHandle pAttrDef_ParticleEffect( "attach particle effect" );
if ( pTestItem->FindAttribute( pAttrDef_ParticleEffect ) )
{
return "#TF_CollectionCrafting_NoUnusual";
}
static CSchemaAttributeDefHandle pAttrDef_TauntUnusualAttr( "on taunt attach particle index" );
if ( pTestItem->FindAttribute( pAttrDef_TauntUnusualAttr ) )
{
return "#TF_CollectionCrafting_NoUnusual";
}
// Invalid Items
static CSchemaAttributeDefHandle pAttrDef_CannotTransmute( "cannot_transmute" );
if ( pTestItem->FindAttribute( pAttrDef_CannotTransmute ) )
{
return "#TF_HalloweenOffering_Invalid";
}
static CSchemaAttributeDefHandle pAttrDef_CannotDelete( "cannot delete" );
if ( pTestItem->FindAttribute( pAttrDef_CannotDelete ) )
{
return "#TF_HalloweenOffering_Invalid";
}
const CEconItemDefinition *pItemDef = pTestItem->GetItemDefinition();
if ( pItemDef == NULL )
{
return "#TF_CollectionCrafting_NoItem";
}
if ( pTestItem->IsTemporaryItem() )
{
return "#TF_CollectionCrafting_NoItem";
}
// If you are a taunt or a cosmetic you are allowed
if ( pTestItem->GetItemDefinition()->GetLoadoutSlot( 0 ) == LOADOUT_POSITION_MISC || pTestItem->GetItemDefinition()->GetLoadoutSlot( 0 ) == LOADOUT_POSITION_TAUNT )
{
// do not 'medal' equip region items
if ( pTestItem->GetItemDefinition()->GetEquipRegionMask() & GetItemSchema()->GetEquipRegionBitMaskByName( "medal" ) )
{
return "#TF_HalloweenOffering_Invalid";
}
return NULL;
}
// Do not allow Crates
if ( ( pItemDef->GetCapabilities() & ITEM_CAP_DECODABLE ) != 0 )
{
return "#TF_HalloweenOffering_Invalid";
}
// Cause of weird legacy items lets be explicit about what we allow
if ( pItemDef->IsTool() )
{
// ignore everything that is not a paint can tool
const IEconTool *pEconTool = pItemDef->GetEconTool();
if ( !pEconTool )
return "#TF_HalloweenOffering_Invalid";
const char *pToolType = pEconTool->GetTypeName();
if ( !V_strcmp( pToolType, "paint_can" ) )
return NULL;
else if ( !V_strcmp( pToolType, "strange_part" ) )
return NULL;
else if ( !V_strcmp( pToolType, "name" ) )
return NULL;
else if ( !V_strcmp( pToolType, "desc" ) )
return NULL;
else if ( !V_strcmp( pToolType, "killstreakifier" ) )
return NULL;
else if ( !V_strcmp( pToolType, "strangifier" ) )
return NULL;
// Not a tool we are allowing
return "#TF_HalloweenOffering_Invalid";
}
// Otherwise you must be a weapon or we won't allow
if ( pTestItem->GetItemDefinition()->GetLoadoutSlot( 0 ) == LOADOUT_POSITION_PRIMARY
|| pTestItem->GetItemDefinition()->GetLoadoutSlot( 0 ) == LOADOUT_POSITION_SECONDARY
|| pTestItem->GetItemDefinition()->GetLoadoutSlot( 0 ) == LOADOUT_POSITION_MELEE
|| pTestItem->GetItemDefinition()->GetLoadoutSlot( 0 ) == LOADOUT_POSITION_BUILDING
|| pTestItem->GetItemDefinition()->GetLoadoutSlot( 0 ) == LOADOUT_POSITION_PDA
|| pTestItem->GetItemDefinition()->GetLoadoutSlot( 0 ) == LOADOUT_POSITION_PDA2
) {
// Must be strange, genuine, vintage, haunted or paintkit (ie a marketable weapon)
eQuality = pTestItem->GetQuality();
if ( eQuality == AE_RARITY1
|| eQuality == AE_VINTAGE
|| eQuality == AE_HAUNTED
|| eQuality == AE_COLLECTORS
|| eQuality == AE_PAINTKITWEAPON
) {
return NULL;
}
// Weapons with rarity are allowed
uint8 nRarity = pTestItem->GetItemDefinition()->GetRarity();
if ( nRarity != k_unItemRarity_Any )
{
return NULL;
}
// Strange items. Dont just check for strange quality, actually check for a strange attribute.
// See if we've got any strange attributes.
for ( int i = 0; i < GetKillEaterAttrCount(); i++ )
{
if ( pTestItem->FindAttribute( GetKillEaterAttr_Score( i ) ) )
{
return NULL;
}
}
}
return "#TF_HalloweenOffering_Invalid";
}
const char* GetCraftCommonStatClockInvalidReason( const class IEconItemInterface *pTestItem, const class IEconItemInterface *pSourceItem )
{
if ( !pTestItem )
{
return "#TF_CollectionCrafting_NoItem";
}
// Not allowed to be crafted?
if ( !pTestItem->IsUsableInCrafting() )
{
return "#TF_CollectionCrafting_NotCraftable";
}
// No self mades or community items
uint32 eQuality = pTestItem->GetQuality();
if ( eQuality == AE_SELFMADE || eQuality == AE_COMMUNITY )
return "#TF_CollectionCrafting_NoUnusual";
// This is how we test for unusuals. Don't let unusuals be crafted
static CSchemaAttributeDefHandle pAttrDef_ParticleEffect( "attach particle effect" );
if ( pTestItem->FindAttribute( pAttrDef_ParticleEffect ) )
return "#TF_CollectionCrafting_NoUnusual";
static CSchemaAttributeDefHandle pAttrDef_TauntUnusualAttr( "on taunt attach particle index" );
if ( pTestItem->FindAttribute( pAttrDef_TauntUnusualAttr ) )
return "#TF_CollectionCrafting_NoUnusual";
const CEconItemDefinition *pItemDef = pTestItem->GetItemDefinition();
if ( pItemDef == NULL )
return "#TF_CollectionCrafting_NoItem";
if ( pTestItem->IsTemporaryItem() )
return "#TF_CollectionCrafting_NoItem";
// Strange items. Dont just check for strange quality, actually check for a strange attribute.
// See if we've got any strange attributes.
for ( int i = 0; i < GetKillEaterAttrCount(); i++ )
{
if ( pTestItem->FindAttribute( GetKillEaterAttr_Score( i ) ) )
{
return NULL;
}
}
// Needs Rarity
uint8 nRarity = pTestItem->GetItemDefinition()->GetRarity();
if ( nRarity != k_unItemRarity_Any && nRarity > 1 ) // do not allow default nor common rarity
{
return NULL;
}
return "#TF_MannCoTrade_ItemInvalid";
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
enum { kMaxCardUpgradesPerItem = 2 };
int GetMaxCardUpgradesPerItem()
{
return kMaxCardUpgradesPerItem;
}
const CEconItemAttributeDefinition *GetCardUpgradeForIndex( const IEconItemInterface *pItem, int i )
{
Assert( pItem );
Assert( i >= 0 );
Assert( i < kMaxCardUpgradesPerItem );
class CGetNthUserGeneratedAttributeIterator : public IEconItemUntypedAttributeIterator
{
public:
CGetNthUserGeneratedAttributeIterator( int iTargetIndex )
: m_iCount( iTargetIndex )
, m_pAttrDef( NULL )
{
}
virtual bool OnIterateAttributeValueUntyped( const CEconItemAttributeDefinition *pAttrDef ) OVERRIDE
{
if ( pAttrDef->GetUserGenerationType() != 0 && m_iCount-- == 0 )
{
m_pAttrDef = pAttrDef;
return false;
}
return true;
}
const CEconItemAttributeDefinition *GetAttrDef() const { return m_pAttrDef; }
private:
int m_iCount;
const CEconItemAttributeDefinition *m_pAttrDef;
};
CGetNthUserGeneratedAttributeIterator findNthAttrIterator( i );
pItem->IterateAttributes( &findNthAttrIterator );
return findNthAttrIterator.GetAttrDef();
}
|