Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function int LamePow(int a, int pow)
- {
- int res = a;
- for(int i = 1; i < pow; i++)
- res *= a;
- return res;
- }
- function int DMulScale16(int a, int b, int c, int d)
- {
- return (FixedMul(a, b) + FixedMul(c, d));
- }
- function int DivScale13(int a, int b)
- {
- return FixedDiv(a, b);
- }
- function int GetCVarFixed(str name)
- {
- str c = GetCVarString(name);
- // [-|+][123123123][.123123123]
- int part_integer = 0;
- int part_fractional = 0;
- // first, get the location of the dot
- int i;
- int dot = 0;
- for (i = 0; i < StrLen(c); i++)
- {
- if (GetChar(c, i) == '.')
- break;
- }
- dot = i;
- bool negative = false;
- for (i = 0; i < dot; i++)
- {
- if (i == 0 && (GetChar(c, i) == '-'))
- {
- negative = true;
- }
- else
- {
- int ch = GetChar(c, i);
- ch -= 0x30;
- int countOr = dot-i-1;
- for (int j = 0; j < countOr; j++)
- ch *= 10;
- part_integer += ch;
- }
- }
- for (i = dot+1; i < StrLen(c); i++)
- {
- ch = GetChar(c, i);
- ch -= 0x30;
- ch <<= 16;
- countOr = i-dot;
- for (j = 0; j < countOr; j++)
- ch /= 10;
- part_fractional += ch;
- }
- return ((part_integer & 0xFFFF) << 16) | (part_fractional & 0xFFFF);
- }
- function int /* fixed */ CalculateBob(int tid)
- {
- int momx = GetActorVelX(tid);
- int momy = GetActorVelY(tid);
- //print(f:momx, s:";", f:momy);
- int bob = DMulScale16(momx, momx, momy, momy);
- bool still = false;
- if(bob == 0)
- {
- still = true;
- }
- else
- {
- bob = FixedMul(bob, GetCVarFixed("movebob"));
- if(bob < 0 || bob > 0x100000)
- bob = 0x100000;
- int angle = DivScale13(Timer() % 65536, 20);
- int wloffset = 1;
- if(GetActorProperty(tid, APROP_Waterlevel) > 1)
- wloffset = 2;
- bob = FixedMul(bob>>wloffset, sin(angle));
- }
- return bob;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement