jacksonmj: Move EMP triggering into SPRK_update 6ae719deb70d

This commit is contained in:
jacob1 2015-12-18 23:17:25 -05:00
parent bb9b35f01d
commit 52a22bc7d6
2 changed files with 10 additions and 26 deletions

View File

@ -43,7 +43,7 @@ Element_EMP::Element_EMP()
HighTemperature = ITH;
HighTemperatureTransition = NT;
Update = &Element_EMP::update;
Update = NULL;
Graphics = &Element_EMP::graphics;
}
@ -71,31 +71,6 @@ public:
}
};
//#TPT-Directive ElementHeader Element_EMP static int update(UPDATE_FUNC_ARGS)
int Element_EMP::update(UPDATE_FUNC_ARGS)
{
if (parts[i].life)
return 0;
for (int rx =- 2; rx <= 2; rx++)
for (int ry = -2; ry <= 2; ry++)
if (x+rx>=0 && y+ry>=0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
int r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((r&0xFF)==PT_SPRK && parts[r>>8].life > 0 && parts[r>>8].life < 4)
{
sim->emp_trigger_count++;
sim->emp_decor += 3;
if (sim->emp_decor > 40)
sim->emp_decor = 40;
parts[i].life = 220;
return 0;
}
}
return 0;
}
//#TPT-Directive ElementHeader Element_EMP static int Trigger(Simulation *sim, int triggerCount)
int Element_EMP::Trigger(Simulation *sim, int triggerCount)
{

View File

@ -239,6 +239,15 @@ int Element_SPRK::update(UPDATE_FUNC_ARGS)
if (receiver==PT_NTCT||receiver==PT_PTCT)
continue;
}
case PT_EMP:
if (!parts[r>>8].life && parts[i].life > 0 && parts[i].life < 4)
{
sim->emp_trigger_count++;
sim->emp_decor += 3;
if (sim->emp_decor > 40)
sim->emp_decor = 40;
parts[r>>8].life = 220;
}
break;
}