A virtual sphere to eject player.
At first, I'm glad to be validated on this forum, I hope I won't act as fool and will respect every rules written, and I'll try to be understood as well I can do.
I lack english a bit but it should be ok. To start and introduce you to what I want to mean, I will explain what my plugin is supposed to do and what it does... Perhaps, some of you have tested a Natural-Selection Plugin, which change the colt into an explosive colt. Where it shoots, an explosion appear, and if you're in the area, you will be propelled in the air according a mathematical process which follow vectors rules. I wanted to create a similar one on counter-strike, but actually, I have done everything wrong, even though my plugin is working, Vectors rules are just messed up. I have made a little scheme [IMG]http://img58.**************/img58/2008/boomshotxy3.png[/IMG] It should help you to understand what I am saying. I'll share you my code too (it should be indented well) Code: Code:
Of course, I removed useless parts. I think to make it works as I want, I have to create a vector with "targeted position as the origin" (on the scheme) "Player's position as the direction" (still on the scheme) But I don't have any idea how to proceed. I would be glad of having any help, Thanks Salepate. |
Re: A virtual sphere to eject player.
If you only want to make the player who fired the shot fly, this may work.
velocity_by_aim ( iIndex, iVelocity, Float:vRetValue[3] ) iIndex is of course the player index, iVelocity is the multiplier for the velocity. for you power adjustment try: iVelocity = (pl_bullet_distance - MAX_SPHERE_RADIUS) * ORIGIN_POWER Note that this will give you a negative value (which should send you flying backward). |
Re: A virtual sphere to eject player.
Code:
This worked pretty nice. The power calculation is a bit linear, so you end up flying pretty high if you shoot right near your feet. You could take the square root of the stuff in parenthesis and that may give it a more natural feeling drop-off. |
Re: A virtual sphere to eject player.
Hello, it will help me a lot, so many thanks it's exactly what I was searching for.
Good day. |
Re: A virtual sphere to eject player.
Is there a way to simulate an aim. Because If I'm not aiming the position where the explosion fires, I won't be propelled from the explosion, but from my aim. (if you know what I mean).
|
Re: A virtual sphere to eject player.
Code:
OK, so this is what you want to do mathwise. 1. Find the displacement between the player and the explosion. For the example the explosion location (origin_bullet) is where the bullet hits based on aim (user_get_origin mode 3). Where the bullet really hits is a bit more complicated but there is a tutorial in the forums about finding that. 2. Find the length of the displacement vector. There is a native function for that. 3. Normalize the displacement vector. You will use this as your normalized velocity. The normalized vector is a vector that points in the same direction, but has a length of 1. 4. Multiply the normalized vector by your power scalar to get the velocity vector. Then you just plug in the velocity to set_pev. Please note that PM made some functions for doing all the math in the example. They are located scripting/includes/XS.inc. I did it the long way so that you can see how the math works. For further reading try this great vector math introduction. |
Re: A virtual sphere to eject player.
Okay thanks, I ported the code for making effective the explosion against all present players, and it perfectly works.
The last thing which doesn't work is the blast circle effect, and the explosion is not appearing as well, only some sparks show theirselves. I at first, supposed that the blast circle was burried in the ground, but when shooting on someone in the air, it didn't appear. I'll try to fix it myself, and to keep you informed on my plugin's state Edit: nevermind, I've though about it during school, Code:
|
| All times are GMT -4. The time now is 22:19. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.