1//************************************************************************** 2//** 3//** ## ## ## ## ## #### #### ### ### 4//** ## ## ## ## ## ## ## ## ## ## #### #### 5//** ## ## ## ## ## ## ## ## ## ## ## ## ## ## 6//** ## ## ######## ## ## ## ## ## ## ## ### ## 7//** ### ## ## ### ## ## ## ## ## ## 8//** # ## ## # #### #### ## ## 9//** 10//** $Id: Coin.vc 3205 2008-03-01 11:18:11Z dj_jl $ 11//** 12//** Copyright (C) 1999-2006 Jānis Legzdiņš 13//** 14//** This program is free software; you can redistribute it and/or 15//** modify it under the terms of the GNU General Public License 16//** as published by the Free Software Foundation; either version 2 17//** of the License, or (at your option) any later version. 18//** 19//** This program is distributed in the hope that it will be useful, 20//** but WITHOUT ANY WARRANTY; without even the implied warranty of 21//** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22//** GNU General Public License for more details. 23//** 24//************************************************************************** 25 26class Coin : Inventory 27 game(GAME_Strife) 28 __mobjinfo__(93); 29 30//========================================================================== 31// 32// HandlePickup 33// 34//========================================================================== 35 36bool HandlePickup(Inventory Item) 37{ 38 if (Coin(Item)) 39 { 40 if (Amount < MaxAmount) 41 { 42 Amount += Item.Amount; 43 if (Amount > MaxAmount) 44 { 45 Amount = MaxAmount; 46 } 47 Item.bPickupGood = true; 48 } 49 return true; 50 } 51 52 if (Inventory) 53 { 54 return Inventory.HandlePickup(Item); 55 } 56 return false; 57} 58 59//========================================================================== 60// 61// CreateCopy 62// 63//========================================================================== 64 65Inventory CreateCopy(EntityEx Toucher) 66{ 67 if (Class == Coin) 68 { 69 return ::CreateCopy(Toucher); 70 } 71 else 72 { 73 Inventory Copy = Spawn(Coin,,,, false); 74 Copy.Amount = Amount; 75 GoAwayAndDie(); 76 return Copy; 77 } 78} 79 80//========================================================================== 81// 82// CreateTossable 83// 84//========================================================================== 85 86Inventory CreateTossable() 87{ 88 Inventory Copy; 89 90 if (bUndroppable || !Owner || Amount <= 0) 91 { 92 return none; 93 } 94 // Gold is dropped with maximal throwable amount. 95 if (Amount >= 50) 96 { 97 Copy = Spawn(Gold50,,,, false); 98 Amount -= 50; 99 } 100 else if (Amount >= 25) 101 { 102 Copy = Spawn(Gold25,,,, false); 103 Amount -= 25; 104 } 105 else if (Amount >= 10) 106 { 107 Copy = Spawn(Gold10,,,, false); 108 Amount -= 10; 109 } 110 else if (Amount > 1 || bKeepDepleted) 111 { 112 Copy = Spawn(Coin,,,, false); 113 Amount -= 1; 114 } 115 else 116 { 117 Copy = self; 118 BecomePickup(); 119 } 120 Copy.DropTime = 1.0; 121 Copy.bSpecial = false; 122 Copy.bSolid = false; 123 if (Copy != self && Amount <= 0 && !bKeepDepleted) 124 { 125 Destroy(); 126 } 127 return Copy; 128} 129 130states 131{ 132Spawn: 133 COIN A -1 134 Stop 135} 136 137defaultproperties 138{ 139 ConversationID = 168; 140 PickupMessage = "$txt_coin"; 141 MaxAmount = 0x7fffffff; 142 IconName = 'i_coin'; 143 bDropped = true; 144 bNoDeathmatch = true; 145 bFloorClip = true; 146 bInvBar = true; 147} 148