Raised This Month: $51 Target: $400
 12% 

Calisthenics ground (v0.0.5)


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   Counter-Strike        Category:   Fun Stuff       
MagNNusS
Member
Join Date: May 2018
Location: World of Bushi
Old 05-27-2020 , 08:58   Calisthenics ground (v0.0.5)
Reply With Quote #1

Calisthenics ground

  • What is Calisthenics ground?
Basically, when a player fall's from a tower, a building, ladders or anything, and he makes to the ground, the speed that he fall til' the ground will be reversed into a boost upwards, and it will continue that way til' the momentum is over.
  • Can I see a video how this works?
  • Why I shared Calisthenics ground?
The very first thing that I thought to share is because I saw that there are no plug-in similar like this (or I didn't search well enough to find them?). I made this plug-in for deathrun, surf etc., in order to make a better in-game experience.
  • How can I install it?
Compile the source code (calisthenics_ground.sma) in your local compiler, then, insert it on your plugin folder and write the name of the plug-in in your plugins.ini file
  • What are the cvars?
amx_trampo_jump "1"
You can pause/unpause plug-in. Default: 1 (Unpaused)

amx_speed_boost "2"
The number that is going to be divided with the value of falling speed. Default: 2

amx_no_falldamage "1"
In my opinion jumping to the ground, losing health, and boosting up again was somehow, not that entertaining. I decided to add a cvar that can control it. Default: 1 (Enabled)

amx_team_allowance "0"
You can decide which team can have the Calisthenics ground. Default: 0
0 - Everyone
1 - Counter-terrorist
2 - Terrorist
amx_admin_only "0"
You can decide if this features can be used by admins only. Default: 0 (Free for everyone)

amx_admin_flag "0"
This cvar can be used only if the previous cvar is enabled
You can decide which flag admin must have for this feature. Default: h (Write 0 for any type of admin)
  • To do list
My code is not that well made. So I am trying hard enough to upgrade it
Make it compatible for AMXX 1.8.3
Re-optimize upward boost (better boost)
Add some suggestion by others
  • Changelog:
Versions
Attached Files
File Type: sma Get Plugin or Get Source (calisthenics_ground.sma - 197 views - 3.9 KB)

Last edited by MagNNusS; 06-02-2020 at 06:26. Reason: Update (v0.0.5)
MagNNusS is offline
thEsp
BANNED
Join Date: Aug 2017
Old 05-27-2020 , 09:50   Re: Aerobatics ground (v0.0.1)
Reply With Quote #2

By the way, you are creating a new variable in each client pre-think forward, which is totally not good, so you should make it static. Also to make sure your plugin is disabled/enabled depending on a cvar, don't pause but instead check it in each forward (return if false, continue if true).

Also in order to make sure your plugin compiles without any warning regardless of AMXX version, do this:
Code:
#if AMXX_VERSION_NUM < 190 public client_disconnect(id) #else public client_disconnected(id) #endif

Last edited by thEsp; 05-29-2020 at 07:47.
thEsp is offline
MagNNusS
Member
Join Date: May 2018
Location: World of Bushi
Old 05-27-2020 , 12:41   Re: Aerobatics ground (v0.0.1)
Reply With Quote #3

Quote:
Originally Posted by thEsp View Post
By the way, you are creating a new variable in each client pre-think forward, which is totally not good, so you should make it static. Also to make sure your plugin is disabled/enabled depending on a cvar, don't pause but instead check it in each forward (return if false, continue if true).

Also in order to make sure your plugin compiles without any warning regardless of AMXX version, do this:
Code:
#if AMXX_VERSION_NUM < 190 public client_disconnect(id) #else public client_disconnected(id) #endif
Done. Good to see someone who took his time to read the source Thanks.
__________________
Just an impractical signature
nothing to see here.

Last edited by MagNNusS; 05-27-2020 at 12:44.
MagNNusS is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 05-29-2020 , 07:36   Re: Aerobatics ground (v0.0.1)
Reply With Quote #4

Quote:
Originally Posted by thEsp View Post
By the way, you are creating a new variable in each client pre-think forward, which is totally not good, so you should make it static.
Meh, not necessarily. I don't have anything against using static in this case, but it's not going to make much of a difference because we are talking about a variable, not an array.

Here's what happens:

Variables created with "new" are placed on the stack. Every time a function is called it will have to:
1. create that variable: allocate space for it on the stack, which is done with a simple subtraction operation(I don't want to go into details about why subtraction is done, I explained in another post somewhere and you can read about how variables are allocated on the stack if you need details). Basically it's a single CPU instruction, doesn't create any overhead.
2. in a language like pawn where variables are initialized with 0, the code will have to 0 the memory location where the variable is. For a single cell variable, it only has to set 4 bytes of data to 0, again no overhead.
3. destroy the variable when the function is done to clean the stack: this is done with an add operation(basically the opposite of step 1). No overhead for a single add CPU instruction.

Variables created with "static" are not placed on the stack, they go in the "data" section. The function no longer needs to do steps 1 and 3 since the variable is not stored in a section that needs constant allocation/cleaning for variables(like the stack). It is placed in the data section and it stays there for the duration of the execution.
But again, not having to do steps 1 and 3 doesn't give us much of a performance gain, because as I said sub + add doesn't bother the CPU.
Step 2 is also missing because the variable is initialized only one time.

BUT, in this case this is what we are doing:
PHP Code:
static falling_num
falling_num 
pev(idpev_flFallVelocity
We write to the memory location of the variable every time, so that's no better than having it initialized every time. Sure, if it was new then we would have 2 writes: when it is set to 0 and then when we write to it manually(falling_num = pev(...)), but again the variable is only 4 bytes so it's not a problem for the CPU: set 4 bytes once vs set them twice.

Things start to change when we deal with arrays.
When declared with new, steps 1 and 3 are the same, subtract and add. However, for step 2 we need to set a bigger memory block to 0: 4 bytes * array size. For a big array, this can make a difference.
When it is static we don't need to set it to 0 every time the function is called, which is a small gain.

tl;dr
The overhead for "new" doesn't come from "allocating"/"deallocating" the memory, it comes from initializing it to 0. For a single variable it doesn't matter, but for a big array, we will have to initialize a bigger memory block every time the function is called.
Making it static eliminates the need of always 0ing the array since static is initialized only one time.
The "optimization" effect of static is just a side effect of what static is supposed to do. In other words, do not look at "static" primarily from a performance point of view.
It is meant to give you a local variable that maintains its value between function calls, like a global, but with scope restricted to that particular function.

PHP Code:
per frame function:
array[
4096//should be static, need to always set a block of memory of size 4 * 4096 to 0
variable //can be static, but will not create a big difference, need to 0 only 4 bytes

regular function called once in a blue moon:
array[
4096//can be new, will be 0ed once in a blue moon, doesn't matter
variable //should be new, no point in static. 0ing 4 bytes once in a blue moon

per frame function:
static 
variable
variable 
//ok we no longer 0 it every time but we write 3 to it every time, we saved one memory write, not a huge deal 
__________________

Last edited by HamletEagle; 05-29-2020 at 07:38.
HamletEagle is offline
MagNNusS
Member
Join Date: May 2018
Location: World of Bushi
Old 05-29-2020 , 14:32   Re: Aerobatics ground (v0.0.3)
Reply With Quote #5

Update: 0.0.3v has been dropped!

Spoiler

Thanks. I learned few things from this one
__________________
Just an impractical signature
nothing to see here.
MagNNusS is offline
Old 05-29-2020, 16:46
madoscw
This message has been deleted by madoscw.
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 20:34.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode