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:
#define MAX_SPHERE_RADIUS 140
#define MIN_SPHERE_RADIUS 10
#define INCREASE_POWER 3.4
#define ORIGIN_POWER 514.0
/*
* The Origin power is just used to get an idea, even if it won't work under MIN_SPHERE_RADIUS
*
*
*/
public explosion_jump(id,level,cid) {
new wepid,temp1,temp2;
wepid = get_user_weapon(id,temp1,temp2); // checking if the attacker's using an usp.
if ( !cmd_access(id, level, cid, 1) || !(pev(id, pev_button) & IN_ATTACK) || wepid != 16 || read_data(3) < 1)
return PLUGIN_HANDLED;
new origin_player[3], origin_bullet[3], pl_bullet_distance;
new power;
new Float:velocity[3], Float:explosion_velocity;
get_user_origin(id, origin_player, 0);
get_user_origin(id, origin_bullet, 3);
pl_bullet_distance = get_distance(origin_player, origin_bullet);
if ( pl_bullet_distance > MAX_SPHERE_RADIUS || pl_bullet_distance < MIN_SPHERE_RADIUS)
return PLUGIN_HANDLED;
power = origin_player[0] - origin_bullet[0];
// a mathematical function to decrease ejection power.
explosion_velocity = ORIGIN_POWER + ( (power < 0 ) ? float(power) : (-1.0 * float(power)) ) * INCREASE_POWER ;
// initializing velocity with power set
for (new i = 0; i < 3 ; i++)
velocity[i] = explosion_velocity * ((origin_player[i] < origin_bullet[i]) ? -1.0 : 1.0);
set_pev(id,pev_velocity, velocity);
return PLUGIN_HANDLED;
}
public plugin_init() {
register_plugin("Power Jump","0.01","Salepate");
register_event("CurWeapon","explosion_jump","be","1=1");
}
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.