<aside> ⚡ script "map_watersplash" (int direction, int entering, int eyes)

</aside>

Event


This script is called by the player whenever they enter or leave any body of water on the map.

Usage


This script can replaced by adding a new script in your map of the name, map_watersplash, to add additional behavior to this event, or override the existing behavior.

This script is called by the global water management script, which expects a return value of how many tics (1/35th of a second) to wait before splashing again. If the return value is 0, or none is specified, it will default to 20.

Parameters

Default Script


The default water splash script simply spawns the Mega Man water splash in a relevant position.

The spawn position of the splash is the player’s position 1 tic ago (this better syncs the splash with the water’s surface).

If the splash was triggered by the player’s eyes entering or leaving the water, the view height is added to the z-position to account for that.

Finally, determine which splash to use depending on the direction the player splashes from, then spawn it.

The SetResultValue returns how long the global water script should wait before attempting to splash again. Which, by default, is 20 tics.

// Activator: The player who splashed
script "map_watersplash" (int direction, int entering, int eyes)
{
    int x = GetActorX(0)-GetActorVelX(0);
    int y = GetActorY(0)-GetActorVelY(0);
    int z = GetActorZ(0)-GetActorVelZ(0);
    int angle = GetActorAngle(0) >> 8;
    str type;

    if(eyes) {
        z += GetActorProperty(0, APROP_ViewHeight);
    }

    switch(direction) {
        case 0: // From the top
            type = "MMSplash";
            break;
        case 1: // From the bottom
            type = "MMSplash_Down";
            break;
        case 2: // From the side
            type = "MMSplash_Mid";
            break;
    }

    SpawnForced(type, x, y, z, 0, angle);
    
    SetResultValue(20);
}