Skip to content

Commit

Permalink
ACS re-organization (aka Most of what I did while I was out of town)
Browse files Browse the repository at this point in the history
- Split out ACS into vaguely logical files and consolidated all code to
a single library
- Eliminated ~15 constantly looping ENTER scripts, and re-wrote each
into a function that is called from the main BoA_PlayerLoop ENTER
script.  This seems to cut down the ACS thinker time significantly, and
will also let me tweak how often each function is called from one
location as needed
- ZScriptified Lantern and MineSweeper to eliminate their related ACS
functions (MineSweeper uses some publicly available code that I'm
awaiting formal permsision to use, so implimentation may change)
- Re-added the underwater sound SNDINFO entries that disappeared shortly
after they were added (ACS and sounds were still present, but not the
entries).

Needless to say - there might be some unintended consequences of these
changes, so if you see anything that doesn't work as expected, let me
know as soon as possible, please!  I've done full playthroughs of
several levels and not seen anything, but that doesn't mean that I
didn't miss anything.
  • Loading branch information
AFADoomer committed Mar 10, 2018
1 parent 9131247 commit 2357aca
Show file tree
Hide file tree
Showing 36 changed files with 1,558 additions and 1,324 deletions.
Binary file modified acs/boalib.o
Binary file not shown.
Binary file removed acs/boptions.o
Binary file not shown.
Binary file removed acs/droplets.o
Binary file not shown.
Binary file removed acs/flinch.o
Binary file not shown.
Binary file removed acs/kturret.o
Binary file not shown.
Binary file removed acs/lantern.o
Binary file not shown.
Binary file removed acs/mineswpr.o
Binary file not shown.
Binary file removed acs/stealth.o
Binary file not shown.
1 change: 0 additions & 1 deletion actors/hazards/mine.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ ACTOR Mine
States
{
Spawn:
TNT1 A 0 NoDelay ACS_NamedExecuteAlways("SetRadarTID",0)
See:
MINE A 6 A_Chase
Loop
Expand Down
65 changes: 0 additions & 65 deletions actors/items/powerups.txt
Original file line number Diff line number Diff line change
Expand Up @@ -122,44 +122,6 @@ ACTOR Power : Inventory
Inventory.MaxAmount 2400 //Near 1 mins maximum - ozy81
}

ACTOR MineSweeper : CustomInventory
{
//$Category Powerups (Wolf3D)
//$Title Human Mine Scanning (pickups)
//$Color 6
Scale 0.5
Tag "$TAGSWEEP"
Inventory.Icon MSPUB0
Inventory.PickupMessage "$SWEEPER"
Inventory.MaxAmount 1
+INVENTORY.INVBAR
+INVENTORY.UNDROPPABLE
States
{
Spawn:
MSPU A -1
Stop
Pickup:
"####" A 0 {
if (CountInv("MineSweeper") == 0) {
A_GiveInventory ("Power", 2400);
return true;
} else if (CountInv("MineSweeper") > 0 && CountInv("Power") < 2400) {
ACS_NamedExecuteAlways("BoA_MineSweeperOff", 0);
A_GiveInventory ("Power", 2400);
A_TakeInventory ("MineSweeper", 1); // The player will immediately get another minesweeper.
return true;
} else {
return false;
}
}
Stop
Use:
"####" A 0 ACS_NamedExecuteAlways("BoA_MineSweeper",0)
Fail
}
}

ACTOR AdrenalineSpeed : PowerupGiver { +INVENTORY.AUTOACTIVATE +INVENTORY.ADDITIVETIME -INVENTORY.INVBAR Inventory.MaxAmount 0 Powerup.Type "PowerDrugs" }
ACTOR PowerDrugs : PowerDoubleFiringSpeed {Powerup.Duration -10}
ACTOR AdrenalineFactor : PowerupGiver { +INVENTORY.AUTOACTIVATE +INVENTORY.ADDITIVETIME -INVENTORY.INVBAR Inventory.MaxAmount 0 Powerup.Type "PowerFactor" }
Expand Down Expand Up @@ -239,31 +201,4 @@ ACTOR OilPickup : CustomInventory
TNT1 A 0 A_GiveInventory("LanternOil", 1000)
Stop
}
}

ACTOR LanternPickup : CustomInventory
{
//$Category Powerups (Wolf3D)
//$Title Useable Lantern (requires Oil)
//$Color 6
Scale 0.5
Tag "$TAGLANTR"
Inventory.Icon LANTB0
Inventory.PickupMessage "$LANTERN"
Inventory.MaxAmount 1
Inventory.PickupSound "misc/gadget_pickup"
+INVENTORY.INVBAR
+INVENTORY.UNDROPPABLE
States
{
Spawn:
LANT A -1
Stop
Pickup:
"####" A 0 A_GiveInventory("LanternOil", 1000)
Stop
Use:
"####" A 0 ACS_NamedExecuteAlways("BoA_Lantern",0)
Fail
}
}
9 changes: 1 addition & 8 deletions loadacs.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
boalib
stealth
boptions
mineswpr
lantern
kturret
flinch
droplets
boalib
2 changes: 1 addition & 1 deletion mapinfo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ gameinfo
borderflat = "textures/cncr_g29.jpg"

defaultconversationmenuclass = "BoAConversationMenu"
eventhandlers = "BoAEventHandler", "WaterHandler", "CustomShaderHandler", "SpriteShadowHandler"
eventhandlers = "InventoryClearHandler", "WaterHandler", "CustomShaderHandler", "SpriteShadowHandler", "MineSweeperHandler"
statusbarclass = "BoAStatusBar"

ForceKillScripts = true //needed for Droplets - ozy81
Expand Down
180 changes: 180 additions & 0 deletions scripts/ScreenCoordinates.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
// Original code by gutawer; modified by Marisa Kirisame, bastardized by AFADoomer

Class Matrix4
{
private double m[16];

Matrix4 init()
{
int i;
for ( i=0; i<16; i++ ) m[i] = 0;
return self;
}

static Matrix4 create()
{
return new("Matrix4").init();
}

static Matrix4 identity()
{
Matrix4 o = Matrix4.create();
for ( int i=0; i<4; i++ ) o.set(i,i,1);
return o;
}

double get( int c, int r )
{
return m[r*4+c];
}

void set( int c, int r, double v )
{
m[r*4+c] = v;
}

Matrix4 add( Matrix4 o )
{
Matrix4 r = Matrix4.create();
int i, j;
for ( i=0; i<4; i++ ) for ( j=0; j<4; j++ )
r.set(j,i,get(j,i)+o.get(j,i));
return r;
}

Matrix4 scale( double s )
{
Matrix4 r = Matrix4.create();
int i, j;
for ( i=0; i<4; i++ ) for ( j=0; j<4; j++ )
r.set(j,i,get(j,i)*s);
return r;
}

Matrix4 mul( Matrix4 o )
{
Matrix4 r = Matrix4.create();
int i, j;
for ( i=0; i<4; i++ ) for ( j=0; j<4; j++ )
r.set(j,i,get(0,i)*o.get(j,0)+get(1,i)*o.get(j,1)+get(2,i)*o.get(j,2)+get(3,i)*o.get(j,3));
return r;
}

Vector3 vmat( Vector3 o )
{
double x, y, z, w;
x = get(0,0)*o.x+get(1,0)*o.y+get(2,0)*o.z+get(3,0);
y = get(0,1)*o.x+get(1,1)*o.y+get(2,1)*o.z+get(3,1);
z = get(0,2)*o.x+get(1,2)*o.y+get(2,2)*o.z+get(3,2);
w = get(0,3)*o.x+get(1,3)*o.y+get(2,3)*o.z+get(3,3);
return (x,y,z)/w;
}

static Matrix4 rotate( Vector3 axis, double theta )
{
Matrix4 r = Matrix4.identity();
double s, c, oc;
s = sin(theta);
c = cos(theta);
oc = 1.0-c;
r.set(0,0,oc*axis.x*axis.x+c);
r.set(1,0,oc*axis.x*axis.y-axis.z*s);
r.set(2,0,oc*axis.x*axis.z+axis.y*s);
r.set(0,1,oc*axis.y*axis.x+axis.z*s);
r.set(1,1,oc*axis.y*axis.y+c);
r.set(2,1,oc*axis.y*axis.z-axis.x*s);
r.set(0,2,oc*axis.z*axis.x-axis.y*s);
r.set(1,2,oc*axis.z*axis.y+axis.x*s);
r.set(2,2,oc*axis.z*axis.z+c);
return r;
}

static Matrix4 perspective( double fov, double ar, double znear, double zfar )
{
Matrix4 r = Matrix4.create();
double f = 1/tan(fov*0.5);
r.set(0,0,f/ar);
r.set(1,1,f);
r.set(2,2,(zfar+znear)/(znear-zfar));
r.set(3,2,(2*zfar*znear)/(znear-zfar));
r.set(2,3,-1);
return r;
}

// UE-like axes from rotation
static Vector3, Vector3, Vector3 getaxes( double pitch, double yaw, double roll )
{
Vector3 x = (1,0,0), y = (0,-1,0), z = (0,0,1); // y inverted for left-handed result
Matrix4 mRoll = Matrix4.rotate((1,0,0),roll);
Matrix4 mPitch = Matrix4.rotate((0,1,0),pitch);
Matrix4 mYaw = Matrix4.rotate((0,0,1),yaw);
Matrix4 mRot = mRoll.mul(mYaw);
mRot = mRot.mul(mPitch);
x = mRot.vmat(x);
y = mRot.vmat(y);
z = mRot.vmat(z);
return x, y, z;
}
}

Class mkCoordUtil
{
// view matrix setup mostly pulled from gutawer's code
static Vector3 WorldToScreen( Vector3 vect, Vector3 eye, double pitch, double yaw, double roll, double vfov )
{
double ar = Screen.getWidth()/double(Screen.getHeight());
double fovr = (ar>=1.3)?1.333333:ar;
double fov = 2*atan(tan(clamp(vfov,5,170)*0.5)/fovr);
float pr = level.pixelstretch;
double angx = cos(pitch);
double angy = sin(pitch)*pr;
double alen = sqrt(angx*angx+angy*angy);
double apitch = asin(angy/alen);
double ayaw = yaw-90;
// rotations
Matrix4 mRoll = Matrix4.rotate((0,0,1),roll);
Matrix4 mPitch = Matrix4.rotate((1,0,0),apitch);
Matrix4 mYaw = Matrix4.rotate((0,-1,0),ayaw);
// scaling
Matrix4 mScale = Matrix4.identity();
mScale.set(1,1,pr);
// YZ swap
Matrix4 mYZ = Matrix4.create();
mYZ.set(0,0,1);
mYZ.set(2,1,1);
mYZ.set(1,2,-1);
mYZ.set(3,3,1);
// translation
Matrix4 mMove = Matrix4.identity();
mMove.set(3,0,-eye.x);
mMove.set(3,1,-eye.y);
mMove.set(3,2,-eye.z);
// perspective
Matrix4 mPerspective = Matrix4.perspective(fov,ar,5,65535);
// full matrix
Matrix4 mView = mRoll.mul(mPitch);
mView = mView.mul(mYaw);
mView = mView.mul(mScale);
mView = mView.mul(mYZ);
mView = mView.mul(mMove);
Matrix4 mWorldToScreen = mPerspective.mul(mView);
return mWorldToScreen.vmat(vect);
}

// thanks once again to gutawer for making this thing screenblocks-aware
static Vector2 ToViewport( Vector3 screenpos, bool scrblocks = true )
{
if ( scrblocks )
{
int winx, winy, winw, winh;
[winx,winy,winw,winh] = Screen.getViewWindow();
int sh = Screen.getHeight();
int ht = sh;
int screenblocks = CVar.GetCVar("screenblocks",players[consoleplayer]).getInt();
if ( screenblocks < 10 ) ht = (screenblocks*sh/10)&~7;
int bt = sh-(ht+winy-((ht-winh)/2));
return (winx,sh-bt-ht)+((screenpos.x+1)*winw,(-screenpos.y+1)*ht)*0.5;
}
else return ((screenpos.x+1)*Screen.getWidth(),(-screenpos.y+1)*Screen.getHeight())*0.5;
}
}
Loading

0 comments on commit 2357aca

Please sign in to comment.