Page 1 of 2

Immune

Posted: Thu Mar 11, 2004 6:53 am
by chrisjbooth2001
how would i make an area, eg a room, where you enter it (player) and it takes the players weapons and makes them immune to everything?

but this only happens when the door is closed, when it opens you get your guns back and can die again...

Posted: Thu Mar 11, 2004 8:01 am
by Bjarne BZR
Well, the weapons you can do, not sure of the not hurt thing. Anybody less tired than me?

Posted: Thu Mar 11, 2004 11:59 am
by M&M
well i saw this in a tank sciprt so i don tknow if its applicable on a player but

Code: Select all

// Set the tank's immunities.
	self immune bullet
	self immune fast_bullet
	self immune grenade
	self immune bash
hope this helps

Posted: Thu Mar 11, 2004 1:34 pm
by chrisjbooth2001
So i need it scripted so when player touches $immunebox loses guns and immune...

Posted: Thu Mar 11, 2004 2:20 pm
by Bjarne BZR
AND the door is closed, don't forget ;)

Posted: Thu Mar 11, 2004 2:51 pm
by bdbodger
Well I know for ai's you can use nodamage to stop them from takeing damage and then use takedamge to reverse it .

Posted: Fri Mar 12, 2004 12:51 am
by omniscient
couldnt u use $player immnue all
and put like 2 triggers locations, one on a door, one on the ground, and have them set a thread when touched, and not when they arent.

Posted: Fri Mar 12, 2004 2:36 pm
by nuggets
parm.other thread take_it_away
end

take_it_away:
self nodamage
self notsolid
self immune bullet
self immune fast_bullet
self immune explosion
self immune rocket
self takeall
end

Posted: Mon Mar 15, 2004 1:37 am
by chrisjbooth2001
and with that script i do what? lol

This is for a multiplayer map, so it only affects players inside

Posted: Mon Mar 15, 2004 3:10 am
by nuggets
place a trigger_multiple in the room where they will lose everything
key: targetname
value: trigger
key: setthread
value: begin_taking

main:
end

begin_taking:
parm.other thread take_it_away
end

take_it_away:
self nodamage
self notsolid
self immune bullet
self immune fast_bullet
self immune explosion
self immune rocket
self takeall
end

then as you can't give a player back a weapon they originally had, i'd have a weapon rack outside the room so they'd be able to get a weapon again,
remember that they'll need to be made vunerable again after they leave the room

Posted: Mon Mar 15, 2004 3:22 am
by dcoshea
It's easy to take away the player's weapons, but nobody has suggested to you yet how you might give them back, because it's more difficult. I'm not quite sure what you're trying to do, but if everyone in the room is immune to damage while the door is closed, and there are no other openings to the room apart from that one door, why does it matter if they have weapons or not while the door is closed?

If you really want to take their weapons away and then give them back, I'm not sure you can do it accurately. This post on TMT shows you how you can get the player's current weapon (the one they are holding) and get information about it. I figure you would need to go through these steps when taking the weapons away - and note that the code is not tested or even complete, it's just meant to illustrate the algorithm and the pitfalls:

Code: Select all

local.weapon = local.player waitthread get_player_weapon
if (!local.weapon) { // player is not holding a weapon
	local.player stufftext "holster" // maybe they just have their weapon holstered, so try and unholster it
	wait 1 // second, or so, for the weapon to be unholstered
	local.weapon = local.player waitthread get_player_weapon
}
// now either local.weapon points to their weapon from our first call to get the weapon, or the call from after we did a stufftext "holster", or perhaps it's NULL because they aren't holding a weapon even after the "holster"; in the latter case there's a chance they quickly re-holstered their weapon while we were waiting, but that's okay since we'll skip over the while loop below and the 'takeall' after the loop will take away any weapon they were trying to hide from us
while (local.weapon) {
	// record that they have this weapon so we can give it back later
	// NOTE: I don't believe we have any way of recording how much ammo they had
	local.player waitthread record_a_weapon_they_have local.weapon.model

	// now take away the weapon; it looks like you can only take away weapons based on their type, e.g. "rifle", so we need to find out the class of the weapon
	local.weaponclass = waitthread get_weaponclass_from_weapon local.weapon // a thread like this is shown in the post on TMT
	local.player take local.weaponclass

	// now, [b]assuming that when we 'take' it makes the player automatically pull out any other weapon they have[/b], find some other weapon they have
	wait 1 // second to give them time to pull out another weapon, assuming that happens
	local.weapon = local.player waitthread get_player_weapon
	// now we go back to the top of the loop and record that weapon and take it away, etc.
}
// we got here because we've taken away all the player's weapons, assuming they didn't try and hide them from us by holstering them at inopportune moments; do a 'takeall' just to make sure that they didn't try and hide any
local.player takeall
// and we're done taking away the weapons
The "record_a_weapon_they_have" thread would have to maintain some sort of array attached to the Player object of all the model names of the weapons the player had so we can "give" them back later. As I mentioned above, I don't know of any way of recording how much ammo they have, so they'd end up with the default ammo for their weapons, and you'd have to pick some number of grenades you want to give them.

Alternatively, perhaps instead of using "take", you could get the weapon object via some "get_player_weapon" thread, then "stufftext" the command to make them drop their current weapon (and hopefully they didn't change in the meantime causing us to drop a different weapon to the one we have a pointer to), and once the weapon is dropped (we might need to wait a moment for it to happen) we could change the origin of the weapon so it's no longer on the ground in front of the player for them to pick up again. I'm not sure if you can do that but it's just a thought. You could do that for all of their weapons, and that way the ammo amount they had will still be attached to the weapons; you could possibly give the weapons back by moving them to the player's origin, thereby causing the player to be walking over the top of them. An issue here is that weapons disappear a certain amount of time after being dropped, and I don't know how to stop that from happening, even for one particular weapon object.

Regards,
David

Posted: Thu Mar 18, 2004 5:17 pm
by chrisjbooth2001

Code: Select all

//------------------------------------------
allies_box:
//------------------------------------------

	while ($player[local.i].dmteam == "allies" isTouching $alliesbox) 
	{ 
	self immune suicide falling explosion explodewall thrownobject grenade rocket impact
	self immune bullet fast_bullet vehicle fire flashbang on_fire gib impale bash
	self immune shotgun aagun landmine
	local.player takeall 
	}
	end

//------------------------------------------
axis_box:
//------------------------------------------

	while ($player[local.i].dmteam == "axis" isTouching $axisbox)
	{ 
	self immune suicide falling explosion explodewall thrownobject grenade rocket impact
	self immune bullet fast_bullet vehicle fire flashbang on_fire gib impale bash
	self immune shotgun aagun landmine
	local.player takeall 
	}
	end
This is what I have made so far, do you think this is ok, would it stop people dieing and take there weapons when in the box.. Although I only want it to affect a certain team in each box, which you can tell from above?

Posted: Fri Mar 19, 2004 12:58 am
by omniscient
well why take the guns away if theyre immune to everything??

Posted: Fri Mar 19, 2004 1:00 am
by dcoshea
chrisjbooth2001 wrote:

Code: Select all

//------------------------------------------
allies_box:
//------------------------------------------

	while ($player[local.i].dmteam == "allies" isTouching $alliesbox)
What is '$player[local.i]'? I guess you want this to loop through every player, so you must be missing this for loop code around the code:

Code: Select all

for (local.i = 1; local.i <= $player.size; local.i++) {
...
}
You'd want to chagne the 'while' to an 'if' since you'll be adding a 'for' loop.

Code: Select all

	local.player takeall
Like I said, I don't know how you think they're going to get their weapons back after you take them away :)

Regards,
David
[Edit: fixed up formatting]

Posted: Fri Mar 19, 2004 1:03 am
by dcoshea
omniscient wrote:well why take the guns away if theyre immune to everything??
Agreed! Like I said: "if everyone in the room is immune to damage while the door is closed, and there are no other openings to the room apart from that one door, why does it matter if they have weapons or not while the door is closed?" I guess if there was a window, they could snipe from there and be impossible to kill, but if there's no window it's not an issue.

Regards,
David