adversary.lua, projectiles.lua - Boss Toolkit

Share and discuss custom LunaLua code and content packs for SMBX2.

Moderator: Userbase Moderators

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9865
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

adversary.lua, projectiles.lua - Boss Toolkit

Postby Emral » Sun May 10, 2020 5:10 am

Oh, what a doozy.
In development for the past 3 years, these libraries are like siblings, so I'm packing them together.
adversary takes care of the heavy lifting of completely lua-based boss enemies.
projectiles takes care of said boss's completely lua-based attacks and effects.

Included in the download is a demo.
https://drive.google.com/file/d/1I9pnlf ... sp=sharing
Spoiler: show
Image
Image
Here are a few paragraphs about what you can expect from each library. There's further documentation within the files, and the sample gives a solid overview over what each library lets you do.

Adversary:
Spoiler: show
Adversary is a boss library I started in 2017 for the bosses in my ongoing episode. Now that I have finished programming all the bosses, I think the library has evolved into a solid position for release. It has a lot of features for doing the heavy lifting for your bosses, but you the logic itself is something you will have to write yourself.
- Exposes onTick, onDraw and onHarm functions for you to use
- Includes a :draw() function that you can optionally use. If your boss is more complex, you might opt to choose to draw the boss yourself, however.
- Includes a harm type system that can distinguish between jump, slash, yoshi tongue, down slash, tail, as well as any NPC collision. Freely expandable using string-based harm types for custom collider-collider collision.
- Each harm type can have a damage multiplier.
- Includes a state system, in which a table mapping states to harm multipliers can be provided (e.g. "boss takes less damage when shielded")
- Includes a collider registration system, in which a boss can be assigned any amount of colliders, each with their own harm damage multiplier (weak spots, sour spots)
- Boss's hp drawing functions are overridable on a per-instance basis.
- Works with any amount of bosses simultaneously.
- Mininmal overhead
- Multiplayer support
Adversary is currently unable to natively provide harm types for the SMBX2 characters. However, you can cover those with the custom harmtypes on a per-boss basis, by calling boss:damage("Harmtype") when you detect a collision.
Also worth noting: The hpSlice sprite is drawn truncated. Feel free to try one wider than 1 pixel to see how it looks.

Projectiles:
Spoiler: show
Projectiles is a projectile library (duh) started before the new effect rewrite of SMBX2. The effect rewrite ended up taking a lot of ideas from it, and the library evolved in parallel to it.
The library serves as a lightweight alternative to using NPCs or effects for certain things. It handles keeping track of inidividual entities, as well as spawning them and managing their speeds. Drawing is not handled.
For handling drawing and logic, each list has an onTick and an onDraw function (see the sample) which are invoked for each entry in the list.
Furthermore, a projectile can optionally provide a kill effect that is to be invoked when the :kill() function is called.
The sample, what does it show?
Spoiler: show
The sample shows a boss fight against a Waddle Dee. It shows:
- Custom collision programming
- Sample of a state machine system with walk, jump and hurt states
- Custom hp bar drawing
- Multiple bosses
- Harm type registration
- Two projectiles, one with a custom harmtype collider that harms the boss
For a little reference to how easy this makes things: I wrote the sample in 3 hours this morning.
Last edited by Emral on Sun May 10, 2020 11:55 am, edited 3 times in total.

Eri7
Banned
Posts: 1770
Joined: Sat Jan 28, 2017 4:48 pm
Flair: Good Foundation allows for strong Execution
Contact:

Re: adversary.lua, projectiles.lua - Boss Toolkit

Postby Eri7 » Sun May 10, 2020 5:15 am

Wow, that's an awesome system! It seems you have put a lot of thought in the creation of bosses to be so much easier for creators.

Taycamgame
Gold Yoshi Egg
Gold Yoshi Egg
Posts: 1483
Joined: Mon Jun 19, 2017 11:35 am
Flair: Stargard
Contact:

Re: adversary.lua, projectiles.lua - Boss Toolkit

Postby Taycamgame » Sun May 10, 2020 9:36 am

Is the idea behind this toolkit meant to be a replacement of the traditional way to create lua bosses, or is it simply just another way of doing it?

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9865
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: adversary.lua, projectiles.lua - Boss Toolkit

Postby Emral » Sun May 10, 2020 9:40 am

Taycamgame wrote:
Sun May 10, 2020 9:36 am
Is the idea behind this toolkit meant to be a replacement of the traditional way to create lua bosses, or is it simply just another way of doing it?
Not quite sure what you mean by "traditional way". Could you describe that way to me?

Taycamgame
Gold Yoshi Egg
Gold Yoshi Egg
Posts: 1483
Joined: Mon Jun 19, 2017 11:35 am
Flair: Stargard
Contact:

Re: adversary.lua, projectiles.lua - Boss Toolkit

Postby Taycamgame » Sun May 10, 2020 10:54 am

Enjl wrote:
Sun May 10, 2020 9:40 am
Taycamgame wrote:
Sun May 10, 2020 9:36 am
Is the idea behind this toolkit meant to be a replacement of the traditional way to create lua bosses, or is it simply just another way of doing it?
Not quite sure what you mean by "traditional way". Could you describe that way to me?
I mean like, the normal way of creating lua bosses. You know, where you'd do it all yourself and whatnot. Without this kind of tool to do parts for you.

Is this tool supposed to just make it easier to create bosses in future?

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9865
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: adversary.lua, projectiles.lua - Boss Toolkit

Postby Emral » Sun May 10, 2020 11:22 am

Taycamgame wrote:
Sun May 10, 2020 10:54 am
Enjl wrote:
Sun May 10, 2020 9:40 am
Taycamgame wrote:
Sun May 10, 2020 9:36 am
Is the idea behind this toolkit meant to be a replacement of the traditional way to create lua bosses, or is it simply just another way of doing it?
Not quite sure what you mean by "traditional way". Could you describe that way to me?
I mean like, the normal way of creating lua bosses. You know, where you'd do it all yourself and whatnot. Without this kind of tool to do parts for you.

Is this tool supposed to just make it easier to create bosses in future?
I think it's best to answer this with an analogy. Imagine you need custom collision in your level. You can either hardcode it all yourself, using coordinate checks and whatnot, or you could use colliders.lua. adversary.lua is that, but for bosses instead of collision. The underlying principle is the same (it's a table), you just don't have to reinvent the wheel every time.
That isn't to say that aversary is "the definitive" boss library. I know of a couple of other WIP episodes that have their own specialized boss libraries (because copying boss code between levels is a tad inefficient). It's just... I guess the first to be released.

lolcode
Hoopster
Hoopster
Posts: 41
Joined: Sat Jul 11, 2020 7:55 pm

Re: adversary.lua, projectiles.lua - Boss Toolkit

Postby lolcode » Sat Aug 08, 2020 9:01 pm

i need a tutorial for this

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9865
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: adversary.lua, projectiles.lua - Boss Toolkit

Postby Emral » Sun Aug 09, 2020 3:10 am

the lolie wrote:
Sat Aug 08, 2020 9:01 pm
i need a tutorial for this
A sample boss is included in the download. If you don't understand that, you wouldn't understand a tutorial. I recommend learning the basics of programming and lunalua. These libraries are frameworks that don't do any of the thinking of how to program AI for you, merely making the setup and common situations faster to handle uniformly.

lolcode
Hoopster
Hoopster
Posts: 41
Joined: Sat Jul 11, 2020 7:55 pm

Re: adversary.lua, projectiles.lua - Boss Toolkit

Postby lolcode » Sun Aug 09, 2020 6:48 am

Enjl wrote:
Sun Aug 09, 2020 3:10 am
the lolie wrote:
Sat Aug 08, 2020 9:01 pm
i need a tutorial for this
A sample boss is included in the download. If you don't understand that, you wouldn't understand a tutorial. I recommend learning the basics of programming and lunalua. These libraries are frameworks that don't do any of the thinking of how to program AI for you, merely making the setup and common situations faster to handle uniformly.
i can't learn lunalua cuz wiki is outdated

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9865
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: adversary.lua, projectiles.lua - Boss Toolkit

Postby Emral » Sun Aug 09, 2020 6:51 am

the lolie wrote:
Sun Aug 09, 2020 6:48 am
i can't learn lunalua cuz wiki is outdated
Wiki is outdated in parts but a lot of it still applies. On top of that there are general programming tutorials all over the internet, there's the handbook for when you need references for new features not present on the old wiki, and there's a lunalua tutorial video series you can find in the guides forum. Even if all those resources weren't there, SMBX2 is open source (you download the source code with the program) so it's always possible to learn something simply from examining what basegame actually does.

lolcode
Hoopster
Hoopster
Posts: 41
Joined: Sat Jul 11, 2020 7:55 pm

Re: adversary.lua, projectiles.lua - Boss Toolkit

Postby lolcode » Sun Aug 09, 2020 6:55 am

im bad with video tutorials

Added in 1 minute 45 seconds:
i just want my custom npc to have multiple hp

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9865
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: adversary.lua, projectiles.lua - Boss Toolkit

Postby Emral » Sun Aug 09, 2020 6:59 am

This library has nothing to do with that. It's for creating pure lua implementations of bosses. Use lighthitpoint for adding HP to npcs. It's really, really easy to use. I can only give more specific help once you can present a piece of code you tried that didn't work as you expected it to.

lolcode
Hoopster
Hoopster
Posts: 41
Joined: Sat Jul 11, 2020 7:55 pm

Re: adversary.lua, projectiles.lua - Boss Toolkit

Postby lolcode » Mon Aug 10, 2020 8:38 pm

so...
all i need to do is copy adversary.lua and projectiles.lua in my level
then create boss file similar to waddledeeboss.lua
correct?

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9865
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: adversary.lua, projectiles.lua - Boss Toolkit

Postby Emral » Mon Aug 10, 2020 11:45 pm

Correct, and then you need to program a boss from scratch, which requires a good amount of lunalua experience.

lolcode
Hoopster
Hoopster
Posts: 41
Joined: Sat Jul 11, 2020 7:55 pm

Re: adversary.lua, projectiles.lua - Boss Toolkit

Postby lolcode » Mon Aug 10, 2020 11:55 pm

ok then
how do i make bassic koopaling battle?

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9865
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: adversary.lua, projectiles.lua - Boss Toolkit

Postby Emral » Tue Aug 11, 2020 12:00 am

the lolie wrote:
Mon Aug 10, 2020 11:55 pm
ok then
how do i make bassic koopaling battle?
So, this library is not meant for beginners, so you need to learn how to make things with lua.
I provided links to learning resources earlier, but you'll have to do the learning part yourself. I recommend starting with some easier things, like just changing the projectiles a vanilla npc throws, and then gradually working your way up to making custom NPCs, and then eventually a fully lua-implemented boss.

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9865
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: adversary.lua, projectiles.lua - Boss Toolkit

Postby Emral » Fri Sep 04, 2020 4:58 pm

Rixi let me know that i messed up my projectiles.lua upload so I sneakily updated the download link to fix that. Juuust mentioning in case someone ran into such issues.

ditditdit
Buster Beetle
Buster Beetle
Posts: 92
Joined: Sun Jan 02, 2022 4:25 pm
Flair: e
Pronouns: she/they
Contact:

Re: adversary.lua, projectiles.lua - Boss Toolkit

Postby ditditdit » Sun Apr 16, 2023 5:28 pm

maybe next time, i'm still learning very basic lua...


Return to “LunaLua”

Who is online

Users browsing this forum: LordekVein and 1 guest

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari