View Single Post
Violet CLM Violet CLM's Avatar

JCF Éminence Grise

Joined: Mar 2001

Posts: 10,978

Violet CLM has disabled reputation

Aug 23, 2019, 04:21 PM
Violet CLM is offline
Reply With Quote
Instructions for using custom weapons and MLLE

Making a level

Editor interface
While editing a JJ2+ level with MLLE, click the "JJ2+ Properties" dropdown menu at the top of the window and select the "Weapons..." option. This will bring up a modal window with a 3×3 grid of the nine weapons used in this level. Each panel in the grid shows, by default: the weapon number, a preview icon of the weapon, and the weapon's name.

The weapon's name is actually a dropdown menu. By clicking on it, you open up the menu to see the rest of the weapons available to you, and selecting any one of them will cause your level to use that weapon instead. For example, if you click the dropdown box in panel 2 and change it from "Bouncer" to "Electro Blaster," then all bullets players shoot in this level with weapon 2 selected will be electro blaster bullets, and all ammo pickups, ammo crates, and powerups for weapon 2 will use electro blaster sprites as well.

If you have downloaded any custom weapons that are compatible with MLLE, they will also appear as options in each panel's main dropdown box, so for example you could change weapon 2 from "Bouncer" to "Laser Blaster" instead. Again, that is all you need to do. (Here are a bunch of custom weapons you can download to start off with.)

Notice that each of the nine weapon panels has a vertical scrollbar on its far right. By scrolling down, you can look at and edit a list of options. All weapons share the following six options:
  1. Maximum: How much ammo of this weapon a player can carry. The cheat codes JJAMMO, JJGUNS, and JJGOD all instantly set each weapon's ammo to this number, and when a player has maximum ammo for a weapon, ammo pickups for that weapon can no longer be collected. The default value of "-1" is special and is interpreted as either 99 or 50 depending on whether you are playing single player, but other values are also accepted. Some weapons are so powerful that you might want to lower their maximum value to maybe 25 or even 1.
  2. Birds: If your level contains any bird cage objects (or if the player uses the JJBIRD cheat code), this property affects whether the birds will be able to fire this bullet type (if the player has it selected) or whether they'll default to weapon 1 instead.
  3. Appears in gun crates: By default, only ammo pickups for weapons 2, 3, 4, 5, and 6 can appear in Gun Crate and Gun Barrel events. This property lets you change that. (No effect for weapon 1, which has no ammo pickup objects.)
  4. Gems lost (normal): This option is only useful in Treasure Hunt levels, where it specifies how many gems a player loses after being hit by a normal bullet of this weapon. If this is not a Treasure Hunt level, you can ignore this option completely.
  5. Gems lost (powerup): Same, but for powered-up bullets.
  6. Availability: Whether players should start with the maximum amount of ammo for this weapon, and whether ammo pickups are necessary. These options are changed very rarely but might be useful for a high-concept level.

Besides those six options, some weapons have additional options that are specific to them only: these appear below the six common options and can also be found by using the panel's scrollbar. Of the nine default weapons, four have weapon-specific options: Bouncer, Ice, TNT, and Gun8. Some custom weapons have weapon-specific options and most do not; the only way to check is to use the scrollbar.

Interacting with MLLE code
Using almost any of MLLE's JJ2+ tools in a level will cause MLLE to write some code to the level's .j2as file, and the Weapons window is no exception to this. As ever, though, the rule is basically this: leave it alone and nothing will go wrong.

The most important of MLLE's interaction with your .j2as file are the following two lines (or similar):
Code:
#include "MLLE-Include-1.5.asc" ///@MLLE-Generated
const bool MLLESetupSuccessful = MLLE::Setup(); ///@MLLE-Generated
MLLE-Include-1.5.asc is a special angelscript library generated by MLLE that interprets all the various JJ2+ properties that MLLE embeds in your .j2l file, and MLLE::Setup() is the function call to run the library. 99% of the time you can (and should) ignore these two lines and let MLLE worry about them. If for whatever reason you want some code to run before the function call, you can use the following pattern instead and nothing should go wrong:
Code:
#include "MLLE-Include-1.5.asc" ///@MLLE-Generated
void onLevelLoad() {
	//do something important
	MLLE::Setup();
}
This changes slightly if you use the Weapons window to use any custom weapons in your level, or even to make significant enough modifications to the default weapons. In that case, those two lines will look more like this:
Code:
#include "MLLE-Include-1.5w.asc" ///@MLLE-Generated
const bool MLLESetupSuccessful = MLLE::Setup(array = {SzmolWeaponPack::MeleeSword::Weapon(), null, SzmolWeaponPack::DischargeGun::Weapon(), SzmolWeaponPack::LockOnMissile::Weapon(), SzmolWeaponPack::AutoTurret::Weapon(), null, SzmolWeaponPack::PetrolBomb::Weapon(), null, null}); ///@MLLE-Generated
Note that the MLLE::Setup function call now takes a single argument: an array initializing each of the nine weapons used in your level. (Or null if you're leaving the default weapon for that slot unchanged.) The angelscript library filename is also changed slightly: MLLE-Include-1.5w.asc is a special version of MLLE-Include-1.5.asc that has a lot of additional code specifically for dealing with custom weapons.

To be continued... documentation currently unfinished at this point.
Making a level: advanced

Making a weapon

Minimum requirements
MLLEWeapons::WeaponInterface
__________________

Last edited by Violet CLM; Aug 23, 2019 at 08:43 PM.