Log in

View Full Version : Feature Request a new onDraw variant for jjBEHAVIORINTERFACE


Zah dud4h
Apr 26, 2025, 01:31 PM
Unsure how the onDraw(jjOBJ@ obj) hook works internally and if it's possible to have a variant that accepts a second parameter of "jjPLAYER@ play" so you can specify how differently it should draw for a specific player, similar to how the PU blaster monitors and the fast fire pickups work

Example:
void onDraw(jjOBJ@ obj,jjPLAYER@ play) {
if (play.currChar == CHAR::JAZZ) {
//draw the sprite for jazz
} else {
// draw the default sprite
}
}

Seren
Apr 27, 2025, 03:11 AM
All jjDraw* (https://docs.jj2.plus/plus-angelscript.html#jjDrawTile) functions take an optional playerID argument that can be used to specify which player the sprite should be drawn for (the default of -1 denoting all). This already enables patterns such as
void onDraw(jjOBJ@ obj) {
for (int i = 0; i < jjLocalPlayerCount; i++) {
const auto@ player = jjLocalPlayers[i];
// draw the sprite facing the player's direction instead of the object's
jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame,
player.direction, playerID: player.playerID);
}
}
The proposed overload couldn't really do anything more than move this loop outside of the function and into JJ2+ code - which we could do, but this use case comes up rarely enough that it would probably do more harm than good to provide a dedicated shorthand for it.