#include "zcommon.acs"
#library "wcolors"

#DEFINE MEGABUSTER 0
#DEFINE BUBBLELEAD 1
#DEFINE LEAFSHIELD 2
#DEFINE ATOMICFIRE 3
#DEFINE SHADOWBLADE 4
#DEFINE NAPALMBOMB 5
#DEFINE AIRSHOOTER 6
#DEFINE HYPERBOMB 7
#DEFINE MAGNETMISSILE 8
#DEFINE TOPSPIN 9
#DEFINE NEEDLECANNON 10
#DEFINE GEMINILASER 11
#DEFINE SEARCHSNAKE 12
#DEFINE TIMESTOPPER 13
#DEFINE SUPERARM 14
#DEFINE ICESLASHER 15
#DEFINE THUNDERBEAM 16
#DEFINE METALBLADE 17
#DEFINE HARDKNUCKLE 18
#DEFINE DRILLBOMB 19
#DEFINE BLIZZARDATTACK 20
#DEFINE FIRESTORM 21
#DEFINE QUICKBOOMERANG 22
#DEFINE CRASHBOMB 23
#DEFINE CHARGEKICK 24
#DEFINE ROLLINGCUTTER 25
#DEFINE SPARKSHOCK 26
#DEFINE RINGBOOMERANG 27
#DEFINE GYROATTACK 28
#DEFINE POWERSTONE 29
#DEFINE DUSTCRUSHER 30
#DEFINE PHARAOHSHOT 31
#DEFINE WATERWAVE 32
#DEFINE CRYSTALEYE 33
#DEFINE SKULLBARRIER 34
#DEFINE FLAMEBLAST 35
#DEFINE PROTOBUSTER 36
#DEFINE YAMATOSPEAR 37
#DEFINE DIVEMISSILE 38
#DEFINE PLANTBARRIER 39
#DEFINE SILVERTOMAHAWK 40
#DEFINE WINDSTORM 41
#DEFINE KNIGHTCRUSH 42
#DEFINE STARCRASH 43
#DEFINE RAINFLUSH 44
#DEFINE SAKUGARNE 45
#DEFINE BASSBUSTER 46
#DEFINE BALLADECRACKER 47
#DEFINE SCREWCRUSHER 48
#DEFINE FLASHSTOPPER 49
#DEFINE GRAVITYHOLD 50
#DEFINE CENTAURFLASH 51
#DEFINE MIRRORBUSTER 52

#DEFINE BALLADEREAL 53

#DEFINE ATOMICFIRECRG1 60
#DEFINE ATOMICFIRECRG2 61
#DEFINE ATOMICFIRECRG3 62

#DEFINE PROTOCHARGE1 63
#DEFINE PROTOCHARGE2 64

#DEFINE ENKERCHARGE1 65
#DEFINE ENKERCHARGE2 66

#DEFINE METALMANREAL 67

#DEFINE BOSSPAIN 68


#DEFINE FREEZECRACKER 54
#DEFINE NOISECRUSH 55
#DEFINE THUNDERBOLT 56
#DEFINE JUNKSHIELD 57
#DEFINE WILDCOIL 58
#DEFINE SCORCHWHEEL 59
#DEFINE SLASHCLAW 69
#DEFINE DANGERWRAP 70

#DEFINE NOISECRUSHCRG1 71
#DEFINE NOISECRUSHCRG2 72
#DEFINE NOISECRUSHCRG3 73

#DEFINE WILDCOILCRG1 74
#DEFINE WILDCOILCRG2 75
#DEFINE WILDCOILCRG3 76

#DEFINE SUPERADAPTOR 77
#DEFINE SUPERADAPTORCRG1 78
#DEFINE SUPERADAPTORCRG2 79
#DEFINE SUPERADAPTORCRG3 80

#DEFINE CUTMAN 109
#DEFINE OILSLIDER 119
#DEFINE TIMESLOW 120
#DEFINE TIMECHARGE1 121
#DEFINE TIMECHARGE2 122
#DEFINE TIMECHARGE3 123
#DEFINE SHADOWMAN 124

#DEFINE CRYSTALCLASS 223
#DEFINE RUSHCHARGE1 300
#DEFINE RUSHCHARGE2 301
#DEFINE RUSHCHARGE3 302
#DEFINE AIRMAN 102
#DEFINE ALIEN 104
#DEFINE BUBBLEMAN 105
#DEFINE FLASHMAN 106
#DEFINE YAMATOREAL 212
#DEFINE PLANTMANREAL 303
#DEFINE POWERCHARGEAA 304
#DEFINE POWERCHARGEAB 305
#DEFINE POWERCHARGEBA 306
#DEFINE POWERCHARGEBB 307
#DEFINE HARDMANREAL 502
#DEFINE WAVENAPREAL 503
#DEFINE HEATREAL 504

#DEFINE RINGMANREAL 240
#DEFINE BRIGHTMANREAL 241
#DEFINE PHARAOHMANREAL 242
#DEFINE TOADMANREAL 246
#DEFINE CLOUDMAN 247
#DEFINE SHADEMAN 248
#DEFINE SHADECHRG1 249
#DEFINE SHADECHRG2 250
#DEFINE TREBLEBOOST 251
#DEFINE SLASHMAN 252
#DEFINE SPRINGMAN 253
#DEFINE DARKMAN1 261
#DEFINE DARKMAN3 262
#DEFINE ICEMAN 263

script 998 (int weap, int nosound)
{
if(nosound==0){LocalAmbientSound("menu/cursor",127);}
if(GetCvar("teamplay")==1){
if(PlayerTeam()==1){
Thing_SetTranslation(0, 48);}
terminate;}
if(GetCvar("teamlms")==1){
if(PlayerTeam()==1){
Thing_SetTranslation(0, 48);}
terminate;}
if(GetCvar("teampossession")==1){
if(PlayerTeam()==1){
Thing_SetTranslation(0, 48);}
terminate;}
if(GetCvar("ctf")==1){
if(PlayerTeam()==1){
Thing_SetTranslation(0, 48);}
terminate;}
if(GetCvar("oneflagctf")==1){
if(PlayerTeam()==1){
Thing_SetTranslation(0, 48);}
terminate;
}

if (CheckInventory("DocBusterC")) {
	Thing_SetTranslation(0, 67);
	//ACS_ExecuteAlways(648,0,9);
} else if (CheckInventory("BearerFlag")) {
	Thing_SetTranslation(0, 24);
} else {
	Thing_SetTranslation(0, weap);
}

}

Script 993 OPEN
{
CreateTranslation (BUBBLELEAD, 192:192=4:4, 198:198=96:96);
CreateTranslation (LEAFSHIELD, 192:192=4:4, 198:198=114:114);
CreateTranslation (ATOMICFIRE, 192:192=217:217, 198:198=176:176);
CreateTranslation (ATOMICFIRECRG1, 192:192=217:217, 198:198=176:176, 0:2=196:196, 3:8=196:196, 243:247=196:196);
CreateTranslation (ATOMICFIRECRG2, 192:192=217:217, 198:198=194:194, 0:2=217:217, 3:8=217:217, 243:247=217:217);
CreateTranslation (ATOMICFIRECRG3, 192:192=217:217, 198:198=4:4, 0:2=4:4, 3:8=4:4, 243:247=4:4);
CreateTranslation (SHADOWBLADE, 192:192=250:250, 198:198=252:252);
CreateTranslation (NAPALMBOMB, 192:192=217:217, 198:198=201:201);
CreateTranslation (AIRSHOOTER, 192:192=4:4);
CreateTranslation (HYPERBOMB, 192:192=4:4, 198:198=112:112);
CreateTranslation (MAGNETMISSILE, 192:192=96:96, 198:198=176:176);
CreateTranslation (TOPSPIN, 192:192=210:210, 198:198=96:96);
CreateTranslation (NEEDLECANNON, 192:192=4:4, 198:198=218:218);
CreateTranslation (GEMINILASER, 192:192=4:4);
CreateTranslation (SEARCHSNAKE, 192:192=4:4, 198:198=114:114);
CreateTranslation (TIMESTOPPER, 192:192=250:250, 198:198=252:252);
CreateTranslation (SUPERARM, 192:192=4:4, 198:198=218:218);
CreateTranslation (ICESLASHER, 192:192=4:4);
CreateTranslation (THUNDERBEAM, 192:192=249:249, 198:198=96:96);
CreateTranslation (METALBLADE, 192:192=210:210, 198:198=164:164);
CreateTranslation (HARDKNUCKLE, 192:192=88:88, 198:198=200:200);
CreateTranslation (DRILLBOMB, 192:192=96:96, 198:198=176:176);
CreateTranslation (BLIZZARDATTACK, 192:192=4:4);
CreateTranslation (FIRESTORM, 192:192=217:217, 198:198=176:176);
CreateTranslation (QUICKBOOMERANG, 192:192=170:170, 198:198=173:173);
CreateTranslation (CRASHBOMB, 192:192=4:4, 198:198=172:172);
CreateTranslation (CHARGEKICK, 192:192=4:4, 198:198=172:172);
CreateTranslation (ROLLINGCUTTER, 192:192=4:4, 198:198=96:96);
CreateTranslation (SPARKSHOCK, 192:192=4:4, 198:198=172:172);
CreateTranslation (RINGBOOMERANG, 192:192=210:210, 198:198=164:164);
CreateTranslation (GYROATTACK, 192:192=4:4, 198:198=114:114);
CreateTranslation (POWERSTONE, 192:192=4:4, 198:198=167:167);
CreateTranslation (DUSTCRUSHER, 192:192=4:4, 198:198=96:96);
CreateTranslation (PHARAOHSHOT, 192:192=52:52, 198:198=172:172);
CreateTranslation (WATERWAVE, 192:192=4:4);
CreateTranslation (CRYSTALEYE, 192:192=4:4, 198:198=192:192);
CreateTranslation (SKULLBARRIER, 198:198=193:193);
CreateTranslation (FLAMEBLAST, 192:192=52:52, 198:198=172:172);
CreateTranslation (PROTOBUSTER, 192:192=87:87, 198:198=178:178);
CreateTranslation (PROTOCHARGE1, 192:192=87:87, 198:198=178:178, 0:2=253:253, 3:8=253:253, 243:247=253:253);
CreateTranslation (PROTOCHARGE2, 192:192=160:160, 198:198=148:148, 0:2=166:166, 3:8=204:166, 243:247=166:166);
CreateTranslation (YAMATOSPEAR, 192:192=4:4, 198:198=250:250);
CreateTranslation (DIVEMISSILE, 192:192=4:4);
CreateTranslation (PLANTBARRIER, 192:192=4:4, 198:198=173:173);
CreateTranslation (SILVERTOMAHAWK, 192:192=52:52, 198:198=218:218);
CreateTranslation (WINDSTORM, 192:192=4:4, 198:198=96:96);
CreateTranslation (KNIGHTCRUSH, 192:192=88:88, 198:198=200:200);
CreateTranslation (STARCRASH, 192:192=249:249, 198:198=218:218);
CreateTranslation (RAINFLUSH, 192:192=4:4, 198:198=112:112);
CreateTranslation (SAKUGARNE, 192:192=228:228, 198:198=121:121);
CreateTranslation (BASSBUSTER, 192:192=214:214, 198:198=99:99);
CreateTranslation (BALLADECRACKER, 192:192=250:250, 198:198=254:254);
CreateTranslation (SCREWCRUSHER, 192:192=16:16, 198:198=178:178);
CreateTranslation (FLASHSTOPPER, 192:192=4:4, 198:198=252:252);
CreateTranslation (GRAVITYHOLD, 192:192=4:4, 198:198=252:252);
CreateTranslation (CENTAURFLASH, 192:192=4:4, 198:198=114:114);
CreateTranslation (MIRRORBUSTER, 192:192=161:161, 198:198=199:199);
CreateTranslation (ENKERCHARGE1, 192:192=161:161, 198:198=199:199, 0:2=4:4, 3:8=4:4, 243:247=4:4);
CreateTranslation (ENKERCHARGE2, 192:192=161:161, 198:198=199:199, 0:2=196:204, 3:8=196:204, 243:247=204:204);
CreateTranslation (BALLADEREAL, 192:192=231:231, 198:198=254:254);
CreateTranslation (METALMANREAL, 192:192=231:231, 198:198=176:176);
CreateTranslation (FREEZECRACKER, 192:192=4:4);
CreateTranslation (NOISECRUSH, 192:192=197:197, 198:198=254:254);
CreateTranslation (NOISECRUSHCRG1, 192:192=197:197, 198:198=254:254, 0:2=112:112, 3:8=112:112, 243:247=112:112);
CreateTranslation (NOISECRUSHCRG2, 192:192=0:0, 198:198=197:197, 0:2=254:254, 3:8=254:254, 243:247=254:254);
CreateTranslation (NOISECRUSHCRG3, 192:192=254:254, 198:198=0:0, 0:2=197:197, 3:8=197:197, 243:247=197:197);
CreateTranslation (WILDCOIL, 192:192=112:112, 198:198=216:216);
CreateTranslation (WILDCOILCRG1, 192:192=112:112, 198:198=216:216, 0:2=172:172, 3:8=172:172, 243:247=172:172);
CreateTranslation (WILDCOILCRG2, 192:192=0:0, 198:198=112:112, 0:2=216:216, 3:8=216:216, 243:247=216:216);
CreateTranslation (WILDCOILCRG3, 192:192=216:216, 198:198=0:0, 0:2=112:112, 3:8=112:112, 243:247=112:112);
CreateTranslation (DANGERWRAP, 192:192=4:4, 198:198=64:64);
CreateTranslation (SCORCHWHEEL, 192:192=161:161, 198:198=220:220);
CreateTranslation (JUNKSHIELD, 192:192=196:196, 198:198=98:98);
CreateTranslation (SLASHCLAW, 192:192=162:162, 198:198=118:118);
CreateTranslation (THUNDERBOLT, 192:192=162:162, 198:198=199:199);
CreateTranslation (BOSSPAIN, 5:247=4:4,0:3=4:4);
CreateTranslation (SUPERADAPTOR, 192:192=4:4, 198:198=176:176);
CreateTranslation (SUPERADAPTORCRG1, 192:192=4:4, 198:198=176:176, 0:2=22:22, 3:8=22:22, 243:247=22:22);
CreateTranslation (SUPERADAPTORCRG2, 192:192=0:0, 198:198=176:176, 0:2=4:4, 3:8=4:4, 243:247=4:4);
CreateTranslation (SUPERADAPTORCRG3, 192:192=4:4, 198:198=0:0, 0:2=176:176, 3:8=176:176, 243:247=176:176);
CreateTranslation (CRYSTALCLASS, 198:198=122:122);
CreateTranslation (CUTMAN, 192:192=4:4, 198:198=175:175);
CreateTranslation (SHADOWMAN, 192:192=225:225, 198:198=200:200);
CreateTranslation (RUSHCHARGE1, 0:2=251:251, 3:8=251:251, 243:247=251:251);
CreateTranslation (RUSHCHARGE2, 192:192=0:0, 198:198=192:192, 0:2=198:198, 3:8=198:198, 243:247=198:198);
CreateTranslation (RUSHCHARGE3, 192:192=198:198, 198:198=0:0, 0:2=192:192, 3:8=192:192, 243:247=192:192);
CreateTranslation (AIRMAN, 192:192=231:231, 198:198=200:200);
CreateTranslation (ALIEN, 192:192=114:114, 198:198=121:121);
CreateTranslation (BUBBLEMAN, 192:192=4:4, 198:198=121:121);
CreateTranslation (FLASHMAN, 192:192=4:4, 198:198=200:200);
CreateTranslation (PLANTMANREAL, 192:192=112:112, 198:198=201:201);
CreateTranslation (POWERCHARGEAA, 192:192=4:4, 198:198=176:176, 0:2=184:184, 3:8=184:184, 243:247=184:184);
CreateTranslation (POWERCHARGEAB, 192:192=4:4, 198:198=175:175, 0:2=175:175, 3:8=175:175, 243:247=175:175);
CreateTranslation (POWERCHARGEBA, 192:192=176:176, 198:198=0:0, 0:2=4:4, 3:8=4:4, 243:247=4:4);
CreateTranslation (POWERCHARGEBB, 192:192=0:0, 198:198=4:4, 0:2=176:176, 3:8=176:176, 243:247=176:176);
CreateTranslation (HARDMANREAL, 192:192=88:88, 198:198=195:195);
CreateTranslation (WAVENAPREAL, 192:192=213:213);
CreateTranslation (YAMATOREAL, 192:192=213:213, 198:198=254:254);
CreateTranslation (HEATREAL, 192:192=214:214, 198:198=175:175);
CreateTranslation (RINGMANREAL, 192:192=249:249, 198:198=178:178);
CreateTranslation (BRIGHTMANREAL, 192:192=209:209, 198:198=217:217);
CreateTranslation (PHARAOHMANREAL, 192:192=198:198, 198:198=215:215, 4:4=209:209);
CreateTranslation (TOADMANREAL, 192:192=52:52, 198:198=112:112);
CreateTranslation (CLOUDMAN, 192:192=4:4, 198:198=218:218);
CreateTranslation (OILSLIDER, 192:192=95:95, 198:198=105:105);
CreateTranslation (TIMESLOW, 192:192=250:250, 198:198=252:252);
CreateTranslation (TIMECHARGE1, 192:192=250:250, 198:198=252:252, 0:2=253:253, 3:8=253:253, 243:247=253:253);
CreateTranslation (TIMECHARGE2, 192:192=5:5, 198:198=250:250, 0:2=251:251, 243:247=251:251);
CreateTranslation (TIMECHARGE3, 192:192=251:251, 198:198=5:5, 0:2=250:250, 243:247=250:250);
CreateTranslation (SHADEMAN, 192:192=4:4, 198:198=254:254);
CreateTranslation (SHADECHRG1, 192:192=4:4, 198:198=4:4);
CreateTranslation (SHADECHRG2, 192:192=254:254, 198:198=254:254);
CreateTranslation (SLASHMAN, 192:192=4:4, 198:198=118:118);
CreateTranslation (TREBLEBOOST, 192:192=253:253, 198:198=99:99);
CreateTranslation (SPRINGMAN, 192:192=4:4, 198:198=173:173);
CreateTranslation (DARKMAN1, 192:192=4:4, 198:198=120:120);
CreateTranslation (DARKMAN3, 192:192=250:250, 198:198=254:254);
CreateTranslation (ICEMAN, 192:192=4:4, 198:198=197:197);
}

//Energy balancer

#define ARRAY_MAX 63

int lowest = 0;

int current_ammo[63];
int haveWepC[63];

str ammo_types[63] = {
"BubbleAmmo",
"ShadowAmmo",
"NapalmAmmo",
"AtomicAmmo", // +2
"LeafAmmo",
"AirAmmo",
"BombAmmo", // +2
"MagnetAmmo",
"TopAmmo",
"NeedleAmmo",
"GeminiAmmo",
"SnakeAmmo",
//"TimeAmmo",
"SuperArmAmmo",
"IceAmmo",
"ThunderBeamAmmo",
"MetalBladeAmmo",
"HardKnuckleAmmo",
"DrillBombAmmo",
"BlizzardAttackAmmo",
"FireStormAmmo",
"QuickBoomerangAmmo", // +4
"CrashBombAmmo", // +4
"ChargeKickAmmo",
"RollingCutterAmmo",
"SparkShockAmmo",
"RingBoomerangAmmo",
"GyroAttackAmmo",
"PowerStoneAmmo",
"DustCrusherAmmo",
"PharaohShotAmmo",
"WaterWaveAmmo",
"CrystalEyeAmmo",
"SkullBarrierAmmo",
"FlameBlastAmmo",
"YamatoSpearAmmo",
"DiveMissileAmmo",
"PlantBarrierAmmo",
"SilverTomahawkAmmo",
"WindStormAmmo",
"KnightCrushAmmo",
"StarCrashAmmo",
"RainFlushAmmo",
"SakugarneAmmo",
"BalladeCrackerAmmo",
"ScrewCrusherAmmo",
"FlashStopperAmmo",
"GravityHoldAmmo",
"CentaurFlashAmmo",
"MirrorBusterAmmo",
"FreezeCrackerAmmo",
"DangerWrapAmmo",
"JunkShieldAmmo",
"NoiseCrushAmmo",
"ScorchWheelAmmo",
"ThunderBoltAmmo",
"WildCoilAmmo",
"SlashClawAmmo",
"SlowAmmo",
"OilAmmo",
"FlashBulbAmmo",
"SkullSniperAmmo", //+4
"GravitySphereAmmo",
"CentaurArrowAmmo"
};

str weapon_types[63] = {
"BubbleLeadWepC",
"ShadowBladeWepC",
"NapalmBombWepC",
"AtomicFireWepC", // +2
"LeafShieldWepC",
"AirShooterWepC",
"HyperBombWepC", // +2
"MagnetMissileWepC",
"TopSpinWepC",
"NeedleCannonWepC",
"GeminiLaserWepC",
"SearchSnakeWepC",
//"TimeStopperWepC",
"SuperArmWepC",
"IceSlasherWepC",
"ThunderBeamWepC",
"MetalBladeWepC",
"HardKnuckleWepC",
"DrillBombWepC",
"BlizzardAttackWepC",
"FireStormWepC",
"QuickBoomerangWepC", // +4
"CrashBombWepC", // +4
"ChargeKickWepC",
"RollingCutterWepC",
"SparkShockWepC",
"RingBoomerangWepC",
"GyroAttackWepC",
"PowerStoneWepC",
"DustCrusherWepC",
"PharaohShotWepC",
"WaterWaveWepC",
"CrystalEyeWepC",
"SkullBarrierWepC",
"FlameBlastWepC",
"YamatoSpearWepC",
"DiveMissileWepC",
"PlantBarrierWepC",
"SilverTomahawkWepC",
"WindStormWepC",
"KnightCrushWepC",
"StarCrashWepC",
"RainFlushWepC",
"SakugarneWepC",
"BalladeCrackerWepC",
"ScrewCrusherWepC",
"FlashStopperWepC",
"GravityHoldWepC",
"CentaurFlashWepC",
"MirrorBusterWepC",
"FreezeCrackerWepC",
"DangerWrapWepC",
"JunkShieldWepC",
"NoiseCrushWepC",
"ScorchWheelWepC",
"ThunderBoltWepC",
"WildCoilWepC",
"SlashClawWepC",
"TimeSlowWepC",
"OilSliderWepC",
"FlashBulbWepC",
"SkullSniperWepC", //+4
"GravitySphereWepC",
"CentaurArrowWepC"
};

int ammo_maxes[63] = {
28, //BubbleLeadWepC
28, //ShadowBladeWepC
28, //NapalmBombWepC
28, //AtomicFireWepC"
28, //LeafShieldWepC
28, //AirShooterWepC
28, //HyperBombWepC
28, //MagnetMissileWepC
28, //TopSpinWepC
28, //NeedleCannonWepC
28, //GeminiLaserWepC
56, //SearchSnakeWepC
//28, //TimeStopperWepC
28, //SuperArmWepC
28, //IceSlasherWepC
28, //ThunderBeamWepC
28, //MetalBladeWepC
28, //HardKnuckleWepC
28, //DrillBombWepC
28, //BlizzardAttackWepC
28, //FireStormWepC
112, //QuickBoomerangWepC
28, //CrashBombWepC
28, //ChargeKickWepC
28, //RollingCutterWepC
28, //SparkShockWepC
28, //RingBoomerangWepC
28, //GyroAttackWepC
28, //PowerStoneWepC
28, //DustCrusherWepC
28, //PharaohShotWepC
28, //WaterWaveWepC
28, //CrystalEyeWepC
28, //SkullBarrierWepC
28, //FlameBlastWepC
28, //YamatoSpearWepC
28, //DiveMissileWepC
28, //PlantBarrierWepC
28, //SilverTomahawkWepC
28, //WindStormWepC
28, //KnightCrushWepC
28, //StarCrashWepC
28, //RainFlushWepC
28, //SakugarneWepC
28, //BalladeCrackerWepC
112, //ScrewCrusherWepC
28, //FlashStopperWepC
28, //GravityHoldWepC
28, //CentaurFlashWepC
28, //MirrorBusterWepC
28, //FreezeCrackerWepC
28, //DangerWrapWepC
28, //JunkShieldWepC
28, //NoiseCrushWepC
28, //ScorchWheelWepC
28, //ThunderBoltWepC
28, //WildCoilWepC
28, //SlashClawWepC
48, //TimeSlowWepC
28, //OilSliderWepC
28, //FlashBulbWepC
28, //SkullSniperWepC
28, //GravitySphereWepC
28 //CentaurArrowWepC
};

int amount_modifier[63] = {
0,
0,
0,
2,
0,
0,
2,
0,
0,
0,
0,
0,
//0,
0,
0,
0,
0,
0,
0,
0,
0,
4,
4,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
4,
0,
0
};

int ratioammo[63];
int index;
int CurrentAmmo[32]; //Added by Messatsu

script 422 (void) // Energy Balancer main script
{
  int i, j;
  int min = 255;
  int minn = 1.0;
  int minimum;
  //int index;
  
		for (j=0; j<ARRAY_MAX; j++)
		{
		  if ( CheckInventory(weapon_types[j])==1 )
		  {
		    haveWepC[j] = 1;
			current_ammo[j] = CheckInventory(ammo_types[j]);
			ratioammo[j] = FixedDiv(current_ammo[j], ammo_Maxes[j]);
		  }
		  else if ( CheckInventory(weapon_types[j])==0 )
		  {
		    haveWepC[j] = 0;
		  }
		}
		
		for (i=0; i<ARRAY_MAX; i++)
		{
		  //if ( CheckInventory(weapon_types[i])==1 && current_ammo[i]<min )
		  if(CheckWeapon(weapon_types[i])==1){CurrentAmmo[PlayerNumber()]=i;} //Added by Messatsu
		  if ( CheckInventory(weapon_types[i])==1 && ratioammo[i]<minn )
		  {
		    minimum = current_ammo[i];
			//min = current_ammo[i];
			minn = ratioammo[i];
			index = i;
		  }
		}
		
		//log(s:"\cn", s:ammo_types[index], s:", ", d:minimum, s:", ", f:ratioammo[index], s:"\c-");
}

script 423 (int divisor) //Doc Ammo Halver
{
	int i;
	for (i=0; i<ARRAY_MAX; i++) {
		SetAmmoCapacity(ammo_types[i],ammo_maxes[i]/divisor);
	}	
}

script 992 (int amount)
{
//if( (CheckWeapon("MegaBuster")==1 || CheckWeapon("ProtoBuster")==1 || CheckWeapon("BassBuster")==1 || CheckWeapon("ChargeBuster")==1) && CheckInventory("EnergyBalancerActive")==1 )
if (CheckInventory("EnergyBalancerActive")==1)
{

	//ACS_ExecuteAlways(422, 0);
	ACS_ExecuteWait(422,0); //added by Messatsu

	if(
	(CheckInventory(ammo_types[CurrentAmmo[PlayerNumber()]])==Ammo_Maxes[CurrentAmmo[PlayerNumber()]]) || UsingBuster()==1) //added by Messatsu
		{
			//printbold(s:weapon_types[index]);
			if (amount == 255)
				{
					GiveInventory(ammo_types[index], amount);
					terminate; //added by Messatsu
				}
			else
				{
					GiveInventory(ammo_types[index], amount + amount_modifier[index]);
					terminate; //added by Messatsu
				}
		}
}
if(CheckWeapon("BubbleLeadWepC")==1){GiveInventory("BubbleAmmo",amount);}
if(CheckWeapon("ShadowBladeWepC")==1){GiveInventory("ShadowAmmo",amount);}
if(CheckWeapon("NapalmBombWepC")==1){GiveInventory("NapalmAmmo",amount);}
if(CheckWeapon("AtomicFireWepC")==1){GiveInventory("AtomicAmmo",amount+2);}
if(CheckWeapon("LeafShieldWepC")==1){GiveInventory("LeafAmmo",amount);}
if(CheckWeapon("AirShooterWepC")==1){GiveInventory("AirAmmo",amount);}
if(CheckWeapon("HyperBombWepC")==1){GiveInventory("BombAmmo",amount+2);}
if(CheckWeapon("MagnetMissileWepC")==1){GiveInventory("MagnetAmmo",amount);}
if(CheckWeapon("TopSpinWepC")==1){GiveInventory("TopAmmo",amount);}
if(CheckWeapon("NeedleCannonWepC")==1){GiveInventory("NeedleAmmo",amount);}
if(CheckWeapon("GeminiLaserWepC")==1){GiveInventory("GeminiAmmo",amount);}
if(CheckWeapon("SearchSnakeWepC")==1){GiveInventory("SnakeAmmo",amount);}
if(CheckWeapon("TimeStopperWepC")==1){}
if(CheckWeapon("SuperArmWepC")==1){GiveInventory("SuperArmAmmo",amount);}
if(CheckWeapon("IceSlasherWepC")==1){GiveInventory("IceAmmo",amount);}
if(CheckWeapon("ThunderBeamWepC")==1){GiveInventory("ThunderBeamAmmo",amount);}
if(CheckWeapon("MetalBladeWepC")==1){GiveInventory("MetalBladeAmmo",amount);}
if(CheckWeapon("HardKnuckleWepC")==1){GiveInventory("HardKnuckleAmmo",amount);}
if(CheckWeapon("DrillBombWepC")==1){GiveInventory("DrillBombAmmo",amount);}
if(CheckWeapon("BlizzardAttackWepC")==1){GiveInventory("BlizzardAttackAmmo",amount);}
if(CheckWeapon("FireStormWepC")==1){GiveInventory("FireStormAmmo",amount);}
if(CheckWeapon("QuickBoomerangWepC")==1){GiveInventory("QuickBoomerangAmmo",amount+4);}
if(CheckWeapon("CrashBombWepC")==1){GiveInventory("CrashBombAmmo",amount+4);}
if(CheckWeapon("ChargeKickWepC")==1){GiveInventory("ChargeKickAmmo",amount);}
if(CheckWeapon("RollingCutterWepC")==1){GiveInventory("RollingCutterAmmo",amount);}
if(CheckWeapon("SparkShockWepC")==1){GiveInventory("SparkShockAmmo",amount);}
if(CheckWeapon("RingBoomerangWepC")==1){GiveInventory("RingBoomerangAmmo",amount);}
if(CheckWeapon("GyroAttackWepC")==1){GiveInventory("GyroAttackAmmo",amount);}
if(CheckWeapon("PowerStoneWepC")==1){GiveInventory("PowerStoneAmmo",amount);}
if(CheckWeapon("DustCrusherWepC")==1){GiveInventory("DustCrusherAmmo",amount);}
if(CheckWeapon("PharaohShotWepC")==1){GiveInventory("PharaohShotAmmo",amount);}
if(CheckWeapon("WaterWaveWepC")==1){GiveInventory("WaterWaveAmmo",amount);}
if(CheckWeapon("CrystalEyeWepC")==1){GiveInventory("CrystalEyeAmmo",amount);}
if(CheckWeapon("SkullBarrierWepC")==1){GiveInventory("SkullBarrierAmmo",amount);}
if(CheckWeapon("FlameBlastWepC")==1){GiveInventory("FlameBlastAmmo",amount);}
if(CheckWeapon("YamatoSpearWepC")==1){GiveInventory("YamatoSpearAmmo",amount);}
if(CheckWeapon("DiveMissileWepC")==1){GiveInventory("DiveMissileAmmo",amount);}
if(CheckWeapon("PlantBarrierWepC")==1){GiveInventory("PlantBarrierAmmo",amount);}
if(CheckWeapon("SilverTomahawkWepC")==1){GiveInventory("SilverTomahawkAmmo",amount);}
if(CheckWeapon("WindStormWepC")==1){GiveInventory("WindStormAmmo",amount);}
if(CheckWeapon("KnightCrushWepC")==1){GiveInventory("KnightCrushAmmo",amount);}
if(CheckWeapon("StarCrashWepC")==1){GiveInventory("StarCrashAmmo",amount);}
if(CheckWeapon("RainFlushWepC")==1){GiveInventory("RainFlushAmmo",amount);}
if(CheckWeapon("SakugarneWepC")==1){GiveInventory("SakugarneAmmo",amount);}
if(CheckWeapon("BalladeCrackerWepC")==1){GiveInventory("BalladeCrackerAmmo",amount);}
if(CheckWeapon("ScrewCrusherWepC")==1){GiveInventory("ScrewCrusherAmmo",amount);}
if(CheckWeapon("FlashStopperWepC")==1){GiveInventory("FlashStopperAmmo",amount);}
if(CheckWeapon("GravityHoldWepC")==1){GiveInventory("GravityHoldAmmo",amount);}
if(CheckWeapon("CentaurFlashWepC")==1){GiveInventory("CentaurFlashAmmo",amount);}
if(CheckWeapon("MirrorBusterWepC")==1){GiveInventory("MirrorBusterAmmo",amount);}
if(CheckWeapon("FreezeCrackerWepC")==1){GiveInventory("FreezeCrackerAmmo",amount);}
if(CheckWeapon("NoiseCrushWepC")==1){GiveInventory("NoiseCrushAmmo",amount);}
if(CheckWeapon("WildCoilWepC")==1){GiveInventory("WildCoilAmmo",amount);}
if(CheckWeapon("DangerWrapWepC")==1){GiveInventory("DangerWrapAmmo",amount);}
if(CheckWeapon("ScorchWheelWepC")==1){GiveInventory("ScorchWheelAmmo",amount);}
if(CheckWeapon("JunkShieldWepC")==1){GiveInventory("JunkShieldAmmo",amount);}
if(CheckWeapon("SlashClawWepC")==1){GiveInventory("SlashClawAmmo",amount);}
if(CheckWeapon("ThunderBoltWepC")==1){GiveInventory("ThunderBoltAmmo",amount);}
if(CheckWeapon("TimeSlowWepC")==1){GiveInventory("SlowAmmo",amount);}
if(CheckWeapon("OilSliderWepC")==1){GiveInventory("OilAmmo",amount);}
if(CheckWeapon("FlashBulbWepC")==1){GiveInventory("FlashBulbAmmo",amount);}
if(CheckWeapon("SkullSniperWepC")==1){GiveInventory("SkullSniperAmmo",amount+4);}
if(CheckWeapon("GravitySphereWepC")==1){GiveInventory("GravitySphereAmmo",amount);}
if(CheckWeapon("CentaurArrowWepC")==1){GiveInventory("CentaurArrowAmmo",amount);}
if(CheckWeapon("RollSwingBoss")==1){GiveInventory("RollHealAmmo",amount);}
if(CheckWeapon("RollBucketBoss")==1){GiveInventory("RollHealAmmo",amount);}
}

function int UsingBuster(void) //added by Messatsu
{
bool BusterCheck=0;
if(CheckWeapon("MegaBuster")==1
|| CheckWeapon("BassBuster")==1 
|| CheckWeapon("ProtoBuster")==1 
|| CheckWeapon("TimeStopperWepC")==1
|| CheckWeapon("MegaBusterC")==1
|| CheckWeapon("ProtoBusterC")==1
|| CheckWeapon("BassBusterC")==1
|| CheckWeapon("PowerFistC")==1
|| CheckWeapon("JetBusterC")==1
|| CheckWeapon("SuperAdaptorWep")==1
|| CheckWeapon("TrebleBoosterWepC")==1
|| CheckWeapon("ArchiveBusterC")
|| CheckInventory("DocBusterC")==1
//|| (CheckWeapon("OilSliderWep")==1 && CheckInventory("OilCheck")==1)
) 
{BusterCheck=1;}
return BusterCheck;
}