Yes, it is compatible with multiple terrains. Even IV, which has a valley made from 2 terrains, should behave well.
It's important to note, however, that this code only looks in one direction for each terrain, so it's entirely conceivable that a skilled douche will easily thwart it.
Also, it will not give false positives when you are inside the belly of a bunker, or something like that, but it will give positive results for players who go beneath the terrain on maps that allow it, such as Roach Motel... So what is done with this information should be mission specific, even if the ability to retrieve this information is available during any mission.
This is what I plan to do with it, in BottomsUp.
Code: Select all
function Player::Whack_A_Mole(%this)
{
%pos = getBoxCenter(%this);
if(underGround(%pos))
GameBase::applyDamage(%this, $CrushDamageType, 0.01, %pos, "0 0 0", "0 0 0", %this);
}
function Whack_A_Mole(%this)
{
Group::iterateRecursive(MissionCleanup, GameBase::virtual, "Whack_A_Mole");
schedule(sprintf("if($MissionName == \"%1\") Whack_A_Mole(\"%1\");", $MissionName), 1/3);
}
Whack_A_Mole($MissionName);
This script can be executed by any mission file, and will damage players 3 times a second while they remain underground, until the mission changes.
It's important to note that if the mission repeats, the script will run twice as often, sneaky players will die faster, and it may cause lag if the same mission repeats several times in a row... I could probably figure out a way to prevent that if it becomes a problem.