ICCItem *CDeviceClass::GetItemProperty (CItemCtx &Ctx, const CString &sName) // GetItemProperty // // Returns the item property. Subclasses should call this if they do not // understand the property. { CCodeChain &CC = g_pUniverse->GetCC(); // Get the device CInstalledDevice *pDevice = Ctx.GetDevice(); // Get the property if (strEquals(sName, PROPERTY_CAN_BE_DISABLED)) return (pDevice ? CC.CreateBool(pDevice->CanBeDisabled(Ctx)) : CC.CreateBool(CanBeDisabled(Ctx))); else if (strEquals(sName, PROPERTY_ENABLED)) return (pDevice ? CC.CreateBool(pDevice->IsEnabled()) : CC.CreateNil()); else if (strEquals(sName, PROPERTY_POS)) { if (pDevice == NULL) return CC.CreateNil(); // Create a list ICCItem *pResult = CC.CreateLinkedList(); if (pResult->IsError()) return pResult; CCLinkedList *pList = (CCLinkedList *)pResult; // List contains angle, radius, and optional z pList->AppendInteger(CC, pDevice->GetPosAngle()); pList->AppendInteger(CC, pDevice->GetPosRadius()); if (pDevice->GetPosZ() != 0) pList->AppendInteger(CC, pDevice->GetPosZ()); // Done return pResult; } else if (strEquals(sName, PROPERTY_SECONDARY)) return (pDevice ? CC.CreateBool(pDevice->IsSecondaryWeapon()) : CC.CreateNil()); else if (m_pItemType) return CreateResultFromDataField(CC, m_pItemType->GetDataField(sName)); else return CC.CreateNil(); }
ICCItem *CArmorClass::GetItemProperty (CItemCtx &Ctx, const CString &sName) // GetItemProperty // // Returns armor property { CCodeChain &CC = g_pUniverse->GetCC(); if (strEquals(sName, PROPERTY_BLINDING_IMMUNE)) return CC.CreateBool(IsBlindingDamageImmune(Ctx)); else if (strEquals(sName, PROPERTY_COMPLETE_HP)) return CC.CreateInteger(GetMaxHP(Ctx, true)); else if (strEquals(sName, PROPERTY_DEVICE_DAMAGE_IMMUNE)) return CC.CreateBool(IsDeviceDamageImmune(Ctx)); else if (strEquals(sName, PROPERTY_DEVICE_DISRUPT_IMMUNE)) return CC.CreateBool(IsDeviceDamageImmune(Ctx)); else if (strEquals(sName, PROPERTY_DISINTEGRATION_IMMUNE)) return CC.CreateBool(IsDisintegrationImmune(Ctx)); else if (strEquals(sName, PROPERTY_EMP_IMMUNE)) return CC.CreateBool(IsEMPDamageImmune(Ctx)); else if (strEquals(sName, PROPERTY_HP)) return CC.CreateInteger(GetMaxHP(Ctx)); else if (strEquals(sName, PROPERTY_RADIATION_IMMUNE)) return CC.CreateBool(IsRadiationImmune(Ctx)); else if (strEquals(sName, PROPERTY_SHATTER_IMMUNE)) return CC.CreateBool(IsShatterImmune(Ctx)); else if (m_pItemType) return CreateResultFromDataField(CC, m_pItemType->GetDataField(sName)); else return CC.CreateNil(); }