summaryrefslogtreecommitdiff
path: root/src/elements/stkm.c
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2011-10-25 10:31:21 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2011-10-25 10:31:21 (GMT)
commit07a1f21df484a252d54c82262ade6d4117425694 (patch)
tree80df86661553807159f7fda3fbf2506d5df3b5fa /src/elements/stkm.c
parentf01056ee0249ad01ed24824aea39f05083110cd6 (diff)
parentf8d54e66dba5d8448d30f61f84883b4e7e6e1087 (diff)
downloadpowder-07a1f21df484a252d54c82262ade6d4117425694.zip
powder-07a1f21df484a252d54c82262ade6d4117425694.tar.gz
Merge latest with graphicstest
Diffstat (limited to 'src/elements/stkm.c')
-rw-r--r--src/elements/stkm.c69
1 files changed, 49 insertions, 20 deletions
diff --git a/src/elements/stkm.c b/src/elements/stkm.c
index 752f167..261c493 100644
--- a/src/elements/stkm.c
+++ b/src/elements/stkm.c
@@ -36,8 +36,9 @@ int run_stickman(float* playerp, UPDATE_FUNC_ARGS) {
float gvx, gvy;
float gx, gy, dl, dr;
- if ((parts[i].ctype>0 && parts[i].ctype<PT_NUM && ptypes[parts[i].ctype].falldown>0) || parts[i].ctype==SPC_AIR || parts[i].ctype == PT_NEUT || parts[i].ctype == PT_PHOT)
+ if ((parts[i].ctype>0 && parts[i].ctype<PT_NUM && ptypes[parts[i].ctype].falldown>0) || parts[i].ctype==SPC_AIR || parts[i].ctype == PT_NEUT || parts[i].ctype == PT_PHOT || parts[i].ctype == PT_LIGH)
playerp[2] = parts[i].ctype;
+ playerp[28]++;
//Tempirature handling
if (parts[i].temp<243)
@@ -213,6 +214,8 @@ int run_stickman(float* playerp, UPDATE_FUNC_ARGS) {
{
playerp[2] = r&0xFF; //Current element
}
+ if ((r&0xFF)==PT_TESC || (r&0xFF)==PT_LIGH)
+ playerp[2] = PT_LIGH;
if ((r&0xFF) == PT_PLNT && parts[i].life<100) //Plant gives him 5 HP
{
if (parts[i].life<=95)
@@ -245,24 +248,23 @@ int run_stickman(float* playerp, UPDATE_FUNC_ARGS) {
{
ry -= 2*(rand()%2)+1;
r = pmap[ry][rx];
- if (ptypes[r&0xFF].state == ST_SOLID)
- {
- create_part(-1, rx, ry, PT_SPRK);
- }
+ if (ptypes[r&0xFF].state == ST_SOLID)
+ {
+ create_part(-1, rx, ry, PT_SPRK);
+ playerp[28] = 0;
+ }
+ else
+ {
+ 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, 0);
+ else if (playerp[2]==PT_LIGH && playerp[28]<30)//limit lightning creation rate
+ np = -1;
else
+ np = create_part(-1, rx, ry, playerp[2]);
+ if ( (np < NPART) && np>=0)
{
- 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, 0);
- else
- np = create_part(-1, rx, ry, playerp[2]);
- if ( (np < NPART) && np>=0 && playerp[2] != PT_PHOT && playerp[2] != SPC_AIR)
- {
- parts[np].vx -= -gvy*(5*((((int)playerp[1])&0x02) == 0x02) - 5*(((int)(playerp[1])&0x01) == 0x01));
- parts[np].vy -= gvx*(5*((((int)playerp[1])&0x02) == 0x02) - 5*(((int)(playerp[1])&0x01) == 0x01));
- parts[i].vx -= (ptypes[(int)playerp[2]].weight*parts[np].vx)/1000;
- }
- if ((np < NPART) && np>=0 && playerp[2] == PT_PHOT)
+ if (playerp[2] == PT_PHOT)
{
int random = abs(rand()%3-1)*3;
if (random==0)
@@ -278,8 +280,35 @@ int run_stickman(float* playerp, UPDATE_FUNC_ARGS) {
parts[np].vx = random;
}
}
-
+ else if (playerp[2] == PT_LIGH)
+ {
+ float angle;
+ int power = 100;
+ if (gvx!=0 || gvy!=0)
+ angle = atan2(gvx, gvy)*180.0f/M_PI;
+ else
+ angle = rand()%360;
+ if (((int)playerp[1])&0x01)
+ angle += 180;
+ if (angle>360)
+ angle-=360;
+ if (angle<0)
+ angle+=360;
+ parts[np].tmp = angle;
+ parts[np].life=rand()%(2+power/15)+power/7;
+ parts[np].temp=parts[np].life*power/2.5;
+ parts[np].tmp2=1;
+ }
+ else if (playerp[2] != SPC_AIR)
+ {
+ parts[np].vx -= -gvy*(5*((((int)playerp[1])&0x02) == 0x02) - 5*(((int)(playerp[1])&0x01) == 0x01));
+ parts[np].vy -= gvx*(5*((((int)playerp[1])&0x02) == 0x02) - 5*(((int)(playerp[1])&0x01) == 0x01));
+ parts[i].vx -= (ptypes[(int)playerp[2]].weight*parts[np].vx)/1000;
+ }
+ playerp[28] = 0;
}
+
+ }
}
//Simulation of joints
@@ -385,12 +414,12 @@ void STKM_interact(float* playerp, int i, int x, int y)
r = pmap[y][x];
if (r)
{
- if ((r&0xFF)==PT_SPRK) //If on charge
+ if ((r&0xFF)==PT_SPRK && playerp[2]!=PT_LIGH) //If on charge
{
parts[i].life -= (int)(rand()*20/RAND_MAX)+32;
}
- if (ptypes[r&0xFF].hconduct && (parts[r>>8].temp>=323 || parts[r>>8].temp<=243))
+ if (ptypes[r&0xFF].hconduct && ((playerp[2]!=PT_LIGH && parts[r>>8].temp>=323) || parts[r>>8].temp<=243))
{
parts[i].life -= 2;
playerp[22] -= 1;