2012-01-19 07:44:59 -06:00
|
|
|
#include "simulation/Element.h"
|
2012-01-08 11:39:03 -06:00
|
|
|
|
|
|
|
int update_FIGH(UPDATE_FUNC_ARGS)
|
|
|
|
{
|
|
|
|
playerst* figh = &sim->fighters[(unsigned char)parts[i].tmp];
|
|
|
|
|
2012-04-18 08:57:29 -05:00
|
|
|
unsigned int tarx, tary;
|
2012-01-08 11:39:03 -06:00
|
|
|
|
|
|
|
parts[i].tmp2 = 0; //0 - stay in place, 1 - seek a stick man
|
|
|
|
|
|
|
|
//Set target cords
|
2012-04-18 08:57:29 -05:00
|
|
|
if (sim->player.spwn && sim->player2.spwn)
|
2012-01-08 11:39:03 -06:00
|
|
|
{
|
2012-04-26 07:10:47 -05:00
|
|
|
if ((pow((float)sim->player.legs[2]-x, 2) + pow((float)sim->player.legs[3]-y, 2))<=
|
|
|
|
(pow((float)sim->player2.legs[2]-x, 2) + pow((float)sim->player2.legs[3]-y, 2)))
|
2012-01-08 11:39:03 -06:00
|
|
|
{
|
2012-04-18 08:57:29 -05:00
|
|
|
tarx = (unsigned int)sim->player.legs[2];
|
|
|
|
tary = (unsigned int)sim->player.legs[3];
|
2012-01-08 11:39:03 -06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-04-18 08:57:29 -05:00
|
|
|
tarx = (unsigned int)sim->player2.legs[2];
|
|
|
|
tary = (unsigned int)sim->player2.legs[3];
|
2012-01-08 11:39:03 -06:00
|
|
|
}
|
2012-04-18 08:57:29 -05:00
|
|
|
parts[i].tmp2 = 1;
|
2012-01-08 11:39:03 -06:00
|
|
|
}
|
|
|
|
else
|
2012-04-18 08:57:29 -05:00
|
|
|
{
|
|
|
|
if (sim->player.spwn)
|
|
|
|
{
|
|
|
|
tarx = (unsigned int)sim->player.legs[2];
|
|
|
|
tary = (unsigned int)sim->player.legs[3];
|
|
|
|
parts[i].tmp2 = 1;
|
|
|
|
}
|
2012-01-08 11:39:03 -06:00
|
|
|
if (sim->player2.spwn)
|
|
|
|
{
|
2012-04-18 08:57:29 -05:00
|
|
|
tarx = (unsigned int)sim->player2.legs[2];
|
|
|
|
tary = (unsigned int)sim->player2.legs[3];
|
2012-01-08 11:39:03 -06:00
|
|
|
parts[i].tmp2 = 1;
|
|
|
|
}
|
2012-04-18 08:57:29 -05:00
|
|
|
}
|
2012-01-08 11:39:03 -06:00
|
|
|
|
|
|
|
switch (parts[i].tmp2)
|
|
|
|
{
|
|
|
|
case 1:
|
2012-04-26 07:10:47 -05:00
|
|
|
if ((pow(float(tarx-x), 2) + pow(float(tary-y), 2))<600)
|
2012-01-08 11:39:03 -06:00
|
|
|
{
|
|
|
|
if (figh->elem == PT_LIGH || figh->elem == PT_NEUT
|
2012-04-18 08:57:29 -05:00
|
|
|
|| sim->ptypes[figh->elem].properties&(PROP_DEADLY|PROP_RADIOACTIVE)
|
2012-01-08 11:39:03 -06:00
|
|
|
|| sim->ptypes[figh->elem].heat>=323 || sim->ptypes[figh->elem].heat<=243)
|
|
|
|
figh->comm = (int)figh->comm | 0x08;
|
|
|
|
}
|
|
|
|
else
|
2012-04-18 08:57:29 -05:00
|
|
|
if (tarx<x)
|
2012-01-08 11:39:03 -06:00
|
|
|
{
|
2012-04-18 08:57:29 -05:00
|
|
|
if(!(sim->eval_move(PT_DUST, figh->legs[4]-10, figh->legs[5]+6, NULL)
|
|
|
|
&& sim->eval_move(PT_DUST, figh->legs[4]-10, figh->legs[5]+3, NULL)))
|
2012-01-08 11:39:03 -06:00
|
|
|
figh->comm = 0x01;
|
|
|
|
else
|
|
|
|
figh->comm = 0x02;
|
|
|
|
|
|
|
|
if (!sim->eval_move(PT_DUST, figh->legs[4]-4, figh->legs[5]-1, NULL)
|
|
|
|
|| !sim->eval_move(PT_DUST, figh->legs[12]-4, figh->legs[13]-1, NULL)
|
|
|
|
|| sim->eval_move(PT_DUST, 2*figh->legs[4]-figh->legs[6], figh->legs[5]+5, NULL))
|
|
|
|
figh->comm = (int)figh->comm | 0x04;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-04-18 08:57:29 -05:00
|
|
|
if (!(sim->eval_move(PT_DUST, figh->legs[12]+10, figh->legs[13]+6, NULL)
|
|
|
|
&& sim->eval_move(PT_DUST, figh->legs[12]+10, figh->legs[13]+3, NULL)))
|
2012-01-08 11:39:03 -06:00
|
|
|
figh->comm = 0x02;
|
|
|
|
else
|
|
|
|
figh->comm = 0x01;
|
|
|
|
|
|
|
|
if (!sim->eval_move(PT_DUST, figh->legs[4]+4, figh->legs[5]-1, NULL)
|
|
|
|
|| !sim->eval_move(PT_DUST, figh->legs[4]+4, figh->legs[5]-1, NULL)
|
|
|
|
|| sim->eval_move(PT_DUST, 2*figh->legs[12]-figh->legs[14], figh->legs[13]+5, NULL))
|
|
|
|
figh->comm = (int)figh->comm | 0x04;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
figh->comm = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
figh->pcomm = figh->comm;
|
|
|
|
|
|
|
|
run_stickman(figh, UPDATE_FUNC_SUBCALL_ARGS);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int graphics_FIGH(GRAPHICS_FUNC_ARGS)
|
|
|
|
{
|
|
|
|
playerst * cplayer;// = &sim->fighters[(unsigned char)cpart->tmp];
|
|
|
|
*pixel_mode = PSPEC_STICKMAN;
|
|
|
|
/*if (cplayer->elem<PT_NUM)
|
|
|
|
{
|
|
|
|
*colr = PIXR(sim->ptypes[cplayer->elem].pcolors);
|
|
|
|
*colg = PIXG(sim->ptypes[cplayer->elem].pcolors);
|
|
|
|
*colb = PIXB(sim->ptypes[cplayer->elem].pcolors);
|
|
|
|
}
|
|
|
|
else*/
|
|
|
|
{
|
|
|
|
*colr = *colg = *colb = 255;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|