Esempio n. 1
0
int update_SHLD1(UPDATE_FUNC_ARGS) {
	int r, nnx, nny, rx, ry;
	for (rx=-1; rx<2; rx++)
		for (ry=-1; ry<2; ry++)
			if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
			{
				r = pmap[y+ry][x+rx];
				if (!r)
					continue;
				else if ((r&0xFF)==PT_SPRK&&parts[i].life==0)
				{
					if (55>rand()%200&&parts[i].life==0)
					{
						part_change_type(i,x,y,PT_SHLD2);
						parts[i].life = 7;
					}
					for ( nnx=-1; nnx<2; nnx++)
						for ( nny=-1; nny<2; nny++)
						{
							if (!pmap[y+ry+nny][x+rx+nnx])
							{
								create_part(-1,x+rx+nnx,y+ry+nny,PT_SHLD1);
								//parts[pmap[y+ny+nny][x+nx+nnx]>>8].life=7;
							}
						}
				}
				else if ((r&0xFF)==PT_SHLD3&&4>rand()%10)
				{
					part_change_type(i,x,y,PT_SHLD2);
					parts[i].life = 7;
				}
			}
	return 0;
}
Esempio n. 2
0
int update_FWRK(UPDATE_FUNC_ARGS) {
	int r, rx, ry, np;
	if ((parts[i].temp>400&&(9+parts[i].temp/40)>rand()%100000&&parts[i].life==0&&!pmap[y-1][x])||parts[i].ctype==PT_DUST)
	{
		np = create_part(-1, x , y-1 , PT_FWRK);
		if (np!=-1)
		{
			parts[np].vy = rand()%8-22;
			parts[np].vx = rand()%20-rand()%20;
			parts[np].life=rand()%15+25;
			parts[np].dcolour = parts[i].dcolour;
			kill_part(i);
			return 1;
		}
	}
	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))
	{
		int r = (rand()%245+11);
		int g = (rand()%245+11);
		int b = (rand()%245+11);
		int n;
		float angle, magnitude;
		unsigned col = (r<<16) | (g<<8) | b;
		for (n=0; n<40; n++)
		{
			np = create_part(-3, x, y, PT_EMBR);
			if (np>-1)
			{
				magnitude = ((rand()%60)+40)*0.05f;
				angle = (rand()%6284)*0.001f;//(in radians, between 0 and 2*pi)
				parts[np].vx = parts[i].vx + cosf(angle)*magnitude;
				parts[np].vy = parts[i].vy + sinf(angle)*magnitude - 2.5f;
				parts[np].ctype = col;
				parts[np].tmp = 1;
				parts[np].life = rand()%40+70;
				parts[np].temp = (rand()%500)+5750.0f;
				parts[np].dcolour = parts[i].dcolour;
			}
		}
		pv[y/CELL][x/CELL] += 8.0f;
		kill_part(i);
		return 1;
	}
	return 0;
}
Esempio n. 3
0
DDS::DomainParticipant_var
DDSApp::participant(DDS::DomainId_t domain_id)
{
  return create_part(domain_id,
                     PARTICIPANT_QOS_DEFAULT,
                     DDS::DomainParticipantListener::_nil(),
                     OpenDDS::DCPS::DEFAULT_STATUS_MASK);
}
Esempio n. 4
0
int update_BOMB(UPDATE_FUNC_ARGS) {
	int r, rx, ry, nb;
	for (rx=-2; rx<3; rx++)
		for (ry=-2; ry<3; ry++)
			if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
			{
				r = pmap[y+ry][x+rx];
				if (!r)
					continue;
				if ((r&0xFF)!=PT_BOMB && (r&0xFF)!=PT_EMBR && (r&0xFF)!=PT_DMND && (r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && (r&0xFF)!=PT_BCLN)
				{
					int rad = 8;
					int nxi;
					int nxj;
					pmap[y][x] = 0;
					for (nxj=-rad; nxj<=rad; nxj++)
						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, 0);
									pv[(y+nxj)/CELL][(x+nxi)/CELL] += 0.1f;
									nb = create_part(-3, x+nxi, y+nxj, PT_EMBR);
									if (nb!=-1) {
										parts[nb].tmp = 2;
										parts[nb].life = 2;
										parts[nb].temp = MAX_TEMP;
									}
								}
					for (nxj=-(rad+1); nxj<=(rad+1); nxj++)
						for (nxi=-(rad+1); nxi<=(rad+1); nxi++)
							if ((pow(nxi,2))/(pow((rad+1),2))+(pow(nxj,2))/(pow((rad+1),2))<=1 && !(pmap[y+nxj][x+nxi]&0xFF)) {
								nb = create_part(-3, x+nxi, y+nxj, PT_EMBR);
								if (nb!=-1) {
									parts[nb].tmp = 0;
									parts[nb].life = 50;
									parts[nb].temp = MAX_TEMP;
									parts[nb].vx = rand()%40-20;
									parts[nb].vy = rand()%40-20;
								}
							}
					kill_part(i);
					return 1;
				}
			}
	return 0;
}
Esempio n. 5
0
DDS::DomainParticipant_var
DDSApp::participant(DDS::DomainId_t                    domain_id,
                    DDS::DomainParticipantListener_var listener,
                    DDS::StatusMask                    mask)
{
  return create_part(domain_id,
                     PARTICIPANT_QOS_DEFAULT,
                     listener,
                     mask);
}
Esempio n. 6
0
CManager::CManager() {
    m_vpart.clear();
    std::vector<CPartition>(m_vpart).swap(m_vpart);
    m_filepath = "Configuration/Config.txt";
    m_compath = "Configuration/Communication.txt";


    init_process();
    create_part();
}
Esempio n. 7
0
int update_ISZ(UPDATE_FUNC_ARGS) { // for both ISZS and ISOZ
	float rr, rrr;
	if (1>rand()%200 && ((int)(-4.0f*(pv[y/CELL][x/CELL])))>(rand()%1000))
	{
		create_part(i, x, y, PT_PHOT);
		rr = (rand()%228+128)/127.0f;
		rrr = (rand()%360)*3.14159f/180.0f;
		parts[i].vx = rr*cosf(rrr);
		parts[i].vy = rr*sinf(rrr);
	}
	return 0;
}
Esempio n. 8
0
static PyObject* emb_create(PyObject *self, PyObject *args, PyObject *keywds)
{
	int x,y,t;
	char *name = "";
	char *kwlist[] = {"x","y","t","name", NULL};
	if (!PyArg_ParseTupleAndKeywords(args, keywds, "II|Is:create",kwlist, &x,&y,&t,&name))
		return NULL;
	//
	if (strcmp(name,"")!=0)
		console_parse_type(name, &t, console_error);
	return Py_BuildValue("i",create_part(-1,x,y,t));
}
Esempio n. 9
0
int update_COAL(UPDATE_FUNC_ARGS) {
	int r, rx, ry, trade, temp;
	if (parts[i].life<=0) {
		create_part(i, x, y, PT_FIRE);
		return 1;
	} else if (parts[i].life < 100) {
		parts[i].life--;
		create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_FIRE);
	}
	if ((pv[y/CELL][x/CELL] > 4.3f)&&parts[i].tmp>40)
		parts[i].tmp=39;
	else if (parts[i].tmp<40&&parts[i].tmp>0)
		parts[i].tmp--;
	else if (parts[i].tmp<=0) {
		create_part(i, x, y, PT_BCOL);
		return 1;
	}
	for (rx=-1; rx<2; rx++)
		for (ry=-1; ry<2; ry++)
			if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
			{
				r = pmap[y+ry][x+rx];
				if (!r)
					continue;
				if (((r&0xFF)==PT_FIRE || (r&0xFF)==PT_PLSM) && 1>(rand()%500))
				{
					if (parts[i].life>100) {
						parts[i].life = 99;
					}
				}
				if ((r&0xFF)==PT_LAVA && 1>(rand()%500))
				{
					if (parts[r>>8].ctype == PT_IRON) {
						parts[r>>8].ctype = PT_METL;
						kill_part(i);
						return 1;
					}
				}
			}
Esempio n. 10
0
int update_FSEP(UPDATE_FUNC_ARGS) {
	int r, rx, ry;
	if (parts[i].life<=0) {
		r = create_part(i, x, y, PT_PLSM);
        if (r!=-1)
        {
            parts[r].ctype = PT_FUSE;
            parts[r].life = 50;
        }
		return 1;
	} else if (parts[i].life < 40) {
		parts[i].life--;
		if ((rand()%10)==0) {
			r = create_part(-1, (rx=x+rand()%3-1), (ry=y+rand()%3-1), PT_PLSM);
			if (r!=-1)
			{
			    parts[r].ctype = PT_FUSE;
				parts[r].life = 50;
			}
		}
	}
	else {
		for (rx=-2; rx<3; rx++)
			for (ry=-2; ry<3; ry++)
				if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
				{
					r = pmap[y+ry][x+rx];
					if (!r)
						continue;
					if (((r&0xFF)==PT_SPRK || (parts[i].temp>=(273.15+400.0f))) && 1>(rand()%15))
					{
						if (parts[i].life>40) {
							parts[i].life = 39;
						}
					}
				}
	}
	return 0;
}
Esempio n. 11
0
int update_NBLE(UPDATE_FUNC_ARGS)
{
	if (parts[i].temp > 5273.15 && pv[y/CELL][x/CELL] > 100.0f)
	{
		if (rand()%5 < 1)
		{
			int j;
			float temp = parts[i].temp;
			part_change_type(i,x,y,PT_PLSM);
			parts[i].life = rand()%150+50;
			j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_NEUT); if (j != -1) parts[j].temp = temp;
			if (!(rand()%25)) { j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_ELEC); if (j != -1) parts[j].temp = temp; }
			j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_PHOT);
			if (j != -1) { parts[j].ctype = 0xFF0000; parts[j].temp = temp; }

			j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_CO2);
			if (j != -1) parts[j].temp = temp;

			parts[i].temp += 1750+rand()%500;
			pv[y/CELL][x/CELL] += 50;
		}
	}
	return 0;
}
Esempio n. 12
0
int update_VINE(UPDATE_FUNC_ARGS) {
	int r, np, rx =(rand()%3)-1, ry=(rand()%3)-1;
	if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
	{
		r = pmap[y+ry][x+rx];
		if (1>rand()%15)
			part_change_type(i,x,y,PT_PLNT);
		else if (!r)
		{
			np = create_part(-1,x+rx,y+ry,PT_VINE);
			if (np<0) return 0;
			parts[np].temp = parts[i].temp;
			part_change_type(i,x,y,PT_PLNT);
		}
	}
	return 0;
}
Esempio n. 13
0
int update_ELEC(UPDATE_FUNC_ARGS) {
	int r, rt, rx, ry, nb, rrx, rry;
	float rr, rrr;
	parts[i].pavg[0] = x;
	parts[i].pavg[1] = y;
	if(pmap[y][x]==PT_GLOW)
	{
		part_change_type(i, x, y, PT_PHOT);
	}
	for (rx=-2; rx<=2; rx++)
		for (ry=-2; ry<=2; ry++)
			if (x+rx>=0 && y+ry>=0 && x+rx<XRES && y+ry<YRES) {
				r = pmap[y+ry][x+rx];
				if (!r)
					r = photons[y+ry][x+rx];
				if (!r)
					continue;
				if ((r&0xFF)==PT_GLAS)
				{
					fire_r[y/CELL][x/CELL] += rand()%200;	//D: Doesn't work with OpenGL, also shouldn't be here
					fire_g[y/CELL][x/CELL] += rand()%200;
					fire_b[y/CELL][x/CELL] += rand()%200;
					for (rrx=-1; rrx<=1; rrx++)
					{
						for (rry=-1; rry<=1; rry++)
						{
							if (x+rx+rrx>=0 && y+ry+rry>=0 && x+rx+rrx<XRES && y+ry+rry<YRES) {
								nb = create_part(-1, x+rx+rrx, y+ry+rry, PT_BOMB);
								if (nb!=-1) {
									parts[nb].tmp = 1;
									parts[nb].life = 50;
									parts[nb].temp = 400.0f;
									parts[nb].vx = rand()%20-10;
									parts[nb].vy = rand()%20-10;
								}
							}
						}
					}
					kill_part(i);
					return 1;
				}
				if ((r&0xFF)==PT_LCRY)
				{
					parts[r>>8].tmp2 = 5+rand()%5;
				}
Esempio n. 14
0
int new_tronhead(int x, int y, int i, int direction)
{
	int np = create_part(-1, x , y ,PT_TRON);
	if (np==-1)
		return -1;
	if (parts[i].life >= 100) // increase tail length
	{
		parts[i].tmp2++;
		parts[i].life = 5;
	}
	//give new head our properties
	parts[np].tmp = 1 | direction<<5 | parts[i].tmp&(TRON_NOGROW|TRON_NODIE) | (parts[i].tmp&0xF800);
	if (np > i)
		parts[np].tmp |= TRON_WAIT;
	
	parts[np].ctype = parts[i].ctype;
	parts[np].tmp2 = parts[i].tmp2;
	parts[np].life = parts[i].life + 2;
	return 1;
}
Esempio n. 15
0
int update_RADI(UPDATE_FUNC_ARGS)
{
    int r,rx,ry;
	for(rx=-1; rx<2; rx++)
		for(ry=-1; ry<2; ry++)
			if(x+rx>=0 && y+ry>0 &&
			   x+rx<XRES && y+ry<YRES && (rx || ry))
			{
				r = pmap[y+ry][x+rx];
				if((r>>8)>=NPART || !r)
					continue;
				if(10>rand()/(RAND_MAX/100))
					parts[i].life--;

				if(parts[i].life <= 0)
				{
					kill_part(i);
					create_part(i,x,y,PT_RADO);
				}
			}
Esempio n. 16
0
int update_CLNE(UPDATE_FUNC_ARGS) {
	if (!parts[i].ctype)
	{
		int rx, ry;
		for (rx=-1; rx<2; rx++)
			for (ry=-1; ry<2; ry++)
				if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES &&
				        pmap[y+ry][x+rx] &&
				        (pmap[y+ry][x+rx]&0xFF)!=PT_CLNE &&
				        (pmap[y+ry][x+rx]&0xFF)!=PT_BCLN &&
				        (pmap[y+ry][x+rx]&0xFF)!=PT_PCLN &&
				        (pmap[y+ry][x+rx]&0xFF)!=PT_STKM &&
				        (pmap[y+ry][x+rx]&0xFF)!=PT_STKM2 &&
				        (pmap[y+ry][x+rx]&0xFF)!=0xFF)
					parts[i].ctype = pmap[y+ry][x+rx]&0xFF;
	}
	else {
		create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype);
	}
	return 0;
}
Esempio n. 17
0
int update_WIRE(UPDATE_FUNC_ARGS) {
    int s,r,rx,ry,count;    
    /*
    0:  wire
    1:  spark head
    2:  spark tail
    
    tmp is previous state, ctype is current state
    */
    //parts[i].tmp=parts[i].ctype;
    parts[i].ctype=0;
    if(parts[i].tmp==1)
	{
		parts[i].ctype=2;
	}
    if(parts[i].tmp==2)
	{
		parts[i].ctype=0;
	}
    
    count=0;
    for(rx=-1; rx<2; rx++)
        for(ry=-1; ry<2; ry++)
        {
            if(x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
            {
                r = pmap[y+ry][x+rx];
				if (!r)
					continue;
                if((r&0xFF)==PT_SPRK && parts[r>>8].life==3 && parts[r>>8].ctype==PT_PSCN)
                {
						parts[i].ctype=1;
						return 0;
				}
				else if((r&0xFF)==PT_NSCN && parts[i].tmp==1){create_part(-1, x+rx, y+ry, PT_SPRK);}
                else if((r&0xFF)==PT_WIRE && parts[r>>8].tmp==1 && !parts[i].tmp){count++;}
            }
Esempio n. 18
0
int luatpt_create(lua_State* l)
{
	int x, y, retid, t = 0;
	char * name;
	x = abs(luaL_optint(l, 1, 0));
	y = abs(luaL_optint(l, 2, 0));
	if(x < XRES && y < YRES){
		if(lua_isnumber(l, 3)){
			t = luaL_optint(l, 3, 0);
			if(t >= PT_NUM)
				return -1;
		} else {
			name = luaL_optstring(l, 3, "dust");
			if (name[0]!=0)
				console_parse_type(name, &t, console_error);
		}
		retid = create_part(-1, x, y, t);
		if(retid==-1)
			return -1;
		lua_pushinteger(l, retid);
		return 1;	
	}
	return -1;
}
Esempio n. 19
0
int run_stickman(playerst* playerp, UPDATE_FUNC_ARGS) {
	int r, rx, ry;
	int t = parts[i].type;
	float pp, d;
	float dt = 0.9;///(FPSB*FPSB);  //Delta time in square
	float gvx, gvy;
	float gx, gy, dl, dr;

	if ((parts[i].ctype>0 && parts[i].ctype<PT_NUM && ptypes[parts[i].ctype].enabled && 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->elem = parts[i].ctype;
	playerp->frames++;

	//Temperature handling
	if (parts[i].temp<243)
		parts[i].life -= 1;
	if ((parts[i].temp<309.6f) && (parts[i].temp>=243))
		parts[i].temp += 1;

	//Death
	if (parts[i].life<1 || (pv[y/CELL][x/CELL]>=4.5f && playerp->elem != SPC_AIR) ) //If his HP is less that 0 or there is very big wind...
	{
		for (r=-2; r<=1; r++)
		{
			create_part(-1, x+r, y-2, playerp->elem);
			create_part(-1, x+r+1, y+2, playerp->elem);
			create_part(-1, x-2, y+r+1, playerp->elem);
			create_part(-1, x+2, y+r, playerp->elem);
		}
		kill_part(i);  //Kill him
		return 1;
	}

	//Follow gravity
	gvx = gvy = 0.0f;
	switch (gravityMode)
	{
		default:
		case 0:
			gvy = 1;
			break;
		case 1:
			gvy = gvx = 0.0f;
			break;
		case 2:
			{
				float gravd;
				gravd = 0.01f - hypotf((parts[i].x - XCNTR), (parts[i].y - YCNTR));
				gvx = ((float)(parts[i].x - XCNTR) / gravd);
				gvy = ((float)(parts[i].y - YCNTR) / gravd);
			}
	}

	gvx += gravx[((int)parts[i].y/CELL)*(XRES/CELL)+((int)parts[i].x/CELL)];
	gvy += gravy[((int)parts[i].y/CELL)*(XRES/CELL)+((int)parts[i].x/CELL)];

	parts[i].vx -= gvx*dt;  //Head up!
	parts[i].vy -= gvy*dt;

	//Verlet integration
	pp = 2*playerp->legs[0]-playerp->legs[2]+playerp->accs[0]*dt*dt;
	playerp->legs[2] = playerp->legs[0];
	playerp->legs[0] = pp;
	pp = 2*playerp->legs[1]-playerp->legs[3]+playerp->accs[1]*dt*dt;
	playerp->legs[3] = playerp->legs[1];
	playerp->legs[1] = pp;

	pp = 2*playerp->legs[4]-playerp->legs[6]+(playerp->accs[2]+gvx)*dt*dt;
	playerp->legs[6] = playerp->legs[4];
	playerp->legs[4] = pp;
	pp = 2*playerp->legs[5]-playerp->legs[7]+(playerp->accs[3]+gvy)*dt*dt;
	playerp->legs[7] = playerp->legs[5];
	playerp->legs[5] = pp;

	pp = 2*playerp->legs[8]-playerp->legs[10]+playerp->accs[4]*dt*dt;
	playerp->legs[10] = playerp->legs[8];
	playerp->legs[8] = pp;
	pp = 2*playerp->legs[9]-playerp->legs[11]+playerp->accs[5]*dt*dt;
	playerp->legs[11] = playerp->legs[9];
	playerp->legs[9] = pp;

	pp = 2*playerp->legs[12]-playerp->legs[14]+(playerp->accs[6]+gvx)*dt*dt;
	playerp->legs[14] = playerp->legs[12];
	playerp->legs[12] = pp;
	pp = 2*playerp->legs[13]-playerp->legs[15]+(playerp->accs[7]+gvy)*dt*dt;
	playerp->legs[15] = playerp->legs[13];
	playerp->legs[13] = pp;

	//Setting acceleration to 0
	playerp->accs[0] = 0;
	playerp->accs[1] = 0;

	playerp->accs[2] = 0;
	playerp->accs[3] = 0;

	playerp->accs[4] = 0;
	playerp->accs[5] = 0;

	playerp->accs[6] = 0;
	playerp->accs[7] = 0;

	gx = (playerp->legs[4] + playerp->legs[12])/2 - gvy;
	gy = (playerp->legs[5] + playerp->legs[13])/2 + gvx;
	dl = pow(gx - playerp->legs[4], 2) + pow(gy - playerp->legs[5], 2);
	dr = pow(gx - playerp->legs[12], 2) + pow(gy - playerp->legs[13], 2);
	
	//Go left
	if (((int)(playerp->comm)&0x01) == 0x01)
	{
		if (dl>dr)
		{
			if (INBOND(playerp->legs[4], playerp->legs[5]) && !eval_move(t, playerp->legs[4], playerp->legs[5], NULL))
			{
				playerp->accs[2] = -3*gvy-3*gvx;
				playerp->accs[3] = 3*gvx-3*gvy;
				playerp->accs[0] = -gvy;
				playerp->accs[1] = gvx;
			}
		}
		else
		{
			if (INBOND(playerp->legs[12], playerp->legs[13]) && !eval_move(t, playerp->legs[12], playerp->legs[13], NULL))
			{
				playerp->accs[6] = -3*gvy-3*gvx;
				playerp->accs[7] = 3*gvx-3*gvy;
				playerp->accs[0] = -gvy;
				playerp->accs[1] = gvx;
			}
		}
	}

	//Go right
	if (((int)(playerp->comm)&0x02) == 0x02)
	{
		if (dl<dr)
		{
			if (INBOND(playerp->legs[4], playerp->legs[5]) && !eval_move(t, playerp->legs[4], playerp->legs[5], NULL))
			{
				playerp->accs[2] = 3*gvy-3*gvx;
				playerp->accs[3] = -3*gvx-3*gvy;
				playerp->accs[0] = gvy;
				playerp->accs[1] = -gvx;
			}
		}
		else
		{
			if (INBOND(playerp->legs[12], playerp->legs[13]) && !eval_move(t, playerp->legs[12], playerp->legs[13], NULL))
			{
				playerp->accs[6] = 3*gvy-3*gvx;
				playerp->accs[7] = -3*gvx-3*gvy;
				playerp->accs[0] = gvy;
				playerp->accs[1] = -gvx;
			}
		}
	}

	//Jump
	if (((int)(playerp->comm)&0x04) == 0x04 && 
			((INBOND(playerp->legs[4], playerp->legs[5]) && !eval_move(t, playerp->legs[4], playerp->legs[5], NULL))
			 || (INBOND(playerp->legs[12], playerp->legs[13]) && !eval_move(t, playerp->legs[12], playerp->legs[13], NULL))))
	{
		parts[i].vy -= 4*gvy;
		playerp->accs[3] -= gvy;
		playerp->accs[7] -= gvy;
	}

	//Charge detector wall if foot inside
	if (bmap[(int)(playerp->legs[5]+0.5)/CELL][(int)(playerp->legs[4]+0.5)/CELL]==WL_DETECT)
		set_emap((int)playerp->legs[4]/CELL, (int)playerp->legs[5]/CELL);
	if (bmap[(int)(playerp->legs[13]+0.5)/CELL][(int)(playerp->legs[12]+0.5)/CELL]==WL_DETECT)
		set_emap((int)(playerp->legs[12]+0.5)/CELL, (int)(playerp->legs[13]+0.5)/CELL);

	//Searching for particles near head
	for (rx=-2; rx<3; rx++)
		for (ry=-2; ry<3; ry++)
			if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
			{
				r = pmap[y+ry][x+rx];
				if (!r)
					r = photons[y+ry][x+rx];

				if (!r && !bmap[(y+ry)/CELL][(x+rx)/CELL])
					continue;
				
				if (ptypes[r&0xFF].falldown!=0 || ptypes[r&0xFF].state == ST_GAS 
						|| ptypes[r&0xFF].properties&TYPE_GAS
						|| ptypes[r&0xFF].properties&TYPE_LIQUID
						|| (r&0xFF) == PT_NEUT || (r&0xFF) == PT_PHOT)
				{
					playerp->elem = r&0xFF;  //Current element
				}
				if ((r&0xFF)==PT_TESC || (r&0xFF)==PT_LIGH)
					playerp->elem = PT_LIGH;
				if ((r&0xFF) == PT_PLNT && parts[i].life<100) //Plant gives him 5 HP
				{
					if (parts[i].life<=95)
						parts[i].life += 5;
					else
						parts[i].life = 100;
					kill_part(r>>8);
				}

				if ((r&0xFF) == PT_NEUT)
				{
					if (parts[i].life<=100) parts[i].life -= (102-parts[i].life)/2;
					else parts[i].life *= 0.9f;
					kill_part(r>>8);
				}
				if (bmap[(ry+y)/CELL][(rx+x)/CELL]==WL_FAN)
					playerp->elem = SPC_AIR;
				if ((r&0xFF)==PT_PRTI)
					STKM_interact(playerp, i, rx, ry);
				if (!parts[i].type)//STKM_interact may kill STKM
					return 1;
			}
Esempio n. 20
0
int update_SPAWN(UPDATE_FUNC_ARGS) {
	if (!player.spwn)
		create_part(-1, x, y, PT_STKM);

	return 0;
}
Esempio n. 21
0
int update_BOMB(UPDATE_FUNC_ARGS) {
	int r, rx, ry, nb;
	if (parts[i].tmp==1) {
		for (rx=-1; rx<2; rx++)
			for (ry=-1; ry<2; ry++)
				if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
				{
					r = pmap[y+ry][x+rx];
					if (!r)
						continue;
					if (ptypes[r&0xFF].properties & (TYPE_SOLID | TYPE_PART | TYPE_LIQUID) && (r&0xFF)!=PT_BOMB) {
						kill_part(i);
						return 1;
					}
				}
	} else if (parts[i].tmp==0) {
		for (rx=-2; rx<3; rx++)
			for (ry=-2; ry<3; ry++)
				if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
				{
					r = pmap[y+ry][x+rx];
					if (!r)
						continue;
					if ((r&0xFF)!=PT_BOMB && (r&0xFF)!=PT_DMND && (r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && (r&0xFF)!=PT_BCLN) {
						int rad = 8;
						int nxi;
						int nxj;
						pmap[y][x] = 0;
						for (nxj=-(rad+1); nxj<=(rad+1); nxj++)
							for (nxi=-(rad+1); nxi<=(rad+1); nxi++)
								if ((pow(nxi,2))/(pow((rad+1),2))+(pow(nxj,2))/(pow((rad+1),2))<=1) {
									nb = create_part(-1, x+nxi, y+nxj, PT_BOMB);
									if (nb!=-1) {
										parts[nb].tmp = 1;
										parts[nb].life = 50;
										parts[nb].temp = MAX_TEMP;
										parts[nb].vx = rand()%20-10;
										parts[nb].vy = rand()%20-10;
									}
								}
						for (nxj=-rad; nxj<=rad; nxj++)
							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, 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) {
											parts[nb].tmp = 2;
											parts[nb].life = 2;
											parts[nb].temp = MAX_TEMP;
										}
									}
						//create_parts(x, y, 9, 9, PT_BOMB);
						//create_parts(x, y, 8, 8, PT_NONE);
						kill_part(i);
						return 1;
					}
				}
	}
	return 0;
}
Esempio n. 22
0
int update_BANG(UPDATE_FUNC_ARGS) {
	int r, rx, ry, nb;
	if(parts[i].tmp==0)
	{
		if(parts[i].temp>=673.0f)
			parts[i].tmp = 1;
		else
			for (rx=-1; rx<2; rx++)
				for (ry=-1; ry<2; ry++)
					if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
					{
						r = pmap[y+ry][x+rx];
						if (!r)
							continue;
						if ((r&0xFF)==PT_FIRE || (r&0xFF)==PT_PLSM)
						{
							parts[i].tmp = 1;
						}
						else if ((r&0xFF)==PT_SPRK || (r&0xFF)==PT_LIGH)
						{
							parts[i].tmp = 1;
						}
					}
	
	}
	else if(parts[i].tmp==1)
	{
		int tempvalue = 2;
		flood_prop(x, y, offsetof(particle, tmp), &tempvalue, 0);
	}
	else if(parts[i].tmp==2)
	{
		parts[i].tmp = 3;
	}
	else if(parts[i].tmp>=3)
	{
		float otemp = parts[i].temp-275.13f;
		//Explode!!
		pv[y/CELL][x/CELL] += 0.5f;
		parts[i].tmp = 0;
		if(!(rand()%3))
		{
			if(!(rand()%2))
			{
				create_part(i, x, y, PT_FIRE);
				parts[i].temp = (MAX_TEMP/4)+otemp;
			}
			else
			{
				create_part(i, x, y, PT_SMKE);
				parts[i].temp = (MAX_TEMP/4)+otemp;
			}
		}
		else
		{
			if(!(rand()%15))
			{
				create_part(i, x, y, PT_BOMB);
				parts[i].tmp = 1;
				parts[i].life = 50;
				parts[i].temp = (MAX_TEMP/3)+otemp;
				parts[i].vx = rand()%20-10;
				parts[i].vy = rand()%20-10;
			}
			else
			{
				kill_part(i);
			}
		}
		return 1;
	}
	return 0;
}
Esempio n. 23
0
    Piece::Piece(b2World& world,int pos_x,int pos_y,Tetrimino_Types type,float rotation) : _world(world)
    {
        b2BodyDef bodyDef;

        bodyDef.position.Set(book::converter::pixel_to_meters<double>(pos_x),book::converter::pixel_to_meters<double>(pos_y));
        bodyDef.type = b2_dynamicBody;
        bodyDef.angle = converter::deg_to_rad(rotation);

        _body = world.CreateBody(&bodyDef);

        switch(type)
        {
            case Tetrimino_Types::O :
            {
                create_part(0,0,type);
                create_part(0,1,type);
                create_part(1,0,type);
                create_part(1,1,type);
            }break;
            case Tetrimino_Types::I :
            {
                create_part(0,0,type);
                create_part(1,0,type);
                create_part(2,0,type);
                create_part(3,0,type);
            }break;
            case Tetrimino_Types::S :
            {
                create_part(0,1,type);
                create_part(1,1,type);
                create_part(1,0,type);
                create_part(2,0,type);
            }break;
            case Tetrimino_Types::Z :
            {
                create_part(0,0,type);
                create_part(1,0,type);
                create_part(1,1,type);
                create_part(2,1,type);
            }break;
            case Tetrimino_Types::L :
            {
                create_part(0,1,type);
                create_part(0,0,type);
                create_part(1,0,type);
                create_part(2,0,type);
            }break;
            case Tetrimino_Types::J :
            {
                create_part(0,0,type);
                create_part(1,0,type);
                create_part(2,0,type);
                create_part(2,1,type);
            }break;
            case Tetrimino_Types::T :
            {
                create_part(0,0,type);
                create_part(1,0,type);
                create_part(1,1,type);
                create_part(2,0,type);
            }break;
            default:break;
        }

        _body->SetUserData(this);
        update();
    }
Esempio n. 24
0
//#TPT-Directive ElementHeader Element_NEUT static int update(UPDATE_FUNC_ARGS)
int Element_NEUT::update(UPDATE_FUNC_ARGS)
{
	int r, rx, ry;
	unsigned int pressureFactor = 3 + (int)sim->pv[y/CELL][x/CELL];
	for (rx=-1; rx<2; rx++)
		for (ry=-1; ry<2; ry++)
			if (BOUNDS_CHECK)
			{
				r = pmap[y+ry][x+rx];
				switch (TYP(r))
				{
				case PT_WATR:
					if (RNG::Ref().chance(3, 20))
						sim->part_change_type(ID(r),x+rx,y+ry,PT_DSTW);
				case PT_ICEI:
				case PT_SNOW:
					parts[i].vx *= 0.995;
					parts[i].vy *= 0.995;
					break;
				case PT_PLUT:
					if (RNG::Ref().chance(pressureFactor, 1000))
					{
						if (RNG::Ref().chance(1, 3))
						{
							sim->create_part(ID(r), x+rx, y+ry, RNG::Ref().chance(1, 3) ? PT_LAVA : PT_URAN);
							parts[ID(r)].temp = MAX_TEMP;
							if (parts[ID(r)].type==PT_LAVA) {
								parts[ID(r)].tmp = 100;
								parts[ID(r)].ctype = PT_PLUT;
							}
						}
						else
						{
							sim->create_part(ID(r), x+rx, y+ry, PT_NEUT);
							parts[ID(r)].vx = 0.25f*parts[ID(r)].vx + parts[i].vx;
							parts[ID(r)].vy = 0.25f*parts[ID(r)].vy + parts[i].vy;
						}
						sim->pv[y/CELL][x/CELL] += 10.0f * CFDS; //Used to be 2, some people said nukes weren't powerful enough
						Element_FIRE::update(UPDATE_FUNC_SUBCALL_ARGS);
					}
					break;
#ifdef SDEUT
				case PT_DEUT:
					if (RNG::Ref().chance(pressureFactor + 1 + (parts[ID(r)].life/100), 1000))
					{
						DeutExplosion(sim, parts[ID(r)].life, x+rx, y+ry, restrict_flt(parts[ID(r)].temp + parts[ID(r)].life*500.0f, MIN_TEMP, MAX_TEMP), PT_NEUT);
						sim->kill_part(ID(r));
					}
					break;
#else
				case PT_DEUT:
					if (RNG::Ref().chance(pressureFactor+1, 1000))
					{
						create_part(ID(r), x+rx, y+ry, PT_NEUT);
						parts[ID(r)].vx = 0.25f*parts[ID(r)].vx + parts[i].vx;
						parts[ID(r)].vy = 0.25f*parts[ID(r)].vy + parts[i].vy;
						parts[ID(r)].life --;
						parts[ID(r)].temp = restrict_flt(parts[ID(r)].temp + parts[ID(r)].life*17.0f, MIN_TEMP, MAX_TEMP);
						pv[y/CELL][x/CELL] += 6.0f * CFDS;

					}
					break;
#endif
				case PT_GUNP:
					if (RNG::Ref().chance(3, 200))
						sim->part_change_type(ID(r),x+rx,y+ry,PT_DUST);
					break;
				case PT_DYST:
					if (RNG::Ref().chance(3, 200))
						sim->part_change_type(ID(r),x+rx,y+ry,PT_YEST);
					break;
				case PT_YEST:
					sim->part_change_type(ID(r),x+rx,y+ry,PT_DYST);
					break;
				case PT_PLEX:
					if (RNG::Ref().chance(3, 200))
						sim->part_change_type(ID(r),x+rx,y+ry,PT_GOO);
					break;
				case PT_NITR:
					if (RNG::Ref().chance(3, 200))
						sim->part_change_type(ID(r),x+rx,y+ry,PT_DESL);
					break;
				case PT_PLNT:
					if (RNG::Ref().chance(1, 20))
						sim->create_part(ID(r), x+rx, y+ry, PT_WOOD);
					break;
				case PT_DESL:
				case PT_OIL:
					if (RNG::Ref().chance(3, 200))
						sim->part_change_type(ID(r),x+rx,y+ry,PT_GAS);
					break;
				case PT_COAL:
					if (RNG::Ref().chance(1, 20))
						sim->create_part(ID(r), x+rx, y+ry, PT_WOOD);
					break;
				case PT_BCOL:
					if (RNG::Ref().chance(1, 20))
						sim->create_part(ID(r), x+rx, y+ry, PT_SAWD);
					break;
				case PT_DUST:
					if (RNG::Ref().chance(1, 20))
						sim->part_change_type(ID(r), x+rx, y+ry, PT_FWRK);
					break;
				case PT_FWRK:
					if (RNG::Ref().chance(1, 20))
						parts[ID(r)].ctype = PT_DUST;
					break;
				case PT_ACID:
					if (RNG::Ref().chance(1, 20))
						sim->create_part(ID(r), x+rx, y+ry, PT_ISOZ);
					break;
				case PT_TTAN:
					if (RNG::Ref().chance(1, 20))
					{
						sim->kill_part(i);
						return 1;
					}
					break;
				case PT_EXOT:
					if (RNG::Ref().chance(1, 20))
						parts[ID(r)].life = 1500;
					break;
				case PT_RFRG:
					if (RNG::Ref().chance(1, 2))
						sim->create_part(ID(r), x+rx, y+ry, PT_GAS);
					else
						sim->create_part(ID(r), x+rx, y+ry, PT_CAUS);
					break;
				default:
					break;
				}
			}
	return 0;
}
Esempio n. 25
0
/*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) {
	int r, nnx, rx, ry, np, 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 (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];
				if (!r)
					fe = 1;
				if (r)
					continue;
				if (!r)
				{
					for ( nnx =0 ; nnx<80; nnx++)
					{
						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);
							create_part(-1,x+1,y-1,PT_SPRK);
							create_part(-1,x,y-1,PT_SPRK);
							create_part(-1,x,y+1,PT_SPRK);
							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][nnx] = emptyparticle;
							break;
						}
						else if (portalp[parts[i].tmp][randomness][nnx].type)
						{
							if (portalp[parts[i].tmp][randomness][nnx].type==PT_STKM)
								player[27] = 0;
							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][nnx].type);
							if (np<0) continue;
							parts[np] = portalp[parts[i].tmp][randomness][nnx];
							parts[np].x = x+rx;
							parts[np].y = y+ry;
							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
		if (!parts[i].life) parts[i].life = rand();
		if (!parts[i].ctype) parts[i].life = rand();
		orbitalparts_get(parts[i].life, parts[i].ctype, orbd, orbl);
		for (r = 0; r < 4; r++) {
			if (orbd[r]<254) {
				orbd[r] += 16;
				if (orbd[r]>254) {
					orbd[r] = 0;
					orbl[r] = rand()%255;
				}
				//orbl[r] += 1;
				//orbl[r] = orbl[r]%255;
			} else {
				orbd[r] = 0;
				orbl[r] = rand()%255;
			}
		}
		orbitalparts_set(&parts[i].life, &parts[i].ctype, orbd, orbl);
	} else {
		parts[i].life = 0;
		parts[i].ctype = 0;
	}
	return 0;
}