summaryrefslogtreecommitdiff
path: root/src/elements
diff options
context:
space:
mode:
Diffstat (limited to 'src/elements')
-rw-r--r--src/elements/fwrk.c2
-rw-r--r--src/elements/glow.c4
-rw-r--r--src/elements/prto.c4
-rw-r--r--src/elements/sprk.c21
-rw-r--r--src/elements/stkm.c25
-rw-r--r--src/elements/stkm2.c25
6 files changed, 46 insertions, 35 deletions
diff --git a/src/elements/fwrk.c b/src/elements/fwrk.c
index 06390c5..5095cde 100644
--- a/src/elements/fwrk.c
+++ b/src/elements/fwrk.c
@@ -16,7 +16,7 @@ int update_FWRK(UPDATE_FUNC_ARGS) {
}
if (parts[i].life>=45)
parts[i].life=0;
- if ((parts[i].life<3&&parts[i].life>0)||parts[i].vy>6&&parts[i].life>0)
+ if ((parts[i].life<3&&parts[i].life>0)||(parts[i].vy>6&&parts[i].life>0))
{
int q = (rand()%255+1);
int w = (rand()%255+1);
diff --git a/src/elements/glow.c b/src/elements/glow.c
index 621e5b1..d692233 100644
--- a/src/elements/glow.c
+++ b/src/elements/glow.c
@@ -16,6 +16,10 @@ int update_GLOW(UPDATE_FUNC_ARGS) {
parts[r>>8].life = 10;
}
}
+ parts[i].ctype = pv[y/CELL][x/CELL]*16;
+
+ parts[i].tmp = abs((int)((vx[y/CELL][x/CELL]+vy[y/CELL][x/CELL])*16.0f)) + abs((int)((parts[i].vx+parts[i].vy)*64.0f));
+ //printf("%f %f\n", parts[i].vx, parts[i].vy);
if (parts[i].type==PT_NONE) {
kill_part(i);
return 1;
diff --git a/src/elements/prto.c b/src/elements/prto.c
index 8f743e7..5bf6efe 100644
--- a/src/elements/prto.c
+++ b/src/elements/prto.c
@@ -21,8 +21,8 @@ int update_PRTO(UPDATE_FUNC_ARGS) {
int randomness = count + rand()%3-1;
if (randomness<1)
randomness=1;
- if (randomness>8)
- randomness=8;
+ if (randomness>9)
+ randomness=9;
if (portal[parts[i].tmp][randomness-1][nnx]==PT_SPRK)// TODO: make it look better
{
create_part(-1,x+1,y,portal[parts[i].tmp][randomness-1][nnx]);
diff --git a/src/elements/sprk.c b/src/elements/sprk.c
index f107b9a..89480ad 100644
--- a/src/elements/sprk.c
+++ b/src/elements/sprk.c
@@ -120,7 +120,7 @@ int update_SPRK(UPDATE_FUNC_ARGS) {
conduct_sprk = 0;
if (ct==PT_NSCN && rt==PT_PSCN)
conduct_sprk = 0;
- if (ct==PT_ETRD && (parts[i].life!=5||!(rt==PT_METL||rt==PT_ETRD||rt==PT_BMTL||rt==PT_BRMT||rt==PT_LRBD||rt==PT_RBDM||rt==PT_PSCN||rt==PT_NSCN)))
+ if (ct==PT_ETRD && !(rt==PT_METL||rt==PT_ETRD||rt==PT_BMTL||rt==PT_BRMT||rt==PT_LRBD||rt==PT_RBDM||rt==PT_PSCN||rt==PT_NSCN))
conduct_sprk = 0;
if (ct==PT_INST&&rt!=PT_NSCN) conduct_sprk = 0;
if (ct==PT_SWCH && (rt==PT_PSCN||rt==PT_NSCN||rt==PT_WATR||rt==PT_SLTW||rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR))
@@ -137,15 +137,7 @@ int update_SPRK(UPDATE_FUNC_ARGS) {
conduct_sprk = 0;
if (conduct_sprk) {
- if (ct==PT_ETRD) {
- part_change_type(i,x,y,PT_ETRD);
- parts[i].ctype = PT_NONE;
- parts[i].life = 20;
- part_change_type(r>>8,x+rx,y+ry,PT_SPRK);
- parts[r>>8].life = 4;
- parts[r>>8].ctype = rt;
- }
- else if (rt==PT_WATR||rt==PT_SLTW) {
+ if (rt==PT_WATR||rt==PT_SLTW) {
if (parts[r>>8].life==0 && (parts[i].life<2 || ((r>>8)<i && parts[i].life<3)))
{
part_change_type(r>>8,x+rx,y+ry,PT_SPRK);
@@ -167,6 +159,15 @@ int update_SPRK(UPDATE_FUNC_ARGS) {
if (parts[r>>8].temp+10.0f<673.0f&&!legacy_enable&&(rt==PT_METL||rt==PT_BMTL||rt==PT_BRMT||rt==PT_PSCN||rt==PT_NSCN||rt==PT_ETRD||rt==PT_NBLE||rt==PT_IRON))
parts[r>>8].temp = parts[r>>8].temp+10.0f;
}
+ else if (ct==PT_ETRD && parts[i].life==5)
+ {
+ part_change_type(i,x,y,ct);
+ parts[i].ctype = PT_NONE;
+ parts[i].life = 20;
+ parts[r>>8].life = 4;
+ parts[r>>8].ctype = rt;
+ part_change_type(r>>8,x+rx,y+ry,PT_SPRK);
+ }
}
}
return 0;
diff --git a/src/elements/stkm.c b/src/elements/stkm.c
index 6d6b4ab..fc6dc55 100644
--- a/src/elements/stkm.c
+++ b/src/elements/stkm.c
@@ -185,8 +185,10 @@ int update_STKM(UPDATE_FUNC_ARGS) {
{
r = pmap[y+ry][x+rx];
if (!r || (r>>8)>=NPART)
+ r = photons[y+ry][x+rx];
+ if (!r || (r>>8)>=NPART)
continue;
- if (ptypes[r&0xFF].falldown!=0 || (r&0xFF) == PT_NEUT || (r&0xFF) == PT_PHOT) // TODO: photons are not in the pmap. This line may not work as intended.
+ if (ptypes[r&0xFF].falldown!=0 || (r&0xFF) == PT_NEUT || (r&0xFF) == PT_PHOT)
{
player[2] = r&0xFF; //Current element
}
@@ -225,26 +227,27 @@ int update_STKM(UPDATE_FUNC_ARGS) {
}
else
{
+ int np = -1;
if (player[2] == SPC_AIR)
create_parts(rx + 3*((((int)player[1])&0x02) == 0x02) - 3*((((int)player[1])&0x01) == 0x01), ry, 4, 4, SPC_AIR);
else
- create_part(-1, rx, ry, player[2]);
-
- r = pmap[ry][rx];
- if ( ((r>>8) < NPART) && (r>>8)>=0 && player[2] != PT_PHOT && player[2] != SPC_AIR)
- parts[r>>8].vx = parts[r>>8].vx + 5*((((int)player[1])&0x02) == 0x02) - 5*(((int)(player[1])&0x01) == 0x01);
- if (((r>>8) < NPART) && (r>>8)>=0 && player[2] == PT_PHOT)
+ np = create_part(-1, rx, ry, player[2]);
+ if ( (np < NPART) && np>=0 && player[2] != PT_PHOT && player[2] != SPC_AIR)
+ parts[np].vx = parts[np].vx + 5*((((int)player[1])&0x02) == 0x02) - 5*(((int)(player[1])&0x01) == 0x01);
+ if ((np < NPART) && np>=0 && player[2] == PT_PHOT)
{
int random = abs(rand()%3-1)*3;
if (random==0)
{
- parts[r>>8].life = 0;
- parts[r>>8].type = PT_NONE;
+ kill_part(np);
}
else
{
- parts[r>>8].vy = 0;
- parts[r>>8].vx = (((((int)player[1])&0x02) == 0x02) - (((int)(player[1])&0x01) == 0x01))*random;
+ parts[np].vy = 0;
+ if (((int)player[1])&(0x01|0x02))
+ parts[np].vx = (((((int)player[1])&0x02) == 0x02) - (((int)(player[1])&0x01) == 0x01))*random;
+ else
+ parts[np].vx = random;
}
}
diff --git a/src/elements/stkm2.c b/src/elements/stkm2.c
index 319e388..79dbbdf 100644
--- a/src/elements/stkm2.c
+++ b/src/elements/stkm2.c
@@ -185,8 +185,10 @@ int update_STKM2(UPDATE_FUNC_ARGS) {
{
r = pmap[y+ry][x+rx];
if (!r || (r>>8)>=NPART)
+ r = photons[y+ry][x+rx];
+ if (!r || (r>>8)>=NPART)
continue;
- if (ptypes[r&0xFF].falldown!=0 || (r&0xFF) == PT_NEUT || (r&0xFF) == PT_PHOT) // TODO: photons are not in the pmap. This line may not work as intended.
+ if (ptypes[r&0xFF].falldown!=0 || (r&0xFF) == PT_NEUT || (r&0xFF) == PT_PHOT)
{
player2[2] = r&0xFF; //Current element
}
@@ -225,26 +227,27 @@ int update_STKM2(UPDATE_FUNC_ARGS) {
}
else
{
+ int np = -1;
if (player2[2] == SPC_AIR)
create_parts(rx + 3*((((int)player2[1])&0x02) == 0x02) - 3*((((int)player2[1])&0x01) == 0x01), ry, 4, 4, SPC_AIR);
else
- create_part(-1, rx, ry, player2[2]);
-
- r = pmap[ry][rx];
- if ( ((r>>8) < NPART) && (r>>8)>=0 && player2[2] != PT_PHOT && player2[2] != SPC_AIR)
- parts[r>>8].vx = parts[r>>8].vx + 5*((((int)player2[1])&0x02) == 0x02) - 5*(((int)(player2[1])&0x01) == 0x01);
- if (((r>>8) < NPART) && (r>>8)>=0 && player2[2] == PT_PHOT)
+ np = create_part(-1, rx, ry, player2[2]);
+ if ((np < NPART) && np>=0 && player2[2] != PT_PHOT && player2[2] != SPC_AIR)
+ parts[np].vx = parts[np].vx + 5*((((int)player2[1])&0x02) == 0x02) - 5*(((int)(player2[1])&0x01) == 0x01);
+ if ((np < NPART) && np>=0 && player2[2] == PT_PHOT)
{
int random = abs(rand()%3-1)*3;
if (random==0)
{
- parts[r>>8].life = 0;
- parts[r>>8].type = PT_NONE;
+ kill_part(np);
}
else
{
- parts[r>>8].vy = 0;
- parts[r>>8].vx = (((((int)player2[1])&0x02) == 0x02) - (((int)(player2[1])&0x01) == 0x01))*random;
+ parts[np].vy = 0;
+ if (((int)player2[1])&(0x01|0x02))
+ parts[np].vx = (((((int)player2[1])&0x02) == 0x02) - (((int)(player2[1])&0x01) == 0x01))*random;
+ else
+ parts[np].vx = random;
}
}