Page 1 of 1

Matrix Respawn Snatch?

Posted: Sun Jun 07, 2009 8:41 am
by Sky_216
Quick question for the scripting gurus - is this possible/feasible:

Use GetEntityMatrix to get the position of a unit (only 1, players) when using a certain weapon.
Force respawn player without dying.
Teleport player to exact location of Matrix.

And do it quickly.

Idea is to have a "snatch" weapon that lets you "grab" a weapon from an enemy (use LastHit, check for enemy class) and then get teleported back near instantly to where you were when you snatched.

Re: Matrix Respawn Snatch?

Posted: Sun Jun 07, 2009 9:03 am
by RepSharpshooter
Skyhammer_216 wrote:Force respawn player without dying.
That's the tricky part. You're basically asking if you can remove the player from the battlefield without killing him. There is only one instance of this ever happening in the game, and that is with unlocking heroes. I'm pretty sure unlocking heroes is more of a hard coded thing, so you'd probably have to work something out as is.

Re: Matrix Respawn Snatch?

Posted: Sun Jun 07, 2009 9:36 am
by Maveritchell
I'll go ahead and say "no." You might be able to mitigate the effects of the player dying, but they'll have to be killed if you want to respawn them.

Re: Matrix Respawn Snatch?

Posted: Sun Jun 07, 2009 5:53 pm
by Sky_216
OK...what if you can kill the player to do it?

Re: Matrix Respawn Snatch?

Posted: Sun Jun 07, 2009 5:57 pm
by Maveritchell
Skyhammer_216 wrote:OK...what if you can kill the player to do it?
Then... yes you can? I'm not sure what you're asking - we both had acknowledged that it's possible to do if you can kill the player. Are you asking how?

Re: Matrix Respawn Snatch?

Posted: Sun Jun 07, 2009 6:16 pm
by Sky_216
Maveritchell wrote:
Skyhammer_216 wrote:OK...what if you can kill the player to do it?
Then... yes you can? I'm not sure what you're asking - we both had acknowledged that it's possible to do if you can kill the player. Are you asking how?
Yes.

Re: Matrix Respawn Snatch?

Posted: Sun Jun 07, 2009 6:28 pm
by Maveritchell
You'll want to:
a) Grab a player's location: variable = GetEntityMatrix(GetCharacterUnit())
b) Kill the player: ScriptCB_PlayerSuicide()
c) Select their character class: SelectCharacterClass()
d) Spawn them at the saved location location: SpawnCharacter()

Re: Matrix Respawn Snatch?

Posted: Mon Jun 08, 2009 4:55 pm
by [RDH]Zerted
There are other issues you have to deal with. First, if you mess with the weapons in MP the game will crash. The stealing weapon would only be usable in singleplayer. Second, we can only change weapons for a unit class, not a single unit itself. That means anyone else spawned as that unit class will also get the new weapon. To get around this, you have to make sure no AI play as the stealing unit class.

Sometimes you don't need to respawn for some weapon changes. Mess around with the weapon changing code before you test the respawning. Try setting the weapon to different slots and see if you can get it instantly working.

Leave out step b from Maveritchell and see if it works.

Remember, those steps are just the respawn sequence. You'll have to update the weapon before a or after b. Test to see which works better.

Re: Matrix Respawn Snatch?

Posted: Mon Jun 08, 2009 5:00 pm
by Maveritchell
[RDH]Zerted wrote:There are other issues you have to deal with. First, if you mess with the weapons in MP the game will crash. The stealing weapon would only be usable in singleplayer. Second, we can only change weapons for a unit class, not a single unit itself. That means anyone else spawned as that unit class will also get the new weapon. To get around this, you have to make sure no AI play as the stealing unit class.

Sometimes you don't need to respawn for some weapon changes. Mess around with the weapon changing code before you test the respawning. Try setting the weapon to different slots and see if you can get it instantly working.

Leave out step b from Maveritchell and see if it works.

Remember, those steps are just the respawn sequence. You'll have to update the weapon before a or after b. Test to see which works better.
If you want to check to see whether a weapon change (like ammo, for instance) will go into effect, you might as well leave out all of the above steps - like Zerted said, those are only for respawning a character.

It's worth mentioning that any time you try and change the first primary weapon, you'll get a crash. The character can't not have a first weapon (first primary), and even if you're just swapping it the game will give you a "cannot build without primary weapon" error.