Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class OlympiaMag : Ammo { // This ammo will be used as the magazine
- default {
- // This is just for example; if you use an image here, the amount of this ammo will be visible in the HUD
- Inventory.Icon "SHOTA0";
- Inventory.Amount 1;
- Inventory.MaxAmount 2;
- Ammo.BackpackAmount 0;
- Ammo.BackpackMaxAmount 8;
- }
- }
- class Olympia : Weapon {
- default {
- Inventory.PickupMessage "Picked up a Rottweil Skeet Olympia";
- Weapon.AmmoType "OlympiaMag";
- Weapon.AmmoUse 1;
- // The weapon shouldn't refill the magazine when it's picked up, hence this is 0
- Weapon.AmmoGive 0;
- // This is the reserve ammo; in this case this is regular Doom Shell
- Weapon.AmmoType2 "Shell";
- Weapon.AmmoGive2 16;
- Inventory.Pickupsound "weapons/olympia/pickup";
- // See here: https://zdoom.org/wiki/Actor_properties#Obituaries
- Obituary "%o was blasted apart by %k's Olympia";
- // Without this flag the weapon will be automatically deselected when we run out of magazine ammo, so we need this
- +WEAPON.AMMO_OPTIONAL
- }
- states {
- Spawn:
- SHOT A -1;
- Stop;
- Ready:
- // Without this flag you won't be able to reload at all
- OLYM A 1 A_WeaponReady (WRF_ALLOWRELOAD);
- Loop;
- Select:
- OLYM A 1 A_Raise;
- Loop;
- Deselect:
- OLYM A 1 A_Lower;
- Loop;
- Fire:
- TNT1 A 0 A_JumpIfNoAmmo ("Reload"); // There's a special function that checks primary ammo and performs the jump
- OLYM B 1 A_FireBullets (1, 1, 10, 6, "BulletPuff", FBF_USEAMMO);
- OLYM B 1 Offset ( 4, 40); // It might be better to use https://zdoom.org/wiki/A_WeaponOffset, but this will work for now
- OLYM B 3 Offset (12, 48);
- OLYM B 1 Offset (10, 44);
- OLYM B 1 Offset ( 8, 40);
- OLYM B 1 Offset ( 6, 37);
- OLYM A 1 Offset ( 4, 35);
- OLYM A 1 Offset ( 2, 33);
- OLYM A 15;
- Goto Ready;
- // This is activated by the player pressing Reload button
- Reload:
- // This starts an anonymous function — a little block where several things can happen at once
- TNT1 A 0 {
- // Check if we already have full magazine (OlympiaMag == 2) OR (||) if we don't have any Shell (Shell < 1)
- if (CountInv ("OlympiaMag") == 2 || CountInv ("Shell") < 1)
- return ResolveState ("Ready"); // If ANY of the above is true — go back to Ready state and don't try to reload
- return ResolveState (null); // OTHERWISE continue
- }
- OLYM A 1 Offset (0, 35) A_PlaySound ("weapons/shotgr", 5); // You don't really need A_PlayWeaponSound, you can use a soundslot to make sure sounds don't overlap; here I use slot 5
- OLYM A 1 Offset (0, 38);
- OLYM A 1 Offset (0, 44);
- OLYM A 1 Offset (0, 52);
- OLYM A 1 Offset (0, 62);
- OLYM A 1 Offset (0, 72);
- OLYM A 1 Offset (0, 82);
- TNT1 A 8 { // Here we'll perform the actual reload
- while (CountInv ("OlympiaMag") < 2 && CountInv ("Shell") > 0) { // WHILE we have less than 2 ammo in our magazine AND we have more than 0 Shell...
- TakeInventory ("Shell", 1); // ... Take 1 ammo from reserves
- GiveInventory ("OlympiaMag", 1); // ... And give 1 ammo into magazine
- }
- }
- OLYM A 1 Offset (0, 82);
- OLYM A 1 Offset (0, 72);
- OLYM A 1 Offset (0, 62);
- OLYM A 1 Offset (0, 52);
- OLYM A 1 Offset (0, 44);
- OLYM A 1 Offset (0, 38);
- OLYM A 1 Offset (0, 35);
- OLYM A 1 Offset (0, 32);
- Goto Ready;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement