From 80a77f47501336f5d690965a6e8f79f2ef231943 Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Tue, 17 Apr 2012 18:42:36 +0100 Subject: [PATCH] TPT: Added FRAY - Force-ray and RPEL - Repeller f6696282e1 --- src/elements/fray.cpp | 29 +++++++++++++++++++++++++++++ src/elements/repl.cpp | 22 ++++++++++++++++++++++ src/simulation/ElementFunctions.h | 2 ++ src/simulation/Elements.h | 4 +++- src/simulation/SimulationData.cpp | 9 +++++++-- src/simulation/SimulationData.h | 27 ++++++++++++++------------- 6 files changed, 77 insertions(+), 16 deletions(-) create mode 100644 src/elements/fray.cpp create mode 100644 src/elements/repl.cpp diff --git a/src/elements/fray.cpp b/src/elements/fray.cpp new file mode 100644 index 000000000..eaf82a01f --- /dev/null +++ b/src/elements/fray.cpp @@ -0,0 +1,29 @@ +#include "simulation/Element.h" + +int update_FRAY(UPDATE_FUNC_ARGS) { + int r, nxx, nyy, docontinue, len, nxi, nyi, rx, ry, nr, ry1, rx1; + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rx= 0 && y+nyi+nyy >= 0) || len>10) { + break; + } + r = pmap[y+nyi+nyy][x+nxi+nxx]; + if (!r) + r = sim->photons[y+nyi+nyy][x+nxi+nxx]; + + if (r && !(sim->ptypes[r&0xFF].properties & TYPE_SOLID)){ + parts[r>>8].vx += nxi*((parts[i].temp-273.15)/10.0f); + parts[r>>8].vy += nyi*((parts[i].temp-273.15)/10.0f); + } + } + } + } + return 0; +} diff --git a/src/elements/repl.cpp b/src/elements/repl.cpp new file mode 100644 index 000000000..e9cb1e6fc --- /dev/null +++ b/src/elements/repl.cpp @@ -0,0 +1,22 @@ +#include "simulation\Element.h" + +int update_REPL(UPDATE_FUNC_ARGS) { + int r, rx, ry, ri; + for(ri = 0; ri <= 10; ri++) + { + rx = (rand()%20)-10; + ry = (rand()%20)-10; + if (x+rx>=0 && y+ry>0 && x+rxphotons[y+ry][x+rx]; + + if (r && !(sim->ptypes[r&0xFF].properties & TYPE_SOLID)){ + parts[r>>8].vx += isign(rx)*((parts[i].temp-273.15)/10.0f); + parts[r>>8].vy += isign(ry)*((parts[i].temp-273.15)/10.0f); + } + } + } + return 0; +} diff --git a/src/simulation/ElementFunctions.h b/src/simulation/ElementFunctions.h index ef80b6f13..be3f9f4ea 100644 --- a/src/simulation/ElementFunctions.h +++ b/src/simulation/ElementFunctions.h @@ -105,6 +105,8 @@ int update_DCEL(UPDATE_FUNC_ARGS); int update_BANG(UPDATE_FUNC_ARGS); int update_IGNT(UPDATE_FUNC_ARGS); int update_MISC(UPDATE_FUNC_ARGS); +int update_FRAY(UPDATE_FUNC_ARGS); +int update_REPL(UPDATE_FUNC_ARGS); int update_legacy_PYRO(UPDATE_FUNC_ARGS); int update_legacy_all(UPDATE_FUNC_ARGS); int run_stickman(playerst* playerp, UPDATE_FUNC_ARGS); diff --git a/src/simulation/Elements.h b/src/simulation/Elements.h index 8acafded9..7d59dcb22 100644 --- a/src/simulation/Elements.h +++ b/src/simulation/Elements.h @@ -275,7 +275,9 @@ #define PT_WIRE 156 #define PT_GBMB 157 #define PT_FIGH 158 -#define PT_NUM 159 +#define PT_FRAY 159 +#define PT_REPL 160 +#define PT_NUM 161 //#endif /* ELEMENTS_H_ */ diff --git a/src/simulation/SimulationData.cpp b/src/simulation/SimulationData.cpp index 2fb10b261..47ce638ab 100644 --- a/src/simulation/SimulationData.cpp +++ b/src/simulation/SimulationData.cpp @@ -158,6 +158,7 @@ menu_section * LoadMenus(int & menuCount) {"\xC1", "Walls", 0, 1}, {"\xC2", "Electronics", 0, 1}, {"\xD6", "Powered Materials", 0, 1}, + {"\xE2", "Force", 0, 1}, {"\xC3", "Explosives", 0, 1}, {"\xC5", "Gasses", 0, 1}, {"\xC4", "Liquids", 0, 1}, @@ -321,8 +322,8 @@ part_type * LoadElements(int & elementCount) {"EMP", PIXPACK(0x66AAFF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.0f, 0.0f * CFDS, 0, 0, 0, 0, 3, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 121, "Breaks activated electronics.", ST_SOLID, TYPE_SOLID|PROP_LIFE_DEC, &update_EMP, &graphics_EMP}, {"BREL", PIXPACK(0x707060), 0.4f, 0.04f * CFDS, 0.94f, 0.95f, -0.1f, 0.18f, 0.00f, 0.000f * CFDS, 1, 0, 0, 2, 2, 1, 1, 90, SC_POWDERS, R_TEMP+0.0f +273.15f, 211, "Broken electronics", ST_SOLID, TYPE_PART|PROP_CONDUCTS|PROP_LIFE_DEC|PROP_HOT_GLOW, NULL, NULL}, {"ELEC", PIXPACK(0xDFEFFF), 0.0f, 0.00f * CFDS, 1.00f, 1.00f, -0.99f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 1, -1, SC_NUCLEAR, R_TEMP+200.0f+273.15f, 251, "Electrons", ST_GAS, TYPE_ENERGY|PROP_LIFE_DEC|PROP_LIFE_KILL_DEC, &update_ELEC, &graphics_ELEC}, - {"ACEL", PIXPACK(0x0099CC), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 1, 100, SC_POWERED, R_TEMP+0.0f +273.15f, 251, "Accelerator", ST_NONE, TYPE_SOLID, &update_ACEL, &graphics_ACEL}, - {"DCEL", PIXPACK(0x99CC00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 1, 100, SC_POWERED, R_TEMP+0.0f +273.15f, 251, "Decelerator", ST_NONE, TYPE_SOLID, &update_DCEL, &graphics_DCEL}, + {"ACEL", PIXPACK(0x0099CC), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 1, 100, SC_FORCE, R_TEMP+0.0f +273.15f, 251, "Accelerator", ST_NONE, TYPE_SOLID, &update_ACEL, &graphics_ACEL}, + {"DCEL", PIXPACK(0x99CC00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 1, 100, SC_FORCE, R_TEMP+0.0f +273.15f, 251, "Decelerator", ST_NONE, TYPE_SOLID, &update_DCEL, &graphics_DCEL}, {"TNT", PIXPACK(0xC05050), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 1, 100, SC_EXPLOSIVE, R_TEMP+0.0f +273.15f, 88, "Explosive.", ST_SOLID, TYPE_SOLID | PROP_NEUTPENETRATE, &update_BANG, NULL}, {"IGNC", PIXPACK(0xC0B050), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 1, 100, SC_EXPLOSIVE, R_TEMP+0.0f +273.15f, 88, "Ignition cord.", ST_SOLID, TYPE_SOLID | PROP_NEUTPENETRATE | PROP_SPARKSETTLE | PROP_LIFE_KILL, &update_IGNT, NULL}, {"BOYL", PIXPACK(0x0A3200), 1.0f, 0.01f * CFDS, 0.99f, 0.30f, -0.1f, 0.0f, 0.18f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 1, 1, SC_GAS, R_TEMP+2.0f +273.15f, 42, "Boyle, variable pressure gas. Expands when heated.", ST_GAS, TYPE_GAS, &update_BOYL, NULL}, @@ -343,6 +344,8 @@ part_type * LoadElements(int & elementCount) {"WIRE", PIXPACK(0xFFCC00), 0.0f, 0.00f * CFDS, 0.00f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 250, "WireWorld wires.",ST_SOLID,TYPE_SOLID,&update_WIRE, &graphics_WIRE}, {"GBMB", PIXPACK(0x1144BB), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 20, 1, 1, 30, SC_EXPLOSIVE, R_TEMP-2.0f +273.15f, 29, "Sticks to first object it touches then produces strong gravity push.", ST_NONE, TYPE_PART|PROP_LIFE_DEC|PROP_LIFE_KILL_DEC, &update_GBMB, &graphics_GBMB}, {"FIGH", PIXPACK(0x000000), 0.5f, 0.00f * CFDS, 0.2f, 1.0f, 0.0f, 0.0f, 0.0f, 0.00f * CFDS, 0, 0, 0, 0, 0, 1, 1, 50, SC_SPECIAL, R_TEMP+14.6f+273.15f, 0, "Fighter. Tries to kill stickmen.", ST_NONE, 0, &update_FIGH, &graphics_FIGH}, + {"FRAY", PIXPACK(0x00BBFF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 1, 100, SC_FORCE, 20.0f+0.0f +273.15f, 0, "Force Emitter. Push or pull objects based on temp value, use like ARAY", ST_SOLID, TYPE_SOLID|PROP_LIFE_DEC, &update_FRAY, NULL}, + {"RPEL", PIXPACK(0x99CC00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 1, 100, SC_FORCE, 20.0f+0.0f +273.15f, 0, "Repel or attract particles based on temp value.", ST_NONE, TYPE_SOLID, &update_REPL, NULL}, //Name Colour Advec Airdrag Airloss Loss Collid Grav Diffus Hotair Fal Burn Exp Mel Hrd M Use Weight Section H Ins Description }; elementCount = PT_NUM; @@ -523,6 +526,8 @@ part_transition * LoadTransitions(int & transitionCount) /* WIRE */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, /* GBMB */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, /* FIGH */ {IPL, NT, IPH, NT, ITL, NT, 620.0f, PT_FIRE}, + /* FRAY */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* REPL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, }; #undef IPL #undef IPH diff --git a/src/simulation/SimulationData.h b/src/simulation/SimulationData.h index 3e35af694..2c1345033 100644 --- a/src/simulation/SimulationData.h +++ b/src/simulation/SimulationData.h @@ -8,19 +8,20 @@ #define SC_WALL 0 #define SC_ELEC 1 #define SC_POWERED 2 -#define SC_EXPLOSIVE 3 -#define SC_GAS 4 -#define SC_LIQUID 5 -#define SC_POWDERS 6 -#define SC_SOLIDS 7 -#define SC_NUCLEAR 8 -#define SC_SPECIAL 9 -#define SC_LIFE 10 -#define SC_TOOL 11 -#define SC_DECO 12 -#define SC_CRACKER 13 -#define SC_CRACKER2 14 -#define SC_TOTAL 13 +#define SC_FORCE 3 +#define SC_EXPLOSIVE 4 +#define SC_GAS 5 +#define SC_LIQUID 6 +#define SC_POWDERS 7 +#define SC_SOLIDS 8 +#define SC_NUCLEAR 9 +#define SC_SPECIAL 10 +#define SC_LIFE 11 +#define SC_TOOL 12 +#define SC_DECO 13 +#define SC_CRACKER 14 +#define SC_CRACKER2 15 +#define SC_TOTAL 14 #define UI_WALLSTART 222 #define UI_ACTUALSTART 122