mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-07-31 13:40:12 +02:00
fix STKM + fan wall
This commit is contained in:
@@ -18,6 +18,7 @@ extern "C"
|
|||||||
}
|
}
|
||||||
|
|
||||||
GameSave::GameSave(GameSave & save):
|
GameSave::GameSave(GameSave & save):
|
||||||
|
majorVersion(save.majorVersion),
|
||||||
waterEEnabled(save.waterEEnabled),
|
waterEEnabled(save.waterEEnabled),
|
||||||
legacyEnable(save.legacyEnable),
|
legacyEnable(save.legacyEnable),
|
||||||
gravityEnable(save.gravityEnable),
|
gravityEnable(save.gravityEnable),
|
||||||
@@ -162,6 +163,7 @@ void GameSave::InitData()
|
|||||||
// Called on every new GameSave, except the copy constructor
|
// Called on every new GameSave, except the copy constructor
|
||||||
void GameSave::InitVars()
|
void GameSave::InitVars()
|
||||||
{
|
{
|
||||||
|
majorVersion = 0;
|
||||||
waterEEnabled = false;
|
waterEEnabled = false;
|
||||||
legacyEnable = false;
|
legacyEnable = false;
|
||||||
gravityEnable = false;
|
gravityEnable = false;
|
||||||
@@ -567,6 +569,7 @@ void GameSave::readOPS(char * data, int dataLength)
|
|||||||
unsigned partsCount = 0;
|
unsigned partsCount = 0;
|
||||||
unsigned int blockX, blockY, blockW, blockH, fullX, fullY, fullW, fullH;
|
unsigned int blockX, blockY, blockW, blockH, fullX, fullY, fullW, fullH;
|
||||||
int savedVersion = inputData[4];
|
int savedVersion = inputData[4];
|
||||||
|
majorVersion = savedVersion;
|
||||||
bool fakeNewerVersion = false; // used for development builds only
|
bool fakeNewerVersion = false; // used for development builds only
|
||||||
|
|
||||||
bson b;
|
bson b;
|
||||||
@@ -1149,12 +1152,6 @@ void GameSave::readOPS(char * data, int dataLength)
|
|||||||
if (savedVersion < 91)
|
if (savedVersion < 91)
|
||||||
particles[newIndex].temp = 283.15;
|
particles[newIndex].temp = 283.15;
|
||||||
break;
|
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:
|
case PT_FILT:
|
||||||
if (savedVersion < 89)
|
if (savedVersion < 89)
|
||||||
{
|
{
|
||||||
@@ -1322,6 +1319,7 @@ void GameSave::readPSv(char * saveDataChar, int dataLength)
|
|||||||
if (saveData[4]>SAVE_VERSION)
|
if (saveData[4]>SAVE_VERSION)
|
||||||
throw ParseException(ParseException::WrongVersion, "Save from newer version");
|
throw ParseException(ParseException::WrongVersion, "Save from newer version");
|
||||||
ver = saveData[4];
|
ver = saveData[4];
|
||||||
|
majorVersion = saveData[4];
|
||||||
|
|
||||||
if (ver<34)
|
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]));
|
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 (ver < 89)
|
||||||
{
|
{
|
||||||
if (particles[i-1].type == PT_FILT)
|
if (particles[i-1].type == PT_FILT)
|
||||||
|
@@ -43,6 +43,7 @@ public:
|
|||||||
|
|
||||||
int blockWidth, blockHeight;
|
int blockWidth, blockHeight;
|
||||||
bool fromNewerVersion;
|
bool fromNewerVersion;
|
||||||
|
int majorVersion;
|
||||||
bool hasPressure;
|
bool hasPressure;
|
||||||
bool hasAmbientHeat;
|
bool hasAmbientHeat;
|
||||||
|
|
||||||
|
@@ -1505,20 +1505,17 @@ void Renderer::render_parts()
|
|||||||
}
|
}
|
||||||
else if (colour_mode != COLOUR_HEAT)
|
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);
|
||||||
colr = PIXR(0x8080FF);
|
colb = PIXB(0x8080FF);
|
||||||
colg = PIXG(0x8080FF);
|
}
|
||||||
colb = PIXB(0x8080FF);
|
else if (cplayer->elem < PT_NUM && cplayer->elem > 0)
|
||||||
}
|
{
|
||||||
else
|
colr = PIXR(elements[cplayer->elem].Colour);
|
||||||
{
|
colg = PIXG(elements[cplayer->elem].Colour);
|
||||||
colr = PIXR(elements[cplayer->elem].Colour);
|
colb = PIXB(elements[cplayer->elem].Colour);
|
||||||
colg = PIXG(elements[cplayer->elem].Colour);
|
|
||||||
colb = PIXB(elements[cplayer->elem].Colour);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@@ -165,12 +165,23 @@ int Simulation::Load(int fullX, int fullY, GameSave * save, bool includePressure
|
|||||||
player.spwn = 1;
|
player.spwn = 1;
|
||||||
player.elem = PT_DUST;
|
player.elem = PT_DUST;
|
||||||
player.rocketBoots = false;
|
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;
|
break;
|
||||||
case PT_STKM2:
|
case PT_STKM2:
|
||||||
Element_STKM::STKM_init_legs(this, &player2, i);
|
Element_STKM::STKM_init_legs(this, &player2, i);
|
||||||
player2.spwn = 1;
|
player2.spwn = 1;
|
||||||
player2.elem = PT_DUST;
|
player2.elem = PT_DUST;
|
||||||
player2.rocketBoots = false;
|
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;
|
break;
|
||||||
case PT_SPAWN:
|
case PT_SPAWN:
|
||||||
player.spawnID = i;
|
player.spawnID = i;
|
||||||
@@ -2084,9 +2095,11 @@ void Simulation::clear_sim(void)
|
|||||||
player.spwn = 0;
|
player.spwn = 0;
|
||||||
player.spawnID = -1;
|
player.spawnID = -1;
|
||||||
player.rocketBoots = false;
|
player.rocketBoots = false;
|
||||||
|
player.fan = false;
|
||||||
player2.spwn = 0;
|
player2.spwn = 0;
|
||||||
player2.spawnID = -1;
|
player2.spawnID = -1;
|
||||||
player2.rocketBoots = false;
|
player2.rocketBoots = false;
|
||||||
|
player2.fan = false;
|
||||||
//memset(pers_bg, 0, WINDOWW*YRES*PIXELSIZE);
|
//memset(pers_bg, 0, WINDOWW*YRES*PIXELSIZE);
|
||||||
//memset(fire_r, 0, sizeof(fire_r));
|
//memset(fire_r, 0, sizeof(fire_r));
|
||||||
//memset(fire_g, 0, sizeof(fire_g));
|
//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)
|
if (t>=0 && t<PT_NUM && !elements[t].Enabled)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (t == SPC_AIR)
|
if (t==PT_SPRK)
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
int type = TYP(pmap[y][x]);
|
int type = TYP(pmap[y][x]);
|
||||||
int index = ID(pmap[y][x]);
|
int index = ID(pmap[y][x]);
|
||||||
|
@@ -12,6 +12,7 @@ struct playerst
|
|||||||
char spwn; //if stick man was spawned
|
char spwn; //if stick man was spawned
|
||||||
unsigned int frames; //frames since last particle spawn - used when spawning LIGH
|
unsigned int frames; //frames since last particle spawn - used when spawning LIGH
|
||||||
bool rocketBoots;
|
bool rocketBoots;
|
||||||
|
bool fan;
|
||||||
int spawnID; //id of the SPWN particle that spawns it
|
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 rocketBootsHeadEffectV = 0.3f;// stronger acceleration vertically, to counteract gravity
|
||||||
float rocketBootsFeetEffectV = 0.45f;
|
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);
|
STKM_set_element(sim, playerp, parts[i].ctype);
|
||||||
playerp->frames++;
|
playerp->frames++;
|
||||||
|
|
||||||
@@ -89,7 +89,7 @@ int Element_STKM::run_stickman(playerst *playerp, UPDATE_FUNC_ARGS) {
|
|||||||
parts[i].temp += 1;
|
parts[i].temp += 1;
|
||||||
|
|
||||||
//Death
|
//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++)
|
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));
|
sim->kill_part(ID(r));
|
||||||
}
|
}
|
||||||
if (sim->bmap[(ry+y)/CELL][(rx+x)/CELL]==WL_FAN)
|
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)
|
else if (sim->bmap[(ry+y)/CELL][(rx+x)/CELL]==WL_EHOLE)
|
||||||
playerp->rocketBoots = false;
|
playerp->rocketBoots = false;
|
||||||
else if (sim->bmap[(ry+y)/CELL][(rx+x)/CELL]==WL_GRAV /* && parts[i].type!=PT_FIGH */)
|
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
|
else
|
||||||
{
|
{
|
||||||
int np = -1;
|
int np = -1;
|
||||||
if (playerp->elem == SPC_AIR)
|
if (playerp->fan)
|
||||||
{
|
{
|
||||||
for(int j = -4; j < 5; j++)
|
for(int j = -4; j < 5; j++)
|
||||||
for (int k = -4; k < 5; k++)
|
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
|
else if (playerp->elem==PT_LIGH && playerp->frames<30)//limit lightning creation rate
|
||||||
np = -1;
|
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].temp=parts[np].life*power/2.5;
|
||||||
parts[np].tmp2=1;
|
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].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));
|
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->comm = 0;
|
||||||
playerp->pcomm = 0;
|
playerp->pcomm = 0;
|
||||||
playerp->frames = 0;
|
playerp->frames = 0;
|
||||||
|
playerp->fan = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//#TPT-Directive ElementHeader Element_STKM static void STKM_set_element(Simulation *sim, playerst *playerp, int element)
|
//#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_GAS
|
||||||
|| sim->elements[element].Properties&TYPE_LIQUID
|
|| sim->elements[element].Properties&TYPE_LIQUID
|
||||||
|| sim->elements[element].Properties&TYPE_ENERGY
|
|| 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)
|
if (!playerp->rocketBoots || element != PT_PLSM)
|
||||||
|
{
|
||||||
playerp->elem = element;
|
playerp->elem = element;
|
||||||
|
playerp->fan = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (element == PT_TESC || element == PT_LIGH)
|
if (element == PT_TESC || element == PT_LIGH)
|
||||||
|
{
|
||||||
playerp->elem = PT_LIGH;
|
playerp->elem = PT_LIGH;
|
||||||
|
playerp->fan = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user