![]() |
JJ2 AngelScript Presets!
Hello everyone, I'm starting this official thread to collect some easy preset codes for jj2's AngelScript so people won't have to make it over and over. It's also a tool to help new people understand seperately without being overwhelmed by really big scripts. only post basic preset scripts please, without much addition. for example, my script about giving a random power up to random players. I'm not adding all kinds of gimmicks like 3% chance of shield and fastfire, unlimited ammo on certain weapons and so on: keep it basic / editable.
Everyone is free to post Angelscripts here that quoted. I will try to compile them in this newspost. I made up a few categories myself (name more if you like). Also make sure your code works well. Text covered in red will be the variables you change Weapon and firing related Code:
Full Ammo randomizer #1 - Cooba (works multiple times)Code:
-Code:
-Code:
-Code:
Day and Night cycle - Sir ElementalerCode:
-Code:
-Code:
-Code:
Punish campers - Grytolle |
Great idea for a thread.
Allow me to submit my own ammo randomizer, though! Not that anything is technically wrong with Faw's (very good and ambitious first script), of course. Code:
int num; |
I would really love to see a Respawn trigger crate script for any ID explained, short and with variables!
|
Maybe this should be done on ERE? Or is the wiki too broken?
|
Working on a code snippet section for J2O as we speak. Of course, as usual with whatever I'm working on, no ETA.
Meanwhile, if you have any feature requests for such a thing already, post them here. |
I want something else than JCF for this too, something easier to look over and with search functions. Meanwhile, best is to use this till there is another solution.
|
Quote:
1) Trigger crates only query their Trigger ID when they're destroyed, so it's a question of the xOrg/yOrg bitfeld, not setting some other property to the desired ID. 2) Unless you're doing a single player level, you should probably use a generator object instead, so that the trigger crate is shared throughout the server. Otherwise you run the risk of the crate only existing locally and thus only changing a trigger locally. If you still want such a script, though, I'd be tempted to do something like this pseudocode: Code:
class myTriggerCrateGenerator: |
Quote:
The thing i just want is to regenerate any trigger crate ID that is not just ID 31 that also works in MP (as in works as well as a normal trigger crate). I've never scripted before this update, i also have no idea what psuedo-code is. I just keep wondering if this is possible for MP, and i still haven't got clear answers yet. |
|
Quote:
Code:
formatInt(value,"l"); |
Quote:
Either i did it wrong or it isn't build in with jj2+. |
I hadn't been sure either so I had checked it before I posted that, it works just fine. Try something like this (in multiplayer) to test:
Code:
void onPlayer() |
Quote:
|
I found this for syntax highlighting of AngelScript in Notepad++.
I just dropped it in the program folder\plugins\APIs, and then I am able to select it for a specific file by clicking Language -> AngelScript. It would be nicer if it could be made so that it automatically identifies .j2as files as AngelScript, but I couldn't get it to work and I'm not really intending to try coding anything myself at the moment, so I'll leave that up to you. AngelScript syntax highlighting |
Quote:
|
Add 32 to the leftmost MCE Event's "Event" parameter to make it act as an Off crate, or 64 to make it act as a Switch crate.
|
Day / night cycle
This script will smoothly change tileset palette between day and night. If used in multiplayer, it works for every client locally, meaning that each client will see a different time of the day. Code:
const uint dnCYCLELENGTH=700;
In team games, this script will let players heal their teammates by shooting ice bullets at them. A single bullet can heal multiple people. Each bullet will heal 1 heart of damage. If freezer is powered-up, it shoots two bullets, so if both hit a player, it heals 2 hearts of damage in total. It won't heal the person who shot the bullet nor members of the opposite team. Code:
void onPlayer() |
I would appreciate if someone writes a script that:
1) Makes text on text events not bouncing, or bouncing even more. 2) Changing direction of text on text events appearing. (Default is from right to left) 3) Makes it appear on different horizontal line. |
Just A Random User: I am pretty sure that such functions first need to be implemented in plus.dll, not really anything that a script can solve.
Punish campers xd! This was the first thing I could think of when I wanted to try out AngelScript, but it could probably be altered quite easily for trigger-like purposes or something. It also illustrates the use of (multi-layered) arrays and return in conjunction with an array. semi.j2as: Pastebin'd for easier reading Code:
old code removed to save spaceEdit2: It would make more sense to execute jjPlayers[player].showText("You are camping " + campAreaName[camparea]); outside of the function. If there are more improvements that will have to be made, I will work that into the next version. :P |
Oh NICE Grytolle! That one's REALLY awesome :D
|
Punishment should be -1h. Killing a player sounds too severe. If I use this script, will this work for -1h punishment?
Code:
if (isCamping[1]) |
Quote:
Code:
p.health -= 1;Code:
jjPlayers[pID].pHealth -= 1;Please use pastebin to see everything properly: http://pastebin.com/fwQ1Q3b9 Code:
saving space |
Quote:
|
Quote:
SE, are you proposing drawing text manually by creating objects with individual characters as their sprites? If so, that's very resourceful, but eww. |
Quote:
[IMG]http://img845.imageshack.us/img845/5228/seas1.png[/IMG] But hey, for short enough strings it works! |
I figure we could provide API access to the drawText series of functions, so people can write their own UI elements. By doing it that way such elements would benefit from the fact that someday I'll implement 3D support for the UI itself, which will mostly happen in the drawText stuff.
|
Quote:
Made a new version where you can define several rectangles to form one camp area (see id #3, the seekbox on semi). Illustrating what tiles are marked: [img]http://jazzjackrabbit.net/gry/camparea.png[/img] It was a bit tricky to select the right ones, because when you jump into a tile above you your head (atleast as spaz) sticks into it a bit (the right outer side of the seekbox). I also made a small alteration to the comparison code, changing (xPos <= aCamp) to (xPos < aCamp). Not sure why it's better, but trial and error tells me that it is so. Punish campers! xd v2.0 http://pastebin.com/XBQhpkAK (as always, please read it on pastebin) Code:
/* |
http://www.jazz2online.com/snippets/
Quick and dirty, but seems to work. Will make it look more fancy later. Feature requests and bug reports are possible, can't say much about when they'd be addressed though. |
Seems to work well, except that the version number didn't increase :)
|
Yeah, as usual all kinds of bugs appear when someone uses it for something else than testing ;)
|
Here's my blade gun!
http://www.youtube.com/watch?v=Qr8pahz-QTs Pastebin: http://pastebin.com/5WYsBEQT It's also on the snippets page, here: http://www.jazz2online.com/snippets/...troblaster-pu/ |
Quote:
|
Quote:
|
DJazz, mind if I put that blade gun video on the Mod DB page? It's pretty cool-looking.
|
Quote:
|
I'm making a little SP level, and I have made a little part of the script...
void onLevelLoad() { jjObjectPresets[OBJECT::NORMTURTLE].energy = 8; jjObjectPresets[OBJECT::BEE].energy = 8; jjObjectPresets[OBJECT::TURTLESHELL].energy = 32; } void onMain() { p.food = 99; if (p.health > 1) p.health = 1; } I managed to make some enemies health x8, emulate the Instagib command, and make Jazz get the sugar rush with one only food item (would help a lot in the Jazz Unleashed Hell level), but I have spent a whole unsuccesful hour trying to make an expression for me to have as the level completing goal to kill every single enemy and collect every single item. I tried "if (OBJECT::NORMTURTLE = 0)", "if (OBJECT::NORMTURTLE.state = STATE::KILL)", "if (OBJECT::NORMTURTLE.jjObjectCount = 0)" but they all crashed the j2as file instead. Can anyone help me here? |
Hmmm. That's a tricky one, because SP doesn't store jjOBJ copies of objects that aren't near to the player. It's only in MP that you get jjOBJs for everything all the time. But there might still be a solution...
Code:
bool areAllNormTurtlesDestroyed() {jjParameterGet(x,y,-1,1), which is a bit that is set to 1 in the event field when an object is created. The bit is set back to 0 if the object passes off screen and gets deactivated, but it is left at 1 if you destroy the object. Basically, if it's at 0 JJ2 takes that as a cue to create the object when that tile is close enough to the player -- if it's at 1, JJ2 ignores it. So that code might work, unless there's something else I'm not thinking of. |
Notice: Undefined variable: oPackage in /home/jazzonli/public_html/J2Ov2/snippets/form.php on line 29
Fatal error: Call to a member function info() on a non-object in /home/jazzonli/public_html/J2Ov2/snippets/form.php on line 29 : ( |
Should be fixed
|
| All times are GMT -8. The time now is 01:37 PM. |
Powered by vBulletin® Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
JCF © 2001-Infinity Jazz2Online