Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Countdown Scripting Question: Making a player invunerable

  1. #1

    Default Countdown Scripting Question: Making a player invunerable

    Hey guys,

    I was taking a swing at modding the countdown mod Elgan made, and I wanted to add the feature where if a player picks up the radio he will not be able to die for 10 seconds.
    I was successful in adding the timer after picking up the radio with "local.player stopwatch 10", but was unable to make the player un-killable.

    The efforts I made to try and add this were based off of looking at scripts from other game types such as base-builder or Liberation, where in one case there was a thread that used "self immune" and the other did "local.player dog"
    Both did not work for me in Countdown, however due to my lack of experience I may have placed them in the wrong area.

    Here is what I had been working on.

    Thanks

    Code:
    // 22/11/2005 18:07 added in radio drop features
    
    main local.origin:
    
    	spawn level.radio_model "targetname" "countdown_radio" "classname" "scriptmodel"
    	//local.radio model "items/explosive.tik" //"items/walkietalkie.tik"
    	local.radio = $countdown_radio
    	local.radio notsolid
    	local.radio hide
    
    	if(local.origin[2] == "hog")
    	{
    		local.radio.origin = local.origin[1]
    		
    		//check if the radio is toching any of the players and wait until it is not to show it.
    
    		while(1)
    		{
    			wait 1
    			
    			// if the players are touching it then local.i wont == player size
    			for(local.i=1;local.i <= $player.size ;local.i++ )
    			{
    				if(local.radio istouching $player[local.i])
    				{
    					break
    				}
    			}
    
    			if(local.i == ($player.size + 1))
    			{
    				break
    			}
    
    		}
    	}
    	else
    	{
    		local.radio.origin = local.origin
    	}
    
    	local.radio show
    	local.radio solid
    
    	local.radio.angles = ( 0 0 0 )
    	local.radio droptofloor 
    	local.radio light 1 0 0 50
    
    	local.hit_box = spawn trigger_multiple "spawnflags" 128 "targetname" "radio_box"
    	local.hit_box setsize ( -20 -20 -20 ) ( 20 20 20 )
    	local.hit_box setthread shot
    	local.hit_box.origin = local.radio.origin
    
    	local.use_box = spawn trigger_use  "targetname" "radio_use"
    	local.use_box setsize ( -35 -35 -35 ) ( 35 35 35 )
    	local.use_box setthread use
    	local.use_box.origin = local.radio.origin
    
    	local.radio.use = local.use_box
    	local.radio.shot = local.hit_box
    
    	local.use_box glue local.radio
    	local.hit_box  glue local.radio
    
    	local.max_idle = getcvar "countdown_idle"
    
    	if(local.max_idle == "")
    	{
    		local.max_idle = 300
    		setcvar "countdown_idle" "300"	
    	}
    	else
    	{
    		local.max_idle = int local.max_idle
    	}
    
    	if(local.max_idle == 0)
    	{
    		local.max_idle = -1
    	}
    
    	local.idle = 0
    	while($countdown_radio)
    	{
    		wait 1
    		local.idle ++
    		if(local.idle == 60)
    		{
    
    			thread flash
    		}
    
    		if(local.idle == local.max_idle && ($countdown_radio))
    		{
    			$countdown_radio.shot delete 
    			$countdown_radio.use delete 
    			$countdown_radio delete 
    			waitframe
    			local.origin = waitexec HTR/setup.scr::getorigin
    			exec HTR/radio.scr local.origin
    			end
    		}
    	}
    
    end
    
    flash:	
    	local.state =1
    
    	while($countdown_radio)
    	{
    		wait 1
    		if($countdown_radio != NIL && $countdown_radio != NULL)
    		{
    			if(local.state ==1)
    			{
    				local.state = 0
    				$countdown_radio light 1 1 0 200
    			}
    			else
    			{
    				local.state = 1
    				$countdown_radio light 1 0 1 200
    			}
    		}
    	}
    end
    
    shot:
    	local.player = parm.other
    	$countdown_radio physics_on
    	$countdown_radio.velocity =  ( 0 0 150 ) + local.player.forwardvector * 500 
    end
    
    use:
    
    	local.player = parm.other
    
    	if(local.player.using_pack == 1)
    	{
    		local.player iprint "You may not use the radio and jetpack" 1
    		end
    	}
    
    	if(level.last_had_radio == local.player)
    	{
    		local.player  iprint "You may not pick up the radio next" 1
    		end
    	}
    	
    	//clear the last player who had it.
    	local.last_had_radio = NIL
    	
    	//remove this line, not sure why it's here
    	//local.player.target = local.player
    
    	local.team = local.player.dmteam
    	local.team  = waitexec global/strings.scr::to_upper local.team  0
    	iprintlnbold (local.team  + " have the radio!")
    
    	$countdown_radio.shot delete
    	$countdown_radio.use delete
    	$countdown_radio delete
    
    	thread give_radio local.player
    end
    
    // give radio to the player
    give_radio local.player:
    
    	local.player playsound m3l2_radio_pickup
    	local.player attachmodel level.radio_model "Bip01 Pelvis" 0.8 "pelvis_radio" 1 -1 -1 -1 -1 ( 1.5 -4 -10.0 )
    	$pelvis_radio.angles = ( 0 90 90 )
    
    	local.player stopwatch 10
    
    	local.light = getcvar "countdown_light"
    
    	if(local.light != "0")
    	{
    		local.player light 0 0 1 200
    	}
    
    	local.player exec HTR/player_radio.scr 
    end

  2. #2
    Purple Developer Purple Elephant1au's Avatar
    Join Date
    Feb 2012
    Location
    Australia
    Posts
    1,269

    Default

    Hi,

    the command you are looking for is

    local.player nodamage // this makes them invulnerable

    and

    local.player takedamage // makes it so the player can take damage again.

    See https://www.x-null.net/forums/thread...3551#post23551 ( links in other comments for downloadable versions )

    Purple's Playground
    OBJ :
    103.29.85.127:12203
    xfire: purpleelephant1au
    email: purpleelephant1au@gmail.com
    skydrive: PurpleElephantSkydrive




  3. #3

    Default

    I would suggest you to make another thread so the code of the mod dont wait for the player to take damage again because could cause some problems.

    I have done the changes:



    give_radio local.player:

    local.player playsound m3l2_radio_pickup
    local.player attachmodel level.radio_model "Bip01 Pelvis" 0.8 "pelvis_radio" 1 -1 -1 -1 -1 ( 1.5 -4 -10.0 )
    $pelvis_radio.angles = ( 0 90 90 )

    thread invunerable_time local.player

    local.light = getcvar "countdown_light"

    if(local.light != "0")
    {
    local.player light 0 0 1 200
    }

    local.player exec HTR/player_radio.scr
    end

    invunerable_time local.player:

    local.player nodamage // no damage to player

    local.player stopwatch 10

    wait 10 // wait this time

    local.player takedamage //takes damage

    end


  4. #4

    Default

    In addition to what DoubleKill posted
    To prevent any script error, after waiting the 10 seconds you need to check if the player still exist with an if statement ( if (local.player) ), and inside this if block put the takedamage code

  5. #5

    Default

    So adding the if statement would it look like this?

    And if what I inserted is correct what would be the statement to check, would it be something like "alive" ?


    Code:
    give_radio local.player:
    
    	local.player playsound m3l2_radio_pickup
    	local.player attachmodel level.radio_model "Bip01 Pelvis" 0.8 "pelvis_radio" 1 -1 -1 -1 -1 ( 1.5 -4 -10.0 )
    	$pelvis_radio.angles = ( 0 90 90 )
    
    	thread invunerable_time local.player
    
    	local.light = getcvar "countdown_light"
    
    	if(local.light != "0")
    	{
    		local.player light 0 0 1 200
    	}
    
    	local.player exec HTR/player_radio.scr
    end
    
    invunerable_time local.player:
    
    local.player nodamage // no damage to player
    
    local.player stopwatch 10
    
    wait 10 // wait this time
    
    local.player takedamage //takes damage
    
    if (local.player)
    {
    	statement
    	...
    	statement
    }
    else
    {
    	statement
    	...
    	statement
    }
    
    end

  6. #6

    Default

    Has to before the command on the player to check if the player exist on the server, like this:


    invunerable_time local.player:

    local.player nodamage // no damage to player

    local.player stopwatch 10

    wait 10 // wait this time

    if (local.player)
    {
    local.player takedamage //takes damage
    }


    end


  7. #7

    Default

    I've not looked at this mod before, but can players drop the radio and pick it up again straight away?

  8. #8

    Default

    In the original mod, I think it is only passable- but other servers have added an option to drop the radio by holding use.

    Thinking on this, would their have to be a separate clause in the script to make sure if a team-mate picked up the radio after the 1st holder died that he wouldn't become invulnerable?
    The idea behind this invulnerable addition is that you only become invulnerable 10 seconds after stealing the radio from the opposite team, or if you are the first on the map to touch the radio.

    As I'm writing this, from looking at other scripts and the SDK i've seen that this sounds like an instance where "case", and allies or axis is needed to specify invulnerability only after initial pickup or a steal?

  9. #9

    Default

    And by passable, I assume you mean taking it from them once they've died? Just checking, cos I can see the need for checks if they can drop it and pick it up again .

    If you want to make a player invulnerable on first acquisition or on acquisition after an enemy has relinquished it, yes you will need more checks. I don't know if there are any variables that already exist you can work with, but you'd want to set one when giving the player a radio.

    So, it would be like:


    invunerable_time local.player:

    // if level.cd_previous_team has a value (thus it's been picked up at least once) and equals to the team picking it up again, end here so we don't make them invincible
    if (level.cd_previous_team && level.cd_previous_team == local.player.dmteam)
    {
    end
    }

    level.cd_previous_team = local.player.dmteam // 'dmteam' is a built-in function that returns the player's team ('axis', 'allies', 'spectator', or 'freeforall' depending on gametype)

    local.player nodamage

    local.player stopwatch 10

    wait 10

    if (local.player)
    {
    local.player takedamage
    }

    end


    Edit: level.cd_previous_team is a new variable, I used 'cd' (countdown) as the prefix as it's good practice to make them unique to the mod so it doesn't conflict with variables defined in other mods.
    Last edited by 1337Smithy; November 18th, 2019 at 04:08 AM.

  10. #10

    Default

    By passable, in the original version if you stand near a teammate and hold use, it gives the teammate the radio. As it stands it doesn't look like the original version offers a way to just drop the radio on the ground unless you die.

Posting Permissions

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