PDA

View Full Version : TS Natives (Version: 0.1b)


Drak
03-26-2009, 18:44
Version: 0.1b

This was quickly done, tested, but probably not well enough. I'm going to add alot more, but it might have some use currently.
As of right now, there is one forward, that is called each time a player does a stunt.

Include the "include" below in your plugin to use this forward.

TS_Stunt(id,Stunt:Type)

Usage:

public TS_Stunt(id,Stunts:Type)
if(Type == ST_DIVE)
client_print(id,print_chat,"[TS] You just dived!");

List of stunts:

enum Stunts
{
ST_DIVE = 0,
ST_DIVE_LEFT,
ST_DIVE_RIGHT,
ST_BACKFLIP,
ST_FRONTFLIP,
}


Planned:
Blocking of Stunts
Attack's Forward (Hooking Melee Attacks)

If you have any suggestions, please post :D

NOTE: You must be running the plugin on the server, for this to work.
There are also empty forwards in the include, do not use them.

Arkshine
03-26-2009, 18:58
You are not allowed to attach *.amxx file ; you should remove it, Drak.

Drak
03-26-2009, 19:03
I only did that, because it requires a local compile, and make it more convenient for the downloader.
The .sma is still attached, but since the rules state so. Okay.

Exolent[jNr]
03-26-2009, 20:36
I think it would be best to separate the .inc into a TSDYNatives.inc for the forward and TSDYNatives_const.inc for the enum{ }. Or, you should just add the enum{ } in your TSDyNatives.sma. This is because there is not reason to include the forward in the plugin that executes it.

Also, a little optimization:public forward_PostThink(id)
{
if(!g_Stunt[id] || !is_user_alive(id))
return FMRES_IGNORED

static Return

switch(pev(id, pev_sequence))
{
case 95: ExecuteForward(g_Forwards[0],Return,id,ST_DIVE);
case 96: ExecuteForward(g_Forwards[0],Return,id,ST_DIVE_LEFT);
case 97: ExecuteForward(g_Forwards[0],Return,id,ST_DIVE_RIGHT);
case 149: ExecuteForward(g_Forwards[0],Return,id,ST_FRONTFLIP);
case 152: ExecuteForward(g_Forwards[0],Return,id,ST_BACKFLIP);
}

g_Stunt[id] = 0
return FMRES_HANDLED
}

Hawk552
03-27-2009, 10:55
Your method is very unreliable. You should get DS's message logger and check through the messages if there's anything sent when you stunt.

Also, Exolent is wrong about the optimization in the switch statement, but correct about the combination of the stop at the beginning. In the assembly, though, it's not less or faster code, it's just that you avoid the pev() call if g_Stunt[id] is false.

Another possible optimization:


enum Stunts
{
ST_DIVE = 95,
ST_DIVE_LEFT = 96,
ST_DIVE_RIGHT = 97,
ST_BACKFLIP = 149,
ST_FRONTFLIP = 152
}

switch(Animation)
{
case ST_DIVE,ST_DIVE_LEFT,ST_DIVE_RIGHT,ST_FRONTFL IP,ST_BACKFLIP: ExecuteForward(g_Forwards[0],Return,id,Animation);
}

Drak
03-28-2009, 19:58
The only message sent when stunts are done, is the "TSMBlur" and as far as I can tell, is only sent when a stunt is done.
But it's the same amount of arguments for each stunt. So I just make sure a stunt as been done before I actually check the animation.

But, I updated to what you suggested Hawk.