From 139bdd7f4d464bb26fc2a4c0999e2330ff6eafc7 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Fri, 18 Dec 2015 20:02:49 -0500 Subject: [PATCH] fix STKM being unable to pick up most energy particles, or LOLZ/LOVE --- src/gui/game/GameController.cpp | 6 ++--- src/simulation/elements/STKM.cpp | 42 ++++++++++++++++++-------------- 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/src/gui/game/GameController.cpp b/src/gui/game/GameController.cpp index f4e4e13cb..1cf5b00a0 100644 --- a/src/gui/game/GameController.cpp +++ b/src/gui/game/GameController.cpp @@ -892,14 +892,14 @@ void GameController::Update() if (activeTool->GetIdentifier().find("DEFAULT_PT_") != activeTool->GetIdentifier().npos) { int sr = activeTool->GetToolID(); - if ((sr>0 && srelements[sr].Enabled && sim->elements[sr].Falldown>0) || sr==SPC_AIR || sr == PT_NEUT || sr == PT_PHOT || sr == PT_LIGH) + if (sr && sim->IsValidElement(sr)) rightSelected = sr; } if (!sim->player.spwn) - sim->player.elem = rightSelected; + Element_STKM::STKM_set_element(sim, &sim->player, rightSelected); if (!sim->player2.spwn) - sim->player2.elem = rightSelected; + Element_STKM::STKM_set_element(sim, &sim->player2, rightSelected); } if(renderOptions && renderOptions->HasExited) { diff --git a/src/simulation/elements/STKM.cpp b/src/simulation/elements/STKM.cpp index 33100645c..eed884c71 100644 --- a/src/simulation/elements/STKM.cpp +++ b/src/simulation/elements/STKM.cpp @@ -65,8 +65,8 @@ int Element_STKM::graphics(GRAPHICS_FUNC_ARGS) #define INBOND(x, y) ((x)>=0 && (y)>=0 && (x)0 && parts[i].ctypeelements[parts[i].ctype].Enabled && sim->elements[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; + STKM_set_element(sim, playerp, parts[i].ctype); playerp->frames++; //Temperature handling @@ -365,16 +364,7 @@ int Element_STKM::run_stickman(playerst* playerp, UPDATE_FUNC_ARGS) { if (!r && !sim->bmap[(y+ry)/CELL][(x+rx)/CELL]) continue; - if (sim->elements[r&0xFF].Falldown != 0 - || sim->elements[r&0xFF].Properties&TYPE_GAS - || sim->elements[r&0xFF].Properties&TYPE_LIQUID - || (r&0xFF) == PT_NEUT || (r&0xFF) == PT_PHOT) - { - if (!playerp->rocketBoots || (r&0xFF)!=PT_PLSM) - playerp->elem = r&0xFF; //Current element - } - if ((r&0xFF)==PT_TESC || (r&0xFF)==PT_LIGH) - playerp->elem = PT_LIGH; + STKM_set_element(sim, playerp, r&0xFF); if ((r&0xFF) == PT_PLNT && parts[i].life<100) //Plant gives him 5 HP { if (parts[i].life<=95) @@ -575,8 +565,8 @@ int Element_STKM::run_stickman(playerst* playerp, UPDATE_FUNC_ARGS) { return 0; } -//#TPT-Directive ElementHeader Element_STKM static void STKM_interact(Simulation * sim, playerst* playerp, int i, int x, int y) -void Element_STKM::STKM_interact(Simulation * sim, playerst* playerp, int i, int x, int y) +//#TPT-Directive ElementHeader Element_STKM static void STKM_interact(Simulation *sim, playerst *playerp, int i, int x, int y) +void Element_STKM::STKM_interact(Simulation *sim, playerst *playerp, int i, int x, int y) { int r; if (x<0 || y<0 || x>=XRES || y>=YRES || !sim->parts[i].type) @@ -642,8 +632,8 @@ void Element_STKM::STKM_interact(Simulation * sim, playerst* playerp, int i, int } } -//#TPT-Directive ElementHeader Element_STKM static void STKM_init_legs(Simulation * sim, playerst* playerp, int i) -void Element_STKM::STKM_init_legs(Simulation * sim, playerst* playerp, int i) +//#TPT-Directive ElementHeader Element_STKM static void STKM_init_legs(Simulation * sim, playerst *playerp, int i) +void Element_STKM::STKM_init_legs(Simulation * sim, playerst *playerp, int i) { int x, y; @@ -677,5 +667,21 @@ void Element_STKM::STKM_init_legs(Simulation * sim, playerst* playerp, int i) playerp->frames = 0; } +//#TPT-Directive ElementHeader Element_STKM static void STKM_set_element(Simulation *sim, playerst *playerp, int element) +void Element_STKM::STKM_set_element(Simulation *sim, playerst *playerp, int element) +{ + if (sim->elements[element].Falldown != 0 + || sim->elements[element].Properties&TYPE_GAS + || sim->elements[element].Properties&TYPE_LIQUID + || sim->elements[element].Properties&TYPE_ENERGY + || element == PT_LOLZ || element == PT_LOVE || element == SPC_AIR) + { + if (!playerp->rocketBoots || element != PT_PLSM) + playerp->elem = element; + } + if (element == PT_TESC || element == PT_LIGH) + playerp->elem = PT_LIGH; +} + Element_STKM::~Element_STKM() {}