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

[INC] CHR Engine v1.1b


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GHW_Chronic
SourceMod Donor
Join Date: Sep 2004
Location: Texas
Old 01-02-2007 , 02:41   [INC] CHR Engine v1.1b
Reply With Quote #1

  • This is a compilation of stocks that required greater than average math skills to create.
  • They have many functionalities.
  • Stocks require the fakemeta module.

Code:
get_speed_vector(const Float:origin1[3],const Float:origin2[3], Float:speed, Float:new_velocity[3]) /* * *  Determines velocity (new_velocity) that *  you would set an entity to in order for *  it to go at "speed" from "origin1" to *  "origin2". * */


Code:
get_speed_vector2(ent1, ent2, Float:speed, Float:new_velocity[3]) /* * *  Determines velocity (new_velocity) that *  you would set "ent1" to in order for it *  to go at "speed" from "ent1"'s origin *  to "ent2"'s origin. * */


Code:
get_offset_origin(ent,const Float:offset[3],Float:origin[3]) /* * *  Determines location ("origin") of an entity *  with supplied offset to its original angles. * *  Example: You want the location of 30 units *  to the left of a model but the model is *  turned at an angle so you cannot simply add *  the offset to the origin. Then you would use *  this. * */


Code:
get_offset_origin_body(ent,const Float:offset[3],Float:origin[3]) /* * *  Determines location ("origin") of a monster *  or player entity with supplied offset to its *  original angles. * *  Example: You want the location of 30 units *  to the left of a model but the model is *  turned at an angle so you cannot simply add *  the offset to the origin. Then you would use *  this. * *  Works same as above but only for players and *  monsters. * */


Code:
is_user_crouching(ent,ignoreplayer=0) /* * *  Determines if a player is crouching or not. *  Return 1 if crouching and 0 if not. * *  Set ignoreplayer to 1 if you are using on *  a HL monster that can crouch. * */


Code:
get_players_distance(const Float:origin[3],players[32], &num,flags[]="",index=0,team[]="") /* * *  Returns indexes of players in order according *  to how close they are to "origin". Indexes are *  stored in "players[32]" and the number of *  indexes returned is stored in num. team[] is *  used only if flag 'e' is passed. * *  Flags: *  "a" - Don't return dead players *  "b" - Don't return alive players *  "c" - Skip bots *  "d" - Skip real players *  "e" - Match with passed team *  "h" - Skip HLTV *  "i" - Is in Viewcone *  "j" - Is Visible * *  If flag 'i' is passed, you must specify into *  variable "index" who's viewcone to check if *  the returned players are in. * */


Code:
entity_set_aim(ent,const Float:origin2[3],bone=0) /* * *  Forces "ent" to aim at "origin" * *  Set bone to a positive value to *  detect a specific bone the function *  should aim from. * */


Code:
get_hudmessage_locs(ent,const Float:origin[3],Float:hudpos[2]) /* * *  If "origin" is in ent's viewcone, the location *  of it using the hudmessage grid will be placed *  into hudpos[2]. * *  Returns 0 if "origin" is not on ent's hud. * *  ent must be a player (index 1-32). * */


Code:
set_speed(ent,Float:speed,mode=0,const Float:origin[3]={0.0,0.0,0.0}) /* * *  Sets ent's speed in the direction specified *  by the mode variable * *  Modes: *   0 = In direction ent is currently moving *        but not including the z axis *   1 = In direction ent is currently moving *   2 = In direction ent is currently looking *   3 = In direction ent is currently looking *        but not including the z axis *   4 = In direction of origin[3] * * *  Use a negative speed to go in the opposite *  direction of the specified mode. * */


Code:
is_within_difference(Float:number1,Float:number2,Float:difference) /* * *  Determines if 2 floats are within "difference" *  between eachother. * *  Example: 2.0 is within 5.0 "difference" of 7.0 * */

Code:
#define MAX_SIDES   20 is_inside(const Float:point[2],const Float:polygon[MAX_SIDES][2],numsides) /* * *  Determines if point[2] is inside of polygon[20][2]. *  Returns 1 if it is and 0 if it isn't. * *  Any polygon of any shape can be put into the polygon *  array. MAX_SIDES define has to be changed for more *  than 20 sides. * *  numsides if the number of sides put into polygon[20][2]. * *  Example Usage: * *  new Float:square[MAX_SIDES][2], Float:point[2] *  point[0] = 0.0 *  point[1] = 0.0 * *  //4 sides are made up between the 4 points. *  //The sides make up a square if you connect *  //the points. *  square[0][0] = 10.0 *  square[0][1] = 10.0 *  square[1][0] = 10.0 *  square[1][1] = -10.0 *  square[2][0] = -10.0 *  square[2][1] = -10.0 *  square[3][0] = -10.0 *  square[3][1] = 10.0 * *  //will return 1 because (0,0) is *  //inside the polygon made by the array. *  is_inside(point,square,4) * */

Code:
stock Float:distance_from_line(Float:start[3],Float:end[3],Float:origin[3],&is_visible) /* * *  Returns the distance origin[3] is at its closest *  location to the line drawn from start[3] to end[3] * *  &is_visible is filled with 1 if origin[3] is visible *  by the line at its nearest point, 0 if it is not * */


CHR_Engine Approved Plugins:
Sparta Mod (300) - DA
GHW Aim Targets - GHW_Chronic
Headcrab Spawner - GHW_Chronic
Monster AI - Headcrab - GHW_Chronic
GHW Pet Followers - GHW_Chronic
Prometheus (Enhanced Hostages) - XxAvalanchexX
Long Jump - GHW_Chronic
"Hacks" Plugin - GHW_Chronic

Your approved CHR Engine plugin not listed? PM me.
Attached Files
File Type: inc chr_engine.inc (16.3 KB, 7895 views)

Last edited by GHW_Chronic; 07-11-2009 at 07:16.
GHW_Chronic is offline
Send a message via AIM to GHW_Chronic
GHW_Chronic
SourceMod Donor
Join Date: Sep 2004
Location: Texas
Old 01-02-2007 , 02:50   Re: [INC] CHR Engine
Reply With Quote #2

also made this script for a friend. This allows you to see how easy it is to make a plugin with these functions.

Edit: This plugin has been submitted as an actual plugin. Link in main post.

Last edited by GHW_Chronic; 01-04-2007 at 21:23.
GHW_Chronic is offline
Send a message via AIM to GHW_Chronic
VEN
Veteran Member
Join Date: Jan 2005
Old 01-02-2007 , 05:31   Re: [INC] CHR Engine
Reply With Quote #3

Some issues.

Code:
anglemode:degrees
degrees already has anglemode tag:
Code:
enum anglemode {  radian = 0,  degrees,  grades }

Code:
<= 45.0
Is this a hardcoded FOV/2? If so then i'd not recommend to hardcode it, it could change.

Also i'd recommend to prepend a const attribute in function headers for arrays that isn't changed by the function. That will allow to pass a constant arrays without "argument type mismatch" error.

Here is the fix to avoid possible instant calling on landing:
Code:
if((pev(id,pev_button) & IN_JUMP) && !(pev(id,pev_oldbuttons) & IN_JUMP) && (pev(id,pev_flags) & FL_ONGROUND)) //
VEN is offline
Zenith77
Veteran Member
Join Date: Aug 2005
Old 01-02-2007 , 11:51   Re: [INC] CHR Engine
Reply With Quote #4

Nice I'll definitely have some uses for this.
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
GHW_Chronic
SourceMod Donor
Join Date: Sep 2004
Location: Texas
Old 01-02-2007 , 12:49   Re: [INC] CHR Engine
Reply With Quote #5

Quote:
Originally Posted by VEN View Post
Code:
anglemode:degrees
degrees already has anglemode tag:
Code:
enum anglemode {  radian = 0,  degrees,  grades }
The anglemode: is still needed on the degrees or else it returns radians. Testing this plugin I couldn't figure out wtf floatsin etc were outputting, and when i added the anglemode: it returned degrees, so I soon found out it was before returning radians.


Quote:
Originally Posted by VEN View Post
Code:
<= 45.0
Yes that is FOV. I didn't really think about it being able to change, I forgot about scopes etc though. I changed code to comply with FOV changes. thx.


Quote:
Originally Posted by VEN View Post
Also i'd recommend to prepend a const attribute in function headers for arrays that isn't changed by the function. That will allow to pass a constant arrays without "argument type mismatch" error.
Got it, fixed, thx.


Quote:
Originally Posted by VEN View Post
Code:
if((pev(id,pev_button) & IN_JUMP) && !(pev(id,pev_oldbuttons) & IN_JUMP) && (pev(id,pev_flags) & FL_ONGROUND))
Forgot about that. thx again, fixed.
GHW_Chronic is offline
Send a message via AIM to GHW_Chronic
VEN
Veteran Member
Join Date: Jan 2005
Old 01-02-2007 , 13:46   Re: [INC] CHR Engine
Reply With Quote #6

Actually i'm not quite sure if i get what you mean (and it doesn't seem logical to me) but what i meant is that technically anglemode:degrees equal to anglemode:anglemode:1. Since degrees already enumerated with the anglemode tag bascially what you actually doing is prepend a second anglemode tag that isn't required of course.

It is somethig like this for example:
new hello:x, hello:y = hello:x

Though the above example will not lead to a compilation warning the following example are more correct:
new hello:x, hello:y = x

And the tag type can't lead to a different function result. It's just a prefix but the value is still the same. So you can do even for example:
hello:(_:degrees)

And you'll get the same result ignoring the compilation warning of course.

Last edited by VEN; 01-02-2007 at 13:53.
VEN is offline
GHW_Chronic
SourceMod Donor
Join Date: Sep 2004
Location: Texas
Old 01-02-2007 , 14:02   Re: [INC] CHR Engine
Reply With Quote #7

hrm, I don't know what I had tested before then because I just retested and your logic is indeed logic.
Code:
#include <amxmodx> public plugin_init() server_print("%f | %f",floatsin(90.0,degrees),floatsin(90.0,anglemode:degrees))
Quote:
1.000000 | 1.000000
meh, I'll take out the anglemode:
GHW_Chronic is offline
Send a message via AIM to GHW_Chronic
GHW_Chronic
SourceMod Donor
Join Date: Sep 2004
Location: Texas
Old 01-04-2007 , 21:48   Re: [INC] CHR Engine
Reply With Quote #8

Fixed a problem where negative speeds in the set_speed stock were not read because the math for it required squaring the speed.
GHW_Chronic is offline
Send a message via AIM to GHW_Chronic
GHW_Chronic
SourceMod Donor
Join Date: Sep 2004
Location: Texas
Old 01-05-2007 , 00:52   Re: [INC] CHR Engine
Reply With Quote #9

Fixed a problem where get_players_distance was returning farthest to closest instead of closest to farthest.
GHW_Chronic is offline
Send a message via AIM to GHW_Chronic
GHW_Chronic
SourceMod Donor
Join Date: Sep 2004
Location: Texas
Old 01-06-2007 , 06:27   Re: [INC] CHR Engine
Reply With Quote #10

Added flags i + j to the get_players_distance function.
Changed array variables in functions who's probable purpose would cause them to be called a lot to static variables.
GHW_Chronic is offline
Send a message via AIM to GHW_Chronic
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 09:30.


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