JazzJackrabbit Community Forums

JazzJackrabbit Community Forums (http://www.jazz2online.com/jcf/index.php)
-   JCS & Scripting (http://www.jazz2online.com/jcf/forumdisplay.php?f=5)
-   -   JJ2 AngelScript Presets! (http://www.jazz2online.com/jcf/showthread.php?t=19491)

Grytolle Feb 4, 2013 04:24 PM

Works!

DennisKainz Feb 5, 2013 07:53 AM

The only thing I don't like is that when you commit a mistake in the code, you aren't notified of which line and which position your mistake is, nor you are notified of what the expression should be.

eg. "Error at line 3 at position 19: Missing brackets" or "Error at line 4 at position 14: Unknown variable "healtj""

djazz Feb 5, 2013 07:58 AM

Quote:

Originally Posted by Gus (Post 478007)
The only thing I don't like is that when you commit a mistake in the code, you aren't notified of which line and which position your mistake is, nor you are notified of what the expression should be.

Like this?

Quote:

Originally Posted by AngelScript Readme
Any error in or outside of any function will prevent any and all AngelScript from running in the level. To get information about such errors, you will need to add a line AngelscriptDebug=True to the [General] group of plus.ini. (AngelscriptDebug defaults to false.)

The errors prints out in the chatlogger window.

DennisKainz Feb 5, 2013 08:01 AM

Oh ... Sorry ... mistake of mine. I never read the ChatLog, you know.

Foly Feb 6, 2013 07:36 AM

I guess this thread can still be used for some advertising of code snippets:

http://www.jazz2online.com/snippets/50/boomerang-gun/

This is a script that changes the powered up blaster into a boomerang gun. Nothing much more to say about it, you'll see how it works if you try it :)

DennisKainz Feb 6, 2013 02:43 PM

Basic code for subdividing a level into mini-rooms, as in Oddworld games:

if (p.xPos > 0)
if (p.xPos < 640)
if (p.yPos > 0)
if (p.yPos < 480)
p.cameraFreeze(0, 0, false, true);
if (p.xPos > 640)
if (p.xPos < 1280)
if (p.yPos > 0)
if (p.yPos < 480)
p.cameraFreeze(640, 0, false, true);
if (p.xPos > 0)
if (p.xPos < 640)
if (p.yPos > 480)
if (p.yPos < 960)
p.cameraFreeze(0, 480, false, true);
if (p.xPos > 640)
if (p.xPos < 1280)
if (p.yPos > 480)
if (p.yPos < 960)
p.cameraFreeze(640, 480, false, true);

And so on ...

Seren Feb 6, 2013 11:09 PM

Quote:

Originally Posted by Gus (Post 478034)
Basic code for subdividing a level into mini-rooms, as in Oddworld games:

if (p.xPos > 0)
if (p.xPos < 640)
if (p.yPos > 0)
if (p.yPos < 480)
p.cameraFreeze(0, 0, false, true);
if (p.xPos > 640)
if (p.xPos < 1280)
if (p.yPos > 0)
if (p.yPos < 480)
p.cameraFreeze(640, 0, false, true);
if (p.xPos > 0)
if (p.xPos < 640)
if (p.yPos > 480)
if (p.yPos < 960)
p.cameraFreeze(0, 480, false, true);
if (p.xPos > 640)
if (p.xPos < 1280)
if (p.yPos > 480)
if (p.yPos < 960)
p.cameraFreeze(640, 480, false, true);

And so on ...

Or, instead of hundreds of lines for barely medium-sized SP levels, you can use this one-liner:
Code:

void onPlayer()
{
  p.cameraFreeze(p.xPos-p.xPos%640,p.yPos-p.yPos%480,false,true);
}


DennisKainz Feb 7, 2013 02:16 AM

Thank you for your help. I didn't know the % could be used for symmetric number skips.

Hey! I won't need that "rest" custom option anymore, since I can use "if (jjGameTicks = jjGameTicks%700)" for things happening every 10 seconds!

I have sooo much to learn yet...

Jerrythabest Feb 7, 2013 02:29 AM

You can also use "if (jjGameTics % 700 == 0)", saves you half the typing. Also, you'll need to use '==' for comparing ;)

DennisKainz Feb 7, 2013 02:47 AM

Thank you for your advice. Besides, the other expression did not work!

Jerrythabest Feb 7, 2013 04:32 AM

Ah, on second thought your expression wouldn't work indeed. The 'jjGameTicks%700' part would only produce numbers 0-699. It would evaluate to true every gametick for the first 10 seconds, and to false ever after that.

Seren Feb 9, 2013 09:03 AM

[IMG]http://img593.imageshack.us/img593/1457/purplej.png[/IMG]

Violet CLM Feb 9, 2013 11:08 AM

Yeah, that one's definitely planned for inclusion, though I hadn't gotten around to it yet, mostly because gem rings are so much more difficult to do that for.

(If you leave var[0] at 0, do they act as coins? I forget how flexible that code is.)

Seren Feb 9, 2013 11:20 AM

Quote:

Originally Posted by Violet CLM (Post 478086)
(If you leave var[0] at 0, do they act as coins? I forget how flexible that code is.)

A bit. Their colors go disco and on being collected they show how many coins you have, but won't add to the amount.

Jerrythabest Feb 10, 2013 04:46 AM

Haha, nice one. We don't need to enhance any more events in Plus, people will do it through scripts! :D

Violet CLM Feb 10, 2013 11:56 AM

I'll admit I'm hoping someone will figure out for us what Auto Fire and Max Weapon should do as useful events.

minmay Feb 10, 2013 05:59 PM

I always pictured Max Weapon as a power-up box that powered up all your weapons and gave them maximum ammo, just like jjgod without the invincibility. That's just my guess as to what it was originally supposed to be like, though, not a suggestion for what would be a good new event (it wouldn't be a good new event IMO).

Personally I'd just leave them nonexistent and save the JCS.ini space for completely new cool events later.

P.S. Jerrythabest: did you add a mod pattern jump function yet? =P

edit: oops offtopic thought this was the actual JJ2+ thread somehow

Grytolle Feb 10, 2013 10:53 PM

Never heard about that event, but intuitively I'd agree with minmay, except that I'd say without powerups (because of the difference between jjgod and jjammo). I'd probably also limit the ammo received to the kinds of ammo that are already present in the level.

Jerrythabest Feb 11, 2013 12:44 AM

Sounds much like a /ready box to me! :D Put one at each CTF base for pure evilness.


@minmay: I haven't looked into the sound stuff at all, so I'm still clueless about how I would do this. I'm focussing more on graphics at the moment ;)

DennisKainz Feb 11, 2013 04:43 AM

The fault if I got a bad rating for "River Secrets" is partly mine, ofcourse, but it is also because of a lot of missing commands in Angel Script.

Now, I don't know if they will ever be included, nor I know if it's POSSIBLE to include them, and I don't EXPECT them to be created, but if they can be, there they are:
- A command for deactivating special moves (one for JUMP JUMP and one for DUCK JUMP)
- A command for deactivating running mode ("ERR: Reference is read-only)
- One for deactivating buttstomp
- Checking and alterating what Jazz and siblings do ("ERR: "state" is not a member of "jjPlayer")
- Making the ammo pickups give you more or less ammunition (I tried var[0-100] unsuccessfully)
- Making some enemies hurt you more than 1 HP
- Making the max health higher or lower than 5 even in SP mode
- Maybe also making the maximum ammunitions higher than 99 (I had no problem making them LOWER than 99)
- Making the blink time higher or lower (in my case 0) even in SP mode
- A command for deactivating direction changes in midair (if the player isn't standing on the ground or a platform, the direction keys do nothing)

Foly Feb 11, 2013 09:23 AM

Quote:

Originally Posted by Gus (Post 478116)
- A command for deactivating running mode ("ERR: Reference is read-only)

You can limit the speed in onMain or onPlayer:

Pseudocode/code:
if (p.xSpeed > value) p.xSpeed = value;
if (p.xSpeed < -value) p.xSpeed = -value;
p.jumpStrength = othervalue;

Or you can use speed = sqrt(p.xSpeed^2 + p.ySpeed^2) and limit that one, it all depends on how you want it to be limited.

Quote:

Originally Posted by Gus (Post 478116)
- Making the ammo pickups give you more or less ammunition (I tried var[0-100] unsuccessfully)
- Making some enemies hurt you more than 1 HP
- Maybe also making the maximum ammunitions higher than 99 (I had no problem making them LOWER than 99)

It is possible to code this, if you want i can give you a pseudocode/code for it.

Quote:

Originally Posted by Gus (Post 478116)
- Making the max health higher or lower than 5 even in SP mode

In multiplayer use jjChat("maxhealth x"), i don't know if this works in sp too.

Quote:

Originally Posted by Gus (Post 478116)
- A command for deactivating direction changes in midair (if the player isn't standing on the ground or a platform, the direction keys do nothing)

If by this you mean when the player jumps it should keep it's xSpeed, then it should be possible to do this with AS.

As for the other stuff, i don't think it's possible yet to do this in AngelScript, correct me if i'm wrong :)

Seren Feb 11, 2013 10:13 AM

Quote:

Originally Posted by Gus (Post 478116)
- Making the blink time higher or lower (in my case 0) even in SP mode

Code:

if(p.invincibility<0)
{
  p.invincibility=0;
}


DennisKainz Feb 12, 2013 08:18 AM

Indeed, I tried the Invincibility cheat, but it resulted to change the invincibility given from the carrots (the one with the translucent circumferences around Jazz), not the blink time.

I just need to know all the expressions it's possible to find in AngelScript, and their exact meaning. I'm too lazy to test them one by one until I find what I need (IF it exists), and I hope someone will add some more expressions and make a simplified version of the AngelScript someday.

Oh, by the way, the AngelScript manual says "jumpSpeed" instead of "jumpStrength". I hope it was fixed already.

Seren Feb 12, 2013 09:24 AM

Uh, so I assume that invincibility going below 0 when you get hurt is a random artifact. The game changes the value but doesn't read it. Surprisingly, "/noblink on" doesn't work in SP either. Feels like somebody worked really hard to make changes on that front difficult.

Violet CLM Feb 12, 2013 01:22 PM

Quote:

Originally Posted by Gus (Post 478129)
I just need to know all the expressions it's possible to find in AngelScript, and their exact meaning.

http://www.jazz2online.com/jj2plus/p...gelscript.html
Quote:

I'm too lazy to test them one by one until I find what I need (IF it exists)
Well, that's your problem, then.
Quote:

and I hope someone will add some more expressions and make a simplified version of the AngelScript someday.
These are two contradictory goals.
Quote:

Oh, by the way, the AngelScript manual says "jumpSpeed" instead of "jumpStrength". I hope it was fixed already.
http://www.jazz2online.com/jj2plus/p....html#lc020413

Jerrythabest Feb 12, 2013 01:34 PM

Quote:

Originally Posted by Sir Ementaler (Post 478130)
Surprisingly, "/noblink on" doesn't work in SP either. Feels like somebody worked really hard to make changes on that front difficult.

Before the Jan 28th release, commands were only available in online games. They have been written for and tested with online games exclusively. Their availability in offline games is a side effect of the new menus and of the AngelScript API. We haven't come to fixing that yet, which means many commands don't work properly offline (neither through AngelScript nor through the menus). This is a thing on the to-do list.

Seren Feb 12, 2013 01:59 PM

Oh, don't mind that, "somebody" was actually meant to point to an abstract entity, I didn't mean to criticize your work. I just figured out that most MP commands would work in SP as a side-effect of the independent implementations of them and the menus you mention, so I was surprised noblink doesn't. But I acknowledge the situation Plus is in and understand that some features don't yet work as expected or planned.

Jerrythabest Feb 12, 2013 03:03 PM

Oh, no worries, I didn't interpret your post as being offensive or anything. Just decided I'd explain how this happened :)

In fact, we even had the menu items available to admins for a few hours. But that turned out to be so extremely buggy that we've decided to disable them for now.

Violet CLM Feb 16, 2013 10:42 PM

Quote:

Originally Posted by Jerrythabest (Post 477944)
I figure we could provide API access to the drawText series of functions, so people can write their own UI elements.

Turns out yes, we can.
LIZARD
Number of objects in screenshot: three.

Jerrythabest Feb 17, 2013 01:57 AM

Oh wow. OH WOW.

Stijn Feb 17, 2013 02:07 AM

Now all that's needed is a putPixel() function and we can have custom GUIs!

Seren Feb 21, 2013 01:57 PM

Uhm, last time I explained a way of converting integers into strings I didn't mention an even simpler way that also works. I actually did it on purpose, because personally I consider it a rather ugly way, but I just realized that some of you might want to choose it as it takes much less space and doesn't require memorizing a function name. There goes:
Code:

""+value
So, the code I used for testing here:
Code:

void onPlayer()
{
  jjChat(formatInt(jjGameTicks,"l"));
}

can also be changed into the following:
Code:

void onPlayer()
{
  jjChat(""+jjGameTicks);
}

with the same effect. You won't even get warnings about mixing variable types. "" can also be replaced with an actual string, if you want one there.

Side note: Assignment in this manner is also allowed, that is, for example, if you use the following code:
Code:

string name=555;
name will become a declared string that says "555". But that's one really ugly piece of code and I beg you to never do something like that.

Oh, right, and I should mention it works fine with floats too.

Jerrythabest Feb 21, 2013 02:55 PM

Hey, those things remind of PHP. Really, the AngelScript guy (what was his name again?) is less strict than I'd expected at first.

Violet CLM Feb 21, 2013 03:26 PM

Of course, a benefit of formatInt is that it lets you use hexadecimal notation, or padding zeroes, or other such, depending on your specific needs.

Jerrythabest Feb 22, 2013 08:01 AM

You know what would be useful? A reverse-lookup for enums. Like
Code:

jjEnum(2, WEAPON::Weapon);
returns "ICE".

cooba Feb 27, 2013 11:59 AM

Sharing is caring: http://www.jazz2online.com/snippets/...mies-on-touch/

Very much room for improvement (never hurting the player when burning would be a good start)...

Violet CLM Feb 27, 2013 12:13 PM

Quote:

Originally Posted by Jerrythabest (Post 478313)
You know what would be useful? A reverse-lookup for enums. Like
Code:

jjEnum(2, WEAPON::Weapon);
returns "ICE".

Doesn't seem to be a thing AngelScript supports, and presumably for good reason. Not all integers have exactly one enum value that represents them -- some have zero, some have two or more.

Quote:

Originally Posted by cooba (Post 478371)
Sharing is caring

Would o.objType | 16 == 16 work there in place of the long list of eventIDs? Also IIRC you should specify the creator ID in jjAddObject as p.playerID, to ensure the right player gets points for destroying the enemy.

cooba Feb 27, 2013 12:21 PM

Quote:

Originally Posted by Violet CLM (Post 478372)
Would o.objType | 16 == 16 work there in place of the long list of eventIDs?

That doesn't work, but I suppose I can just check enemy.objType >= 16.
Quote:

Originally Posted by Violet CLM (Post 478372)
Also IIRC you should specify the creator ID in jjAddObject as p.playerID, to ensure the right player gets points for destroying the enemy.

There are no points received as all, for some weird reason. Yup, adding that did the trick. Updated.

Seren Feb 27, 2013 12:53 PM

Quote:

Originally Posted by Violet CLM (Post 478372)
o.objType | 16 == 16

o.objType & 16 == 16 ?

Violet CLM Feb 27, 2013 12:56 PM

...yes, that's what I meant. Maybe (o.objType & 16) == 16 just to be safe, since I don't remember AngelScript's order of operator priority.


All times are GMT -8. The time now is 06:48 PM.

Powered by vBulletin® Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
JCF © 2001-Infinity Jazz2Online