Trying to create a simple NPC mod

BuckleyTim

Member
Modder
Mar 24, 2024
29
18
280
In the arena!
So I'm currently working on creating a custom behavior resource that mimics how toads work on the base game, only much more modularized so that people can change the dialog, model, and animation it loads in with by editing the lua file. This would hopefully work so that you could have a few sets of data that goes [model, animation, dialog, etc] and then each instance of the behavior would choose which set to display depending on what the last byte the behavior is set to have on the level data.

I'm doing this to hopefully make it easier to make populated looking maps in coopdx. If you can take any model that uses the Mario armature and put it in a level as an NPC that'd open the possibilities for what is quickly doable in coopdx mapping at least a little bit more hopefully.

I'll be using this thread to just compile my attempts to get his to work, as well as get a bit of feedback from people as I attempt to get this working.

No code/pictures yet, but I'll edit the thread later today with my progress.
 
  • Like
Reactions: Chilly
Ok, I'm going to admit to being very newbie and say I don't know how to edit my posts here, so I'm just going to make this first update a separate post.

image.png


video of the behavior in action

Here's a behavior that uses a mario model as an armature. when you get close it starts to turn to look at you, and when you get closer you press b to hear their dialog. very rough and the bugs are obvious, but it technically works.

What I need to figure out in the meantime:

-how to make the model with the mario armature not copy parts of the player's animations (blinking, hands growing when you punch, etc.)
-maybe adding a little "!" billboarded sprite above the npc when you're in range to talk to them.
-locking mario's actions just like how regular npc toads work.
 
  • Like
Reactions: Chilly
Second small Update:

I have in fact added the bill-boarded sprite that appears above an NPC (kinda like how it works in SMBX) while also fixing the idle animation. I've also updated the turn radius to be actual good instead of slow as hell.

image.png


(in this case the sprite placeholder is a yellow coin.)

2nd video of the behavior working

now, I need to figure out how to make it so that a model using mario's armature doesn't copy the player's secondary animations. I could just remove the additional bones that allow mario's limbs to scale and tilt, but I'd have to do that for each additional model, which wouldn't work for the plug and play aspect of this mod I'm trying to facilitate.

If anyone can help me potentially figure out how to code a way to nullify the behavior model reacting to the player's running/punching that would be much appreciated!
 
  • Like
Reactions: Chilly
Third update!:

Third video of test footage

image.png


I've gotten it to work so that the system is now modular. Included with the main code will be an "a-content" lua file that one can edit to introduce new NPC variables (up to 24 for now, but i'll expand that as time goes on).
It's a simple 6-entry array that decides the npc's model, default animation, dialogid, whether it rotates to view mario, whether it can be talked to at all, and the noise it makes while talking (like bob-omb noises or koopa noises, for example).

It still is buggy and I really need to figure out how to make imported models not copy the host player (as you can see with toadette copying my mario's colors), but mechanically it works!

edit: forgot to mention that the arrays can be selected by modifying the behavior params of each instance of the npc behavior that you place in blender. Really efficient, I believe.
 
Last edited:
  • Like
Reactions: Chilly
This is some awesome stuff! This is honestly something I'd love to use myself! I can't wait to see how it comes along 👀👀
 
Player colors are determined by the globalPlayerIndex field of the object. You can't really set it to something custom without modifying the model itself as far as I know.
 
Player colors are determined by the globalPlayerIndex field of the object. You can't really set it to something custom without modifying the model itself as far as I know.
I did try setting it manually in my code. The .globalPlayerIndex shows up as changed when I print it (both regular print and djui_popup_create), but it doesn't do anything for the models. Guess I'll have to keep tinkering (or hope that the next version of coopdx can make it so you can set it to something custom/ignore it entirely).

Edit: doh, I'm realizing it's set in the models themselves, not the code. Yeah, that's gonna be a problem unless I accept that people are going to have to tinker with the models to make them compatible first.
 
Yeah, I could add something to DX to help you out there.

Very appreciated. While I have your attention I might as well suggest a function that would allow me to force the hexcode value of a model's clothes/hair/etc. colors, since I presume that if I set the playerindex of a recolorable object to something like 64 then those values would return as 000000 otherwise.

And maybe a function that allows us to add new additional dialogid but at that point I am asking quite a bit out of you for this

By the way, I just want to say looking at your coding helped my progress on this project immensely, particular the work you did for the Creepy Canyon romhack. I was definitely going to credit you even before this, so thanks again.
 
Very appreciated. While I have your attention I might as well suggest a function that would allow me to force the hexcode value of a model's clothes/hair/etc. colors, since I presume that if I set the playerindex of a recolorable object to something like 64 then those values would return as 000000 otherwise.
If you're using the player index for an npc, you can use network_player_color_to_palette to set a player's colors depending on the network player index.
 
Yeah, I could add something to DX to help you out there.

Question: did you end up adding anything anything that might help to the last dx update? I've been away from coop modding for a hot minute and thus don't know if there's anything i overlooked in the patch notes.
 

Users who are viewing this thread