server/backpack_equipment.go (1898B)
1 package main 2 3 import "ao/server/gamedata" 4 5 func (item ownedItem) isWearableContainer() bool { 6 return item.isPortableContainer() && itemStat(gamedata.ItemTemplates[item.Template], 30)&4 != 0 && 7 gamedata.ItemQualitySupported(item.Template, item.Quality) 8 } 9 10 func (character *character) canWearContainer(item ownedItem) bool { 11 low, high := item.templateIDs() 12 first, second := gamedata.ItemTemplates[low], gamedata.ItemTemplates[high] 13 stats := character.baseStats() 14 for sectionIndex, section := range first.Sections { 15 if section.Actions == nil { 16 continue 17 } 18 for actionIndex, action := range *section.Actions { 19 if action.Type != 6 && action.Type != 8 { 20 continue 21 } 22 for index, requirement := range action.Requirements { 23 // Portable-container wear lists contain equality, strict bounds and AND. 24 if requirement.Operator == 4 { 25 continue 26 } 27 var actual int32 28 switch requirement.Stat { 29 case 19: 30 actual = character.effectiveAbility(19) 31 case 37: 32 actual = int32(character.titleLevel()) 33 case 54: 34 actual = int32(character.level) 35 case 60: 36 actual = int32(max(1, character.profession)) 37 case 131: 38 actual = character.effectiveSkill(131, stats.NanoAiding.TimeAndSpace, [6]uint32{0, 20, 0, 80, 0, 0}) 39 case 137: 40 actual = character.effectiveSkill(137, stats.Body.Adventuring, [6]uint32{20, 50, 30, 0, 0, 0}) 41 case 161: 42 actual = character.effectiveSkill(161, stats.TradeRepair.ComputerLiteracy, [6]uint32{0, 0, 0, 100, 0, 0}) 43 default: 44 return false 45 } 46 value := interpolateItemValue(requirement.Value, (*second.Sections[sectionIndex].Actions)[actionIndex].Requirements[index].Value, *first.Quality, *second.Quality, item.Quality) 47 if requirement.Operator == 0 && actual != value || requirement.Operator == 2 && actual <= value { 48 return false 49 } 50 } 51 return true 52 } 53 } 54 return false 55 }