From eeff570f89ff5519df26dc4c85739a49f7b9d1a0 Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Wed, 18 Apr 2012 14:57:29 +0100 Subject: [PATCH] TPT: Fixed the bug with fighters running away from stick mans, but now boundary check is worser so fighters won't usually notice holes on their way 2b4d0442b5 --- src/elements/figh.cpp | 46 ++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/src/elements/figh.cpp b/src/elements/figh.cpp index 35b5a20b0..6a8bb4e6a 100644 --- a/src/elements/figh.cpp +++ b/src/elements/figh.cpp @@ -4,41 +4,41 @@ int update_FIGH(UPDATE_FUNC_ARGS) { playerst* figh = &sim->fighters[(unsigned char)parts[i].tmp]; - float tarx, tary; + unsigned int tarx, tary; parts[i].tmp2 = 0; //0 - stay in place, 1 - seek a stick man //Set target cords - if (sim->player.spwn) + if (sim->player.spwn && sim->player2.spwn) { - if (sim->player2.spwn) if ((pow(sim->player.legs[2]-x, 2) + pow(sim->player.legs[3]-y, 2))<= (pow(sim->player2.legs[2]-x, 2) + pow(sim->player2.legs[3]-y, 2))) { - tarx = sim->player.legs[2]; - tary = sim->player.legs[3]; + tarx = (unsigned int)sim->player.legs[2]; + tary = (unsigned int)sim->player.legs[3]; } else { - tarx = sim->player2.legs[2]; - tary = sim->player2.legs[3]; + tarx = (unsigned int)sim->player2.legs[2]; + tary = (unsigned int)sim->player2.legs[3]; } - else - { - tarx = sim->player.legs[2]; - tary = sim->player.legs[3]; - } - - parts[i].tmp2 = 1; + parts[i].tmp2 = 1; } else - if (sim->player2.spwn) + { + if (sim->player.spwn) { - tarx = sim->player2.legs[2]; - tary = sim->player2.legs[3]; - + tarx = (unsigned int)sim->player.legs[2]; + tary = (unsigned int)sim->player.legs[3]; parts[i].tmp2 = 1; } + if (sim->player2.spwn) + { + tarx = (unsigned int)sim->player2.legs[2]; + tary = (unsigned int)sim->player2.legs[3]; + parts[i].tmp2 = 1; + } + } switch (parts[i].tmp2) { @@ -46,14 +46,15 @@ int update_FIGH(UPDATE_FUNC_ARGS) if ((pow(tarx-x, 2) + pow(tary-y, 2))<600) { if (figh->elem == PT_LIGH || figh->elem == PT_NEUT - || (sim->ptypes[figh->elem].properties&(PROP_DEADLY|PROP_RADIOACTIVE)) + || sim->ptypes[figh->elem].properties&(PROP_DEADLY|PROP_RADIOACTIVE) || sim->ptypes[figh->elem].heat>=323 || sim->ptypes[figh->elem].heat<=243) figh->comm = (int)figh->comm | 0x08; } else - if (tarxeval_move(PT_DUST, figh->legs[4]-10, figh->legs[5]+6, NULL)) + 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))) figh->comm = 0x01; else figh->comm = 0x02; @@ -65,7 +66,8 @@ int update_FIGH(UPDATE_FUNC_ARGS) } else { - if (!sim->eval_move(PT_DUST, figh->legs[12]+10, figh->legs[13]+6, NULL)) + 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))) figh->comm = 0x02; else figh->comm = 0x01;