1
0
mirror of https://github.com/The-Powder-Toy/The-Powder-Toy.git synced 2025-03-20 14:20:02 +01:00

fix STKM + fan wall

This commit is contained in:
jacob1 2018-03-21 23:58:27 -04:00
parent 126acb7db5
commit 3bd35ce83f
6 changed files with 56 additions and 43 deletions

@ -18,6 +18,7 @@ extern "C"
}
GameSave::GameSave(GameSave & save):
majorVersion(save.majorVersion),
waterEEnabled(save.waterEEnabled),
legacyEnable(save.legacyEnable),
gravityEnable(save.gravityEnable),
@ -162,6 +163,7 @@ void GameSave::InitData()
// Called on every new GameSave, except the copy constructor
void GameSave::InitVars()
{
majorVersion = 0;
waterEEnabled = false;
legacyEnable = false;
gravityEnable = false;
@ -567,6 +569,7 @@ void GameSave::readOPS(char * data, int dataLength)
unsigned partsCount = 0;
unsigned int blockX, blockY, blockW, blockH, fullX, fullY, fullW, fullH;
int savedVersion = inputData[4];
majorVersion = savedVersion;
bool fakeNewerVersion = false; // used for development builds only
bson b;
@ -1149,12 +1152,6 @@ void GameSave::readOPS(char * data, int dataLength)
if (savedVersion < 91)
particles[newIndex].temp = 283.15;
break;
case PT_STKM:
case PT_STKM2:
case PT_FIGH:
if (savedVersion < 88 && particles[newIndex].ctype == OLD_SPC_AIR)
particles[newIndex].ctype = SPC_AIR;
break;
case PT_FILT:
if (savedVersion < 89)
{
@ -1322,6 +1319,7 @@ void GameSave::readPSv(char * saveDataChar, int dataLength)
if (saveData[4]>SAVE_VERSION)
throw ParseException(ParseException::WrongVersion, "Save from newer version");
ver = saveData[4];
majorVersion = saveData[4];
if (ver<34)
{
@ -1857,9 +1855,6 @@ void GameSave::readPSv(char * saveDataChar, int dataLength)
particles[i-1].ctype = (((firw_data[caddress]))<<16) | (((firw_data[caddress+1]))<<8) | ((firw_data[caddress+2]));
}
}
if (ver < 88) //fix air blowing stickmen
if ((particles[i-1].type == PT_STKM || particles[i-1].type == PT_STKM2 || particles[i-1].type == PT_FIGH) && particles[i-1].ctype == OLD_SPC_AIR)
particles[i-1].ctype = SPC_AIR;
if (ver < 89)
{
if (particles[i-1].type == PT_FILT)

@ -43,6 +43,7 @@ public:
int blockWidth, blockHeight;
bool fromNewerVersion;
int majorVersion;
bool hasPressure;
bool hasAmbientHeat;

@ -1505,20 +1505,17 @@ void Renderer::render_parts()
}
else if (colour_mode != COLOUR_HEAT)
{
if (cplayer->elem<PT_NUM && cplayer->elem > 0)
if (cplayer->fan)
{
if (cplayer->elem == SPC_AIR)
{
colr = PIXR(0x8080FF);
colg = PIXG(0x8080FF);
colb = PIXB(0x8080FF);
}
else
{
colr = PIXR(elements[cplayer->elem].Colour);
colg = PIXG(elements[cplayer->elem].Colour);
colb = PIXB(elements[cplayer->elem].Colour);
}
colr = PIXR(0x8080FF);
colg = PIXG(0x8080FF);
colb = PIXB(0x8080FF);
}
else if (cplayer->elem < PT_NUM && cplayer->elem > 0)
{
colr = PIXR(elements[cplayer->elem].Colour);
colg = PIXG(elements[cplayer->elem].Colour);
colb = PIXB(elements[cplayer->elem].Colour);
}
else
{

@ -165,12 +165,23 @@ int Simulation::Load(int fullX, int fullY, GameSave * save, bool includePressure
player.spwn = 1;
player.elem = PT_DUST;
player.rocketBoots = false;
if ((save->majorVersion < 93 && parts[i].ctype == SPC_AIR) ||
(save->majorVersion < 88 && parts[i].ctype == OLD_SPC_AIR))
{
player.fan = true;
}
break;
case PT_STKM2:
Element_STKM::STKM_init_legs(this, &player2, i);
player2.spwn = 1;
player2.elem = PT_DUST;
player2.rocketBoots = false;
if ((save->majorVersion < 93 && parts[i].ctype == SPC_AIR) ||
(save->majorVersion < 88 && parts[i].ctype == OLD_SPC_AIR))
{
player2.fan = true;
}
break;
case PT_SPAWN:
player.spawnID = i;
@ -2084,9 +2095,11 @@ void Simulation::clear_sim(void)
player.spwn = 0;
player.spawnID = -1;
player.rocketBoots = false;
player.fan = false;
player2.spwn = 0;
player2.spawnID = -1;
player2.rocketBoots = false;
player2.fan = false;
//memset(pers_bg, 0, WINDOWW*YRES*PIXELSIZE);
//memset(fire_r, 0, sizeof(fire_r));
//memset(fire_g, 0, sizeof(fire_g));
@ -3014,20 +3027,7 @@ int Simulation::create_part(int p, int x, int y, int t, int v)
if (t>=0 && t<PT_NUM && !elements[t].Enabled)
return -1;
if (t == SPC_AIR)
{
pv[y/CELL][x/CELL] += 0.03f;
if (y+CELL<YRES)
pv[y/CELL+1][x/CELL] += 0.03f;
if (x+CELL<XRES)
{
pv[y/CELL][x/CELL+1] += 0.03f;
if (y+CELL<YRES)
pv[y/CELL+1][x/CELL+1] += 0.03f;
}
return -1;
}
else if (t==PT_SPRK)
if (t==PT_SPRK)
{
int type = TYP(pmap[y][x]);
int index = ID(pmap[y][x]);

@ -12,6 +12,7 @@ struct playerst
char spwn; //if stick man was spawned
unsigned int frames; //frames since last particle spawn - used when spawning LIGH
bool rocketBoots;
bool fan;
int spawnID; //id of the SPWN particle that spawns it
};

@ -78,7 +78,7 @@ int Element_STKM::run_stickman(playerst *playerp, UPDATE_FUNC_ARGS) {
float rocketBootsHeadEffectV = 0.3f;// stronger acceleration vertically, to counteract gravity
float rocketBootsFeetEffectV = 0.45f;
if (parts[i].ctype && sim->IsValidElement(parts[i].ctype))
if (!playerp->fan && parts[i].ctype && sim->IsValidElement(parts[i].ctype))
STKM_set_element(sim, playerp, parts[i].ctype);
playerp->frames++;
@ -89,7 +89,7 @@ int Element_STKM::run_stickman(playerst *playerp, UPDATE_FUNC_ARGS) {
parts[i].temp += 1;
//Death
if (parts[i].life<1 || (sim->pv[y/CELL][x/CELL]>=4.5f && playerp->elem != SPC_AIR) ) //If his HP is less than 0 or there is very big wind...
if (parts[i].life<1 || (sim->pv[y/CELL][x/CELL]>=4.5f && !playerp->fan) ) //If his HP is less than 0 or there is very big wind...
{
for (r=-2; r<=1; r++)
{
@ -385,7 +385,7 @@ int Element_STKM::run_stickman(playerst *playerp, UPDATE_FUNC_ARGS) {
sim->kill_part(ID(r));
}
if (sim->bmap[(ry+y)/CELL][(rx+x)/CELL]==WL_FAN)
playerp->elem = SPC_AIR;
playerp->fan = true;
else if (sim->bmap[(ry+y)/CELL][(rx+x)/CELL]==WL_EHOLE)
playerp->rocketBoots = false;
else if (sim->bmap[(ry+y)/CELL][(rx+x)/CELL]==WL_GRAV /* && parts[i].type!=PT_FIGH */)
@ -413,11 +413,23 @@ int Element_STKM::run_stickman(playerst *playerp, UPDATE_FUNC_ARGS) {
else
{
int np = -1;
if (playerp->elem == SPC_AIR)
if (playerp->fan)
{
for(int j = -4; j < 5; j++)
for (int k = -4; k < 5; k++)
sim->create_part(-2, rx + 3*((((int)playerp->pcomm)&0x02) == 0x02) - 3*((((int)playerp->pcomm)&0x01) == 0x01)+j, ry+k, SPC_AIR);
{
int airx = rx + 3*((((int)playerp->pcomm)&0x02) == 0x02) - 3*((((int)playerp->pcomm)&0x01) == 0x01)+j;
int airy = ry+k;
sim->pv[airy/CELL][airx/CELL] += 0.03f;
if (airy + CELL < YRES)
sim->pv[airy/CELL+1][airx/CELL] += 0.03f;
if (airx + CELL < XRES)
{
sim->pv[airy/CELL][airx/CELL+1] += 0.03f;
if (airy + CELL < YRES)
sim->pv[airy/CELL+1][airx/CELL+1] += 0.03f;
}
}
}
else if (playerp->elem==PT_LIGH && playerp->frames<30)//limit lightning creation rate
np = -1;
@ -460,7 +472,7 @@ int Element_STKM::run_stickman(playerst *playerp, UPDATE_FUNC_ARGS) {
parts[np].temp=parts[np].life*power/2.5;
parts[np].tmp2=1;
}
else if (playerp->elem != SPC_AIR)
else if (!playerp->fan)
{
parts[np].vx -= -gvy*(5*((((int)playerp->pcomm)&0x02) == 0x02) - 5*(((int)(playerp->pcomm)&0x01) == 0x01));
parts[np].vy -= gvx*(5*((((int)playerp->pcomm)&0x02) == 0x02) - 5*(((int)(playerp->pcomm)&0x01) == 0x01));
@ -669,6 +681,7 @@ void Element_STKM::STKM_init_legs(Simulation * sim, playerst *playerp, int i)
playerp->comm = 0;
playerp->pcomm = 0;
playerp->frames = 0;
playerp->fan = false;
}
//#TPT-Directive ElementHeader Element_STKM static void STKM_set_element(Simulation *sim, playerst *playerp, int element)
@ -678,13 +691,19 @@ void Element_STKM::STKM_set_element(Simulation *sim, playerst *playerp, int elem
|| 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)
|| element == PT_LOLZ || element == PT_LOVE)
{
if (!playerp->rocketBoots || element != PT_PLSM)
{
playerp->elem = element;
playerp->fan = false;
}
}
if (element == PT_TESC || element == PT_LIGH)
{
playerp->elem = PT_LIGH;
playerp->fan = false;
}
}