/* * Author: Needles * https://steamcommunity.com/profiles/76561198026257137/ */ printl("*** HANDLER/BURN"); // @TODO - Possibly create entity state flags? Such as ESTATE_BURN ESTATE_AIR, etc.. // Custom conds can apply entity states. // We can then check for these states when figuring out if damage should be a crit or minicrit... Like detonator checks for player cond burning and also ESTATE_BURN... etc... // I would then need to completely rethink how the npc cond system works, because all of the logic that I put into burn would need to be hardcoded behaviour for the burn state when damage events are fired? /* * NOT INTENDED FOR PLAYERS * MAY CREATE UNEXPECTED RESULTS IF ASSIGNED TO A PLAYER */ local BurnHandler = class extends ::Handler.BaseHandler { /* BASE CLASS self = The entity that the handler is assigned to activator = The entity that assigned the handler time = When this handler was assigned */ prevBurnDamageTime = null; constructor() { base.constructor(); prevBurnDamageTime = -1.0; } function OnAdd() { prevBurnDamageTime = Time(); local particleAttachment = ::Particle.Validate(self); if (particleAttachment != null) particleAttachment.AddEffect("burningplayer_red"); ::Utils.TempAmbientGeneric(SOUND_IGNITE_PATH, self.GetOrigin(), 4096.0, 10, 100, 1.0); } function OnRemove() { local particleAttachment = ::Particle.Validate(self); if (particleAttachment != null) particleAttachment.RemoveEffect("burningplayer_red"); ::Utils.TempAmbientGeneric(SOUND_EXTINGUISH_PATH, self.GetOrigin(), 4096.0, 10, 100, 1.0); } function OnEvent_Tick(params) { if (Time() > prevBurnDamageTime + ::Const.BURN_DELAY) { prevBurnDamageTime = Time(); // @TODO - Needs to deal fire damage without repeatedly reapplying burn handler when used with fake_cond self.TakeDamageEx(activator, activator, null, Vector(0,0,0), self.GetOrigin(), ::Const.BURN_DAMAGE, 0); } } function OnEvent_DamagePre(params) { if (params.const_entity != self) return; switch (params.idef) { case ITEM_DEFINITION_INDEX.HUO_LONG_HEATER: params.damage *= ::Const.WEAPON_HUO_LONG_HEATER_DAMAGE_VS_BURNING_FACTOR; break; case ITEM_DEFINITION_INDEX.DETONATOR: case ITEM_DEFINITION_INDEX.SCORCH_SHOT: if (params.crit != CRIT_TYPE.FULL) params.crit = CRIT_TYPE.MINI; break; case ITEM_DEFINITION_INDEX.AXTINGUISHER: params.damage = ::Const.WEAPON_AXTINGUISHER_DAMAGE_MAX - ((Time() - time) / ::Const.BURN_DURATION_MAX) * (::Const.WEAPON_AXTINGUISHER_DAMAGE_MAX - ::Const.WEAPON_AXTINGUISHER_DAMAGE_MIN); if (params.crit != CRIT_TYPE.FULL) params.crit = CRIT_TYPE.MINI; ::Handler.RemoveHandler(self, "burn"); break; case ITEM_DEFINITION_INDEX.FLAREGUN: params.crit = CRIT_TYPE.FULL; break; } } } BurnHandler.SOUND_IGNITE_PATH <- "misc/flame_engulf.wav"; BurnHandler.SOUND_EXTINGUISH_PATH <- "player/flame_out.wav"; PrecacheSound(BurnHandler.SOUND_IGNITE_PATH); PrecacheSound(BurnHandler.SOUND_EXTINGUISH_PATH); ::Handler.RegisterHandler("burn", @() BurnHandler());