AttributeIterator findAttribute(Attributes& attributes, const std::string& name) { CAF_CM_STATIC_FUNC_VALIDATE("MarkupParser", "findAttribute"); CAF_CM_VALIDATE_STRING(name); return std::find_if(attributes.begin(), attributes.end(), std::bind2nd(AttributeName(), name)); }
/* ** Returns the length of the longest attribute name in #obj#. */ int LongestNameLength(const Object obj) { Attribute attr; int nameLen; int returnValue = 0; ForEachAttribute(obj, attr) { nameLen = strlen(AttributeName(attr)); if(nameLen > returnValue) returnValue = nameLen; }
void Disasm::PrintAttributeValue(uint8 id, const AttrValue* table, int size) { if (NumOfArgs() == 1 && ArgAt(0)->Type == HP_UByteData) { uint8 value = ArgAt(0)->val.ubyte; for (int i = 0; i < size; i ++, table ++) { if (table->value == value) { if (fVerbose) PrintAttr(ArgAt(0)); printf("%s %s\n", table->name, AttributeName(id)); return; } } } GenericPrintAttribute(id); }
void Disasm::GenericPrintAttribute(uint8 id) { for (int i = 0; i < NumOfArgs(); i ++) { PrintAttr(ArgAt(i)); } printf(" %s\n", AttributeName(id)); }
bool LootRandomizer::SetAttribute(const csString &op, const csString &attrName, float modifier, RandomizedOverlay* overlay, psItemStats* baseItem, csArray<ValueModifier> &values) { float* value[3] = { NULL, NULL, NULL }; // Attribute Names: // item // weight // damage // slash // pierce // blunt // ... // protection // slash // pierce // blunt // ... // speed csString AttributeName(attrName); AttributeName.Downcase(); if(AttributeName.StartsWith("var.")) { //if var. was found we have a script variable //parse it and place it in the array which will be used later //to handle those variables. ValueModifier val; //start the name of the variable after var. val.name = attrName.Slice(4); val.value = modifier; val.op = op; //add the variable to the array values.Push(val); return true; } if(AttributeName.Compare("item.weight")) { // Initialize the value if needed if(CS::IsNaN(overlay->weight)) { overlay->weight = baseItem->GetWeight(); } value[0] = &overlay->weight; } else if(AttributeName.Compare("item.speed")) { // Initialize the value if needed if(CS::IsNaN(overlay->latency)) { overlay->latency = baseItem->Weapon().Latency(); } value[0] = &overlay->latency; } else if(AttributeName.Compare("item.damage")) { for(int i = 0; i < 3; i++) { // Initialize the value if needed if(CS::IsNaN(overlay->damageStats[i])) { overlay->damageStats[i] = baseItem->Weapon().Damage((PSITEMSTATS_DAMAGETYPE)i); } } value[0] = &overlay->damageStats[PSITEMSTATS_DAMAGETYPE_SLASH]; value[1] = &overlay->damageStats[PSITEMSTATS_DAMAGETYPE_BLUNT]; value[2] = &overlay->damageStats[PSITEMSTATS_DAMAGETYPE_PIERCE]; } else if(AttributeName.Compare("item.damage.slash")) { // Initialize the value if needed if(CS::IsNaN(overlay->damageStats[PSITEMSTATS_DAMAGETYPE_SLASH])) { overlay->damageStats[PSITEMSTATS_DAMAGETYPE_SLASH] = baseItem->Weapon().Damage(PSITEMSTATS_DAMAGETYPE_SLASH); } value[0] = &overlay->damageStats[PSITEMSTATS_DAMAGETYPE_SLASH]; } else if(AttributeName.Compare("item.damage.pierce")) { // Initialize the value if needed if(CS::IsNaN(overlay->damageStats[PSITEMSTATS_DAMAGETYPE_PIERCE])) { overlay->damageStats[PSITEMSTATS_DAMAGETYPE_PIERCE] = baseItem->Weapon().Damage(PSITEMSTATS_DAMAGETYPE_PIERCE); } value[0] = &overlay->damageStats[PSITEMSTATS_DAMAGETYPE_PIERCE]; } else if(AttributeName.Compare("item.damage.blunt")) { // Initialize the value if needed if(CS::IsNaN(overlay->damageStats[PSITEMSTATS_DAMAGETYPE_BLUNT])) { overlay->damageStats[PSITEMSTATS_DAMAGETYPE_BLUNT] = baseItem->Weapon().Damage(PSITEMSTATS_DAMAGETYPE_BLUNT); } value[0] = &overlay->damageStats[PSITEMSTATS_DAMAGETYPE_BLUNT]; } else if(AttributeName.Compare("item.protection")) { for(int i = 0; i < 3; i++) { // Initialize the value if needed if(CS::IsNaN(overlay->damageStats[i])) { overlay->damageStats[i] = baseItem->Armor().Protection((PSITEMSTATS_DAMAGETYPE)i); } } value[0] = &overlay->damageStats[PSITEMSTATS_DAMAGETYPE_SLASH]; value[1] = &overlay->damageStats[PSITEMSTATS_DAMAGETYPE_BLUNT]; value[2] = &overlay->damageStats[PSITEMSTATS_DAMAGETYPE_PIERCE]; } else if(AttributeName.Compare("item.protection.slash")) { // Initialize the value if needed if(CS::IsNaN(overlay->damageStats[PSITEMSTATS_DAMAGETYPE_SLASH])) { overlay->damageStats[PSITEMSTATS_DAMAGETYPE_SLASH] = baseItem->Armor().Protection(PSITEMSTATS_DAMAGETYPE_SLASH); } value[0] = &overlay->damageStats[PSITEMSTATS_DAMAGETYPE_SLASH]; } else if(AttributeName.Compare("item.protection.pierce")) { // Initialize the value if needed if(CS::IsNaN(overlay->damageStats[PSITEMSTATS_DAMAGETYPE_PIERCE])) { overlay->damageStats[PSITEMSTATS_DAMAGETYPE_PIERCE] = baseItem->Armor().Protection(PSITEMSTATS_DAMAGETYPE_PIERCE); } value[0] = &overlay->damageStats[PSITEMSTATS_DAMAGETYPE_PIERCE]; } else if(AttributeName.Compare("item.protection.blunt")) { // Initialize the value if needed if(CS::IsNaN(overlay->damageStats[PSITEMSTATS_DAMAGETYPE_BLUNT])) { overlay->damageStats[PSITEMSTATS_DAMAGETYPE_BLUNT] = baseItem->Armor().Protection(PSITEMSTATS_DAMAGETYPE_BLUNT); } value[0] = &overlay->damageStats[PSITEMSTATS_DAMAGETYPE_BLUNT]; } SetAttributeApplyOP(value, modifier, 3, op); return true; }