Tut | Boss Fight - JasXSL/GoThongs GitHub Wiki

A boss fight can be a strong monster, multiple strong monsters, waves of monsters or just some task you need to do. In this tutorial I'm going to teach you the basics of a boss fight.

First off. You want to configure the boss with the [monster settings in the description](Dev | Monster Setting Sheet). Monster$RF_IS_BOSS will show the big boss health bar on the HUD. Keep in mind that at the moment of writing, only one boss health bar can be shown, which is why the goblin bosses don't use it.

If your boss is more of a fight against the arena you can toggle the boss health bar by GUI$toggleBoss(player, texture), "" as texture will turn it off. Use GUI$bossHP(player, perc) where perc is between 0 and 1 and corresponds to the "boss" health.

You'll also probably want to set the monster's HP to a high value (1000-2000), also through the description conf. To add mechanics to an arena or a boss, you also probably want to add a [monsterscript](Tut | Monsterscript) to it to handle some of it's abilities. That being said, I suggest handling the actual mechanics of the fight through the _MAIN script.

Let's take a look at the _MAIN script for the goblin fight. I have all the mechanics defined as integers for last trigger, and a preprocessor definition for cooldowns:

// Combat mechanics
#define CD_HEALSHROOM 30
integer MECHANIC_HEALSHROOM;    // Require timmy alive
#define CD_CUMSPIN 15
integer MECHANIC_CUMSPIN;       // Require flailer alive
#define CD_COCKSHROOM 15
integer MECHANIC_COCKSHROOM;    // Require shaman alive. Once shaman dies, set a timer every 2-3 sec to increase arousal

When the battle starts (you can tie an event listener for aggro in the monsterscript) I set a repeating timer to check mechanics:

multiTimer([TIMER_MECHANIC_UPDATE, "", 5, TRUE]);

Each 5 sec I run the function "runMechanic()" which will run one mechanic. Simply put the function may look like this:

runMechanic(){
    integer time = llGetUnixTime();
    
    // Checks if Timmy (the helpful goblin) is alive, and if the last use of MECHANIC_HEALSHROOM plus cooldown is less than unix time
    if(MECHANIC_HEALSHROOM+CD_HEALSHROOM, llEuler2Rot(<0,PI_BY_TWO,0>), <0,0,-4>, FALSE, FALSE, TRUE);
    }
    
    // If Jizble is still alive and the last use of MECHANIC_CUMSPIN plus cooldown is less than current time
    else if(MECHANIC_CUMSPIN+CD_CUMSPIN, llEuler2Rot(<0,PI_BY_TWO,0>), <0,0,-4>, FALSE, FALSE, TRUE);
        )
    }
    
    // Shaman dead, spawn at random location
    else if(MECHANIC_COCKSHROOM+CD_COCKSHROOM+10, llEuler2Rot(<0,PI_BY_TWO,0>), <0,0,-4>, FALSE, FALSE, TRUE);
        )
    }
}

All the little mechanics can be written by simply using a portal and the FX system. If you want examples you can just take a look at existing levels, all the code is open source.

Finally after both the goblins in the fight have been defeated, we run Level$setFinished(-1, 0); which will clean up any spawned portal objects and mark the level as completed.

⚠️ **GitHub.com Fallback** ⚠️