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

AngelScript Requests & Help

Reply
 
Thread Tools
Foly Foly's Avatar

JCF Member

Joined: Jan 2009

Posts: 202

Foly has disabled reputation

Feb 16, 2013, 12:57 AM
Foly is offline
Reply With Quote
AngelScript Requests & Help

Since there is no thread like this yet, I've decided to make one. This thread is about requests for scripts and help with JJ2 AngelScript. You can post requests for scripts you want to use in your level and ask people for help when something is not working with your code or you don't know if something is executeable.

There are a few rules/guidelines for posting:
  • When your code is long use a spoiler or link to the code instead.
  • Stay on topic, that also means no discussions about what should be added to jj2+ (there is another thread for that).
  • You can post critics about another code, just make sure this is really going to improve the code and not just changes the style of coding. Also if your code is criticized don't start a flamewar, let others decide if the critics are justified.
  • Be specific with what you want, if you want a frog to fly don't forget to mention how it will fly (i.e. floating at one tile or following the player like a bird).
  • If you know how to code consider asking for pseudocode instead, it is more likely people respond to pseudocode requests.
  • If your code is level specific consider posting the level.
Know that some requests are too hard/long or people don't always have motivation or time to spend to help you. Personally I don't mind to create some codes for other people, so don't think you shouldn't post because noone is going to help you
__________________
[13:07:13] *** Foly is on a KILLING SPREE!
[13:07:14] *** you killed yourself
[13:07:14] *** Foly was looking good but died instead...

Last edited by Foly; Feb 16, 2013 at 11:54 PM.
DoubleGJ DoubleGJ's Avatar

JCF Member

Joined: Sep 2002

Posts: 3,049

DoubleGJ has disabled reputation

Aug 9, 2013, 04:42 AM
DoubleGJ is offline
Reply With Quote
Digging up this thread with a plea for help.

I'm absolutely new to this scripting thing so pardon me if I ask for something completely obvious, but is it possible to write a script so a particular sucker tube will only work if a player moves with enough speed while touching it?
__________________
"So unless I overwrote my heart with yours, I think not. But I might have." - Violet CLM

Two Games Joined releases:
Control / Splinter (twin singles)
|| Ballistic Bunny (EP)
||
Beyond (maxi-single)
|| Beyond: Remixed (remix EP)
|| Inner Monsters OST (mini-album)
||
Shadows (album)
Violet CLM Violet CLM's Avatar

JCF Éminence Grise

Joined: Mar 2001

Posts: 10,978

Violet CLM has disabled reputation

Aug 9, 2013, 10:50 AM
Violet CLM is offline
Reply With Quote
You could try making your own sucker tube out of an onFunction# and the xSpeed, ySpeed, xPos, yPos, ballTime, and noClip properties, but there would still end up being some things you couldn't set at the moment, like turning off special moves. jjEventSet is probably closer to what you want.
__________________
MilloCz2

JCF Member

Joined: Aug 2013

Posts: 5

MilloCz2 is doing well so far

Aug 14, 2013, 04:12 PM
MilloCz2 is offline
Reply With Quote
Could someone explain me please why jjTileSet function does not work properly?

To describe problem: I want it to create 1 tile in the air in the cords X,Y in layer 4. It does not create that 1 tile, but it creates invisible pillars all around the map. I really have no clue why.

If you haven't tried it, you can:
Quote:
void onLevelLoad(){
jjTileSet(4,0,0,8);
}
You can pick any map with any tileset, but created tile (in my code, tile with number 8) should be masked.

Last edited by MilloCz2; Aug 14, 2013 at 04:26 PM.
Violet CLM Violet CLM's Avatar

JCF Éminence Grise

Joined: Mar 2001

Posts: 10,978

Violet CLM has disabled reputation

Aug 14, 2013, 05:47 PM
Violet CLM is offline
Reply With Quote
The 4x1 tile block you're setting a tile in is not unique to that position, therefore all other instances of that same 4x1 block receive the same change. The easiest way to ensure uniqueness is to make one of the tiles an animated tile and place an event—even one that doesn't do anything—on that animated tile.
__________________
MilloCz2

JCF Member

Joined: Aug 2013

Posts: 5

MilloCz2 is doing well so far

Aug 15, 2013, 02:58 AM
MilloCz2 is offline
Reply With Quote
Hah, thanks for quick reply! I will check it out.

(1) Also, is there any way how to show int/doubles etc. in showText/in jjDebug ?

EDIT: (2) What are some good ways of player's INPUT ? I have seen pressing buttons 1-9 as weapon change; is there anything better? Such as input text via jj2 chat?

I'm just starting, both with Angelscript and C++ and I'm very interested in it, since JJ2 is one of my most favourite games.

Last edited by MilloCz2; Aug 15, 2013 at 03:32 AM.
Violet CLM Violet CLM's Avatar

JCF Éminence Grise

Joined: Mar 2001

Posts: 10,978

Violet CLM has disabled reputation

Aug 15, 2013, 03:50 AM
Violet CLM is offline
Reply With Quote
(1) AngelScript has a built-in (i.e. I didn't write it) function formatInt which does what you're looking for and can output in a variety of formats. Search the documentation for details.

(2) There's no direct way of accessing input in the most recent release, but it'll turn up later. "Player-Guided Missile" on J2O is an example of indirectly testing the left and right arrow keys (or A/D or whatever the player happens to be using).
__________________
PurpleJazz PurpleJazz's Avatar

JCF Member

Joined: Aug 2006

Posts: 852

PurpleJazz is OFF DA CHARTPurpleJazz is OFF DA CHARTPurpleJazz is OFF DA CHART

Aug 17, 2013, 01:28 AM
PurpleJazz is offline
Reply With Quote
Is there any way of detecting whether or not a playing is currently pressing the fire button? I'm trying to write a script where the player's ammo regenerates over a period of time, with a short delay after the last press of the fire button. This would stop ammo from regenerating continuously even when the player is constantly firing.
Violet CLM Violet CLM's Avatar

JCF Éminence Grise

Joined: Mar 2001

Posts: 10,978

Violet CLM has disabled reputation

Aug 17, 2013, 01:40 AM
Violet CLM is offline
Reply With Quote
Nope. But you could check whether the ammo count has gone down lately?
__________________
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

Aug 17, 2013, 09:16 AM
Seren is offline
Reply With Quote
This is another possible solution that has insignificantly longer execution time but doesn't use global variables and is more flexible (can be used for players who aren't local):
Code:
bool playerHasShot(jjPLAYER@ player){
  jjOBJ@ obj;
  for(int i=0;i<jjObjectCount;i++){
    @obj=jjObjects[i];
    if(obj.isActive&&(obj.eventID<OBJECT::SMOKERING||obj.eventID==OBJECT::TNT)&&obj.creatorType==CREATOR::PLAYER&&jjPlayers[obj.creator] is player&&(obj.state==STATE::FLY||obj.state==STATE::ROCKETFLY)&&obj.counter==1) return true;
  }
  return false;
}
__________________

I am an official JJ2+ programmer and this has been an official JJ2+ statement.

Last edited by Sir Ementaler; Aug 17, 2013 at 03:15 PM.
Jerrythabest Jerrythabest's Avatar

JCF Member

Joined: Apr 2005

Posts: 2,602

Jerrythabest is a forum legendJerrythabest is a forum legendJerrythabest is a forum legend

Aug 17, 2013, 02:41 PM
Jerrythabest is offline
Reply With Quote
Whoa, that script could use some white space and comments. Is it checking whether a new bullet of a certain player has appeared?
__________________
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

Aug 17, 2013, 03:23 PM
Seren is offline
Reply With Quote
If there exists an object that is active, is a bullet, was created by the player the function is called for, and has parameters that indicate it has just spawned, return true, otherwise don't.
__________________

I am an official JJ2+ programmer and this has been an official JJ2+ statement.
MilloCz

JCF Member

Joined: Jan 2011

Posts: 24

MilloCz is doing well so far

Aug 29, 2013, 09:50 AM
MilloCz is offline
Reply With Quote
Hey it's me again.

Could you tell me how to properly use formatInt? Since I don't understand it. I need jjAlert to display "You have X coins." (where X represents the number of coins you have)
cooba cooba's Avatar

JCF Veteran

Joined: Jan 2004

Posts: 7,812

cooba is a glorious beacon of lightcooba is a glorious beacon of lightcooba is a glorious beacon of lightcooba is a glorious beacon of lightcooba is a glorious beacon of lightcooba is a glorious beacon of light

Aug 29, 2013, 09:52 AM
cooba is offline
Reply With Quote
Code:
jjAlert("You have " + p.coins + " coins.");
MilloCz

JCF Member

Joined: Jan 2011

Posts: 24

MilloCz is doing well so far

Aug 29, 2013, 11:06 AM
MilloCz is offline
Reply With Quote
Oh, when I last tried to write it like that, I forgot to include +'s.
Thanks.
MilloCz

JCF Member

Joined: Jan 2011

Posts: 24

MilloCz is doing well so far

Sep 1, 2013, 08:54 AM
MilloCz is offline
Reply With Quote
Another question: Why doesn't jjEventSet(p.xPos,p.yPos, 65) work for creating objects like, diamonds? It creates nothing instead, while 65 = Blue gem's ID. Doesn't work even for "OBJECT::BLUEGEM".
cooba cooba's Avatar

JCF Veteran

Joined: Jan 2004

Posts: 7,812

cooba is a glorious beacon of lightcooba is a glorious beacon of lightcooba is a glorious beacon of lightcooba is a glorious beacon of lightcooba is a glorious beacon of lightcooba is a glorious beacon of light

Sep 1, 2013, 09:34 AM
cooba is offline
Reply With Quote
Code:
jjAddObject(OBJECT::BLUEGEM, p.xPos, p.yPos);
?
Violet CLM Violet CLM's Avatar

JCF Éminence Grise

Joined: Mar 2001

Posts: 10,978

Violet CLM has disabled reputation

Sep 1, 2013, 10:40 AM
Violet CLM is offline
Reply With Quote
Also, you'd want jjEventSet(p.xPos / 32,p.yPos / 32, OBJECT::BLUEGEM) to the extent that worked at all, since events occupy whole tiles.
__________________
MilloCz

JCF Member

Joined: Jan 2011

Posts: 24

MilloCz is doing well so far

Sep 2, 2013, 01:13 AM
MilloCz is offline
Reply With Quote
Quote:
Originally Posted by Violet CLM View Post
Also, you'd want jjEventSet(p.xPos / 32,p.yPos / 32, OBJECT::BLUEGEM) to the extent that worked at all, since events occupy whole tiles.
Well I give an example; If I place vine event on block and then I use jjEventSet BLUEGEM on the block, the vine disappears, but gem does not appear.

(this works even without dividing xPos by 32)
Toni_

JCF Member

Joined: Oct 2011

Posts: 193

Toni_ is doing well so far

Sep 6, 2013, 11:20 AM
Toni_ is offline
Reply With Quote
I know nothing about angel scripting and it's possibilities, so I will ask some questions:

- is it possible to change counting on DOM level, so the checkpoint increases your points every 10 seconds? For example if your team has 3 CPs, your score increases by 3 every 10 seconds.

- is it possible to trigger somehow gems in DOM, so if your team owns checkpoint, you can spawn at that area? Otherwise you spawn at another CP you own, or your team loses.

- is it possible to make gems first neutralize and then capture, just like on beginning of the game? For example, red team captures the CP, blue player neutralizes it by standing there for 5 seconds (and nobody can spawn there when it's neutralized), and after that 5 more seconds to capture the checkpoint so players could spawn there.

I am trying to make something that looks similar to Shadowgun's Zone Control gamemode. That could work very well in JJ2 with some changes.

Last edited by Toni_; Oct 20, 2013 at 07:28 AM.
Toni_

JCF Member

Joined: Oct 2011

Posts: 193

Toni_ is doing well so far

Sep 14, 2013, 11:22 AM
Toni_ is offline
Reply With Quote
Could anyone answer me, please?
Foly Foly's Avatar

JCF Member

Joined: Jan 2009

Posts: 202

Foly has disabled reputation

Sep 14, 2013, 12:39 PM
Foly is offline
Reply With Quote
I don't think this is possible yet because there is no OBJECT:: DOMAREA. I've also tried to see if I could get the handle of a DOM object in case it's just another object with special properties but no luck there too.
__________________
[13:07:13] *** Foly is on a KILLING SPREE!
[13:07:14] *** you killed yourself
[13:07:14] *** Foly was looking good but died instead...
Toni_

JCF Member

Joined: Oct 2011

Posts: 193

Toni_ is doing well so far

Sep 14, 2013, 02:22 PM
Toni_ is offline
Reply With Quote
I have no knowledge of angel script, but is something like this possible? I will just try to show what I mean, without any real function there.

if gemCaptured = TRUE (activate some trigger)

where trigger is area (for example) 15x15 tiles around the gem, and when player spawns, he can warp there.
Violet CLM Violet CLM's Avatar

JCF Éminence Grise

Joined: Mar 2001

Posts: 10,978

Violet CLM has disabled reputation

Sep 14, 2013, 02:37 PM
Violet CLM is offline
Reply With Quote
JJ2+ doesn't presently allow you direct scripting access to DOM mechanics, but you could probably make your own facsimile.
__________________
Toni_

JCF Member

Joined: Oct 2011

Posts: 193

Toni_ is doing well so far

Sep 15, 2013, 04:30 AM
Toni_ is offline
Reply With Quote
Not sure if I understand you what you wanted to tell me about Foly's level, but I am sad to hear that DOM scripting isn't possible.
Foly Foly's Avatar

JCF Member

Joined: Jan 2009

Posts: 202

Foly has disabled reputation

Sep 15, 2013, 04:42 AM
Foly is offline
Reply With Quote
Quote:
Originally Posted by Just a Random User View Post
Not sure if I understand you what you wanted to tell me about Foly's level, but I am sad to hear that DOM scripting isn't possible.
He means it is also possible to create your own domination area's like I did in that level, although looking back at that level I think it's a bit sloppy
__________________
[13:07:13] *** Foly is on a KILLING SPREE!
[13:07:14] *** you killed yourself
[13:07:14] *** Foly was looking good but died instead...
minmay

JCF Member

Joined: Aug 2002

Posts: 1,184

minmay is immeasurably awesomeminmay is immeasurably awesomeminmay is immeasurably awesomeminmay is immeasurably awesomeminmay is immeasurably awesome

Oct 28, 2013, 09:15 PM
minmay is offline
Reply With Quote
Is there any reliable way to check if a non-local player is spectating via AngelScript?
Violet CLM Violet CLM's Avatar

JCF Éminence Grise

Joined: Mar 2001

Posts: 10,978

Violet CLM has disabled reputation

Oct 28, 2013, 10:11 PM
Violet CLM is offline
Reply With Quote
Testing their position for being inside the level (instead of at 0,0) seems to be the preferred method at present.
__________________
minmay

JCF Member

Joined: Aug 2002

Posts: 1,184

minmay is immeasurably awesomeminmay is immeasurably awesomeminmay is immeasurably awesomeminmay is immeasurably awesomeminmay is immeasurably awesome

Oct 28, 2013, 10:46 PM
minmay is offline
Reply With Quote
I've tried that, but their position seems to lag a few frames behind when they actually start spectating (at least going by the console announcement)...even if they're the server!
Violet CLM Violet CLM's Avatar

JCF Éminence Grise

Joined: Mar 2001

Posts: 10,978

Violet CLM has disabled reputation

Oct 28, 2013, 10:53 PM
Violet CLM is offline
Reply With Quote
Console announcements are, without exception that I can think of, barely more than normal chat messages. They do not reflect the client receiving a notification to actually update any values locally.
__________________
minmay

JCF Member

Joined: Aug 2002

Posts: 1,184

minmay is immeasurably awesomeminmay is immeasurably awesomeminmay is immeasurably awesomeminmay is immeasurably awesomeminmay is immeasurably awesome

Oct 28, 2013, 11:22 PM
minmay is offline
Reply With Quote
Hm, I was expecting they would at least coincide in the server's case.
DoubleGJ DoubleGJ's Avatar

JCF Member

Joined: Sep 2002

Posts: 3,049

DoubleGJ has disabled reputation

Oct 30, 2013, 09:43 AM
DoubleGJ is offline
Reply With Quote
I'm having trouble with using parameters in place of numerical values. I tried making a script that would spawn an object and make it constantly float near the player, but simply inputting p.xPos and p.yPos for the object's x and y values breaks the whole script. Is there any particular syntax I must use to make this work?
__________________
"So unless I overwrote my heart with yours, I think not. But I might have." - Violet CLM

Two Games Joined releases:
Control / Splinter (twin singles)
|| Ballistic Bunny (EP)
||
Beyond (maxi-single)
|| Beyond: Remixed (remix EP)
|| Inner Monsters OST (mini-album)
||
Shadows (album)
Violet CLM Violet CLM's Avatar

JCF Éminence Grise

Joined: Mar 2001

Posts: 10,978

Violet CLM has disabled reputation

Oct 30, 2013, 10:03 AM
Violet CLM is offline
Reply With Quote
Sorry, that description's much too vague for me to diagnose your problem. My best guess is that either a) "p" is not a defined variable at the time the function is called or b) you're not passing the parameters in the correct order. If that's not it, you may have to post some more of your code for inspection.
__________________
DoubleGJ DoubleGJ's Avatar

JCF Member

Joined: Sep 2002

Posts: 3,049

DoubleGJ has disabled reputation

Oct 30, 2013, 10:44 AM
DoubleGJ is offline
Reply With Quote
Okay. Here's how it looks right now, for testing purposes:

void onFunction1()
{
jjOBJ@ angryegg = jjObjects[jjAddObject(OBJECT::EGGPLANT, p.xPos + 50, p.yPos + 50)];
angryegg.bulletHandling(HANDLING::IGNOREBULLET);
angryegg.xPos = p.xPos + 50;
angryegg.yPos = p.yPos + 50;
}

that's the whole thing so far.
__________________
"So unless I overwrote my heart with yours, I think not. But I might have." - Violet CLM

Two Games Joined releases:
Control / Splinter (twin singles)
|| Ballistic Bunny (EP)
||
Beyond (maxi-single)
|| Beyond: Remixed (remix EP)
|| Inner Monsters OST (mini-album)
||
Shadows (album)
cooba cooba's Avatar

JCF Veteran

Joined: Jan 2004

Posts: 7,812

cooba is a glorious beacon of lightcooba is a glorious beacon of lightcooba is a glorious beacon of lightcooba is a glorious beacon of lightcooba is a glorious beacon of lightcooba is a glorious beacon of light

Oct 30, 2013, 10:44 AM
cooba is offline
Reply With Quote
p as a global property got deprecated. You need to use this:
Code:
void onFunction1(jjPLAYER@ p)
This will spawn the eggplant, but not constantly adjust its position. plusHeaven has an example of an object behaving the way you want.
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

Oct 30, 2013, 11:13 AM
Seren is offline
Reply With Quote
Quote:
Originally Posted by DoubleGJ View Post
angryegg.bulletHandling(HANDLING::IGNOREBULLET);
bulletHandling is not a function.
Code:
angryegg.bulletHandling=HANDLING::IGNOREBULLET;
__________________

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

JCF Member

Joined: Sep 2002

Posts: 3,049

DoubleGJ has disabled reputation

Oct 30, 2013, 11:33 AM
DoubleGJ is offline
Reply With Quote
ok after the fixes it works somewhat... the eggplant appears where it should, but when I try to make it stay there with onMain, it says I didn't declare angryegg and I don't know what to do
__________________
"So unless I overwrote my heart with yours, I think not. But I might have." - Violet CLM

Two Games Joined releases:
Control / Splinter (twin singles)
|| Ballistic Bunny (EP)
||
Beyond (maxi-single)
|| Beyond: Remixed (remix EP)
|| Inner Monsters OST (mini-album)
||
Shadows (album)
cooba cooba's Avatar

JCF Veteran

Joined: Jan 2004

Posts: 7,812

cooba is a glorious beacon of lightcooba is a glorious beacon of lightcooba is a glorious beacon of lightcooba is a glorious beacon of lightcooba is a glorious beacon of lightcooba is a glorious beacon of light

Oct 30, 2013, 12:06 PM
cooba is offline
Reply With Quote
The beauty of custom behaviors is that you no longer need onMain to do anything complicated with objects:
Code:
void AngryEgg(jjOBJ@ obj) {
	jjPLAYER@ p = jjLocalPlayers[obj.creatorID];
	obj.xPos = p.xPos + 50;
	obj.yPos = p.yPos + 50;
	obj.draw();
}

void onLevelLoad() {
	jjObjectPresets[OBJECT::EGGPLANT].behavior = AngryEgg;
	jjObjectPresets[OBJECT::EGGPLANT].bulletHandling = HANDLING::IGNOREBULLET;
}

void onFunction1(jjPLAYER@ p) {
	jjAddObject(OBJECT::EGGPLANT, p.xPos + 50, p.yPos + 50, p.playerID, CREATOR::PLAYER);
	jjAlert("Eggplant added!");
}
Violet CLM Violet CLM's Avatar

JCF Éminence Grise

Joined: Mar 2001

Posts: 10,978

Violet CLM has disabled reputation

Oct 30, 2013, 12:22 PM
Violet CLM is offline
Reply With Quote
p the global object should still work, though—deprecated is not the same thing as removed.
__________________
Jerrythabest Jerrythabest's Avatar

JCF Member

Joined: Apr 2005

Posts: 2,602

Jerrythabest is a forum legendJerrythabest is a forum legendJerrythabest is a forum legend

Oct 30, 2013, 03:36 PM
Jerrythabest is offline
Reply With Quote
AngryEgg? I see some Angry Birds game coming!
__________________
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 09:07 AM.