Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fixed] "on fire" state wasn't copied when changing class (new) #2235

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Entities/Common/Attacks/Hitters.as
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,8 @@ bool isWaterHitter(u8 type)
{
return type == Hitters::water || type == Hitters::water_stun_force || type == Hitters::water_stun;
}

bool isIgniteHitter(u8 type)
{
return type == Hitters::fire;
}
26 changes: 3 additions & 23 deletions Entities/Common/FireScripts/FireCommon.as
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@

#include "Hitters.as"

const string burn_duration = "burn duration";
const string burn_hitter = "burn hitter";

const string burn_timer = "burn timer";

const string burning_tag = "burning";
const string spread_fire_tag = "spread fire";

const string burn_counter = "burn counter";

const int fire_wait_ticks = 4;
Expand All @@ -19,25 +13,22 @@ const int burn_thresh = 70;
*/
void server_setFireOn(CBlob@ this)
{
if (!getNet().isServer())
if (!isServer())
return;

this.Tag(burning_tag);
this.Sync(burning_tag, true);

this.set_s16(burn_timer, this.get_s16(burn_duration) / fire_wait_ticks);
this.Sync(burn_timer, true);

if ((this.getCurrentScript().runFlags & Script::tick_infire) != 0)
this.Tag("had only fire flag");
this.getCurrentScript().runFlags &= ~Script::tick_infire;
}

/**
* Put out this's fire and sync everything important
*/
void server_setFireOff(CBlob@ this)
{
if (!getNet().isServer())
if (!isServer())
return;
this.Untag(burning_tag);
this.Sync(burning_tag, true);
Expand All @@ -47,15 +38,4 @@ void server_setFireOff(CBlob@ this)

this.set_s16(burn_counter, 0);
this.Sync(burn_counter, true);

if (this.hasTag("had only fire flag"))
this.getCurrentScript().runFlags |= Script::tick_infire;
}

/**
* Hitters that should start something burning when hit
*/
bool isIgniteHitter(u8 hitter)
{
return hitter == Hitters::fire;
}
11 changes: 7 additions & 4 deletions Entities/Common/FireScripts/IsFlammable.as
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,11 @@ void onInit(CBlob@ this)

if (!this.exists(burn_duration))
this.set_s16(burn_duration , 300);
if (!this.exists(burn_hitter))
this.set_u8(burn_hitter, Hitters::burn);

if (!this.exists(burn_timer))
this.set_s16(burn_timer , 0);

this.getCurrentScript().tickFrequency = fire_wait_ticks;
this.getCurrentScript().runFlags |= Script::tick_infire;
}

f32 onHit(CBlob@ this, Vec2f worldPoint, Vec2f velocity, f32 damage, CBlob@ hitterBlob, u8 customData)
Expand All @@ -40,6 +37,7 @@ f32 onHit(CBlob@ this, Vec2f worldPoint, Vec2f velocity, f32 damage, CBlob@ hitt
this.getSprite().PlaySound("/ExtinguishFire.ogg");
}
server_setFireOff(this);

this.set_netid("burn starter player", 0);
}

Expand All @@ -63,6 +61,11 @@ void onDie(CBlob@ this)

void onTick(CBlob@ this)
{
if (!this.hasTag(burning_tag) && !this.isInFlames())
return;

//print("burn time: " + this.get_s16(burn_timer) + " burn_count: " + this.get_s16(burn_counter));

Vec2f pos = this.getPosition();
CMap@ map = this.getMap();
if (map is null)
Expand Down Expand Up @@ -110,7 +113,7 @@ void onTick(CBlob@ this)
if (blob is null)
@blob = this;

blob.server_Hit(this, pos, Vec2f(0, 0), 0.25, this.get_u8(burn_hitter), true);
blob.server_Hit(this, pos, Vec2f(0, 0), 0.25, Hitters::fire, true);
}

//burninating the burning time
Expand Down
13 changes: 13 additions & 0 deletions Entities/Common/Respawning/StandardRespawnCommand.as
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include "ClassSelectMenu.as"
#include "KnockedCommon.as"
#include "FireCommon.as"


bool canChangeClass(CBlob@ this, CBlob@ blob)
Expand Down Expand Up @@ -160,6 +161,18 @@ void onRespawnCommand(CBlob@ this, u8 cmd, CBitStream @params)
{
setKnocked(newBlob, getKnockedRemaining(caller));
}

//copy fire
if (caller.hasTag(burning_tag))
{
newBlob.Tag(burning_tag);
newBlob.set_s16(burn_duration, caller.get_s16(burn_duration));
newBlob.set_s16(burn_timer, caller.get_s16(burn_timer));

newBlob.Sync(burning_tag, true);
newBlob.Sync(burn_duration, true);
newBlob.Sync(burn_timer, true);
}

// plug the soul
newBlob.server_SetPlayer(caller.getPlayer());
Expand Down
1 change: 0 additions & 1 deletion Entities/Industry/Fireplace/Fireplace.as
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "Requirements.as";
#include "MakeFood.as";
#include "FireParticle.as";
#include "FireCommon.as";
#include "FireplaceCommon.as";
#include "Hitters.as";

Expand Down