Code: Select all
<ItemType UNID="&vtWeaponizer;"
name= "(weaponizer)"
level= "1"
virtual= "true"
>
<MiscellaneousDevice/>
<Events>
<OnGlobalTypesInit>
(block Nil
;Sets theWeapon to the itemStruct
(itmEnumTypes "p -energyWeapon" theWeapon
(block (theType theXML)
;Converts the itemStruct to the UNID and then to the XML
(setq
theXML
(typGetXML
(setq
theType
(itmGetType
theWeapon
)
)
)
)
(if
(or ;For testing
(not
(or
(xmlGetSubElement (xmlGetSubElement theXML 'weapon) 'missiles)
(xmlGetAttrib theXML 'charges)
)
)
True) ;For testing
;The weapon must have infinite ammo
(block (halfValue halfMass)
;Halve the value of the item
(xmlSetAttrib theXML 'value (setq halfValue (cat (divide (int (xmlGetAttribute theXML 'value)) 2))))
;Halve the mass of the item
(xmlSetAttrib theXML 'mass (setq halfMass (cat (divide (int (xmlGetAttribute theXML 'mass)) 2))))
;Add charges to the item
(xmlSetAttrib theXML 'charges "500")
;Add value bonus to item
(xmlSetAttrib theXML 'valueBonusPerCharge (cat (divide halfValue 500)))
;Add mass bonus to item
(xmlSetAttrib theXML 'massBonusPerCharge (cat (divide halfMass 500)))
;Make the weapon use charges
(xmlSetAttrib (xmlGetSubElement theXML 'weapon) 'charges "true")
(typCreate (unvDynamicUNID (xmlSetAttrib theXML 'name (cat "limited " (xmlGetAttribute theXML 'name)))) theXML) ;theType
)
)
)
)
)
</OnGlobalTypesInit>
</Events>
</ItemType>