Skip to content

Commit

Permalink
jacksonmj: Move EMP triggering into SPRK_update 6ae719d
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob1 committed Dec 19, 2015
1 parent bb9b35f commit 52a22bc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 26 deletions.
27 changes: 1 addition & 26 deletions src/simulation/elements/EMP.cpp
Expand Up @@ -43,7 +43,7 @@ Element_EMP::Element_EMP()
HighTemperature = ITH;
HighTemperatureTransition = NT;

Update = &Element_EMP::update;
Update = NULL;
Graphics = &Element_EMP::graphics;
}

Expand Down Expand Up @@ -71,31 +71,6 @@ class DeltaTempGenerator
}
};

//#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)
{
Expand Down
9 changes: 9 additions & 0 deletions src/simulation/elements/SPRK.cpp
Expand Up @@ -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;
}

Expand Down

0 comments on commit 52a22bc

Please sign in to comment.