Skip to content
This repository has been archived by the owner on Jul 27, 2020. It is now read-only.

Commit

Permalink
midpoint sphere
Browse files Browse the repository at this point in the history
  • Loading branch information
GeneralGuy4872 committed Jan 4, 2020
1 parent 5ebbfd2 commit 8c652f5
Show file tree
Hide file tree
Showing 11 changed files with 311 additions and 51 deletions.
50 changes: 46 additions & 4 deletions src/bresenham.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,55 @@ int signz = sgnf(deltaz);
ucoordlist3 * output = ucoordlist3__new(p1);
ucoordlist3 * output_tail = output;

if ( (fabs(deltay) ≤ 1.0) && (fabs(deltaz) ≤ 1.0) ) {
if ( (deltax == 0.0) && (deltay == 0.0) && (deltaz == 0.0) ) {
return output;
}

else if ( (deltay == 0.0) && (deltaz == 0.0) ) {
for (int x = p1[0];x != p2[0];x += signx) {
output_tail = ucoordlist3__tail_push_int(output_tail,x,p1[1],p1[2]);
}
return output;
}

else if ( (deltax == 0.0) && (deltaz == 0.0) ) {
for (int y = p1[1];y != p2[1];y += signy) {
output_tail = ucoordlist3__tail_push_int(output_tail,p1[0],y,p1[2]);
}
return output;
}

else if ( (deltax == 0.0) && (deltay == 0.0) ) {
for (int z = p1[2];z != p2[2];z += signz) {
output_tail = ucoordlist3__tail_push_int(output_tail,p1[0],p1[1],z);
}
return output;
}

/* handling for single zeros here */

else if ( (fabs(deltax) == 1.0) && (fabs(deltay) == 1.0) && (fabs(deltaz) == 1.0) ) {
int x = p1[0];
int y = p1[1];
int z = p1[2];
while (x != p2[0]) { //for 45 degree angles, only one needs to be checked
x += signx;
y += signy;
z += signz;
output_tail = ucoordlist3__tail_push_int(output_tail,x,y,z);
}
return output;
}

else if ( (fabs(deltay) ≤ 1.0) && (fabs(deltaz) ≤ 1.0) ) {
float deltaerrory = fabs(deltay / deltax);
float errory = 0.0;
float deltaerrorz = fabs(deltaz / deltax);
float errorz = 0.0;
int x,y,z;
int x = p1[0];
int y = p1[1];
int z = p1[2];
forever {
output_tail = ucoordlist3__tail_push_int(output_tail,x,y,z);
errory += deltaerrory;
if (errory0.5) {
y += signy;
Expand All @@ -25,12 +66,13 @@ if ( (fabs(deltay) ≤ 1.0) && (fabs(deltaz) ≤ 1.0) ) {
z += signz;
errorz -= 1.0;}
x += signx;
output_tail = ucoordlist3__tail_push_int(output_tail,x,y,z);

/*conditional exits below*/
if (signx < 0) {
if (xp2[0]) {return output}
} else {
if (xp2[0] {return output}
if (xp2[0]) {return output}
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/checkattrib.messy
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
playertyp__movecheck(playertyp this,int x,int y, int z)

18 changes: 15 additions & 3 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ basentyp (*montable[256])[16] = {
* Y : yeti, bigfoot,
* y : ape, monkey, gorilla, chimp, leamur,
* Z : <zombies>
* {}: /(flesh|straw|clay|stone|glass|paper|leather) golem/, /(gold|copper|finite-state) automaton/, chest monster,
* {}: /(flesh|straw|clay|stone|glass|paper|leather) golem/, /(gold|copper|silver|brass|bronze|pewter|tin|lead|iron|steel|finite-state) automaton/, chest monster,
* ? : mystery person
* «»: bass, trout, salmon, tuna, carp, pike, halibut, herring, cod
* × : lizard, geko, skink,
Expand Down Expand Up @@ -857,7 +857,20 @@ A_INVIS is not able to be seen
A_REVERSE video is a magic spell's area of effect
A_UNDERLINE is the shadow of an entity

text that is cat-ed from an nfo file, or otherwise printed using stdio, will not be restricted to ncurses formatting,
(unimplemented)
for playing a musical instrument:
1234567 play a note on a diatonic scale
prefixing with / makes the note one half-step flat
prefixing with * makes the note one half-step sharp
prefixing with - makes the note one quarter-step flat
prefixing with + makes the note one quarter-step sharp
prefixing with < makes the note one octave lower
prefixing with > makes the note one octave higher
the symbols must be entered in the order [<>][-+][*/][1234567]

(mostly obsolete)
text that is cat-ed from an nfo file, or otherwise printed using stdio,
will not be restricted to ncurses formatting,
and will use the full range of ANSI SGR escape codes

rune symbols
Expand All @@ -880,7 +893,6 @@ directional symbols:
◬, ⍫, △, ▽, ⋇, ↯, ♤, ♻, ☼, ☽, ∅, inner planes;
LG, NG, CG, LN, CN, LE, NE, CE, TN, UN, ☠, outer planes;


/*blackbox*/playervelocitycheck() velocitycheck(*entity)
/* if you have a nonzero velocity vector, when you try to move
* you travel in a direction determined by the mean vector of
Expand Down
107 changes: 107 additions & 0 deletions src/midpointsphere.messy
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
shadowmask sphere(ucoord3 omega,int rho) {
shadowmask * output;
{
int point[3][8][3];
/* 0=xy
* 1=xz
* 2=yz
*
* 7 0 0
* 6 1 3 1
* 5 2 2
* 4 3
*/
for (int n = 0;n < 3;n++) {
for (int m = 0;m < 4;m++) {
point[n][m][0] = omega[0]; point[n][m][1] = omega[1]; point[n][m][2] = omega[2];
}
}
while ((squared(point[0][0][0] - omega[0]) + squared(point[0][0][1] - omega[1]) + squared(point[0][0][2] - omega[2])) < squared(rho)) {point[0][0][1]--;}
while ((squared(point[0][1][0] - omega[0]) + squared(point[0][1][1] - omega[1]) + squared(point[0][1][2] - omega[2])) < squared(rho)) {point[0][0][0]++;}
while ((squared(point[0][2][0] - omega[0]) + squared(point[0][2][1] - omega[1]) + squared(point[0][2][2] - omega[2])) < squared(rho)) {point[0][0][1]++;}
while ((squared(point[0][3][0] - omega[0]) + squared(point[0][3][1] - omega[1]) + squared(point[0][3][2] - omega[2])) < squared(rho)) {point[0][0][0]--;}
while ((squared(point[1][0][0] - omega[0]) + squared(point[1][0][1] - omega[1]) + squared(point[1][0][2] - omega[2])) < squared(rho)) {point[1][0][2]++;}
while ((squared(point[1][1][0] - omega[0]) + squared(point[1][1][1] - omega[1]) + squared(point[1][1][2] - omega[2])) < squared(rho)) {point[1][0][0]++;}
while ((squared(point[1][2][0] - omega[0]) + squared(point[1][2][1] - omega[1]) + squared(point[1][2][2] - omega[2])) < squared(rho)) {point[1][0][2]--;}
while ((squared(point[1][3][0] - omega[0]) + squared(point[1][3][1] - omega[1]) + squared(point[1][3][2] - omega[2])) < squared(rho)) {point[1][0][0]--;}
while ((squared(point[2][0][0] - omega[0]) + squared(point[2][0][1] - omega[1]) + squared(point[2][0][2] - omega[2])) < squared(rho)) {point[2][0][2]++;}
while ((squared(point[2][1][0] - omega[0]) + squared(point[2][1][1] - omega[1]) + squared(point[2][1][2] - omega[2])) < squared(rho)) {point[2][0][1]++;}
while ((squared(point[2][2][0] - omega[0]) + squared(point[2][2][1] - omega[1]) + squared(point[2][2][2] - omega[2])) < squared(rho)) {point[2][0][2]--;}
while ((squared(point[2][3][0] - omega[0]) + squared(point[2][3][1] - omega[1]) + squared(point[2][3][2] - omega[2])) < squared(rho)) {point[2][0][1]--;}
for (int a = 0;a < 3;a++) {
for (int b = 0;b < 4;b++) {
maskset(point[a][b][2],point[a][b][1],point[a][b][0],output,true);
}
}
bool stop = (rho > 1); //dubious
for (int i = 1;!stop;i++) {
point[0][0][0] = omega[0] + i; point[0][0][1] = omega[1]; point[0][0][2] = omega[2];
point[0][1][0] = omega[0]; point[0][1][1] = omega[1] - i; point[0][1][2] = omega[2];
point[0][2][0] = omega[0]; point[0][2][1] = omega[1] + i; point[0][2][2] = omega[2];
point[0][3][0] = omega[0] + i; point[0][3][1] = omega[1]; point[0][3][2] = omega[2];
point[0][4][0] = omega[0] - i; point[0][4][1] = omega[1]; point[0][4][2] = omega[2];
point[0][5][0] = omega[0]; point[0][5][1] = omega[1] + i; point[0][5][2] = omega[2];
point[0][6][0] = omega[0]; point[0][6][1] = omega[1] - i; point[0][6][2] = omega[2];
point[0][7][0] = omega[0] - i; point[0][7][1] = omega[1]; point[0][7][2] = omega[2];
while ((squared(point[0][0][0] - omega[0]) + squared(point[0][0][1] - omega[1]) + squared(point[0][0][2] - omega[2])) < squared(rho)) {point[0][0][1]--;}
while ((squared(point[0][1][0] - omega[0]) + squared(point[0][1][1] - omega[1]) + squared(point[0][1][2] - omega[2])) < squared(rho)) {point[0][1][0]++;}
while ((squared(point[0][2][0] - omega[0]) + squared(point[0][2][1] - omega[1]) + squared(point[0][2][2] - omega[2])) < squared(rho)) {point[0][2][0]++;}
while ((squared(point[0][3][0] - omega[0]) + squared(point[0][3][1] - omega[1]) + squared(point[0][3][2] - omega[2])) < squared(rho)) {point[0][3][1]++;}
while ((squared(point[0][4][0] - omega[0]) + squared(point[0][4][1] - omega[1]) + squared(point[0][4][2] - omega[2])) < squared(rho)) {point[0][4][1]++;}
while ((squared(point[0][5][0] - omega[0]) + squared(point[0][5][1] - omega[1]) + squared(point[0][5][2] - omega[2])) < squared(rho)) {point[0][5][0]--;}
while ((squared(point[0][6][0] - omega[0]) + squared(point[0][6][1] - omega[1]) + squared(point[0][6][2] - omega[2])) < squared(rho)) {point[0][6][0]--;}
while ((squared(point[0][7][0] - omega[0]) + squared(point[0][7][1] - omega[1]) + squared(point[0][7][2] - omega[2])) < squared(rho)) {point[0][7][1]--;}
point[1][0][0] = omega[0] + i; point[1][0][1] = omega[1]; point[1][0][2] = omega[2];
point[1][1][0] = omega[0]; point[1][1][1] = omega[1]; point[1][1][2] = omega[2] + i;
point[1][2][0] = omega[0]; point[1][2][1] = omega[1]; point[1][2][2] = omega[2] - i;
point[1][3][0] = omega[0] + i; point[1][3][1] = omega[1]; point[1][3][2] = omega[2];
point[1][4][0] = omega[0] - i; point[1][4][1] = omega[1]; point[1][4][2] = omega[2];
point[1][5][0] = omega[0]; point[1][5][1] = omega[1]; point[1][5][2] = omega[2] - i;
point[1][6][0] = omega[0]; point[1][6][1] = omega[1]; point[1][6][2] = omega[2] + i;
point[1][7][0] = omega[0] - i; point[1][7][1] = omega[1]; point[1][7][2] = omega[2];
while ((squared(point[1][0][0] - omega[0]) + squared(point[1][0][1] - omega[1]) + squared(point[1][0][2] - omega[2])) < squared(rho)) {point[1][0][2]++;}
while ((squared(point[1][1][0] - omega[0]) + squared(point[1][1][1] - omega[1]) + squared(point[1][1][2] - omega[2])) < squared(rho)) {point[1][1][0]++;}
while ((squared(point[1][2][0] - omega[0]) + squared(point[1][2][1] - omega[1]) + squared(point[1][2][2] - omega[2])) < squared(rho)) {point[1][2][0]++;}
while ((squared(point[1][3][0] - omega[0]) + squared(point[1][3][1] - omega[1]) + squared(point[1][3][2] - omega[2])) < squared(rho)) {point[1][3][2]--;}
while ((squared(point[1][4][0] - omega[0]) + squared(point[1][4][1] - omega[1]) + squared(point[1][4][2] - omega[2])) < squared(rho)) {point[1][4][2]--;}
while ((squared(point[1][5][0] - omega[0]) + squared(point[1][5][1] - omega[1]) + squared(point[1][5][2] - omega[2])) < squared(rho)) {point[1][5][0]--;}
while ((squared(point[1][6][0] - omega[0]) + squared(point[1][6][1] - omega[1]) + squared(point[1][6][2] - omega[2])) < squared(rho)) {point[1][6][0]--;}
while ((squared(point[1][7][0] - omega[0]) + squared(point[1][7][1] - omega[1]) + squared(point[1][7][2] - omega[2])) < squared(rho)) {point[1][7][2]++;}
point[2][0][0] = omega[0]; point[2][0][1] = omega[1] + i; point[2][0][2] = omega[2];
point[2][1][0] = omega[0]; point[2][1][1] = omega[1]; point[2][1][2] = omega[2] + i;
point[2][2][0] = omega[0]; point[2][2][1] = omega[1]; point[2][2][2] = omega[2] - i;
point[2][3][0] = omega[0]; point[2][3][1] = omega[1] + i; point[2][3][2] = omega[2];
point[2][4][0] = omega[0]; point[2][4][1] = omega[1] - i; point[2][4][2] = omega[2];
point[2][5][0] = omega[0]; point[2][5][1] = omega[1]; point[2][5][2] = omega[2] - i;
point[2][6][0] = omega[0]; point[2][6][1] = omega[1]; point[2][6][2] = omega[2] + i;
point[2][7][0] = omega[0]; point[2][7][1] = omega[1] - i; point[2][7][2] = omega[2];
while ((squared(point[2][0][0] - omega[0]) + squared(point[2][0][1] - omega[1]) + squared(point[2][0][2] - omega[2])) < squared(rho)) {point[2][0][2]++;}
while ((squared(point[2][1][0] - omega[0]) + squared(point[2][1][1] - omega[1]) + squared(point[2][1][2] - omega[2])) < squared(rho)) {point[2][1][1]++;}
while ((squared(point[2][2][0] - omega[0]) + squared(point[2][2][1] - omega[1]) + squared(point[2][2][2] - omega[2])) < squared(rho)) {point[2][2][1]++;}
while ((squared(point[2][3][0] - omega[0]) + squared(point[2][3][1] - omega[1]) + squared(point[2][3][2] - omega[2])) < squared(rho)) {point[2][3][2]--;}
while ((squared(point[2][4][0] - omega[0]) + squared(point[2][4][1] - omega[1]) + squared(point[2][4][2] - omega[2])) < squared(rho)) {point[2][4][2]--;}
while ((squared(point[2][5][0] - omega[0]) + squared(point[2][5][1] - omega[1]) + squared(point[2][5][2] - omega[2])) < squared(rho)) {point[2][5][1]--;}
while ((squared(point[2][6][0] - omega[0]) + squared(point[2][6][1] - omega[1]) + squared(point[2][6][2] - omega[2])) < squared(rho)) {point[2][6][1]--;}
while ((squared(point[2][7][0] - omega[0]) + squared(point[2][7][1] - omega[1]) + squared(point[2][7][2] - omega[2])) < squared(rho)) {point[2][7][2]++;}
for (int a = 0;a < 3;a++) {
for (int b = 0;b < 8;b++) {
maskset(point[a][b][2],point[a][b][1],point[a][b][0],output,true);
}
}
stop |= (point[0][0][0] == point[0][1][0]); stop |= (point[0][0][1] == point[0][1][1]); stop |= (point[0][0][2] == point[0][1][2]);
stop |= (point[0][2][0] == point[0][3][0]); stop |= (point[0][2][1] == point[0][3][1]); stop |= (point[0][2][2] == point[0][3][2]);
stop |= (point[0][4][0] == point[0][5][0]); stop |= (point[0][4][1] == point[0][5][1]); stop |= (point[0][4][2] == point[0][5][2]);
stop |= (point[0][6][0] == point[0][7][0]); stop |= (point[0][6][1] == point[0][7][1]); stop |= (point[0][6][2] == point[0][7][2]);

stop |= (point[1][0][0] == point[1][1][0]); stop |= (point[1][0][1] == point[1][1][1]); stop |= (point[1][0][2] == point[1][1][2]);
stop |= (point[1][2][0] == point[1][3][0]); stop |= (point[1][2][1] == point[1][3][1]); stop |= (point[1][2][2] == point[1][3][2]);
stop |= (point[1][4][0] == point[1][5][0]); stop |= (point[1][4][1] == point[1][5][1]); stop |= (point[1][4][2] == point[1][5][2]);
stop |= (point[1][6][0] == point[1][7][0]); stop |= (point[1][6][1] == point[1][7][1]); stop |= (point[1][6][2] == point[1][7][2]);

stop |= (point[2][0][0] == point[2][1][0]); stop |= (point[2][0][1] == point[2][1][1]); stop |= (point[2][0][2] == point[2][1][2]);
stop |= (point[2][2][0] == point[2][3][0]); stop |= (point[2][2][1] == point[2][3][1]); stop |= (point[2][2][2] == point[2][3][2]);
stop |= (point[2][4][0] == point[2][5][0]); stop |= (point[2][4][1] == point[2][5][1]); stop |= (point[2][4][2] == point[2][5][2]);
stop |= (point[2][6][0] == point[2][7][0]); stop |= (point[2][6][1] == point[2][7][1]); stop |= (point[2][6][2] == point[2][7][2]);
}
return *output;
}
Empty file added src/move.messy
Empty file.
8 changes: 0 additions & 8 deletions src/questdialogs/README.md

This file was deleted.

55 changes: 55 additions & 0 deletions src/sphere.messy
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
shadowmask ucoord3__sphere(ucoord3 omega,int r) {
shadowmask output;
ucoord2 xy[8],xz[8],yz[8];
for (int i = 0;;i++) {
xy[0][0] = omega[0] + i;
xy[0][1] = omega[1];
xy[1][0] = omega[0];
xy[1][1] = omega[1] - i;
xy[2][0] = omega[0];
xy[2][1] = omega[1] + i;
xy[3][0] = omega[0] + i;
xy[3][1] = omega[1];
xy[4][0] = omega[0] - i;
xy[4][1] = omega[1];
xy[5][0] = omega[0];
xy[5][1] = omega[1] - i;
xy[6][0] = omega[0];
xy[6][1] = omega[1] + i;
xy[7][0] = omega[0] - i;
xy[7][1] = omega[1];
/**HR**/
xz[0][0] = omega[0] + i;
xz[0][1] = omega[2];
xz[1][0] = omega[0];
xz[1][1] = omega[2] - i;
xz[2][0] = omega[0];
xz[2][1] = omega[2] + i;
xz[3][0] = omega[0] + i;
xz[3][1] = omega[2];
xz[4][0] = omega[0] - i;
xz[4][1] = omega[2];
xz[5][0] = omega[0];
xz[5][1] = omega[2] - i;
xz[6][0] = omega[0];
xz[6][1] = omega[2] + i;
xz[7][0] = omega[0] - i;
xz[7][1] = omega[2];
/**HR**/
yz[0][0] = omega[1] + i;
yz[0][1] = omega[2];
yz[1][0] = omega[1];
yz[1][1] = omega[2] - i;
yz[2][0] = omega[1];
yz[2][1] = omega[2] + i;
yz[3][0] = omega[1] + i;
yz[3][1] = omega[2];
yz[4][0] = omega[1] - i;
yz[4][1] = omega[2];
yz[5][0] = omega[1];
yz[5][1] = omega[2] - i;
yz[6][0] = omega[1];
yz[6][1] = omega[2] + i;
yz[7][0] = omega[1] - i;
yz[7][1] = omega[2];
/**HR**/
48 changes: 35 additions & 13 deletions src/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -394,18 +394,18 @@ unsigned mastery : 2

struct baseclasstyp {
struct paffectyp bonus
uchar spd_plus
uchar air_plus
struct conlangtyp lang_plus
uchar spd
uchar air
struct conlangtyp lang
_8BITPTR spell[2]
bitfield psyattack
bool mindless : 1
bool shadow : 1
bool incoporeal : 1
bool immortal : 1
unsigned lde : 3
unsigned alignment : 9
unsigned element : 8
unsigned lde : 3 //grants
unsigned alignment : 9 //requires
unsigned element : 8 //grants
}

struct the8stats: //8* 5D6
Expand All @@ -431,6 +431,30 @@ uchar elecollect[8];
uchar questcollect[3];
}

/* note: everything related to players and entitys is
* copied into the struct, because it might be changed.
* the base entities and base classes are only templates.
*
* whenever you "rest" in-game, all entities are re-verified;
* meaning that all effect registers are recalculated. this
* has the side effect of removing any non-item based buffs
* and debuffs. this should be one of the only times that
* a baseclasstyp or basentyp are referenced; the others
* being adding a class, looseing a class, advancing in a class,
* polymorphing, polylocking, by the renderer,
* and when spawning a new entity.
*
* some stats are spread out accross multiple fields in the structure;
* most effects have one field for permenant and one field for temporary
* versions of the effect. a handful of alteration spells have a third
* register, with the polymorph stack, for timed spells, since the
* other temporary slot has no timer.
*
* nearly all fields of the player struct are created by COMBINING the
* basentyp and baseclasstyp chosen at the creation of the savefile.
* the remainder are based on backstory and user input.
*/

struct playertyp:
char * name
classtyp class[3]
Expand All @@ -439,8 +463,8 @@ agetyp age
struct shiftstackobj race
ucoord3 pos
polar facing
vector3 velo
float carryover //leftover moves; never exceeds 2
uchar spd
float carryover //leftover moves; maximum of 5
paffectyp permenent
effectyp fromequip
trackalignplayertyp align
Expand Down Expand Up @@ -492,8 +516,7 @@ uchar hplvl
uchar mplvl
uchar xplvl
uchar airmax //how long you can hold your breath
struct conlangtyp lang0
struct conlangtyp lang1
struct conlangtyp lang[2]
_8BITPTR spell[4]
bitfield psyattack
char16_t sprite
Expand Down Expand Up @@ -531,7 +554,7 @@ aggrotyp aggro
struct shiftstackobj race
ucoord3 pos
polar facing
vector3 velo
uchar spd
float carryover
paffectyp paffect
effectyp effect
Expand Down Expand Up @@ -574,7 +597,7 @@ aggrotyp aggro
struct shiftstackobj race
ucoord3 pos
polar facing
vector3 velo
uchar spd
float carryover
paffectyp permenent
effectyp fromequip
Expand Down Expand Up @@ -818,7 +841,6 @@ bool atkwing : 1; //affects unarmed attacks, swimming, flying
bool bite : 1;
bool breath : 1;
bool engulf : 1;
bool wingoveride : 1; //needed because the next paramaters can't simply be maxed/ORed together
bool permwings : 1;
bool wingsign : 1;
unsigned wingtype : 2;
Expand Down
Loading

0 comments on commit 8c652f5

Please sign in to comment.