If you're using MOHAA's original bomb_thinkers in global/obj_dm.scr that were added to obj_team1-4, then you can use their level.bomb_set variable to determine if a bomb was placed on an objective. However, their original script doesn't have level variables to determine which specific objective has a bomb on it (only has "level.bomb_set++" or "level.bomb_set--") The code only works on maps with only one objective:
Code:
main:
...
thread bomb_set
level waittill spawn
...
end
...
bomb_set:
while(1)
{
if(level.bomb_set == 0) { huddraw_color 202 1.0 1.0 1.0 }
if(level.bomb_set == 1) { huddraw_color 202 1.0 0.0 0.0 }
wait 1
}
end
Your best bet to distinguish two different objectives is to add a trigger_multiple near an objective's red pulsating explosive. Set the trigger's setsizes to 30 to 50 units radius, and if a player holds USE for 5 seconds (however long the plant time is) while touching this trigger, then a new level variable level.second_bomb_set can be used in the "bomb_set" thread above, to change the HUD color of the respective objective name. You'll need another trigger_multiple at the 1st explosive too. Something similar to below should do the trick.
Code:
main:
...
thread bomb_set
thread bomb_trigger_1st
thread bomb_trigger_2nd
level waittill spawn
...
end
...
bomb_set:
while(1)
{
if(level.first_bomb_set == 0) { huddraw_color 202 1.0 1.0 1.0 }
if(level.first_bomb_set == 1) { huddraw_color 202 1.0 0.0 0.0 }
if(level.second_bomb_set == 0) { huddraw_color 204 1.0 1.0 1.0 }
if(level.second_bomb_set == 1) { huddraw_color 204 1.0 0.0 0.0 }
wait 1
}
end
bomb_trigger_1st:
local.bombtrig1 = spawn trigger_multiple // if you have the targetnames of the red pulsating bomb plant sites, you can do "$player[local.i] istouching $first_bombsite" instead of adding a trigger_multiple (could also be an invisible script_model, since the trigger isn't actually getting triggered here).
local.bombtrig1.origin = ( -3200 165 17 ) // coords of the 1st objective's bomb plant site
local.bombtrig1 setsize ( -40 -40 -40 ) ( 40 40 40 )
while(1)
{
waitframe
for(local.i = 1; local.i <= $player.size; local.i++)
{
local.holdtimer = 0
while($player[local.i].useheld == 1 && $player[local.i] istouching local.bombtrig1)
{
if(local.holdtimer >= 50 && level.first_bomb_set != 1 && $player[local.i].dmteam == "allies") { level.first_bomb_set = 1; break } // bomb has been planted, by allies
if(local.holdtimer >= 50 && level.first_bomb_set == 1 && $player[local.i].dmteam == "axis") { level.first_bomb_set = 0; break } // bomb has been defused, by axis
local.holdtimer++
wait 0.1
}
}
}
end
bomb_trigger_2nd:
local.bombtrig2 = spawn trigger_multiple
local.bombtrig2.origin = ( -2670 165 36 ) // coords of the 2nd objective's bomb plant site
local.bombtrig2 setsize ( -40 -40 -40 ) ( 40 40 40 )
while(1)
{
waitframe
for(local.i = 1; local.i <= $player.size; local.i++)
{
local.holdtimer = 0
while($player[local.i].useheld == 1 && $player[local.i] istouching local.bombtrig2)
{
if(local.holdtimer >= 50 && level.second_bomb_set != 1 && $player[local.i].dmteam == "allies") { level.second_bomb_set = 1; break }
if(local.holdtimer >= 50 && level.second_bomb_set == 1 && $player[local.i].dmteam == "axis") { level.second_bomb_set = 0; break }
local.holdtimer++
wait 0.1
}
}
}
end