new element: PROT (protons) TODO: proton colliders to produce heavier elements
This commit is contained in:
parent
b2957dc1c9
commit
f1145f31f5
@ -2019,13 +2019,15 @@ void Simulation::init_can_move()
|
||||
}
|
||||
//a list of lots of things PHOT can move through
|
||||
// TODO: replace with property
|
||||
for (movingType = 0; movingType < PT_NUM; movingType++)
|
||||
for (destinationType = 0; destinationType < PT_NUM; destinationType++)
|
||||
{
|
||||
if (movingType == PT_GLAS || movingType == PT_PHOT || movingType == PT_FILT || movingType == PT_INVIS
|
||||
|| movingType == PT_CLNE || movingType == PT_PCLN || movingType == PT_BCLN || movingType == PT_PBCN
|
||||
|| movingType == PT_WATR || movingType == PT_DSTW || movingType == PT_SLTW || movingType == PT_GLOW
|
||||
|| movingType == PT_ISOZ || movingType == PT_ISZS || movingType == PT_QRTZ || movingType == PT_PQRT)
|
||||
can_move[PT_PHOT][movingType] = 2;
|
||||
if (destinationType == PT_GLAS || destinationType == PT_PHOT || destinationType == PT_FILT || destinationType == PT_INVIS
|
||||
|| destinationType == PT_CLNE || destinationType == PT_PCLN || destinationType == PT_BCLN || destinationType == PT_PBCN
|
||||
|| destinationType == PT_WATR || destinationType == PT_DSTW || destinationType == PT_SLTW || destinationType == PT_GLOW
|
||||
|| destinationType == PT_ISOZ || destinationType == PT_ISZS || destinationType == PT_QRTZ || destinationType == PT_PQRT)
|
||||
can_move[PT_PHOT][destinationType] = 2;
|
||||
if (destinationType != PT_DMND && destinationType != PT_INSL && destinationType != PT_VOID && destinationType != PT_PVOD)
|
||||
can_move[PT_PROT][destinationType] = 2;
|
||||
}
|
||||
|
||||
//other special cases that weren't covered above
|
||||
@ -2932,7 +2934,8 @@ int Simulation::create_part(int p, int x, int y, int tv)
|
||||
case PT_TSNS:
|
||||
parts[i].tmp2 = 2;
|
||||
break;
|
||||
case PT_FIGH:{
|
||||
case PT_FIGH:
|
||||
{
|
||||
unsigned char fcount = 0;
|
||||
while (fcount < 100 && fcount < (fighcount+1) && fighters[fcount].spwn==1) fcount++;
|
||||
if (fcount < 100 && fighters[fcount].spwn==0)
|
||||
@ -2947,35 +2950,53 @@ int Simulation::create_part(int p, int x, int y, int tv)
|
||||
return i;
|
||||
}
|
||||
parts[i].type=0;
|
||||
return -1;}
|
||||
case PT_PHOT:{
|
||||
return -1;
|
||||
}
|
||||
case PT_PHOT:
|
||||
{
|
||||
float a = (rand()%8) * 0.78540f;
|
||||
parts[i].life = 680;
|
||||
parts[i].ctype = 0x3FFFFFFF;
|
||||
parts[i].vx = 3.0f*cosf(a);
|
||||
parts[i].vy = 3.0f*sinf(a);
|
||||
break;}
|
||||
case PT_ELEC:{
|
||||
break;
|
||||
}
|
||||
case PT_ELEC:
|
||||
{
|
||||
float a = (rand()%360)*3.14159f/180.0f;
|
||||
parts[i].life = 680;
|
||||
parts[i].vx = 2.0f*cosf(a);
|
||||
parts[i].vy = 2.0f*sinf(a);
|
||||
break;}
|
||||
case PT_NEUT:{
|
||||
break;
|
||||
}
|
||||
case PT_NEUT:
|
||||
{
|
||||
float r = (rand()%128+128)/127.0f;
|
||||
float a = (rand()%360)*3.14159f/180.0f;
|
||||
parts[i].life = rand()%480+480;
|
||||
parts[i].vx = r*cosf(a);
|
||||
parts[i].vy = r*sinf(a);
|
||||
break;}
|
||||
case PT_TRON:{
|
||||
break;
|
||||
}
|
||||
case PT_PROT:
|
||||
{
|
||||
float a = (rand()%72)* 0.08727f;
|
||||
parts[i].life = 680;
|
||||
parts[i].vx = 2.0f*cosf(a);
|
||||
parts[i].vy = 2.0f*sinf(a);
|
||||
break;
|
||||
}
|
||||
case PT_TRON:
|
||||
{
|
||||
int randhue = rand()%360;
|
||||
int randomdir = rand()%4;
|
||||
parts[i].tmp = 1|(randomdir<<5)|(randhue<<7);//set as a head and a direction
|
||||
parts[i].tmp2 = 4;//tail
|
||||
parts[i].life = 5;
|
||||
break;}
|
||||
case PT_LIGH:{
|
||||
break;
|
||||
}
|
||||
case PT_LIGH:
|
||||
{
|
||||
float gx, gy, gsize;
|
||||
if (p!=-2)
|
||||
{
|
||||
@ -2994,7 +3015,8 @@ int Simulation::create_part(int p, int x, int y, int tv)
|
||||
}
|
||||
parts[i].tmp = (((int)(atan2f(-gy, gx)*(180.0f/M_PI)))+rand()%40-20+360)%360;
|
||||
parts[i].tmp2 = 4;
|
||||
break;}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -70,7 +70,6 @@ public:
|
||||
bool gravWallChanged;
|
||||
//Portals and Wifi
|
||||
Particle portalp[CHANNELS][8][80];
|
||||
Particle emptyparticle;
|
||||
int portal_rx[8];
|
||||
int portal_ry[8];
|
||||
int wireless[CHANNELS][2];
|
||||
|
@ -91,6 +91,7 @@ int Element_ELEC::update(UPDATE_FUNC_ARGS)
|
||||
sim->create_part(r>>8, x+rx, y+ry, PT_H2);
|
||||
return 1;
|
||||
case PT_NEUT:
|
||||
case PT_PROT: // this is the correct reaction, not NEUT, but leaving NEUT in anyway
|
||||
sim->part_change_type(r>>8, x+rx, y+ry, PT_H2);
|
||||
parts[r>>8].life = 0;
|
||||
parts[r>>8].ctype = 0;
|
||||
@ -124,8 +125,6 @@ int Element_ELEC::update(UPDATE_FUNC_ARGS)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//#TPT-Directive ElementHeader Element_ELEC static int graphics(GRAPHICS_FUNC_ARGS)
|
||||
int Element_ELEC::graphics(GRAPHICS_FUNC_ARGS)
|
||||
|
||||
|
@ -47,11 +47,13 @@ Element_EXOT::Element_EXOT()
|
||||
}
|
||||
|
||||
//#TPT-Directive ElementHeader Element_EXOT static int update(UPDATE_FUNC_ARGS)
|
||||
int Element_EXOT::update(UPDATE_FUNC_ARGS) {
|
||||
int Element_EXOT::update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
int r, rt, rx, ry, nb, rrx, rry, trade, tym;
|
||||
for (rx=-2; rx<=2; rx++)
|
||||
for (ry=-2; ry<=2; ry++)
|
||||
if (BOUNDS_CHECK && (rx || ry)) {
|
||||
if (BOUNDS_CHECK && (rx || ry))
|
||||
{
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (!r)
|
||||
continue;
|
||||
@ -65,11 +67,14 @@ int Element_EXOT::update(UPDATE_FUNC_ARGS) {
|
||||
}
|
||||
else if (rt == PT_EXOT)
|
||||
{
|
||||
if (parts[r>>8].ctype == PT_PROT)
|
||||
parts[i].ctype = PT_PROT;
|
||||
if (parts[r>>8].life == 1500 && !(rand()%1000))
|
||||
parts[i].life = 1500;
|
||||
}
|
||||
else if (rt == PT_LAVA)
|
||||
{
|
||||
//turn molten TTAN or molten GOLD to molten VIBR
|
||||
if (parts[r>>8].ctype == PT_TTAN || parts[r>>8].ctype == PT_GOLD)
|
||||
{
|
||||
if (!(rand()%10))
|
||||
@ -79,66 +84,71 @@ int Element_EXOT::update(UPDATE_FUNC_ARGS) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
//molten VIBR will kill the leftover EXOT though, so the VIBR isn't killed later
|
||||
else if (parts[r>>8].ctype == PT_VIBR)
|
||||
{
|
||||
if (1>rand()%1000)
|
||||
if (!(rand()%1000))
|
||||
{
|
||||
sim->kill_part(i);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((parts[i].tmp>245) && (parts[i].life>1000))
|
||||
if (parts[i].tmp > 245 && parts[i].life > 1000)
|
||||
if (rt!=PT_EXOT && rt!=PT_BREC && rt!=PT_DMND && rt!=PT_CLNE && rt!=PT_PRTI && rt!=PT_PRTO && rt!=PT_PCLN && rt!=PT_VOID && rt!=PT_NBHL && rt!=PT_WARP)
|
||||
{
|
||||
sim->create_part(i, x, y, rt);
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
parts[i].tmp--;
|
||||
parts[i].tmp2--;
|
||||
if (parts[i].tmp<1 || parts[i].tmp>250)
|
||||
//reset tmp every 250 frames, gives EXOT it's slow flashing effect
|
||||
if (parts[i].tmp < 1 || parts[i].tmp > 250)
|
||||
parts[i].tmp = 250;
|
||||
if (parts[i].tmp2<1)
|
||||
|
||||
if (parts[i].tmp2 < 1)
|
||||
parts[i].tmp2 = 1;
|
||||
else if (parts[i].tmp2>6000)
|
||||
else if (parts[i].tmp2 > 6000)
|
||||
{
|
||||
parts[i].tmp2 = 10000;
|
||||
if (parts[i].life<1001)
|
||||
if (parts[i].life < 1001)
|
||||
{
|
||||
sim->part_change_type(i, x, y, PT_WARP);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else if(parts[i].life<1001)
|
||||
else if(parts[i].life < 1001)
|
||||
sim->pv[y/CELL][x/CELL] += (parts[i].tmp2*CFDS)/160000;
|
||||
|
||||
if (sim->pv[y/CELL][x/CELL]>200 && parts[i].temp>9000 && parts[i].tmp2>200)
|
||||
{
|
||||
parts[i].tmp2 = 6000;
|
||||
sim->part_change_type(i, x, y, PT_WARP);
|
||||
return 0;
|
||||
}
|
||||
if (parts[i].tmp2>100)
|
||||
if (parts[i].tmp2 > 100)
|
||||
{
|
||||
for ( trade = 0; trade<9; trade ++)
|
||||
for (trade = 0; trade < 9; trade++)
|
||||
{
|
||||
rx = rand()%5-2;
|
||||
ry = rand()%5-2;
|
||||
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
|
||||
if (BOUNDS_CHECK && (rx || ry))
|
||||
{
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (!r)
|
||||
continue;
|
||||
if ((r&0xFF)==PT_EXOT && (parts[i].tmp2>parts[r>>8].tmp2) && parts[r>>8].tmp2>=0 )//diffusion
|
||||
if ((r&0xFF)==PT_EXOT && (parts[i].tmp2 > parts[r>>8].tmp2) && parts[r>>8].tmp2 >= 0) //diffusion
|
||||
{
|
||||
tym = parts[i].tmp2 - parts[r>>8].tmp2;
|
||||
if (tym ==1)
|
||||
if (tym == 1)
|
||||
{
|
||||
parts[r>>8].tmp2 ++;
|
||||
parts[i].tmp2 --;
|
||||
parts[r>>8].tmp2++;
|
||||
parts[i].tmp2--;
|
||||
break;
|
||||
}
|
||||
if (tym>0)
|
||||
if (tym > 0)
|
||||
{
|
||||
parts[r>>8].tmp2 += tym/2;
|
||||
parts[i].tmp2 -= tym/2;
|
||||
@ -148,7 +158,17 @@ int Element_EXOT::update(UPDATE_FUNC_ARGS) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (parts[i].temp<273.15f)
|
||||
if (parts[i].ctype == PT_PROT)
|
||||
{
|
||||
if (parts[i].temp < 50.0f)
|
||||
{
|
||||
sim->create_part(i, x, y, PT_CFLM);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
parts[i].temp -= 1.0f;
|
||||
}
|
||||
else if (parts[i].temp < 273.15f)
|
||||
{
|
||||
parts[i].vx = 0;
|
||||
parts[i].vy = 0;
|
||||
|
99
src/simulation/elements/PROT.cpp
Normal file
99
src/simulation/elements/PROT.cpp
Normal file
@ -0,0 +1,99 @@
|
||||
#include "simulation/Elements.h"
|
||||
//#TPT-Directive ElementClass Element_PROT PT_PROT 173
|
||||
Element_PROT::Element_PROT()
|
||||
{
|
||||
Identifier = "DEFAULT_PT_PROT";
|
||||
Name = "PROT";
|
||||
Colour = PIXPACK(0x990000);
|
||||
MenuVisible = 1;
|
||||
MenuSection = SC_NUCLEAR;
|
||||
Enabled = 1;
|
||||
|
||||
Advection = 0.0f;
|
||||
AirDrag = 0.00f * CFDS;
|
||||
AirLoss = 1.00f;
|
||||
Loss = 1.00f;
|
||||
Collision = -.99f;
|
||||
Gravity = 0.0f;
|
||||
Diffusion = 0.00f;
|
||||
HotAir = 0.000f * CFDS;
|
||||
Falldown = 0;
|
||||
|
||||
Flammable = 0;
|
||||
Explosive = 0;
|
||||
Meltable = 0;
|
||||
Hardness = 0;
|
||||
|
||||
Weight = -1;
|
||||
|
||||
Temperature = R_TEMP+273.15f;
|
||||
HeatConduct = 61;
|
||||
Description = "Protons. Transfer heat to materials, and removes sparks.";
|
||||
|
||||
State = ST_GAS;
|
||||
Properties = TYPE_ENERGY|PROP_LIFE_KILL;
|
||||
|
||||
LowPressure = IPL;
|
||||
LowPressureTransition = NT;
|
||||
HighPressure = IPH;
|
||||
HighPressureTransition = NT;
|
||||
LowTemperature = ITL;
|
||||
LowTemperatureTransition = NT;
|
||||
HighTemperature = ITH;
|
||||
HighTemperatureTransition = NT;
|
||||
|
||||
Update = &Element_PROT::update;
|
||||
Graphics = &Element_PROT::graphics;
|
||||
}
|
||||
|
||||
//#TPT-Directive ElementHeader Element_PROT static int update(UPDATE_FUNC_ARGS)
|
||||
int Element_PROT::update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
sim->pv[y/CELL][x/CELL] -= .005f;
|
||||
int under = pmap[y][x];
|
||||
//set off explosives (only when hot because it wasn't as fun when it made an entire save explode)
|
||||
if (parts[i].temp > 273.15f+500.0f && (sim->elements[under&0xFF].Flammable || sim->elements[under&0xFF].Explosive || (under&0xFF) == PT_BANG))
|
||||
{
|
||||
sim->create_part(under>>8, x, y, PT_FIRE);
|
||||
parts[under>>8].temp += restrict_flt(sim->elements[under&0xFF].Flammable*5, MIN_TEMP, MAX_TEMP);
|
||||
sim->pv[y/CELL][x/CELL] += 1.00f;
|
||||
}
|
||||
//remove active sparks
|
||||
else if ((under&0xFF) == PT_SPRK)
|
||||
{
|
||||
sim->part_change_type(under>>8, x, y, parts[under>>8].ctype);
|
||||
parts[under>>8].life = 44+parts[under>>8].life;
|
||||
parts[under>>8].ctype = 0;
|
||||
}
|
||||
//prevent inactive sparkable elements from being sparked
|
||||
else if ((sim->elements[under&0xFF].Properties&PROP_CONDUCTS) && parts[under>>8].life <= 4)
|
||||
{
|
||||
parts[under>>8].life = 40+parts[under>>8].life;
|
||||
}
|
||||
else if ((under&0xFF) == PT_EXOT)
|
||||
parts[under>>8].ctype = PT_PROT;
|
||||
|
||||
//make temp of other things closer to it's own temperature. This will change temp of things that don't conduct, and won't change the PROT's temperature
|
||||
if (under)
|
||||
{
|
||||
parts[under>>8].temp -= restrict_flt((parts[under>>8].temp-parts[i].temp)/4.0f, MIN_TEMP, MAX_TEMP);
|
||||
}
|
||||
//else, slowly kill it if it's not inside an element
|
||||
else
|
||||
parts[i].life--;
|
||||
return 0;
|
||||
}
|
||||
|
||||
//#TPT-Directive ElementHeader Element_PROT static int graphics(GRAPHICS_FUNC_ARGS)
|
||||
int Element_PROT::graphics(GRAPHICS_FUNC_ARGS)
|
||||
{
|
||||
*firea = 20;
|
||||
*firer = 250;
|
||||
*fireg = 128;
|
||||
*fireb = 128;
|
||||
|
||||
*pixel_mode |= FIRE_ADD;
|
||||
return 1;
|
||||
}
|
||||
|
||||
Element_PROT::~Element_PROT() {}
|
@ -85,7 +85,7 @@ int Element_PRTO::update(UPDATE_FUNC_ARGS)
|
||||
sim->create_part(-1,x-1,y+1,PT_SPRK);
|
||||
sim->create_part(-1,x-1,y,PT_SPRK);
|
||||
sim->create_part(-1,x-1,y-1,PT_SPRK);
|
||||
sim->portalp[parts[i].tmp][randomness][nnx] = sim->emptyparticle;
|
||||
memset(&sim->portalp[parts[i].tmp][randomness][nnx], 0, sizeof(Particle));
|
||||
break;
|
||||
}
|
||||
else if (sim->portalp[parts[i].tmp][randomness][nnx].type)
|
||||
@ -132,7 +132,7 @@ int Element_PRTO::update(UPDATE_FUNC_ARGS)
|
||||
parts[np] = sim->portalp[parts[i].tmp][randomness][nnx];
|
||||
parts[np].x = x+rx;
|
||||
parts[np].y = y+ry;
|
||||
sim->portalp[parts[i].tmp][randomness][nnx] = sim->emptyparticle;
|
||||
memset(&sim->portalp[parts[i].tmp][randomness][nnx], 0, sizeof(Particle));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user