Downloads containing ammocharger.asc

Downloads
Name Author Game Mode Rating
TSF with JJ2+ Only: TubolationFeatured Download FawFul Capture the flag 9.5 Download file
TSF with JJ2+ Only: Anniversary Bash 26 CTF Jazz2Online Capture the flag N/A Download file
JJ2+ Only: Anniversary Bash 25 CTF Jazz2Online Capture the flag N/A Download file

File preview

#pragma require "ammocharger.asc"

/*Information about the weapons and objects*/
const array<int> nonPUs = {0, 0, 24, 30, 33, 48, 56, 0, 0, 0, 0, 0, 0, 0};	//[1] = blaster, [2] = bnc , ...
const array<int> PUs 	= {0, 0, 25, 29, 34, 49, 57, 0, 0, 0, 0, 0, 0, 0};	//idem

int objectToWeapon(int eventID) {
	int weaponID = 0;
	switch(eventID)	{
		case OBJECT::BOUNCERAMMO15	: 	weaponID = WEAPON::BOUNCER; 	break;
		case OBJECT::ICEAMMO15		: 	weaponID = WEAPON::ICE; 		break;
		case OBJECT::SEEKERAMMO15	:	weaponID = WEAPON::SEEKER; 		break;
		case OBJECT::RFAMMO15		:	weaponID = WEAPON::RF; 			break;
		case OBJECT::TOASTERAMMO15	: 	weaponID = WEAPON::TOASTER; 	break;
	}
	return weaponID;
}

/*The rest!*/
void setOnlyBncFromGunCrates () {
	for (uint j=0; j < 10;j++) {
		if (j != WEAPON::BOUNCER) jjWeapons[j].comesFromGunCrates = false;
	}
}

void superCharge(int Object, int ammo) {
	jjObjectPresets[Object].scriptedCollisions = true;
	jjObjectPresets[Object].behavior = ammoBehaviour;
	jjObjectPresets[Object].determineCurFrame();
	jjObjectPresets[Object].age = ammo;
	jjObjectPresets[Object].state = STATE::FLOATFALL;
	jjObjectPresets[Object].bulletHandling = HANDLING::IGNOREBULLET;
	jjObjectPresets[Object].playerHandling = HANDLING::SPECIAL;
}

void ammoBehaviour(jjOBJ@ obj) {
	int ammoType = objectToWeapon(obj.eventID);
	obj.behave(BEHAVIOR::PICKUP, false);
	obj.xPos = obj.xOrg;
	obj.yPos = obj.yOrg;
	
	jjDrawResizedSprite(
		obj.xPos, obj.yPos, ANIM::AMMO,
		jjLocalPlayers[0].powerup[ammoType] == true? nonPUs[ammoType]:PUs[ammoType],
		jjGameTicks >> 2, 2, 2,	obj.justHit > 0? SPRITE::SINGLECOLOR : SPRITE::NORMAL, 15
	);
	
}

void onObjectHit(jjOBJ@ obj, jjOBJ@ bullet, jjPLAYER@ play, int force) {
	int ammoType = objectToWeapon(obj.eventID);
	if (ammoType > 0 && play.isLocal) {
		if (play.ammo[ammoType] == 0 && jjAutoWeaponChange) play.currWeapon = ammoType;
		if (play.ammo[ammoType] < obj.age) {
			play.ammo[ammoType] = obj.age;
		}
	}
}