Gonnasmoke: The Smoking Mod
Gonnasmoke is a cosmetic mod for Nuclear Throne that makes your player character smoke. Rebel's Allies and enemy Bandits can also smoke, and it's possible to add support for more enemies by editing the script file.
Download
Watch the trailer
Customizing the mod
Editing the script file is relatively straightforward if all you want is some minor changes. If you'd like to alter stuff like animation or drawing code, good luck, you'll need it.
Under #define init
you'll find two global variables that control some special behavior:
global.headless_cigarette
: Set this tofalse
if you have a special sprite for Headless Chicken, or if you just want to disable this specific gag for some reason. Disabling this will make the cigarette drop instead of staying attached to Chicken's body.global.player_only
: If you're concerned about performance issues, set this flag totrue
. It'll make only the player get a cigarette.
Under #define cigarette_create
you'll find all the parameters used to create a cigarette. You can alter a few to your taste:
height
: How tall the cigarette is, including the black outline. 3 should be the minimum. The maximum size that works without looking bad is 6, since the script doesn't compensate for height when creating effects.butt
: How long the cigarette's butt is.length
: How long the white part of the cigarette is.stress_factor
: How many times faster the cigarette will be smoked if at 0 hp with stress, scales linearly with lost hp. Default is 4, which means smoking 4 times faster at 0 hp.fade_in
: Fade-in time when a new cigarette spawns. This, and all the following settings are in frames @ 30 fps. They're scaled automatically by the game if you play at a higher framerate. So essentially, 30 = 1 second.light_delay
: Time to wait before lighting the cigarette.light_time
: Time to spend lighting the cigarette.drop_time
: Time between finishing the cigarette and dropping itputout_time
: How long a dropped cigarette takes before getting put outfade_out
: Fade-out time when dropping a cigarette.
Creating sprite offsets
By sprite offsets, I mean where the cigarette will be put, on each frame of a character's sprite. This can apply to the player, to enemies, or even allies and props. Ideally you should put the cigarette on the character's mouth, but if you wanna do something stupid like making them smoke out of the ass, you can do it by editing the offsets and some of the mod's code I guess.
The following code, which is included with the mod, shows how to define offsets for a Bandit's sprites:
// "sprBanditIdle" is the name of the sprite to match.
ds_map_add(global.offsets, "sprBanditIdle", [
{ x: 3, y: 3 }, // x and y cigarette offsets for frame 0, from the origin of the sprite
{ x: 3, y: 3 }, // Ditto, for frame 1
{ x: 3, y: 4 }, // Frame 2
{ x: 3, y: 4 } // Frame 3
]);
ds_map_add(global.offsets, "sprBanditWalk", [
{ x: 4, y: 3 },
{ x: 5, y: 1 },
{ x: 4, y: 4 },
{ x: 5, y: 3 },
{ x: 5, y: 1 },
{ x: 4, y: 4 }
]);
ds_map_add(global.offsets, "sprBanditHurt", [
{ x: 3, y: 2 },
{ x: 3, y: 2 },
{ x: 3, y: 2 }
]);
To add Gonnasmoke support to a custom skin, you have to define a gonnasmoke_offsets
function somewhere in the skin's script file. The following is an example for my Rocket Cop skin for Fish:
#define gonnasmoke_offsets
var offsets = ds_map_create(); // Define a DS Map that'll contain the offsets.
ds_map_add(offsets, "idle", [ // "idle" is the name of the skin's idle sprite. No fancy text here, just "idle".
{ x: 3, y: 3 }, Frame 0 of idle sprite
{ x: 3, y: 3 }, Frame 1
{ x: 3, y: 4 }, Frame 2
{ x: 3, y: 4 } Frame 3
]);
ds_map_add(offsets, "walk", [ // Walking sprite
{ x: 4, y: 3 },
{ x: 4, y: 2 },
{ x: 4, y: 4 },
{ x: 5, y: 3 },
{ x: 5, y: 2 },
{ x: 5, y: 4 }
]);
ds_map_add(offsets, "hurt", [ // Hurt sprite
{ x: 3, y: 3 },
{ x: 3, y: 3 },
{ x: 3, y: 3 }
]);
ds_map_add(offsets, "gosit", [ // Thronesitting animation
{ x: 1, y: 3 },
{ x: 1, y: 3 },
{ x: 1, y: 3 }
]);
ds_map_add(offsets, "sit", [ // Thronesitting loop
{ x: 1, y: 3 }
]);
return offsets; // Once all offsets are added, return the DS Map so Gonnasmoke can read it and add it to its own sprite map.
In case you forget to add an offset for all frames, the mod will default to using the offsets for frame 0 of the sprite. If you don't define the sprite at all, no cigarette will be shown.
Known issues
- Gonnasmoke only recognizes smoking support for skins that are already loaded. This means that you have to load Gonnasmoke AFTER you load any skin mods that it supports.
- Smoke particles get culled by the game automatically, if there's too many of them.
- There's a small positioning error with the cigarette's burn point, this is noticeable when it's rotated. It affects the spawn point of the flame, the cigarette tip's glow, and the point where smoke comes out from.
- There's performance issues when there's a large amount of cigarettes on the stage. I don't know how to optimize the mod further, so I built a switch at the top of the script that makes only the player smoke.
- Cigarettes can get through walls when dropped. This won't be fixed, it happens because cigarettes don't have a bounding box. To compensate, if the center of the cigarette is overlapping a wall, it'll draw on top of it.
To report a bug, you can either ping legitleemon on the official NT Discord, or post a comment on the Itch.io page for the mod.