Skip to content

Instantly share code, notes, and snippets.

@FloooD
FloooD / lcv2-0.lua
Created March 4, 2011 05:09
latest version at https://raw.github.com/FloooD/C_lag_comp/master/llc.lua....................lag compensation eliminates the need of players with high latencies to "lead shots (a.k.a. "do ping calculations") to consistently hit enemies. visit http://cs2d.
--see https://raw.github.com/FloooD/C_lag_comp/master/llc.lua for latest version
@FloooD
FloooD / usgn_decrypt.c
Created March 6, 2011 06:27
get your unrealsoftware password from <cs2d>/sys/usgn_pw.dat
#include <stdio.h>
int main(void)
{
FILE *pw = fopen("usgn_pw.dat", "rb");
if (pw == NULL) {
printf("Put me in the same folder as usgn_pw.dat!\n\nPress enter to exit...");
getchar();
return 1;
}
@FloooD
FloooD / wallbang.lua
Created March 9, 2011 22:52
Lua Lag Comp v1.0.1 + wallbang mod
----------------------------------------------------------------
--LUA Lag Compensation + wallbanging by FlooD-------------------
----------------------------------------------------------------
--thx to Jermuk for his custom server, which first encouraged---
-- me to make lag compensation.------------------------------
--thx to lasthope and def3ct for initial testing.---------------
--thx to 3rr0r for ideas and suggestions for refining the code.-
----------------------------------------------------------------
--visit cs2d.nl/index.php?mod=board&action=thread&where=120 for-
-- the lastest version and information-----------------------
@FloooD
FloooD / line_square_collision.c
Created March 18, 2011 18:22
gets first collision between line segment and square
inline int line_square_collision(float ex, float ey, float sqx, float sqy, float sqhlen, float *ox, float *oy)
{
if (!ox) {float x; ox = &x;}
if (!oy) {float y; oy = &y;}
int cx = (fabsf(sqx) <= sqhlen);
int cy = (fabsf(sqy) <= sqhlen);
if (cx && cy) {
if (fabsf(ex - sqx) <= sqhlen && fabsf(ey - sqy) <= sqhlen) {
*ox = ex; *oy = ey;
return 1;
@FloooD
FloooD / line_circle_collision.c
Created March 22, 2011 00:56
returns 1 if a line segment intersects a circle. returns 0 otherwise. (note: uses polar coordinates.)
int line_seg_circ_polar(float er, float etheta, float cr, float ctheta, float cradius)
{
if (cradius >= cr) return 1;
if (fabsf(etheta - ctheta) > asinf(cradius / cr)) return 0;
if (er * er < cr * cr - cradius * cradius && er * er + cr * cr - 2 * er * cr * cosf(etheta - ctheta) > cradius * cradius) return 0;
return 1;
}
> means client to server
< means server to client
pa
ck
et
id
\/
>02:00:03:3e:6b:fc:00
@FloooD
FloooD / squaremat.lua
Created April 5, 2011 16:28 — forked from leegao/squaremat.lua
only for diagonalizable 2x2 matrices
function m_pow(matrix, n)
local tr = matrix[1][1]+matrix[2][2] -- trace of matrix
local s = math.sqrt((matrix[1][1]-matrix[2][2])^2+4*matrix[1][2]*matrix[2][1]) -- sqrt(tr^2 - 4*determinant)
local r1 = 0.5*(tr+s) --1st eigenvalue
local r2 = tr-r1 --2nd eigenvalue
local r1n = r1^n
local r2n = r2^n
@FloooD
FloooD / matrix.lua
Created April 5, 2011 18:25
should be pretty slow
function matrixpower(m, n)
local d = #m
local temp = {}
local mm = {}
for i = 1, d do
temp[i] = {}
mm[i] = {}
for j = 1, d do
mm[i][j] = m[i][j]
end
@FloooD
FloooD / lasermod.lua
Created April 27, 2011 22:57
LaserMod = lasers + geometric optics
----------------------------------------------------------------
--LUA Lag Compensation version 1.0.1 + LaserMod by FlooD--------
----------------------------------------------------------------
--thx to Jermuk for his custom server, which first encouraged---
-- me to make lag compensation.------------------------------
--thx to lasthope and def3ct for initial testing.---------------
--thx to 3rr0r for ideas and suggestions for refining the code.-
----------------------------------------------------------------
--visit cs2d.nl/index.php?mod=board&action=thread&where=120 for-
@FloooD
FloooD / snowball.lua
Created April 28, 2011 04:02
all weapons shoot snowballs :D
----------------------------------------------------------------
--LUA Lag Compensation version 1.0.1 + snowball by FlooD--------
----------------------------------------------------------------
--thx to Jermuk for his custom server, which first encouraged---
-- me to make lag compensation.------------------------------
--thx to lasthope and def3ct for initial testing.---------------
--thx to 3rr0r for ideas and suggestions for refining the code.-
----------------------------------------------------------------
--visit cs2d.nl/index.php?mod=board&action=thread&where=120 for-
-- the lastest version and information-----------------------