Results 1 to 5 of 5

Thread: OBJ Hud Help

  1. #1

    Default OBJ Hud Help

    Hello, I was working on a script to create a Hud that displays the objective. I've been successful on that part. Now I want to be able to change the color of the OBJ location when the bomb is set. Below is the script I have. I run the TDM to OBJ mod, so I was trying to thread things from the global/libmef/bomb.scr during a plant/defuse event, but nothing was successful. I was wondering if anyone could point me in the right direction?


    Thanks!

    Code:
    main:
    
    if(int(getcvar("objhud"))!=1)
    	end
    
    level waittill spawn
    
    // clear bomb locations ---------------------------------------------------------------
    
    	local.bomb_team = ""
    	local.location = 0
    	local.location2 = 0
    
    // set map location & teams ---------------------------------------------------------------
    
    if((getcvar(mapname)) == "dm/mohdm1") {
    	local.bomb_team = ("textures/hud/allies")
    	local.location = "Center Building Radio"
    	local.location2 = 0
    	}
    
    if((getcvar(mapname)) == "dm/mohdm2") {
    	local.bomb_team = ("textures/hud/axis")
    	local.location = "Church Flak 88"
    	local.location2 = 0
    	}
    
    if((getcvar(mapname)) == "dm/mohdm3") {
    	local.bomb_team = ("textures/hud/allies")
    	local.location = "Pub Radio"
    	local.location2 = 0
    	}
    
    if((getcvar(mapname)) == "dm/mohdm5") {
    	local.bomb_team = ("textures/hud/axis")
    	local.location = "South Nebelwerfer"
    	local.location2 = 0
    	}
    
    if((getcvar(mapname)) == "dm/mohdm6") {
    	local.bomb_team = ("textures/hud/axis")
    	local.location = "Boiler Room Radio"
    	local.location2 = 0
    	}
    
    if((getcvar(mapname)) == "dm/mohdm7") {
    	local.bomb_team = ("textures/hud/allies")
    	local.location = "Northeast Flak 88"
    	local.location2 = 0
    	}
    
    if((getcvar(mapname)) == "obj/obj_team1") {
    	local.bomb_team = ("textures/hud/axis")
    	local.location = "Church Flak 88"
    	local.location2 = 0
    	}
    
    if((getcvar(mapname)) == "obj/obj_team2") {
    	local.bomb_team = ("textures/hud/axis")
    	local.location = "V2 Rocket"
    	local.location2 = "Control Room"
    	}
    
    if((getcvar(mapname)) == "obj/obj_team3") {
    	local.bomb_team = ("textures/hud/axis")
    	local.location = "East Cannon"
    	local.location2 = "West Cannon"
    	}
    
    if((getcvar(mapname)) == "obj/obj_team4") {
    	local.bomb_team = ("textures/hud/axis")
    	local.location = "Bridge"
    	local.location2 = 0
    	}
    
    if((getcvar(mapname)) == "obj/blutstein") {
    	local.bomb_team = ("textures/hud/axis")
    	local.location = "North Cannon"
    	local.location2 = 0
    	}
    
    if((getcvar(mapname)) == "obj/dasboot") {
    	local.bomb_team = ("textures/hud/axis")
    	local.location = "U-BOAT"
    	local.location2 = 0
    	}
    
    if((getcvar(mapname)) == "obj/obj_fallenvillage") {
    	local.bomb_team = ("textures/hud/axis")
    	local.location = "Ammo Truck"
    	local.location2 = 0
    	}
    
    if((getcvar(mapname)) == "obj/obj_howitzer") {
    	local.bomb_team = ("textures/hud/axis")
    	local.location = "West Cannon"
    	local.location2 = 0
    	}
    
    if((getcvar(mapname)) == "obj/obj_merville") {
    	local.bomb_team = ("textures/hud/axis")
    	local.location = "Ammo Truck"
    	local.location2 = 0
    	}
    
    if((getcvar(mapname)) == "obj/obj_morning2") {
    	local.bomb_team = ("textures/hud/axis")
    	local.location = "NE Halftrack"
    	local.location2 = 0
    	}
    
    if((getcvar(mapname)) == "obj/opcenter_obj") {
    	local.bomb_team = ("textures/hud/axis")
    	local.location = "Radar Dish"
    	local.location2 = 0
    	}
    
    if((getcvar(mapname)) == "obj/questufou_s_yvette_obj") {
    	local.bomb_team = ("textures/hud/axis")
    	local.location = "NE Halftrack"
    	local.location2 = 0
    	}
    
    if((getcvar(mapname)) == "obj/renan") {
    	local.bomb_team = ("textures/hud/allies")
    	local.location = "Bridge"
    	local.location2 = 0
    	}
    
    if((getcvar(mapname)) == "obj/obj_rush_party") {
    	local.bomb_team = ("textures/hud/axis")
    	local.location = "Ammo Truck"
    	local.location2 = "King Tiger Tank"
    	}
    
    if((getcvar(mapname)) == "obj/schplatzburg_obj") {
    	local.bomb_team = ("textures/hud/axis")
    	local.location = "Bomb 1"
    	local.location2 = "Bomb 2"
    	}
    
    if((getcvar(mapname)) == "obj/stlo") {
    	local.bomb_team = ("textures/hud/axis")
    	local.location = "South Cannon"
    	local.location2 = 0
    	}
    
    if((getcvar(mapname)) == "obj/thechurch_final_obj") {
    	local.bomb_team = ("textures/hud/axis")
    	local.location = "Church Cannon"
    	local.location2 = 0
    	}
    
    if((getcvar(mapname)) == "obj/the_lost_village") {
    	local.bomb_team = ("textures/hud/axis")
    	local.location = "Axis Safe"
    	local.location2 = "Secret Documents"
    	}
    	
    if(local.location == 0) 
    	end
    
    // Display Hud -------------------------------------------------------------------
    
    while (level.mef_gametype == "obj" || level.mef_gametype == "ftobj") {
    
    	huddraw_align  206 right top
    	huddraw_font   206 "courier-16"
    	huddraw_rect   206 -160 55 50 14
    	huddraw_alpha  206 1.0
    	huddraw_string 206 ("= OBJECTIVE = ")
    
    	huddraw_shader 205 (local.bomb_team)
    	huddraw_align  205 right top
    	huddraw_rect   205 -170 77 15 15
    	huddraw_alpha  205 1.0
    
    	huddraw_align  202 right top
    	huddraw_font   202 "courier-15"
    	huddraw_rect   202 -150 77 50 14
    	huddraw_color  202 1.0 1.0 1.0
    	huddraw_alpha  202 1.0
    	huddraw_string 202 (local.location)
    
    if(local.location2 != 0) {
    	huddraw_shader 203 (local.bomb_team)
    	huddraw_align  203 right top
    	huddraw_rect   203 -170 99 15 15
    	huddraw_alpha  203 1.0
    
    	huddraw_align  204 right top
    	huddraw_font   204 "courier-15"
    	huddraw_rect   204 -150 99 50 14
    	huddraw_alpha  204 1.0
    	huddraw_string 204 (local.location2)
    	}
    
    wait 5
    }
    
    end

  2. #2

    Default

    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

  3. #3

    Default

    Thanks Searingwolfe. The Hud updates when there is a single OBJ. But I have an issue setting up the triggers for two bombs. I wanted to set the bomb coords in the maplist check for each map, but the trigger doesn't seem to work.

    I had something like this...


    Code:
    if((getcvar(mapname)) == "obj/obj_team2") {
    	local.bomb_team = ("textures/hud/axis")
    	local.location = "V2 Rocket"
    	local.origin1 = ( 2358 1207 -729 )
    	local.location2 = "Control Room"
    	local.origin2 = ( 2309 2680 71 )
    	}
    Code:
    	local.bombtrig1 = spawn trigger_multiple 
    	//local.bombtrig1.origin = ( 2358 1207 -729 ) // coords of the 1st objective's bomb plant site
    	local.bombtrig1.origin = local.origin1
    	local.bombtrig1 setsize ( -50 -50 -50 ) ( 50 50 50 )
    (and something similar for the second trigger)

    When I place the coordinates directly in the local.bombtrig1.origin line, it works fine. But when I try to use local.bombtrig1.origin = local.origin1, it doesn't work.

    You mentioned something about using the trigger name. How would I set that up exactly? It would probably be easier than setting coordinates. The maps I need it for have trigger names I can use.

  4. #4

    Default

    If you spawn in the bombtrig1 trigger_multiple in a different thread, you'll have to carry over the local.origin1, local.origin2 into that thread.
    Or more simply, you can turn those local variables into level variables: level.origin1, level.origin2. I recommend putting them in an array with level.origin[1], level.origin[2], works the same way. Try these out below:

    Code:
    main: // level variables, carries through all threads for the current map.
    ...
    if((getcvar(mapname)) == "obj/obj_team2") {
    	local.bomb_team = ("textures/hud/axis")
    	local.location = "V2 Rocket"
    	level.origin[1] = ( 2358 1207 -729 )
    	local.location2 = "Control Room"
    	level.origin[2] = ( 2309 2680 71 )
    	}
    ...
    level waittill prespawn
    ...
    level waittill spawn
    ...
    thread triggers
    end
    
    triggers:
    
    	local.bombtrig1 = spawn trigger_multiple targetname "bombtrig1" // change its origin at any time with $bombtrig1.origin = ...
    	//local.bombtrig1.origin = ( 2358 1207 -729 ) // coords of the 1st objective's bomb plant site
    	local.bombtrig1.origin = level.origin[1]
    	local.bombtrig1 setsize ( -50 -50 -50 ) ( 50 50 50 )
    end
    Code:
    main: // non-level variable method
    ...
    if((getcvar(mapname)) == "obj/obj_team2") {
    	local.bomb_team = ("textures/hud/axis")
    	local.location = "V2 Rocket"
    	local.origin1 = ( 2358 1207 -729 )
    	local.location2 = "Control Room"
    	local.origin2 = ( 2309 2680 71 )
    	}
    ...
    level waittill prespawn
    ...
    level waittill spawn
    ...
    thread triggers local.origin1 local.origin2
    end
    
    triggers local.origin1 local.origin2:
    
    	local.bombtrig1 = spawn trigger_multiple targetname "bombtrig1"
    	//local.bombtrig1.origin = ( 2358 1207 -729 ) // coords of the 1st objective's bomb plant site
    	local.bombtrig1.origin = local.origin1
    	local.bombtrig1 setsize ( -50 -50 -50 ) ( 50 50 50 )
    end

  5. #5

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •