summaryrefslogtreecommitdiff
path: root/src/elements
diff options
context:
space:
mode:
authorBryan Hoyle <starfoxprime@gmail.com>2011-08-24 00:29:26 (GMT)
committer Bryan Hoyle <starfoxprime@gmail.com>2011-08-24 00:29:26 (GMT)
commit578144c48a1b35ae8d0763637752d935169663ac (patch)
treead0407b144aca61502e8419c96fc385a9f5aea28 /src/elements
parentf577c319db982e6b3d3b3731f1980c89182da982 (diff)
parent6581c29bf7eaf07483178804199f090b1c0e43ff (diff)
downloadpowder-578144c48a1b35ae8d0763637752d935169663ac.zip
powder-578144c48a1b35ae8d0763637752d935169663ac.tar.gz
Merge remote branch 'origin/master'
Diffstat (limited to 'src/elements')
-rw-r--r--src/elements/bomb.c2
-rw-r--r--src/elements/prti.c28
-rw-r--r--src/elements/prto.c43
-rw-r--r--src/elements/sprk.c4
-rw-r--r--src/elements/stkm.c60
5 files changed, 68 insertions, 69 deletions
diff --git a/src/elements/bomb.c b/src/elements/bomb.c
index 8115a88..de10fcc 100644
--- a/src/elements/bomb.c
+++ b/src/elements/bomb.c
@@ -44,7 +44,7 @@ int update_BOMB(UPDATE_FUNC_ARGS) {
for (nxi=-rad; nxi<=rad; nxi++)
if ((pow(nxi,2))/(pow(rad,2))+(pow(nxj,2))/(pow(rad,2))<=1)
if ((pmap[y+nxj][x+nxi]&0xFF)!=PT_DMND && (pmap[y+nxj][x+nxi]&0xFF)!=PT_CLNE && (pmap[y+nxj][x+nxi]&0xFF)!=PT_PCLN && (pmap[y+nxj][x+nxi]&0xFF)!=PT_BCLN) {
- delete_part(x+nxi, y+nxj);//it SHOULD kill anything but the exceptions above, doesn't seem to always work
+ delete_part(x+nxi, y+nxj, 0);//it SHOULD kill anything but the exceptions above, doesn't seem to always work
pv[(y+nxj)/CELL][(x+nxi)/CELL] += 0.1f;
nb = create_part(-1, x+nxi, y+nxj, PT_BOMB);
if (nb!=-1) {
diff --git a/src/elements/prti.c b/src/elements/prti.c
index f7599bf..7038412 100644
--- a/src/elements/prti.c
+++ b/src/elements/prti.c
@@ -1,26 +1,27 @@
#include <element.h>
-/*these are the count vaules of where the particle gets stored, depending on where it came from
- 1 4 6
- 2 . 7
- 3 5 8
- PRTO counts backwards, so that it will come out at the opposite place of where it came in
- 8 5 3
- 7 . 2
- 6 4 1
+/*these are the count values of where the particle gets stored, depending on where it came from
+ 0 1 2
+ 7 . 3
+ 6 5 4
+ PRTO does (count+4)%8, so that it will come out at the opposite place to where it came in
PRTO does +/-1 to the count, so it doesn't jam as easily
*/
+int portal_rx[8] = {-1, 0, 1, 1, 1, 0,-1,-1};
+int portal_ry[8] = {-1,-1,-1, 0, 1, 1, 1, 0};
+
int update_PRTI(UPDATE_FUNC_ARGS) {
int r, nnx, rx, ry, fe = 0;
int count =0;
parts[i].tmp = (int)((parts[i].temp-73.15f)/100+1);
if (parts[i].tmp>=CHANNELS) parts[i].tmp = CHANNELS-1;
else if (parts[i].tmp<0) parts[i].tmp = 0;
- for (rx=-1; rx<2; rx++)
- for (ry=-1; ry<2; ry++)
+ for (count=0; count<8; count++)
+ {
+ rx = portal_rx[count];
+ ry = portal_ry[count];
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
- count ++;
if (!r)
fe = 1;
if ((r>>8)>=NPART)
@@ -38,9 +39,9 @@ int update_PRTI(UPDATE_FUNC_ARGS) {
detach(r>>8);
for ( nnx=0; nnx<80; nnx++)
- if (!portalp[parts[i].tmp][count-1][nnx].type)
+ if (!portalp[parts[i].tmp][count][nnx].type)
{
- portalp[parts[i].tmp][count-1][nnx] = parts[r>>8];
+ portalp[parts[i].tmp][count][nnx] = parts[r>>8];
if ((r&0xFF)==PT_SPRK)
part_change_type(r>>8,x+rx,y+ry,parts[r>>8].ctype);
else
@@ -49,6 +50,7 @@ int update_PRTI(UPDATE_FUNC_ARGS) {
break;
}
}
+ }
if (fe) {
diff --git a/src/elements/prto.c b/src/elements/prto.c
index 38718a5..880de20 100644
--- a/src/elements/prto.c
+++ b/src/elements/prto.c
@@ -1,12 +1,9 @@
#include <element.h>
-/*these are the count vaules of where the particle gets stored, depending on where it came from
- 1 4 6
- 2 . 7
- 3 5 8
- PRTO counts backwards, so that it will come out at the opposite place of where it came in
- 8 5 3
- 7 . 2
- 6 4 1
+/*these are the count values of where the particle gets stored, depending on where it came from
+ 0 1 2
+ 7 . 3
+ 6 5 4
+ PRTO does (count+4)%8, so that it will come out at the opposite place to where it came in
PRTO does +/-1 to the count, so it doesn't jam as easily
*/
int update_PRTO(UPDATE_FUNC_ARGS) {
@@ -15,12 +12,13 @@ int update_PRTO(UPDATE_FUNC_ARGS) {
parts[i].tmp = (int)((parts[i].temp-73.15f)/100+1);
if (parts[i].tmp>=CHANNELS) parts[i].tmp = CHANNELS-1;
else if (parts[i].tmp<0) parts[i].tmp = 0;
- for (rx=1; rx>-2; rx--)
- for (ry=1; ry>-2; ry--)
+ for (count=0; count<8; count++)
+ {
+ rx = portal_rx[count];
+ ry = portal_ry[count];
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
- count ++;
if (!r)
fe = 1;
if ((r>>8)>=NPART || r)
@@ -29,12 +27,8 @@ int update_PRTO(UPDATE_FUNC_ARGS) {
{
for ( nnx =0 ; nnx<80; nnx++)
{
- int randomness = count + rand()%3-1;//add -1,0,or 1 to count
- if (randomness<1)
- randomness=1;
- if (randomness>8)
- randomness=8;
- if (portalp[parts[i].tmp][randomness-1][nnx].type==PT_SPRK)// TODO: make it look better, spark creation
+ int randomness = (count + rand()%3-1 + 4)%8;//add -1,0,or 1 to count
+ if (portalp[parts[i].tmp][randomness][nnx].type==PT_SPRK)// TODO: make it look better, spark creation
{
create_part(-1,x+1,y,PT_SPRK);
create_part(-1,x+1,y+1,PT_SPRK);
@@ -44,26 +38,27 @@ int update_PRTO(UPDATE_FUNC_ARGS) {
create_part(-1,x-1,y+1,PT_SPRK);
create_part(-1,x-1,y,PT_SPRK);
create_part(-1,x-1,y-1,PT_SPRK);
- portalp[parts[i].tmp][randomness-1][nnx] = emptyparticle;
+ portalp[parts[i].tmp][randomness][nnx] = emptyparticle;
break;
}
- else if (portalp[parts[i].tmp][randomness-1][nnx].type)
+ else if (portalp[parts[i].tmp][randomness][nnx].type)
{
- if (portalp[parts[i].tmp][randomness-1][nnx].type==PT_STKM)
+ if (portalp[parts[i].tmp][randomness][nnx].type==PT_STKM)
player[27] = 0;
- if (portalp[parts[i].tmp][randomness-1][nnx].type==PT_STKM2)
+ if (portalp[parts[i].tmp][randomness][nnx].type==PT_STKM2)
player2[27] = 0;
- np = create_part(-1,x+rx,y+ry,portalp[parts[i].tmp][randomness-1][nnx].type);
+ np = create_part(-1,x+rx,y+ry,portalp[parts[i].tmp][randomness][nnx].type);
if (np<0) continue;
- parts[np] = portalp[parts[i].tmp][randomness-1][nnx];
+ parts[np] = portalp[parts[i].tmp][randomness][nnx];
parts[np].x = x+rx;
parts[np].y = y+ry;
- portalp[parts[i].tmp][randomness-1][nnx] = emptyparticle;
+ portalp[parts[i].tmp][randomness][nnx] = emptyparticle;
break;
}
}
}
}
+ }
if (fe) {
int orbd[4] = {0, 0, 0, 0}; //Orbital distances
int orbl[4] = {0, 0, 0, 0}; //Orbital locations
diff --git a/src/elements/sprk.c b/src/elements/sprk.c
index 039453f..0f3d8e9 100644
--- a/src/elements/sprk.c
+++ b/src/elements/sprk.c
@@ -35,7 +35,7 @@ int update_SPRK(UPDATE_FUNC_ARGS) {
nearp = nearest_part(i, PT_ETRD);
if (nearp!=-1&&parts_avg(i, nearp, PT_INSL)!=PT_INSL)
{
- create_line(x, y, (int)(parts[nearp].x+0.5f), (int)(parts[nearp].y+0.5f), 0, 0, PT_PLSM);
+ create_line(x, y, (int)(parts[nearp].x+0.5f), (int)(parts[nearp].y+0.5f), 0, 0, PT_PLSM, 0);
part_change_type(i,x,y,ct);
ct = parts[i].ctype = PT_NONE;
parts[i].life = 20;
@@ -152,7 +152,7 @@ int update_SPRK(UPDATE_FUNC_ARGS) {
else if (rt==PT_INST) {
if (parts[i].life>=3&&parts[r>>8].life==0)
{
- flood_parts(x+rx,y+ry,PT_SPRK,PT_INST,-1);//spark the wire
+ flood_parts(x+rx,y+ry,PT_SPRK,PT_INST,-1, 0);//spark the wire
}
}
else if (parts[r>>8].life==0 && (parts[i].life<3 || ((r>>8)<i && parts[i].life<4))) {
diff --git a/src/elements/stkm.c b/src/elements/stkm.c
index 4b43f57..6873ef5 100644
--- a/src/elements/stkm.c
+++ b/src/elements/stkm.c
@@ -240,7 +240,7 @@ int run_stickman(float* playerp, UPDATE_FUNC_ARGS) {
{
int np = -1;
if (playerp[2] == SPC_AIR)
- create_parts(rx + 3*((((int)playerp[1])&0x02) == 0x02) - 3*((((int)playerp[1])&0x01) == 0x01), ry, 4, 4, SPC_AIR);
+ create_parts(rx + 3*((((int)playerp[1])&0x02) == 0x02) - 3*((((int)playerp[1])&0x01) == 0x01), ry, 4, 4, SPC_AIR, 0);
else
np = create_part(-1, rx, ry, playerp[2]);
if ( (np < NPART) && np>=0 && playerp[2] != PT_PHOT && playerp[2] != SPC_AIR)
@@ -389,21 +389,23 @@ void STKM_interact(float* playerp, int i, int x, int y)
if ((r&0xFF)==PT_PLUT) //If on plut
parts[i].life -= 1;
+
+ if (ptypes[r&0xFF].properties&PROP_DEADLY)
+ parts[i].life -= 1;
if ((r&0xFF)==PT_PRTI && parts[i].type)
{
- int nnx, count;
+ int nnx, count=1;//gives rx=0, ry=1 in update_PRTO
parts[r>>8].tmp = (int)((parts[r>>8].temp-73.15f)/100+1);
if (parts[r>>8].tmp>=CHANNELS) parts[r>>8].tmp = CHANNELS-1;
else if (parts[r>>8].tmp<0) parts[r>>8].tmp = 0;
- for (count=1; count<=8; count++)
- for (nnx=0; nnx<80; nnx++)
- if (!portalp[parts[r>>8].tmp][count-1][nnx].type)
- {
- portalp[parts[r>>8].tmp][count-1][nnx] = parts[i];
- kill_part(i);
- playerp[27] = 1;//stop SPWN creating a new STKM while he is in portal
- }
+ for (nnx=0; nnx<80; nnx++)
+ if (!portalp[parts[r>>8].tmp][count][nnx].type)
+ {
+ portalp[parts[r>>8].tmp][count][nnx] = parts[i];
+ kill_part(i);
+ playerp[27] = 1;//stop SPWN creating a new STKM while he is in portal
+ }
}
}
}
@@ -415,23 +417,23 @@ void STKM_init_legs(float* playerp, int i)
x = (int)(parts[i].x+0.5f);
y = (int)(parts[i].y+0.5f);
- player[3] = x-1;
- player[4] = y+6;
- player[5] = x-1;
- player[6] = y+6;
-
- player[7] = x-3;
- player[8] = y+12;
- player[9] = x-3;
- player[10] = y+12;
-
- player[11] = x+1;
- player[12] = y+6;
- player[13] = x+1;
- player[14] = y+6;
-
- player[15] = x+3;
- player[16] = y+12;
- player[17] = x+3;
- player[18] = y+12;
+ playerp[3] = x-1;
+ playerp[4] = y+6;
+ playerp[5] = x-1;
+ playerp[6] = y+6;
+
+ playerp[7] = x-3;
+ playerp[8] = y+12;
+ playerp[9] = x-3;
+ playerp[10] = y+12;
+
+ playerp[11] = x+1;
+ playerp[12] = y+6;
+ playerp[13] = x+1;
+ playerp[14] = y+6;
+
+ playerp[15] = x+3;
+ playerp[16] = y+12;
+ playerp[17] = x+3;
+ playerp[18] = y+12;
}