166 lines
3.8 KiB
C
166 lines
3.8 KiB
C
// Copyright © 2016-2017 Graham Sanderson, all rights reserved.
|
|
#include "lith_common.h"
|
|
#include "lith_weapons.h"
|
|
#include "lith_player.h"
|
|
#include "lith_hudid.h"
|
|
#include "lith_world.h"
|
|
|
|
#include <math.h>
|
|
|
|
// How to make DECORATE into a decent VM: Registers!
|
|
|
|
#define PVarFunc(fn, expr) \
|
|
script acs int fn \
|
|
{ \
|
|
withplayer(LocalPlayer) { \
|
|
int *val = &p->decvars[var - 1]; \
|
|
return expr; \
|
|
} \
|
|
return 0; \
|
|
}
|
|
|
|
#define WVarFunc(fn, expr) \
|
|
script acs int fn {int *val = &world.decvars[var - 1]; return expr;}
|
|
|
|
#define RegisterMachine(reg, name) \
|
|
reg(L##name##Get(int var ), (*val) ) \
|
|
reg(L##name##Inc(int var ), (*val)++ ) \
|
|
reg(L##name##Dec(int var ), (*val)-- ) \
|
|
reg(L##name##Set(int var, int num), (*val) = num) \
|
|
reg(L##name##Add(int var, int num), (*val) += num) \
|
|
reg(L##name##Sub(int var, int num), (*val) -= num) \
|
|
reg(L##name##Mul(int var, int num), (*val) *= num) \
|
|
reg(L##name##Div(int var, int num), (*val) /= num) \
|
|
reg(L##name##Mod(int var, int num), (*val) %= num) \
|
|
reg(L##name##Min(int var, int num), (*val) = min(*val, num)) \
|
|
reg(L##name##Max(int var, int num), (*val) = max(*val, num))
|
|
|
|
RegisterMachine(PVarFunc, PVar)
|
|
RegisterMachine(WVarFunc, WVar)
|
|
|
|
//
|
|
// Lith_UniqueTID
|
|
//
|
|
script acs int Lith_UniqueTID(void)
|
|
{
|
|
return ACS_UniqueTID();
|
|
}
|
|
|
|
//
|
|
// Lith_Timer
|
|
//
|
|
script acs int Lith_Timer(void)
|
|
{
|
|
return ACS_Timer();
|
|
}
|
|
|
|
//
|
|
// Lith_UpdateScore
|
|
//
|
|
script acs void Lith_UpdateScore(void)
|
|
{
|
|
i96 score = ACS_CheckInventory("Lith_ScoreCount") * (double)RandomFloat(0.7f, 1.2f);
|
|
Lith_GiveAllScore(score, false);
|
|
ACS_TakeInventory("Lith_ScoreCount", 0x7FFFFFFF);
|
|
}
|
|
|
|
//
|
|
// Lith_Velocity
|
|
//
|
|
script acs fixed Lith_Velocity(fixed velx, fixed vely)
|
|
{
|
|
fixed x = ACS_GetActorX(0);
|
|
fixed y = ACS_GetActorY(0);
|
|
return ACS_FixedSqrt((x * x) + (y * y));
|
|
}
|
|
|
|
//
|
|
// Lith_VelHax
|
|
//
|
|
script acs int Lith_VelHax(int fuck)
|
|
{
|
|
ACS_SetActivator(0, AAPTR_MASTER);
|
|
|
|
switch(fuck)
|
|
{
|
|
case 1: return ACS_GetActorVelX(0);
|
|
case 2: return ACS_GetActorVelY(0);
|
|
case 3: return ACS_GetActorVelZ(0);
|
|
}
|
|
|
|
return -1;
|
|
}
|
|
|
|
//
|
|
// Lith_Barrier
|
|
//
|
|
script acs void Lith_Barrier()
|
|
{
|
|
withplayer(LocalPlayer)
|
|
for(int i = 0; p->active && i < 35 * 30; i++)
|
|
{
|
|
ACS_GiveInventory("Lith_BarrierSpell", 1);
|
|
ACS_Delay(1);
|
|
}
|
|
}
|
|
|
|
//
|
|
// Lith_BarrierBullets
|
|
//
|
|
script acs void Lith_BarrierBullets()
|
|
{
|
|
struct player *p = Lith_GetPlayer(0, AAPTR_TARGET);
|
|
|
|
fixed ang = ACS_VectorAngle(ACS_GetActorX(0) - p->x, ACS_GetActorY(0) - p->y);
|
|
fixed xang = ACS_VectorAngle(p->x - ACS_GetActorX(0), p->y - ACS_GetActorY(0));
|
|
fixed zdiff = p->z - ACS_GetActorZ(0);
|
|
fixed s = ACS_Sin(ang) * 48.0;
|
|
fixed c = ACS_Cos(ang) * 48.0;
|
|
fixed z = (p->z + p->viewheight / 2) - (zdiff / 2);
|
|
|
|
ACS_SpawnForced("Lith_BarrierFX", p->x + c, p->y + s, z);
|
|
ACS_LineAttack(p->tid, ang + ACS_RandomFixed(-0.1, 0.1), PITCH_BASE + ACS_RandomFixed(0.45, 0.55), 10);
|
|
}
|
|
|
|
//
|
|
// Lith_BarrierCheck
|
|
//
|
|
script acs bool Lith_BarrierCheck()
|
|
{
|
|
ACS_SetActivatorToTarget(0);
|
|
return ACS_CheckFlag(0, "COUNTKILL");
|
|
}
|
|
|
|
//
|
|
// Lith_PoisonFXTicker
|
|
//
|
|
script acs void Lith_PoisonFXTicker()
|
|
{
|
|
for(int i = 0; i < 17; i++)
|
|
{
|
|
if(ACS_CheckInventory("Lith_PoisonFXReset"))
|
|
{
|
|
ACS_TakeInventory("Lith_PoisonFXReset", 999);
|
|
ACS_TakeInventory("Lith_PoisonFXTimer", 999);
|
|
ACS_GiveInventory("Lith_PoisonFXGiverGiver", 1);
|
|
return;
|
|
}
|
|
}
|
|
|
|
if(ACS_GetActorProperty(0, APROP_Health) <= 0)
|
|
{
|
|
ACS_TakeInventory("Lith_PoisonFXReset", 999);
|
|
ACS_TakeInventory("Lith_PoisonFXTimer", 999);
|
|
ACS_TakeInventory("Lith_PoisonFXGiverGiver", 999);
|
|
return;
|
|
}
|
|
|
|
if(ACS_CheckInventory("Lith_PoisonFXTimer"))
|
|
{
|
|
ACS_GiveInventory("Lith_PoisonFXGiver", 1);
|
|
ACS_TakeInventory("Lith_PoisonFXTimer", 1);
|
|
}
|
|
}
|
|
|
|
// EOF
|