Immune
Moderator: Moderators
-
chrisjbooth2001
- Colour Sergeant
- Posts: 77
- Joined: Thu Dec 18, 2003 12:57 am
Immune
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...
but this only happens when the door is closed, when it opens you get your guns back and can die again...
-
Bjarne BZR
- Site Admin
- Posts: 3298
- Joined: Wed Feb 05, 2003 2:04 pm
- Location: Sweden
- Contact:
well i saw this in a tank sciprt so i don tknow if its applicable on a player but
hope this helps
Code: Select all
// Set the tank's immunities.
self immune bullet
self immune fast_bullet
self immune grenade
self immune bash-
chrisjbooth2001
- Colour Sergeant
- Posts: 77
- Joined: Thu Dec 18, 2003 12:57 am
-
Bjarne BZR
- Site Admin
- Posts: 3298
- Joined: Wed Feb 05, 2003 2:04 pm
- Location: Sweden
- Contact:
-
omniscient
- Major General
- Posts: 694
- Joined: Tue Sep 16, 2003 12:02 am
-
chrisjbooth2001
- Colour Sergeant
- Posts: 77
- Joined: Thu Dec 18, 2003 12:57 am
-
nuggets
- General
- Posts: 1006
- Joined: Fri Feb 28, 2003 2:57 am
- Location: U-england-K (england in the UK) :P
- Contact:
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
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
hope this helps, prob not cos it's all foreign 2 me :-/
-
dcoshea
- Colour Sergeant
- Posts: 94
- Joined: Thu Mar 04, 2004 3:00 am
- Location: Sydney, Australia
- Contact:
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:
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
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
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
-
chrisjbooth2001
- Colour Sergeant
- Posts: 77
- Joined: Thu Dec 18, 2003 12:57 am
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-
omniscient
- Major General
- Posts: 694
- Joined: Tue Sep 16, 2003 12:02 am
-
dcoshea
- Colour Sergeant
- Posts: 94
- Joined: Thu Mar 04, 2004 3:00 am
- Location: Sydney, Australia
- Contact:
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:chrisjbooth2001 wrote:Code: Select all
//------------------------------------------ allies_box: //------------------------------------------ while ($player[local.i].dmteam == "allies" isTouching $alliesbox)
Code: Select all
for (local.i = 1; local.i <= $player.size; local.i++) {
...
}Code: Select all
local.player takeallRegards,
David
[Edit: fixed up formatting]
-
dcoshea
- Colour Sergeant
- Posts: 94
- Joined: Thu Mar 04, 2004 3:00 am
- Location: Sydney, Australia
- Contact:
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.omniscient wrote:well why take the guns away if theyre immune to everything??
Regards,
David


