#  ![](https://www.realm667.com/media/kunena/topic_icons/realm667/user/help.png) Converting the Medical Backpack from ACS to ZScript

##

- **Salahmander**
- ![Salahmander's Avatar](https://www.realm667.com/media/kunena/avatars/resized/size144/users/avatar1650.png?1601326422) Topic Author
- Wicked
- ![Wicked](https://www.realm667.com/media/kunena/ranks/rank_81_wicked.png)

 Less More- Posts: 213
-
-
-
-

   8 months 2 weeks ago [\#12836](#12836) by Salahmander  *[Converting the Medical Backpack from ACS to ZScript](https://www.realm667.com/forum/the-workshop/2281-converting-the-medical-backpack-from-acs-to-zscript#12836 "Hiya, so looking to do the above in the title, but not sure how, anyone know how to go about it? Would be terrific for it to be all ZScript.")* was created by *Salahmander*

 Hiya, so looking to do the above in the title, but not sure how, anyone know how to go about it? Would be terrific for it to be all ZScript.

Please [Log in](https://www.realm667.com/component/users/login?return=aHR0cHM6Ly93d3cucmVhbG02NjcuY29tL2ZvcnVtL3RoZS13b3Jrc2hvcC8yMjgxLWNvbnZlcnRpbmctdGhlLW1lZGljYWwtYmFja3BhY2stZnJvbS1hY3MtdG8tenNjcmlwdA==&Itemid=2662) or [Create an account](https://www.realm667.com/component/users/registration?Itemid=2662) to join the conversation.

- **DeVloek**
- ![DeVloek's Avatar](https://www.realm667.com/media/kunena/avatars/resized/size144/users/avatar11145.png?1542216928)
- Arachnotron
- ![Arachnotron](https://www.realm667.com/media/kunena/ranks/rank_10_arachno.png)

 Less More- Posts: 416
-
-

   8 months 2 weeks ago - 8 months 2 weeks ago [\#12837](#12837) by DeVloek  Replied by *DeVloek* on topic *[Converting the Medical Backpack from ACS to ZScript](https://www.realm667.com/forum/the-workshop/2281-converting-the-medical-backpack-from-acs-to-zscript#12837 "Hiya, so looking to do the above in the title, but not sure how, anyone know how to go about it? Would be terrific for it to be all ZScript.")*

 Here's a zscript version of the item that uses GetMaxHealth() instead of the ACS script.

Code:

class HealthBackpack : Inventory { Default { +INVENTORY.INVBAR; +INVENTORY.ISHEALTH; +INVENTORY.TRANSFER; Inventory.Amount 100; Inventory.MaxAmount 100; Inventory.InterHubAmount 100; Inventory.PickupMessage "You got a Health Backpack."; Tag "Health Pack"; Inventory.Icon "I_MBPK"; } States { Spawn: MBPK A -1; Stop; } override bool Use(bool pickup) { if (owner &amp;&amp; owner.player) { int maxhp = owner.GetMaxHealth(); int curhp = owner.health; int diff = maxhp - curhp; if (diff &gt; 0) { S_StartSound("FKITUSE",CHAN_ITEM); owner.GiveBody(min(diff,owner.countinv("HealthBackpack")),maxhp); owner.TakeInventory("HealthBackpack",diff); } } return false; } override void OnDrop(Actor dropper) { if (dropper &amp;&amp; dropper.player) { int amount = dropper.countinv("HealthBackpack"); dropper.TakeInventory("HealthBackpack",amount); SetInventory("HealthBackpack",amount); } } }

The original item had a bug, dropping the item dropped a backpack with 1 use in it, so you could drop 100 backpacks with 1 hp each.
To fix this I added the TRANSFER flag and the OnDrop override, this retains the amount of uses when dropping the item and picking it back up.
The ISHEALTH flag is just to signal the game that the item shouldn't spawn when health items are turned off on a server.
I also noticed another mildly irritating thing. When the item has only 1 use left, the amount number is not displayed anymore. No idea how to fix this.

btw isn't it a bit irritating that the item is called Medical Backpack in the repo, but Health Backpack in the code and in the game? I think Medical Backpack sounds better, maybe we should rename it to that everywhere.

 Last edit: 8 months 2 weeks ago by DeVloek.

Please [Log in](https://www.realm667.com/component/users/login?return=aHR0cHM6Ly93d3cucmVhbG02NjcuY29tL2ZvcnVtL3RoZS13b3Jrc2hvcC8yMjgxLWNvbnZlcnRpbmctdGhlLW1lZGljYWwtYmFja3BhY2stZnJvbS1hY3MtdG8tenNjcmlwdA==&Itemid=2662) or [Create an account](https://www.realm667.com/component/users/registration?Itemid=2662) to join the conversation.

- **Salahmander**
- ![Salahmander's Avatar](https://www.realm667.com/media/kunena/avatars/resized/size144/users/avatar1650.png?1601326422) Topic Author
- Wicked
- ![Wicked](https://www.realm667.com/media/kunena/ranks/rank_81_wicked.png)

 Less More- Posts: 213
-
-
-
-

   8 months 2 weeks ago [\#12838](#12838) by Salahmander  Replied by *Salahmander* on topic *[Converting the Medical Backpack from ACS to ZScript](https://www.realm667.com/forum/the-workshop/2281-converting-the-medical-backpack-from-acs-to-zscript#12838 "Hiya, so looking to do the above in the title, but not sure how, anyone know how to go about it? Would be terrific for it to be all ZScript.")*

 Ahhh you're a gem! Cheers matey, the medical backpack has been given it's repo name throughout now.

Please [Log in](https://www.realm667.com/component/users/login?return=aHR0cHM6Ly93d3cucmVhbG02NjcuY29tL2ZvcnVtL3RoZS13b3Jrc2hvcC8yMjgxLWNvbnZlcnRpbmctdGhlLW1lZGljYWwtYmFja3BhY2stZnJvbS1hY3MtdG8tenNjcmlwdA==&Itemid=2662) or [Create an account](https://www.realm667.com/component/users/registration?Itemid=2662) to join the conversation.

- **DeVloek**
- ![DeVloek's Avatar](https://www.realm667.com/media/kunena/avatars/resized/size144/users/avatar11145.png?1542216928)
- Arachnotron
- ![Arachnotron](https://www.realm667.com/media/kunena/ranks/rank_10_arachno.png)

 Less More- Posts: 416
-
-

   8 months 1 week ago [\#12842](#12842) by DeVloek  Replied by *DeVloek* on topic *[Converting the Medical Backpack from ACS to ZScript](https://www.realm667.com/forum/the-workshop/2281-converting-the-medical-backpack-from-acs-to-zscript#12842 "Hiya, so looking to do the above in the title, but not sure how, anyone know how to go about it? Would be terrific for it to be all ZScript.")*

 No worries, happy to help ![:-)](https://www.realm667.com/media/kunena/emoticons/cacsmi.gif ":-)")

Regarding the "bug" I described, I just looked the holodoomguy item and it has the same issue, only 1 unit out of 60 is dropped. But 60 is the seconds remaining so I need to fix this as well.

Are you aware of other items in the repo that have a large quantity of units, that should drop only 1 item with all units in it?

Please [Log in](https://www.realm667.com/component/users/login?return=aHR0cHM6Ly93d3cucmVhbG02NjcuY29tL2ZvcnVtL3RoZS13b3Jrc2hvcC8yMjgxLWNvbnZlcnRpbmctdGhlLW1lZGljYWwtYmFja3BhY2stZnJvbS1hY3MtdG8tenNjcmlwdA==&Itemid=2662) or [Create an account](https://www.realm667.com/component/users/registration?Itemid=2662) to join the conversation.

[Powered by](https://www.realm667.com/forum/credits) [Kunena Forum](https://www.kunena.org)
