Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class GreenArmorPickup : GreenArmor {} //copied class so we can still use GreenArmor under another name
- class ArmorWrapper : CustomInventory
- {
- action bool DoPickup(int amount, double percent, string pickup)
- {
- //store some relevant references
- let p = players[consoleplayer].mo; //playerpawn actor
- let armor = BasicArmor(p.FindInventory("BasicArmor")); //player's armor
- /*
- If you want to add global cases where armor should always be picked up, here is the spot
- for example, you could check to see if the player's HP is below a certain value, then
- return true if it is.
- */
- // Copied from ZS source, accounts for null case. Shouldn't ever be tripped but whatever
- if (armor == null)
- {
- armor = BasicArmor(Spawn("BasicArmor"));
- armor.BecomeItem();
- armor.Amount = 0;
- armor.MaxAmount = 0;
- p.AddInventory(armor);
- }
- /*
- This measures the current amount of damage the player can absorb with his armor at a given health
- it assumes no healing takes place, so there are cases where it may block a green->green or blue->blue
- on the grounds that the current armor protects the player adequately at their current health
- */
- double currentSaveAmount = min(armor.Amount, p.player.health)*armor.SavePercent;
- double newSaveAmount = min(amount, p.player.health) * percent;//0.333350;
- if(newSaveAmount > currentSaveAmount)
- {
- p.A_GiveInventory(pickup);
- return true;
- }
- return false;
- }
- }
- class GreenArmorWrapper : ArmorWrapper Replaces GreenArmor
- {
- default
- {
- /*
- Make sure you fill in these variables so the size is right and the messages appear
- */
- Radius 20;
- Height 16;
- Inventory.PickupMessage "$GOTARMOR";
- }
- States
- {
- //Looping state for while we're on the ground
- Spawn:
- ARM1 A 6;
- ARM1 B 7 Bright;
- Loop;
- //Pickup state, obviously
- Pickup:
- TNT1 A 0
- {
- //Boolean check to see if we should pick up the armor based on its attributes
- if(DoPickup(100, 0.333350, "GreenArmorPickup"))
- {
- return ResolveState(null);
- }
- return ResolveState("Spawn");
- }
- //This frame needs to be here for some reason as listed on the wiki.
- TNT1 A 0 A_RailWait(); //does nothing
- Stop;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement