I tried making a medical item use animation using a fake weapon that plays the animation, then returns back to previosly selected weapon. Basicaly the same approach as used in NTMAI with the keycard use. The point is, it doesnt return to my previously selected weapon, but to the first weapon (weapon in slotNumber 01). Zscript is not really my strength here, so I really don't know if I'm doing something wrong here.
Here is code for the mentioned item:
Code: Select all
class hyposprej_heal : Health {
Default {
inventory.amount 25;
}
}
class hyposprej_item : CustomInventory {
Default {
//$Category "Health and Armor/WoS"
//$Title "Hyposprej"
-SOLID
+SHOOTABLE
+NODAMAGE
+NOBLOOD
+CANPASS
+INVENTORY.INVBAR
Tag "$T_HYPOSPREJ";
height 16;
radius 14;
//scale 0.65;
Inventory.MaxAmount 20;
Inventory.InterHubAmount 20;
Inventory.PickupMessage "$F_HYPOSPREJ";
Inventory.Icon "I_MED1";
//Inventory.useSound "sounds/med";
}
States {
Spawn:
MED1 V -1;
Stop;
Use:
TNT1 A 0 A_GiveInventory("dx_applyHyposprej", 1);
Stop;
}
}
class dx_applyHyposprej : weapon {
class<weapon> selectedWeapon;
Default {
+Inventory.Undroppable
}
States {
Select:
AMHS A 1 A_Raise(10);
Loop;
Ready:
AMHS A 1 A_WeaponReady;
Fire:
ApplyMed:
AMHS BCDEFGH 2;
AMHS I 2 A_Playsound("sounds/med");
AMHS J 2 A_GiveInventory("hyposprej_heal", 1); //do stuff
Deselect:
AMHS K 1 A_Lower(9);
AMHS K 0 A_SelectPrevWeapon();
Stop;
}
action void A_SelectPrevWeapon() {
let owner = binderPlayer(invoker.owner);
owner.takeInventory("dx_applyHyposprej", 1);
A_SelectWeapon(invoker.selectedWeapon, SWF_SELECTPRIORITY);
}
}