Register FAQ Search Today's Posts Mark Forums Read
Go Back   JazzJackrabbit Community Forums » Open Forums » JCS & Scripting

AngelScript Requests & Help

Reply
 
Thread Tools
DennisKainz DennisKainz's Avatar

JCF Member

Joined: Dec 2005

Posts: 415

DennisKainz is notorious for his worthless posts

Dec 14, 2015, 10:04 AM
DennisKainz is offline
Reply With Quote
There's a new problem ... (Warn me if double posting is not authorized. I don't know all the rules)
I wrote a script. It works flawlessly on my computer, but Blaze the Movie Fan says it's extremely laggy on his computer, so I'll post it and see if you can help me.
Hopefully I'll learn something new and useful!

Code:
uint shownText = 0;
bool textShift = false;
uint textShiftTotal = 0;
uint thunderCounter = 0;
uint debugger = 0;
uint killedDemons = 0;
uint wallFall = 0;
uint wallFall1 = 0;
uint wallFall2 = 0;
uint isSugarRush = 0;
bool justMorphed = false;

void onLevelLoad()
	{
	jjPalette.gradient(224, 192, 255, 0, 0, 0, 16, 8, 1);
	jjPalette.gradient(192, 255, 224, 0, 0, 0, 24, 8, 1);
	jjPalette.gradient(255, 255, 192, 0, 0, 0, 32, 8, 1);
	jjPalette.gradient(255, 192, 255, 0, 0, 0, 40, 8, 1);
	jjPalette.gradient(192, 255, 192, 0, 0, 0, 48, 8, 1);
	jjPalette.gradient(255, 192, 224, 0, 0, 0, 58, 6, 1);
	jjPalette.gradient(224, 224, 255, 0, 0, 0, 64, 8, 1);
	jjPalette.gradient(255, 192, 192, 0, 0, 0, 72, 8, 1);
	jjPalette.gradient(255, 224, 224, 0, 0, 0, 80, 8, 1);
	jjPalette.gradient(192, 255, 224, 0, 0, 0, 88, 8, 1);
	jjPalette.gradient(224, 192, 160, 0, 0, 0, 104, 12, 1);
	jjPalette.gradient(16, 0, 16, 32, 0, 0, 176, 32, 1);
	jjPalette.gradient(0, 0, 0, 0, 0, 0, 10, 1, 1);
	jjPalette.apply();
	jjUseLayer8Speeds = true;
	jjTexturedBGTexture = TEXTURE::NORMAL;
	p.lives = 5;
	jjObjectPresets[OBJECT::BAT].energy = 5;
	jjObjectPresets[OBJECT::DEMON].energy = 25;
	jjObjectPresets[OBJECT::DOGGYDOGG].energy = 15;
	jjObjectPresets[OBJECT::DRAGON].energy = 10;
	jjObjectPresets[OBJECT::HELMUT].energy = 15;
	jjObjectPresets[OBJECT::MONKEY].energy = 20;
	jjObjectPresets[OBJECT::RAPIER].energy = 25;
	jjObjectPresets[OBJECT::RAVEN].energy = 10;
	jjObjectPresets[OBJECT::STANDMONKEY].energy = 25;
	jjObjectPresets[OBJECT::BOLLPLATFORM].behavior = myPlatform;
	jjObjectPresets[OBJECT::BOLLPLATFORM].deactivates = false;
	jjObjectPresets[OBJECT::SPIKEBOLL].energy = 0;
	jjObjectPresets[OBJECT::SPIKEPLATFORM].behavior = bruiser;
	}
	
void onLevelReload()
	{
	jjPalette.gradient(224, 192, 255, 0, 0, 0, 16, 8, 1);
	jjPalette.gradient(192, 255, 224, 0, 0, 0, 24, 8, 1);
	jjPalette.gradient(255, 255, 192, 0, 0, 0, 32, 8, 1);
	jjPalette.gradient(255, 192, 255, 0, 0, 0, 40, 8, 1);
	jjPalette.gradient(192, 255, 192, 0, 0, 0, 48, 8, 1);
	jjPalette.gradient(255, 192, 224, 0, 0, 0, 58, 6, 1);
	jjPalette.gradient(224, 224, 255, 0, 0, 0, 64, 8, 1);
	jjPalette.gradient(255, 192, 192, 0, 0, 0, 72, 8, 1);
	jjPalette.gradient(255, 224, 224, 0, 0, 0, 80, 8, 1);
	jjPalette.gradient(192, 255, 224, 0, 0, 0, 88, 8, 1);
	jjPalette.gradient(224, 192, 160, 0, 0, 0, 104, 12, 1);
	jjPalette.gradient(16, 0, 16, 32, 0, 0, 176, 32, 1);
	jjPalette.gradient(0, 0, 0, 0, 0, 0, 10, 1, 1);
	jjPalette.apply();
	jjUseLayer8Speeds = true;
	jjTexturedBGTexture = TEXTURE::NORMAL;
	wallFall = 0;
	wallFall1 = 0;
	wallFall2 = 0;
	}
	
void onLevelBegin()
	{
	p.xPos = 5.5 * 32;
	p.yPos = 0;
	p.xOrg = 5.5 * 32;
	p.yOrg = 0;
	ActivateEventAt(27, 6);
	ActivateEventAt(32, 9);
	}
	
jjOBJ@ ActivateEventAt(int xTile, int yTile) {
	if (jjParameterGet(xTile, yTile, -1, 1) == 1)
		return null;
	jjParameterSet(xTile, yTile, -1, 1, 1);
	return jjObjects[jjAddObject(jjEventGet(xTile, yTile), xTile * 32 + 15, yTile * 32 + 15, 0, CREATOR::LEVEL)];
	}
	
void onMain()
	{
	if (textShift == true && textShiftTotal < 70)
		textShiftTotal = textShiftTotal + 1;
	if (textShift == false && textShiftTotal > 0)
		textShiftTotal = textShiftTotal - 1;
	if (jjRandom() & 3500 == 0)
		thunderCounter = 16;
	if (thunderCounter > 0)
		thunderCounter = thunderCounter - 1;
	jjPalette.gradient(16 - thunderCounter + (thunderCounter * 16), 0 + (thunderCounter * 16), 16 - thunderCounter + (thunderCounter * 16), 32, 0, 0, 176, 32, 1);
	jjPalette.apply();
	jjSetFadeColors(16 - thunderCounter + (thunderCounter * 16), 0 + (thunderCounter * 16), 16 - thunderCounter + (thunderCounter * 16));
	if (killedDemons >= 1 && jjTriggers[0] == false)
		jjSwitchTrigger(0);
	if (wallFall > 0 && wallFall1 < 256)
		wallFall1 = wallFall1 + 8;
	if (wallFall1 == 256 && jjTriggers[30] == false)
		jjSwitchTrigger(30);
	if (wallFall > 1 && wallFall2 < 256)
		wallFall2 = wallFall2 + 8;
	if (wallFall2 == 256 && jjTriggers[31] == false)
		jjSwitchTrigger(31);
	if (killedDemons >= 5 && jjTriggers[5] == false)
		jjSwitchTrigger(5);
	if (p.health < 1)
		{
		textShift = false;
		textShiftTotal = 0;
		}
	if (isSugarRush > 0)
		isSugarRush = isSugarRush - 1;
	}

void onPlayer()
	{
	if (p.yPos < 32 && p.ySpeed < 0)
		p.yPos = 32;
	if (p.food >= 1)
		{
		p.startSugarRush(1400);
		isSugarRush = 1400;
		p.food = 0;
		}
	if (p.health < 1)
		isSugarRush = 0;
	if (p.blink != 0 && isSugarRush < 1)
		{
		p.blink = 0;
		p.invincibility = 0;
		}
	p.fastfire = 6;
	if (isSugarRush == 0)
		p.jumpStrength = -8.5;
	if (isSugarRush > 0)
		p.jumpStrength = -11.5;
	if (p.yPos > 16 * 32 && p.health > 0)
		{
		p.health = 0;
		p.kill();
		}
	for (int i = 1; i < jjObjectCount; i++)
		{
		jjOBJ@ o = jjObjects[i];
		if (o.eventID == OBJECT::DEMON && o.state == STATE::KILL && o.justHit == 1)
			killedDemons = killedDemons + 1;
		}
	p.cameraFreeze(p.xPos, 272, true, true);
	}
	
void onPlayerInput(jjPLAYER@ p)
	{
	if (isSugarRush == 0)
		p.keyRun = false;
	if (p.health < 1)
		{
		p.keyDown = false;
		p.keyFire = false;
		p.keyJump = false;
		p.keyLeft = false;
		p.keyRight = false;
		p.keySelect = false;
		p.keyUp = false;
		}
	if (jjKey[0x4A] == true && p.charCurr == CHAR::SPAZ)
		p.morphTo(CHAR::JAZZ, true);
	if (jjKey[0x53] == true && p.charCurr == CHAR::JAZZ)
		p.morphTo(CHAR::SPAZ, true);
	}
	
void onFunction0()
	{
	textShift = false;
	}
	
void onFunction1()
	{
	textShift = true;
	shownText = 1;
	}
	
void onFunction2()
	{
	textShift = true;
	shownText = 2;
	}
	
void onFunction5()
	{
	textShift = true;
	shownText = 5;
	}
	
void onFunction20()
	{
	if (wallFall < 1)
		wallFall = 1;
	textShift = true;
	shownText = 10;
	}
	
void onFunction21()
	{
	if (wallFall < 2)
		wallFall = 2;
	}
	
void bruiser(jjOBJ@ bruise)
	{
	bruise.behave(BEHAVIOR::PLATFORM, true);
	bruise.playerHandling = HANDLING::ENEMYBULLET;
	bruise.animSpeed = 1;
	if (bruise.xOrg % 32 == 15)
		bruise.xOrg = bruise.xOrg - 16;
	if (p.health < 1)
		bruise.state = STATE::KILL;
	if (p.yPos < bruise.yPos + 32 && wallFall > 0)
		p.yPos = bruise.yPos + 32;
	if (wallFall > 0 && bruise.yOrg < 14 * 32)
		bruise.yOrg = bruise.yOrg + 0.5;
	debugger = jjParameterGet(27, 6, -1, 1);
	}
	
void myPlatform(jjOBJ@ myPlat)
	{
	myPlat.behave(BEHAVIOR::PLATFORM, true);
	if (p.health < 1)
		myPlat.state = STATE::KILL;
	if (myPlat.yOrg % 32 == 15)
		myPlat.yOrg = myPlat.yOrg - 12;
	if (myPlat.var[0] == -35)
		myPlat.xOrg = myPlat.xOrg + myPlat.var[1];
	if (myPlat.var[0] == 35)
		myPlat.xOrg = myPlat.xOrg - myPlat.var[1];
	if (jjEventGet((myPlat.xOrg + 18) / 32, (myPlat.yOrg) / 32) == AREA::SLIDE && myPlat.var[0] < 35)
		{
		myPlat.var[0] = myPlat.var[0] + 1;
		}
	if (jjEventGet((myPlat.xOrg - 18) / 32, (myPlat.yOrg) / 32) == AREA::SLIDE && myPlat.var[0] > -35)
		{
		myPlat.var[0] = myPlat.var[0] - 1;
		}
	}
	
void onDrawLayer4(jjPLAYER@ p, jjCANVAS@ screen)
	{
	jjDrawTile(233 * 32, (7 * 32) + (jjSin(wallFall1 - 256) * 64), 268, TILE::ALLQUADRANTS, 4, 4, -1);
	jjDrawTile(233 * 32, (8 * 32) + (jjSin(wallFall1 - 256) * 64), 216, TILE::ALLQUADRANTS, 4, 4, -1);
	jjDrawTile(233 * 32, (9 * 32) + (jjSin(wallFall1 - 256) * 64), 216, TILE::ALLQUADRANTS, 4, 4, -1);
	jjDrawTile(233 * 32, (10 * 32) + (jjSin(wallFall1 - 256) * 64), 216, TILE::ALLQUADRANTS, 4, 4, -1);
	jjDrawTile(233 * 32, (11 * 32) + (jjSin(wallFall1 - 256) * 64), 216, TILE::ALLQUADRANTS, 4, 4, -1);
	jjDrawTile(233 * 32, (12 * 32) + (jjSin(wallFall1 - 256) * 64), 216, TILE::ALLQUADRANTS, 4, 4, -1);
	jjDrawTile(233 * 32, (13 * 32) + (jjSin(wallFall1 - 256) * 64), 216, TILE::ALLQUADRANTS, 4, 4, -1);
	jjDrawTile(233 * 32, (14 * 32) + (jjSin(wallFall1 - 256) * 64), 268, TILE::ALLQUADRANTS, 4, 4, -1);
	jjDrawTile(252 * 32, (7 * 32) + (jjSin(wallFall2 - 256) * 64), 268, TILE::ALLQUADRANTS, 4, 4, -1);
	jjDrawTile(252 * 32, (8 * 32) + (jjSin(wallFall2 - 256) * 64), 216, TILE::ALLQUADRANTS, 4, 4, -1);
	jjDrawTile(252 * 32, (9 * 32) + (jjSin(wallFall2 - 256) * 64), 216, TILE::ALLQUADRANTS, 4, 4, -1);
	jjDrawTile(252 * 32, (10 * 32) + (jjSin(wallFall2 - 256) * 64), 216, TILE::ALLQUADRANTS, 4, 4, -1);
	jjDrawTile(252 * 32, (11 * 32) + (jjSin(wallFall2 - 256) * 64), 216, TILE::ALLQUADRANTS, 4, 4, -1);
	jjDrawTile(252 * 32, (12 * 32) + (jjSin(wallFall2 - 256) * 64), 216, TILE::ALLQUADRANTS, 4, 4, -1);
	jjDrawTile(252 * 32, (13 * 32) + (jjSin(wallFall2 - 256) * 64), 216, TILE::ALLQUADRANTS, 4, 4, -1);
	jjDrawTile(252 * 32, (14 * 32) + (jjSin(wallFall2 - 256) * 64), 268, TILE::ALLQUADRANTS, 4, 4, -1);
	}
	
void onDrawLayer1(jjPLAYER@ p, jjCANVAS@ screen)
	{
	jjTEXTAPPEARANCE mytext;
	mytext.at = STRING::SPECIALSIGN;
	mytext.pipe = STRING::SPECIALSIGN;
	mytext.align = STRING::CENTER;
	if (shownText == 1)
		screen.drawString(p.cameraX + 320, -20 + textShiftTotal, "'Welcome' to Hell!@If you complete the test,@you'll obtain a reward!", STRING::SMALL, mytext, 0);
	if (shownText == 2)
		screen.drawString(p.cameraX + 320, -20 + textShiftTotal, "Press J to turn into Jazz.@Press S to turn into Spaz.", STRING::SMALL, mytext, 0);
	if (shownText == 5)
		screen.drawString(p.cameraX + 320, -20 + textShiftTotal, "Kill 5 demons@to open this door.", STRING::SMALL, mytext, 0);
	if (shownText == 10)
		screen.drawString(p.cameraX + 320, -20 + textShiftTotal, "I lied!@No reward for you!@Just pain!", STRING::SMALL, mytext, 0);
	screen.drawString(p.xPos, 64, "", STRING::SMALL, mytext, 0);
	}
HERE'S THE LEVEL
__________________
Free will was a mistake.
- God
Violet CLM Violet CLM's Avatar

JCF Éminence Grise

Joined: Mar 2001

Posts: 10,978

Violet CLM has disabled reputation

Dec 14, 2015, 11:24 AM
Violet CLM is offline
Reply With Quote
I suspect the issue is that you're calling jjPAL::apply every single gametick, and it's one of the slowest operations in the game (for justifiable reasons). You should at least be able to only call it every second or third tick without much noticeable difference, and I'm fond of disabling it entirely when jjLowDetail is true.
__________________
Seren Seren's Avatar

JCF Member

Joined: Feb 2010

Posts: 864

Seren is a name known to allSeren is a name known to allSeren is a name known to allSeren is a name known to allSeren is a name known to allSeren is a name known to all

Dec 14, 2015, 12:15 PM
Seren is offline
Reply With Quote
More importantly there's no reason to call it at all when the palette doesn't change in the first place, which would be most of the time in your script. Also I don't think the bitwise AND operator & does what you think it does.
Slaz Slaz's Avatar

JCF Member

Joined: Aug 2004

Posts: 1,314

Slaz is OFF DA CHARTSlaz is OFF DA CHARTSlaz is OFF DA CHART

Dec 16, 2015, 01:38 PM
Slaz is offline
Reply With Quote
I'm looking for 2 things that are probably simple and straightforward to most readers here:

1: I'd like to have snow from ANIM::SNOW appear through jjParticle, with original coloring (not loading palette entries from other tilesets).

2: I'd like to set a textured background on levelload, like TEXTURE::WTF, and keep the original textured BG color range from the tileset in use (so just swapping the texture).

This to polish up an old unreleased Xmas level I feel like releasing with proper modifications.
__________________
Add SlazRabbit on Xbox Live if you want to play some GoW1/2/3/J or Destiny1/2.
Jazz Jackrabbit 2 Forever!!
Civilian Defence Force - Jazz2 Visual Fantasers
Violet CLM Violet CLM's Avatar

JCF Éminence Grise

Joined: Mar 2001

Posts: 10,978

Violet CLM has disabled reputation

Dec 16, 2015, 08:13 PM
Violet CLM is offline
Reply With Quote
In both cases you seem to want to be (permanently) recoloring images, so you'll need jjPIXELMAP. The first one is pretty much the same as the RecolorRain function from plusPixelMapEx, so look there, but work on ANIM::SNOW instead. For the second, I don't think they're covered in that level, but jjPIXELMAP does have both a constructor and a makeTexture method for working with textures specifically.
__________________
Slaz Slaz's Avatar

JCF Member

Joined: Aug 2004

Posts: 1,314

Slaz is OFF DA CHARTSlaz is OFF DA CHARTSlaz is OFF DA CHART

Dec 17, 2015, 09:04 AM
Slaz is offline
Reply With Quote
Thanks! I looked there and found something for the snow. For the texture, I just loaded a default one from Plus and reset it's color range through jjPalette. I didn't even need a pixelmap there.
__________________
Add SlazRabbit on Xbox Live if you want to play some GoW1/2/3/J or Destiny1/2.
Jazz Jackrabbit 2 Forever!!
Civilian Defence Force - Jazz2 Visual Fantasers
DennisKainz DennisKainz's Avatar

JCF Member

Joined: Dec 2005

Posts: 415

DennisKainz is notorious for his worthless posts

Dec 21, 2015, 03:18 AM
DennisKainz is offline
Reply With Quote
I have this script:
Code:
void onLevelLoad() {
	jjAnimSets[ANIM::CUSTOM[0]].load(0, "sausage.j2a");
	jjObjectPresets[OBJECT::WEENIE].determineCurAnim(ANIM::CUSTOM[0], 0);
	jjTileType[659] = 5;
	jjTileType[669] = 5; // White hot lava.
	jjPalette.gradient(128 + (jjP.cameraY / 16), 192 + (jjP.cameraY / 32), 255, 0 + (jjP.cameraY / 8), 32 + (jjP.cameraY / 12), 128, 144, 16, 1);
	jjPalette.gradient(112 + (jjP.cameraY / 16), 64 + (jjP.cameraY / 24), 32 - (jjP.cameraY / 64), 0 + (jjP.cameraY / 12), 0, 0, 160, 16, 1);
	jjPalette.gradient(255, 128, 0, 0 + (jjP.cameraY / 16), 0 + (jjP.cameraY / 256), 0, 208, 24, 1);
	jjPalette.gradient(0 + (jjP.cameraY / 8), 192 - (jjP.cameraY / 16), 0, 0, 0, 0, 96, 8, 1);
	jjPalette.gradient(0 + (jjP.cameraY / 8), 192 - (jjP.cameraY / 16), 0, 0, 0, 0, 128, 8, 1);
	jjPalette.gradient(128 + (jjP.cameraY / 16), 64 + (jjP.cameraY / 32), 0, 0 + (jjP.cameraY / 16), 0, 0, 176, 32, 1);
	jjPalette.gradient(192 + (jjP.cameraY / 32), 128 - (jjP.cameraY / 32), 64 - (jjP.cameraY / 32), 0 + (jjP.cameraY / 32), 0, 0, 120, 8, 1);
	jjPalette.gradient(128 + (jjP.cameraY / 32), 64 - (jjP.cameraY / 32), 0, 0 + (jjP.cameraY / 32), 0, 0, 136, 8, 1);
	jjPalette.gradient(192 + (jjP.cameraY / 64), 128 - (jjP.cameraY / 64), 32, 0, 0, 0, 104, 8, 1);
	jjPalette.apply();
	}
	
void onLevelReload() {
	jjPalette.gradient(128 + (jjP.cameraY / 16), 192 + (jjP.cameraY / 32), 255, 0 + (jjP.cameraY / 8), 32 + (jjP.cameraY / 12), 128, 144, 16, 1);
	jjPalette.gradient(112 + (jjP.cameraY / 16), 64 + (jjP.cameraY / 24), 32 - (jjP.cameraY / 64), 0 + (jjP.cameraY / 12), 0, 0, 160, 16, 1);
	jjPalette.gradient(255, 128, 0, 0 + (jjP.cameraY / 16), 0 + (jjP.cameraY / 256), 0, 208, 24, 1);
	jjPalette.gradient(0 + (jjP.cameraY / 8), 192 - (jjP.cameraY / 16), 0, 0, 0, 0, 96, 8, 1);
	jjPalette.gradient(0 + (jjP.cameraY / 8), 192 - (jjP.cameraY / 16), 0, 0, 0, 0, 128, 8, 1);
	jjPalette.gradient(128 + (jjP.cameraY / 16), 64 + (jjP.cameraY / 32), 0, 0 + (jjP.cameraY / 16), 0, 0, 176, 32, 1);
	jjPalette.gradient(192 + (jjP.cameraY / 32), 128 - (jjP.cameraY / 32), 64 - (jjP.cameraY / 32), 0 + (jjP.cameraY / 32), 0, 0, 120, 8, 1);
	jjPalette.gradient(128 + (jjP.cameraY / 32), 64 - (jjP.cameraY / 32), 0, 0 + (jjP.cameraY / 32), 0, 0, 136, 8, 1);
	jjPalette.gradient(192 + (jjP.cameraY / 64), 128 - (jjP.cameraY / 64), 32, 0, 0, 0, 104, 8, 1);
	jjPalette.apply();
	}
	
void onMain() {
	jjUseLayer8Speeds = true; // The long awaited feature that changed my gaming experience!
	jjSetFadeColors(200);
	jjTexturedBGTexture = TEXTURE::WTF;
	}

void onPlayer(jjPLAYER@ jjP) {
	if (jjGameTicks % 7 == 6)
	{
		jjPalette.gradient(128 + (jjP.cameraY / 16), 192 + (jjP.cameraY / 32), 255, 0 + (jjP.cameraY / 8), 32 + (jjP.cameraY / 12), 128, 144, 16, 1);
		jjPalette.gradient(112 + (jjP.cameraY / 16), 64 + (jjP.cameraY / 24), 32 - (jjP.cameraY / 64), 0 + (jjP.cameraY / 12), 0, 0, 160, 16, 1);
		jjPalette.gradient(255, 128, 0, 0 + (jjP.cameraY / 16), 0 + (jjP.cameraY / 256), 0, 208, 24, 1);
		jjPalette.gradient(0 + (jjP.cameraY / 8), 192 - (jjP.cameraY / 16), 0, 0, 0, 0, 96, 8, 1);
		jjPalette.gradient(0 + (jjP.cameraY / 8), 192 - (jjP.cameraY / 16), 0, 0, 0, 0, 128, 8, 1);
		jjPalette.gradient(128 + (jjP.cameraY / 16), 64 + (jjP.cameraY / 32), 0, 0 + (jjP.cameraY / 16), 0, 0, 176, 32, 1);
		jjPalette.gradient(192 + (jjP.cameraY / 32), 128 - (jjP.cameraY / 32), 64 - (jjP.cameraY / 32), 0 + (jjP.cameraY / 32), 0, 0, 120, 8, 1);
		jjPalette.gradient(128 + (jjP.cameraY / 32), 64 - (jjP.cameraY / 32), 0, 0 + (jjP.cameraY / 32), 0, 0, 136, 8, 1);
		jjPalette.gradient(192 + (jjP.cameraY / 64), 128 - (jjP.cameraY / 64), 32, 0, 0, 0, 104, 8, 1);
		jjPalette.apply(); // The hues depend on how close to the lava the player is.
		}
	if (jjGameState == GAME::OVERTIME)
		jjMusicLoad("hurry_up.mod"); // Music changes along with overtime.
	if (jjP.yPos > (62.5 * 32) - jjLayerYOffset[2]) {
		jjP.xSpeed = 0;
		jjP.ySpeed = 1;
		}
	jjTexturedBGFadePositionY = 0.55 - (jjP.cameraY / 16384);
	jjPARTICLE@ lavaspecks = jjAddParticle(PARTICLE::SMOKE); // Creates fumes from the lava.
		lavaspecks.xPos = -480 + jjP.xPos + (jjRandom() % 960);
		lavaspecks.yPos = 63*32 - (jjRandom() % 256);
		lavaspecks.ySpeed = -1;
	jjPARTICLE@ raindrops = jjAddParticle(PARTICLE::RAIN); // Water drops from the ceiling.
		raindrops.xPos = -480 + jjP.xPos + (jjRandom() % 960);
		raindrops.yPos = 0 + (jjRandom() % 256);
		raindrops.ySpeed = 5 + (jjRandom() % 5);
	}

void onDrawLayer2(jjPLAYER@ jjP, jjCANVAS@ canvas) {
	jjLayerYOffset[2] = jjSin(jjGameTicks) * 16; // Lava moving up and down.
	}
	
void onDrawLayer7(jjPLAYER@ jjP, jjCANVAS@ screen)
	{
	jjPIXELMAP drawBigHills(0, 0, 6 * 32, 8 * 32, 7);
	jjANIMFRAME@ bigHills = jjAnimFrames[jjAnimations[jjAnimSets[ANIM::SONICPLAT].firstAnim].firstFrame];
	drawBigHills.save(bigHills); // Actually giving the game additional layers!!!
	screen.drawResizedSprite((-5 * 32) - ((jjP.cameraX * 0.0625) % (9 * 32)), (-1 * 32) - (jjP.cameraY * 0.015625), ANIM::SONICPLAT, 0, 0, 1.5, 3, SPRITE::NORMAL, 0);
	screen.drawResizedSprite((4 * 32) - ((jjP.cameraX * 0.0625) % (9 * 32)), (-1 * 32) - (jjP.cameraY * 0.015625), ANIM::SONICPLAT, 0, 0, 1.5, 3, SPRITE::NORMAL, 0);
	screen.drawResizedSprite((13 * 32) - ((jjP.cameraX * 0.0625) % (9 * 32)), (-1 * 32) - (jjP.cameraY * 0.015625), ANIM::SONICPLAT, 0, 0, 1.5, 3, SPRITE::NORMAL, 0);
	screen.drawResizedSprite((22 * 32) - ((jjP.cameraX * 0.0625) % (9 * 32)), (-1 * 32) - (jjP.cameraY * 0.015625), ANIM::SONICPLAT, 0, 0, 1.5, 3, SPRITE::NORMAL, 0);
	screen.drawResizedSprite((31 * 32) - ((jjP.cameraX * 0.0625) % (9 * 32)), (-1 * 32) - (jjP.cameraY * 0.015625), ANIM::SONICPLAT, 0, 0, 1.5, 3, SPRITE::NORMAL, 0);
	screen.drawResizedSprite((40 * 32) - ((jjP.cameraX * 0.0625) % (9 * 32)), (-1 * 32) - (jjP.cameraY * 0.015625), ANIM::SONICPLAT, 0, 0, 1.5, 3, SPRITE::NORMAL, 0);
	screen.drawResizedSprite((-5 * 32) - ((jjP.cameraX * 0.1875) % (18 * 32)), (-3.5 * 32) - (jjP.cameraY * 0.0416666666666667), ANIM::SONICPLAT, 0, 0, 3, 6, SPRITE::NORMAL, 0);
	screen.drawResizedSprite((13 * 32) - ((jjP.cameraX * 0.1875) % (18 * 32)), (-3.5 * 32) - (jjP.cameraY * 0.0416666666666667), ANIM::SONICPLAT, 0, 0, 3, 6, SPRITE::NORMAL, 0);
	screen.drawResizedSprite((31 * 32) - ((jjP.cameraX * 0.1875) % (18 * 32)), (-3.5 * 32) - (jjP.cameraY * 0.0416666666666667), ANIM::SONICPLAT, 0, 0, 3, 6, SPRITE::NORMAL, 0);
	screen.drawResizedSprite((49 * 32) - ((jjP.cameraX * 0.1875) % (18 * 32)), (-3.5 * 32) - (jjP.cameraY * 0.0416666666666667), ANIM::SONICPLAT, 0, 0, 3, 6, SPRITE::NORMAL, 0);
	}
Essentially, I'm using Layer 7 as 3 different layers of hills, each with its X Speed and Y Speed, giving the level a total of 10 layers.
And yes, it is way too pixelated, but this is NOT the problem. The actual problem is:
It works fine on Single Player mode, but on Multiplayer, the following problems occur:
- The extra layers work, but are shifted far in the upper left corner (and 2 of their color indexes are incorrect)
- I get the error message "memAlloc() Amnesia error: Out of Memory" after 4 seconds, divided by the amount of players in the game.

And yes, it is important that it works fine on Multiplayer mode, since it's a Battle game.
__________________
Free will was a mistake.
- God

Last edited by DennisKainz; Dec 21, 2015 at 03:30 AM.
Violet CLM Violet CLM's Avatar

JCF Éminence Grise

Joined: Mar 2001

Posts: 10,978

Violet CLM has disabled reputation

Dec 21, 2015, 09:27 AM
Violet CLM is offline
Reply With Quote
Try moving the first three lines of onDrawLayer7 into onLevelLoad?
__________________
DennisKainz DennisKainz's Avatar

JCF Member

Joined: Dec 2005

Posts: 415

DennisKainz is notorious for his worthless posts

Dec 21, 2015, 10:23 AM
DennisKainz is offline
Reply With Quote
My bad. I always forget to make my expressions one-timed.

I still have the problem of the background's location.
It seems that the calculation of the player's camera position is different in Multiplayer.
And now that I put the expressions into OnLevel Load, I can't see the hills at all in Multiplayer. And yet in Single Player they're always there!
__________________
Free will was a mistake.
- God
Violet CLM Violet CLM's Avatar

JCF Éminence Grise

Joined: Mar 2001

Posts: 10,978

Violet CLM has disabled reputation

Dec 21, 2015, 10:39 AM
Violet CLM is offline
Reply With Quote
Again just guessing, but you're using ANIM::SONICPLAT, but I don't see any explicit calls to jjOBJ::determineCurAnim or jjANIMSET::load, the two ways of manually loading an animset. So I suspect you're loading the animations by placing one or more Sonic Platform events in the level... but those don't work in multiplayer unless they're set to MP-Only.

Alternatively, use ANIM::CUSTOM[1] instead (after an appropriate allocate method call), since it doesn't look like you're interested in Sonic Platforms as Sonic Platforms?

(None of the stuff you're doing in onMain needs to be done every gametick either, fwiw.)
__________________
DennisKainz DennisKainz's Avatar

JCF Member

Joined: Dec 2005

Posts: 415

DennisKainz is notorious for his worthless posts

Dec 21, 2015, 11:16 AM
DennisKainz is offline
Reply With Quote
All I had to do was set it to MP-Only? Great!

And yes, I definitely need to learn which expressions are one-time and which ones aren't.

EDIT: I did it! No more sonic platforms needed. The level now creates the background automatically.
__________________
Free will was a mistake.
- God

Last edited by DennisKainz; Dec 21, 2015 at 11:48 AM.
Slaz Slaz's Avatar

JCF Member

Joined: Aug 2004

Posts: 1,314

Slaz is OFF DA CHARTSlaz is OFF DA CHARTSlaz is OFF DA CHART

Dec 31, 2015, 08:06 AM
Slaz is offline
Reply With Quote
Sorry for being so terrible at programming, but is there some way of making a certain gun your default one?

Do I need to check if BLASTER is WEAPON::CURRENT on jjPLAYER and then change it on levelbegin?
__________________
Add SlazRabbit on Xbox Live if you want to play some GoW1/2/3/J or Destiny1/2.
Jazz Jackrabbit 2 Forever!!
Civilian Defence Force - Jazz2 Visual Fantasers
Blaze The Movie Fan

JCF Member

Joined: Mar 2004

Posts: 769

Blaze The Movie Fan has disabled reputation

Jan 9, 2016, 10:02 AM
Blaze The Movie Fan is offline
Reply With Quote
AngelScript didn't exist when I left back in 2004, so it is a new thing to me. And I have a couple of question.
  1. How does it work exactly?
  2. Is there a special program I can use to make angelscript? Because I'm not good with doing code manually that's why I use the program Microsoft Expression to edit web pages for my website server.
  3. What's the best way to make cutscenes with that program? I played RabbitCity and noticed that has a lot of cut scenes.
Stijn Stijn's Avatar

Administrator

Joined: Mar 2001

Posts: 6,964

Stijn is a splendid one to beholdStijn is a splendid one to beholdStijn is a splendid one to beholdStijn is a splendid one to beholdStijn is a splendid one to beholdStijn is a splendid one to beholdStijn is a splendid one to behold

Jan 9, 2016, 10:11 AM
Stijn is offline
Reply With Quote
1. http://www.jazz2online.com/jj2plus/p...gelscript.html
2. Any text editor. You're going to have to write scripting code, there's no way around that. If you use Notepad++ there is a syntax highlighting module you can use.
3. There is no part of JJ2+'s AngelScript support specifically aimed at making cutscenes. You're probably best off reading the readme, seeing how other scripts do things (e.g. take a look at the RabbitCity scripts) and then ask specific questions in this thread.
luke11685

Banned

Joined: Jan 2016

Posts: 454

luke11685 is doing well so far

Jan 9, 2016, 11:41 AM
luke11685 is offline
Reply With Quote
did you ever make jj1 levels in jj2 style?I hope I'm not spamming.Just one very request.
Violet CLM Violet CLM's Avatar

JCF Éminence Grise

Joined: Mar 2001

Posts: 10,978

Violet CLM has disabled reputation

Jan 9, 2016, 11:44 AM
Violet CLM is offline
Reply With Quote
Do you mean this?
__________________
luke11685

Banned

Joined: Jan 2016

Posts: 454

luke11685 is doing well so far

Jan 9, 2016, 12:09 PM
luke11685 is offline
Reply With Quote
Yeah sure.Something more like level extension of flashback chapter from Jazz Jackrabbit 2 with more stages.
Violet CLM Violet CLM's Avatar

JCF Éminence Grise

Joined: Mar 2001

Posts: 10,978

Violet CLM has disabled reputation

Jan 9, 2016, 12:35 PM
Violet CLM is offline
Reply With Quote
Oh. Well, that doesn't have much of anything to do with Angelscript requests, but here are some tilesets you might be interested in.
__________________
luke11685

Banned

Joined: Jan 2016

Posts: 454

luke11685 is doing well so far

Jan 9, 2016, 12:55 PM
luke11685 is offline
Reply With Quote
Thanks ViolentCLM.Welll it's like recreating EarthBound Zero using 16-bit style,but it's jRPG.I think Jazz Jackrabbit 1 Creation Station is created to remake Jazz 1 maps to make them looking like in jazz 2 style.I mean widescreen in jazz 1 was 4:9 in jazz 2 it's 16:9.
http://www.jazz2online.com/downloads/jj1-level/
Stijn Stijn's Avatar

Administrator

Joined: Mar 2001

Posts: 6,964

Stijn is a splendid one to beholdStijn is a splendid one to beholdStijn is a splendid one to beholdStijn is a splendid one to beholdStijn is a splendid one to beholdStijn is a splendid one to beholdStijn is a splendid one to behold

Jan 9, 2016, 01:02 PM
Stijn is offline
Reply With Quote
please stop talking about stuff that's not angelscript
Old Jan 9, 2016, 01:18 PM
luke11685
This message has been deleted by Stijn.
Old Jan 9, 2016, 01:49 PM
DennisKainz
This message has been deleted by Stijn.
Old Jan 9, 2016, 01:56 PM
luke11685
This message has been deleted by Stijn.
Old Jan 10, 2016, 02:23 AM
luke11685
This message has been deleted by Stijn.
Old Jan 10, 2016, 02:48 AM
DennisKainz
This message has been deleted by Stijn.
Old Jan 10, 2016, 02:57 AM
luke11685
This message has been deleted by Stijn.
Blaze The Movie Fan

JCF Member

Joined: Mar 2004

Posts: 769

Blaze The Movie Fan has disabled reputation

Jan 10, 2016, 02:07 PM
Blaze The Movie Fan is offline
Reply With Quote
Quote:
Originally Posted by Stijn View Post
1. http://www.jazz2online.com/jj2plus/p...gelscript.html
2. Any text editor. You're going to have to write scripting code, there's no way around that. If you use Notepad++ there is a syntax highlighting module you can use.
3. There is no part of JJ2+'s AngelScript support specifically aimed at making cutscenes. You're probably best off reading the readme, seeing how other scripts do things (e.g. take a look at the RabbitCity scripts) and then ask specific questions in this thread.
Thanks for the help.

Jungle Jackrabbit 2 will probably me the first levelpack where I use angelscript, it's likely not gonna be easy, and if I need help I will ask here.
Blaze The Movie Fan

JCF Member

Joined: Mar 2004

Posts: 769

Blaze The Movie Fan has disabled reputation

Jan 11, 2016, 02:05 PM
Blaze The Movie Fan is offline
Reply With Quote
Is it possible to make it look like Spaz/Jazz is talking to the cellphone? The reason I'm asking is because I'm gonna make Spaz/Jazz do just that at several points during my next levelpack.
Violet CLM Violet CLM's Avatar

JCF Éminence Grise

Joined: Mar 2001

Posts: 10,978

Violet CLM has disabled reputation

Jan 11, 2016, 02:38 PM
Violet CLM is offline
Reply With Quote
Yes. I have no idea how you would want that to look, but whatever you have in mind is almost certainly possible.

EDIT:
Quote:
Originally Posted by Slaz View Post
Sorry for being so terrible at programming, but is there some way of making a certain gun your default one?

Do I need to check if BLASTER is WEAPON::CURRENT on jjPLAYER and then change it on levelbegin?
I forgot about this question, sorry. The answer is yes and no... yes, there are ways to achieve this effect, but it's not a simple one-time setting like it intuitively feels it should be. Instead you're probably going to need to check the player every tick (onPlayer, presumably) and compare/set jjPLAYER::currWeapon based on whatever you think the right criteria are.

And WEAPON::CURRENT looks like it's what you want, but unfortunately it's not. It's just some random magic number like -36 or 173 or something which certain functions understand to mean "ignore this number and look at jjPLAYER::currWeapon instead." In fact, I'm not sure I'd endorse using it at all—it works in the cases that it works, but that requires you to keep track of which cases those are, and that's a quirk of the API instead of a quirk of JJ2.
__________________

Last edited by Violet CLM; Jan 12, 2016 at 12:04 AM.
XxMoNsTeRXM XxMoNsTeRXM's Avatar

JCF Member

Joined: Sep 2013

Posts: 191

XxMoNsTeRXM is doing well so far

Apr 22, 2016, 07:56 AM
XxMoNsTeRXM is offline
Reply With Quote
In the new 5.2 plus update they were added privileges, but they don't work for me and I don't know why.
Here are the admin.ini settings:
Code:
[Admin.Settings]
Enabled=True
Password=somepassword
Spammers=false

[Admin.IPs]

[Admin.AllowedCommands]
r
c
k
start
stop
bluescore
redscore
greenscore
yellowscore
gamemode
coop
battle
ctf
treasure
dom
jb

[Admin.BlockedCommands]

[Admin.Privileges]
*:admin
And here is the script with which I test it:
Code:
bool pressed;

void onPlayer(jjPLAYER@ p) {
	if (jjKey[0x5A] && !pressed) {
		jjAlert(p.hasPrivilege("admin", jjScriptModuleID) + "");
	}
	pressed = jjKey[0x5A];
}
If I am logged in the "Admin" group, and press Z, it says false (which means that I don't have the privilege), but I added the privilege in Admin.Privileges.
__________________
~XxMoNsTeR
Seren Seren's Avatar

JCF Member

Joined: Feb 2010

Posts: 864

Seren is a name known to allSeren is a name known to allSeren is a name known to allSeren is a name known to allSeren is a name known to allSeren is a name known to all

Apr 22, 2016, 08:32 AM
Seren is offline
Reply With Quote
Docs for hasPrivilege:
Quote:
Because privileges are only known to the host, this function will always return false if called client-side.
Correct usage of privileges assumes a setup where messages (in form of chat or custom packets) are sent to the host, who can then use the privilege list to determine whether they are valid requests.

On a side note, the privilege *:admin can be shortened to just admin for convenience.
__________________

I am an official JJ2+ programmer and this has been an official JJ2+ statement.
XxMoNsTeRXM XxMoNsTeRXM's Avatar

JCF Member

Joined: Sep 2013

Posts: 191

XxMoNsTeRXM is doing well so far

Apr 22, 2016, 09:48 AM
XxMoNsTeRXM is offline
Reply With Quote
ah, ok
__________________
~XxMoNsTeR
Old Apr 26, 2016, 08:01 AM
Stijn
This message has been deleted by Stijn. Reason: I know why this happened
Old May 2, 2016, 04:51 AM
Stijn
This message has been deleted by Stijn. Reason: talk less, think more
AvalancheMaster AvalancheMaster's Avatar

JCF Member

Joined: Sep 2013

Posts: 89

AvalancheMaster is doing well so far

Jul 13, 2016, 10:13 AM
AvalancheMaster is offline
Reply With Quote
How do I address the banana of the monkey enemy? I want to make the monkey throw the regular food banana, which bounces off masked tiles, and explodes after 2 seconds, throwing off three smaller bananas (kind of like the banana bomb in Worms World Party).

Also, is it possible to use SPRITE::PLAYER in any way so that the darker fur on the animal is shifted to white? Or do I have to find a workaround this?

EDIT: never mind the last part. I got the colors correctly; still struggling to address the banana.


Last edited by AvalancheMaster; Jul 13, 2016 at 02:11 PM.
Violet CLM Violet CLM's Avatar

JCF Éminence Grise

Joined: Mar 2001

Posts: 10,978

Violet CLM has disabled reputation

Jul 13, 2016, 06:43 PM
Violet CLM is offline
Reply With Quote
What I would do is search for objects whose behavior is BEHAVIOR::MONKEYBULLET and assign them a new behavior in your script that does the things you want it to do.
__________________
AvalancheMaster AvalancheMaster's Avatar

JCF Member

Joined: Sep 2013

Posts: 89

AvalancheMaster is doing well so far

Jul 13, 2016, 07:04 PM
AvalancheMaster is offline
Reply With Quote
So I can change existing behavior, not only behavior of objects?

I thought the only thing I could do is search for existing objects, and assign a new behavior to them. I thought this would mean re-creating the monkey behavior from scratch.

EDIT: To expand upon my question, MONKEYBULLET is a behavior without an object. I think the easiest way would be to create a new object, monkeyBanana, which will, in turn, when exploding, create three instances of MONKEYBULLET. Am I able to replace behavior with object?

Last edited by AvalancheMaster; Jul 13, 2016 at 07:16 PM.
Violet CLM Violet CLM's Avatar

JCF Éminence Grise

Joined: Mar 2001

Posts: 10,978

Violet CLM has disabled reputation

Jul 13, 2016, 08:00 PM
Violet CLM is offline
Reply With Quote
Objects whose behavior is BEHAVIOR::MONKEY will create objects whose behavior is BEHAVIOR::MONKEYBULLET. You can in turn do a loop over existing objects, find the ones whose behavior is BEHAVIOR::MONKEYBULLET, and change their behaviors to something else.

It's also possible to recreate BEHAVIOR::MONKEY, either completely or just the tick in which it throws a banana, but that would be more work.
__________________
AvalancheMaster AvalancheMaster's Avatar

JCF Member

Joined: Sep 2013

Posts: 89

AvalancheMaster is doing well so far

Jul 13, 2016, 08:05 PM
AvalancheMaster is offline
Reply With Quote
So, for example, I can replace all instances of BEHAVIOR::MONKEYBULLET with BEHAVIOR:WITCHBULLET.

But if I want BEHAVIOR::MONKEYBULLET to be changed by a new behavior, which creates an instance of BEHAVIOR::MONKEYBULLET, I believe that will be problematic.

Correct?
Violet CLM Violet CLM's Avatar

JCF Éminence Grise

Joined: Mar 2001

Posts: 10,978

Violet CLM has disabled reputation

Jul 13, 2016, 08:20 PM
Violet CLM is offline
Reply With Quote
You could replace instances of BEHAVIOR::MONKEYBULLET with a custom behavior that creates instances of (objects using ) a different custom behavior that calls behave(BEHAVIOR::MONKEYBULLET)
__________________
AvalancheMaster AvalancheMaster's Avatar

JCF Member

Joined: Sep 2013

Posts: 89

AvalancheMaster is doing well so far

Jul 13, 2016, 09:40 PM
AvalancheMaster is offline
Reply With Quote
Maybe I don't understand what you mean.

So, I have placed various MONKEY and STANDMONKEY enemies in my level. I want to modify the behavior of their MONKEYBULLETs. The new behavior will include in itself BEHAVIOR::MONKEYBULLET.

For me to create this, I will need to recreate the MONKEY behavior, correct?
Violet CLM Violet CLM's Avatar

JCF Éminence Grise

Joined: Mar 2001

Posts: 10,978

Violet CLM has disabled reputation

Jul 13, 2016, 10:56 PM
Violet CLM is offline
Reply With Quote
Code:
void onMain() {
  for (int i = 1; i < jjObjectCount; ++i) {
    jjOBJ@ obj = jjObjects[i];
    if (obj.behavior == BEHAVIOR::MONKEYBULLET)
      obj.behavior = BananaMaker;
  }
}
void BananaMaker(jjOBJ@ obj) {
  //bounce off walls and stuff, then eventually:
  jjAddObject(OBJECT::BULLET, obj.xPos, obj.yPos, obj.objectID, OBJECT::CREATOR, function(obj){ obj.behave(BEHAVIOR::MONKEYBULLET); });
}
Something like that. Yes, you could recreate the monkey behavior and skip over this stuff, but the above feels like less work for nearly the same effect.
__________________
AvalancheMaster AvalancheMaster's Avatar

JCF Member

Joined: Sep 2013

Posts: 89

AvalancheMaster is doing well so far

Jul 14, 2016, 01:24 AM
AvalancheMaster is offline
Reply With Quote
Wouldn't that cause the new object to spawn itself, since we are replacing all instances of BEHAVIOR:: MONKEYBULLET?
Old Jul 14, 2016, 01:57 AM
AvalancheMaster
This message has been deleted by AvalancheMaster. Reason: Two instances of the same post. Lesson learned: do not refresh page immediately after posting.
Violet CLM Violet CLM's Avatar

JCF Éminence Grise

Joined: Mar 2001

Posts: 10,978

Violet CLM has disabled reputation

Jul 14, 2016, 08:07 AM
Violet CLM is offline
Reply With Quote
No, that is and continues to be the point of jjOBJ::behave
__________________
Exploder Exploder's Avatar

JCF Member

Joined: Jul 2016

Posts: 3

Exploder is doing well so far

Jul 21, 2016, 06:56 AM
Exploder is offline
Reply With Quote
Sorry if this is a stupid question, is it possible to set an enemy monster's team?

Example of what I mean: Making a turtle on the blue team (Cannot be attacked by blue players and doesn't hurt them).
Violet CLM Violet CLM's Avatar

JCF Éminence Grise

Joined: Mar 2001

Posts: 10,978

Violet CLM has disabled reputation

Jul 21, 2016, 07:58 AM
Violet CLM is offline
Reply With Quote
Yeah, you'd want to write an onObjectHit that compared the jjPLAYER::team to a team variable specific to the enemy.
__________________
AvalancheMaster AvalancheMaster's Avatar

JCF Member

Joined: Sep 2013

Posts: 89

AvalancheMaster is doing well so far

Jul 21, 2016, 08:00 AM
AvalancheMaster is offline
Reply With Quote
Quote:
Originally Posted by Exploder View Post
Sorry if this is a stupid question, is it possible to set an enemy monster's team?

Example of what I mean: Making a turtle on the blue team (Cannot be attacked by blue players and doesn't hurt them).
A little off-topic, but that is one of the more original uses of AngelScript I've heard here. I think it would be possible to make the smoke rings of the Caterpillar affect only one team.
AvalancheMaster AvalancheMaster's Avatar

JCF Member

Joined: Sep 2013

Posts: 89

AvalancheMaster is doing well so far

Jul 23, 2016, 09:51 AM
AvalancheMaster is offline
Reply With Quote
Is there a way I can achieve this effect? I know for sure I'll have to use Pixelmapping, but I am stuck on the part where I need to define the player/object entering/leaving the area.

Reply

Tags
angelscript, code, jcs, request

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump

All times are GMT -8. The time now is 06:47 AM.