![]() |
Some small functions I made
Well, I finnaly decided to release some simple functions I've been using lately helping me script stuff.. so here they are :o
PS: This is also my first release in the Code-Gallery :) class PHP Code:
reverseDir(): Well, I made this function for knockback effects, because it gets the direction behind the player, for example input 2 would be 0, 1 would be 3 etc.. example of use: PHP Code:
reversedeg(): Well, this functions does almost the same as reversedir but reverses degrees, for example: 360 would be 180, 180 would be 0 and 247 would be 67 Well, I haven't actually used this alot, but it could be used by projectiles or even spells (wall hit, reflect spells) reverserad(): Yep, it reverses radians, actually it starts reversedeg() and then uses degtorad() to get output, can be used as reversedeg() can be used.. percentage(of, value) Well, easy math thingy, gets a percentage amount of a value, for example PHP Code:
NPC Code: Easy function, I've used this for alot (Spells taking a percentage as mana, damage bonuses etc...) radianequaldir() Basicly all it does it gets the radian value of the current direction of the player I simple used this for a movement system, to get the start radian of the direction Formula used: The formula I've used to get the reverse is in this format: (VALUE+HALF)%FULL where VALUE is the float being reversed, FULL is the max value, for example 360, while HALF is the half value of FULL, for example 180 Notes: All examples are serverside (knockback isn't); the functions will work clientside if you edit the class containing the functions (moving the functions to the clientside) Thanks Dusty for telling an easier formula :D I'll release some "small"-functions later when I make them :O And I also hope some other scripters will release some of their "nifty"-functions :) |
Holy ****!! I smell long equations.... oh wait nvm u made it simple
|
No need for the absolute value in reversedir, modulus will make sure it doesn't go under 0. Same for reversedeg.
Also, why do dir%4? I usually just do (dir+2)%4 |
Quote:
Thanks, will edit my post :) |
You're aware that abs turns a negative value to a posative, right?
|
Quote:
|
Quote:
|
All times are GMT +2. The time now is 09:51 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.