From af2f07b21edf0f51790e677fbf9ae763a6268340 Mon Sep 17 00:00:00 2001 From: Ambroise Garel <47314805+akaAgar@users.noreply.github.com> Date: Tue, 10 Oct 2023 23:35:10 +0200 Subject: [PATCH 1/4] Added six new RTS command related to sector edition New commands are : AIRLESS_SECTOR DAMAGE_SECTOR DRAG_SECTOR [ABSOLUTE] FRICTION_SECTOR [ABSOLUTE] GRAVITY_SECTOR [ABSOLUTE] VISCOSITY_SECTOR [ABSOLUTE] --- source_files/edge/r_defs.h | 2 +- source_files/edge/rad_act.cc | 108 +++++++++++++++++++++++++ source_files/edge/rad_act.h | 7 +- source_files/edge/rad_defs.h | 36 +++++++++ source_files/edge/rad_pars.cc | 147 ++++++++++++++++++++++++++++++++++ 5 files changed, 298 insertions(+), 2 deletions(-) diff --git a/source_files/edge/r_defs.h b/source_files/edge/r_defs.h index afc768e1d..8b671eec6 100644 --- a/source_files/edge/r_defs.h +++ b/source_files/edge/r_defs.h @@ -118,7 +118,7 @@ typedef struct region_properties_s // special type (e.g. damaging) int type; - const sectortype_c *special; + sectortype_c *special; bool secret_found = false; // -KM- 1998/10/29 Added gravity + friction diff --git a/source_files/edge/rad_act.cc b/source_files/edge/rad_act.cc index 6e4d65158..e74f4cc08 100644 --- a/source_files/edge/rad_act.cc +++ b/source_files/edge/rad_act.cc @@ -903,6 +903,7 @@ void RAD_ActLightSector(rad_trigger_t *R, void *param) } } + void RAD_ActFogSector(rad_trigger_t *R, void *param) { s_fogsector_t *t = (s_fogsector_t *) param; @@ -1510,5 +1511,112 @@ void RAD_ActReplaceThing(rad_trigger_t *R, void *param) } +void RAD_ActAirlessSector(rad_trigger_t *R, void *param) +{ + s_airlesssector_t *t = (s_airlesssector_t *) param; + int i; + + for (i=0; i < numsectors; i++) + { + if (sectors[i].tag != t->tag) continue; + + sectortype_c *originalSpecial = P_LookupSectorType(sectors[i].props.type); + + sectors[i].props.special = new sectortype_c; + if (originalSpecial != NULL) + sectors[i].props.special->CopyDetail(*originalSpecial); + + if (t->enable) + sectors[i].props.special->special_flags = (sector_flag_e)((int)sectors[i].props.special->special_flags | (int)SECSP_AirLess); + else + sectors[i].props.special->special_flags = (sector_flag_e)((int)sectors[i].props.special->special_flags & ~(int)SECSP_AirLess); + } +} + +void RAD_ActDamageSector(rad_trigger_t *R, void *param) +{ + s_sectortypecopy_t *t = (s_sectortypecopy_t *) param; + int i; + + sectortype_c *specialTemplate = P_LookupSectorType(t->sourceSpecialType); + + for (i=0; i < numsectors; i++) + { + if (sectors[i].tag != t->tag) continue; + + sectortype_c *originalSpecial = P_LookupSectorType(sectors[i].props.type); + + sectors[i].props.special = new sectortype_c; + if (originalSpecial != NULL) + sectors[i].props.special->CopyDetail(*originalSpecial); + + sectors[i].props.special->damage = specialTemplate->damage; + } +} + +void RAD_ActGravitySector(rad_trigger_t *R, void *param) +{ + s_floatsector_t *t = (s_floatsector_t *) param; + int i; + + for (i=0; i < numsectors; i++) + { + if (sectors[i].tag != t->tag) continue; + + if (t->relative) + sectors[i].props.gravity += t->amount * GRAVITY; + else + sectors[i].props.gravity = t->amount * GRAVITY; + } +} + +void RAD_ActDragSector(rad_trigger_t *R, void *param) +{ + s_floatsector_t *t = (s_floatsector_t *) param; + int i; + + for (i=0; i < numsectors; i++) + { + if (sectors[i].tag != t->tag) continue; + + if (t->relative) + sectors[i].props.drag += t->amount; + else + sectors[i].props.drag = t->amount; + } +} + +void RAD_ActFrictionSector(rad_trigger_t *R, void *param) +{ + s_floatsector_t *t = (s_floatsector_t *) param; + int i; + + for (i=0; i < numsectors; i++) + { + if (sectors[i].tag != t->tag) continue; + + if (t->relative) + sectors[i].props.friction += t->amount; + else + sectors[i].props.friction = t->amount; + } +} + +void RAD_ActViscositySector(rad_trigger_t *R, void *param) +{ + s_floatsector_t *t = (s_floatsector_t *) param; + int i; + + for (i=0; i < numsectors; i++) + { + if (sectors[i].tag != t->tag) continue; + + if (t->relative) + sectors[i].props.viscosity += t->amount; + else + sectors[i].props.viscosity = t->amount; + } +} + //--- editor settings --- // vi:ts=4:sw=4:noexpandtab diff --git a/source_files/edge/rad_act.h b/source_files/edge/rad_act.h index ea73f24a9..b1537fdf0 100644 --- a/source_files/edge/rad_act.h +++ b/source_files/edge/rad_act.h @@ -63,7 +63,12 @@ void RAD_ActTeleportToStart(rad_trigger_t *R, void *param); void RAD_ActReplaceWeapon(rad_trigger_t *R, void *param); void RAD_ActWeaponEvent(rad_trigger_t *R, void *param); void RAD_ActReplaceThing(rad_trigger_t *R, void *param); - +void RAD_ActAirlessSector(rad_trigger_t *R, void *param); +void RAD_ActDamageSector(rad_trigger_t *R, void *param); +void RAD_ActDragSector(rad_trigger_t *R, void *param); +void RAD_ActFrictionSector(rad_trigger_t *R, void *param); +void RAD_ActGravitySector(rad_trigger_t *R, void *param); +void RAD_ActViscositySector(rad_trigger_t *R, void *param); #endif /*__RAD_ACT_H__*/ diff --git a/source_files/edge/rad_defs.h b/source_files/edge/rad_defs.h index 4702da758..2bb6d49ae 100644 --- a/source_files/edge/rad_defs.h +++ b/source_files/edge/rad_defs.h @@ -298,6 +298,42 @@ typedef struct s_fogsector_s } s_fogsector_t; +// Sector airless change +typedef struct s_airlesssector_s +{ + // sector tag + int tag = 0; + + // should the airless flag be set? + bool enable = true; +} +s_airlesssector_t; + +// Sector parameter changed by copying from another sector type +typedef struct s_sectortypecopy_s +{ + // sector tag + int tag = 0; + + // source special type to copy from + int sourceSpecialType = 0; +} +s_sectortypecopy_t; + +// Sector value change using a relative or absolute float parameter (used for drag, friction, gravity and viscosity) +typedef struct s_floatsector_t +{ + // sector tag + int tag = 0; + + // float amount + float amount = 0; + + // is the change relative? + bool relative = true; +} +s_frictionsector_t; + // Enable/Disable typedef struct s_enabler_s { diff --git a/source_files/edge/rad_pars.cc b/source_files/edge/rad_pars.cc index 137e1e50f..d585c4e6a 100644 --- a/source_files/edge/rad_pars.cc +++ b/source_files/edge/rad_pars.cc @@ -2224,6 +2224,147 @@ static void RAD_ParseReplaceThing(param_set_t& pars) AddStateToScript(this_rad, 0, RAD_ActReplaceThing, thingarg); } +static void RAD_ParseAirlessSector(param_set_t& pars) +{ + // AirlessSector + + s_airlesssector_t *seca; + seca = new s_airlesssector_t; + + RAD_CheckForInt(pars[1], &seca->tag); + + if (seca->tag == 0) + RAD_Error("%s: Invalid tag number: %d\n", pars[0], seca->tag); + + seca->enable = CheckForBoolean(pars[2]); + + AddStateToScript(this_rad, 0, RAD_ActAirlessSector, seca); +} + +static void RAD_ParseDamageSector(param_set_t& pars) +{ + // DamageSector + + s_sectortypecopy_t *sect; + sect = new s_sectortypecopy_t; + + RAD_CheckForInt(pars[1], §->tag); + + if (sect->tag == 0) + RAD_Error("%s: Invalid tag number: %d\n", pars[0], sect->tag); + + RAD_CheckForInt(pars[2], §->sourceSpecialType); + + if (P_LookupSectorType(sect->sourceSpecialType) == NULL) + RAD_Error("%s: Invalid special sector type: %d\n", pars[0], sect->sourceSpecialType); + + AddStateToScript(this_rad, 0, RAD_ActDamageSector, sect); +} + +static void RAD_ParseDragSector(param_set_t& pars) +{ + // DragSector + // DragSector ABSOLUTE + + s_floatsector_t *secf; + secf = new s_floatsector_t; + + RAD_CheckForInt(pars[1], &secf->tag); + + if (secf->tag == 0) + RAD_Error("%s: Invalid tag number: %d\n", pars[0], secf->tag); + + RAD_CheckForFloat(pars[2], &secf->amount); + + if (pars.size() >= 4) + { + if (DDF_CompareName(pars[3], "ABSOLUTE") == 0) + secf->relative = false; + else + RAD_WarnError("%s: expected 'ABSOLUTE' but got '%s'.\n", pars[0], pars[3]); + } + + AddStateToScript(this_rad, 0, RAD_ActDragSector, secf); +} + +static void RAD_ParseFrictionSector(param_set_t& pars) +{ + // FrictionSector + // FrictionSector ABSOLUTE + + s_floatsector_t *secf; + secf = new s_floatsector_t; + + RAD_CheckForInt(pars[1], &secf->tag); + + if (secf->tag == 0) + RAD_Error("%s: Invalid tag number: %d\n", pars[0], secf->tag); + + RAD_CheckForFloat(pars[2], &secf->amount); + + if (pars.size() >= 4) + { + if (DDF_CompareName(pars[3], "ABSOLUTE") == 0) + secf->relative = false; + else + RAD_WarnError("%s: expected 'ABSOLUTE' but got '%s'.\n", pars[0], pars[3]); + } + + AddStateToScript(this_rad, 0, RAD_ActFrictionSector, secf); +} + +static void RAD_ParseGravitySector(param_set_t& pars) +{ + // GravitySector + // GravitySector ABSOLUTE + + s_floatsector_t *secf; + secf = new s_floatsector_t; + + RAD_CheckForInt(pars[1], &secf->tag); + + if (secf->tag == 0) + RAD_Error("%s: Invalid tag number: %d\n", pars[0], secf->tag); + + RAD_CheckForFloat(pars[2], &secf->amount); + + if (pars.size() >= 4) + { + if (DDF_CompareName(pars[3], "ABSOLUTE") == 0) + secf->relative = false; + else + RAD_WarnError("%s: expected 'ABSOLUTE' but got '%s'.\n", pars[0], pars[3]); + } + + AddStateToScript(this_rad, 0, RAD_ActGravitySector, secf); +} + +static void RAD_ParseViscositySector(param_set_t& pars) +{ + // ViscositySector + // ViscositySector ABSOLUTE + + s_floatsector_t *secf; + secf = new s_floatsector_t; + + RAD_CheckForInt(pars[1], &secf->tag); + + if (secf->tag == 0) + RAD_Error("%s: Invalid tag number: %d\n", pars[0], secf->tag); + + RAD_CheckForFloat(pars[2], &secf->amount); + + if (pars.size() >= 4) + { + if (DDF_CompareName(pars[3], "ABSOLUTE") == 0) + secf->relative = false; + else + RAD_WarnError("%s: expected 'ABSOLUTE' but got '%s'.\n", pars[0], pars[3]); + } + + AddStateToScript(this_rad, 0, RAD_ActViscositySector, secf); +} + // PARSER TABLE static const rts_parser_t radtrig_parsers[] = @@ -2315,6 +2456,12 @@ static const rts_parser_t radtrig_parsers[] = {2, "REPLACE_WEAPON", 3,3, RAD_ParseReplaceWeapon}, {2, "WEAPON_EVENT", 3,3, RAD_ParseWeaponEvent}, {2, "REPLACE_THING", 3,3, RAD_ParseReplaceThing}, + {2, "AIRLESS_SECTOR", 3,3, RAD_ParseAirlessSector}, + {2, "DAMAGE_SECTOR", 3,3, RAD_ParseDamageSector}, + {2, "DRAG_SECTOR", 3,4, RAD_ParseDragSector}, + {2, "FRICTION_SECTOR", 3,4, RAD_ParseFrictionSector}, + {2, "GRAVITY_SECTOR", 3,4, RAD_ParseGravitySector}, + {2, "VISCOSITY_SECTOR", 3,4, RAD_ParseViscositySector}, // old crud {2, "SECTORV", 4,4, RAD_ParseMoveSector}, From ac92d32302f6b43bc02e2064b6f1db9f5bb6cffe Mon Sep 17 00:00:00 2001 From: Ambroise Garel <47314805+akaAgar@users.noreply.github.com> Date: Wed, 11 Oct 2023 13:52:27 +0200 Subject: [PATCH 2/4] Replaced AIRLESS_SECTOR by generic FLAG_SECTOR RTS command Format is now FLAG_SECTOR where : - tag is the sector(s) tag - flag is the flag to set (AIRLESS, PROPORTIONAL, PUSH_ALL, PUSH_CONSTANT, REVERB_SFX, SUBMERGED_SFX, SWIMMING, VACCUM_SFX, WHOLE_REGION) - true means the flag must be set, false that it must be unset --- source_files/edge/rad_act.cc | 36 ++++++++++++++++++------------ source_files/edge/rad_act.h | 2 +- source_files/edge/rad_defs.h | 11 ++++++---- source_files/edge/rad_pars.cc | 41 ++++++++++++++++++++++++++--------- 4 files changed, 61 insertions(+), 29 deletions(-) diff --git a/source_files/edge/rad_act.cc b/source_files/edge/rad_act.cc index e74f4cc08..db9c6d8e3 100644 --- a/source_files/edge/rad_act.cc +++ b/source_files/edge/rad_act.cc @@ -1511,25 +1511,29 @@ void RAD_ActReplaceThing(rad_trigger_t *R, void *param) } -void RAD_ActAirlessSector(rad_trigger_t *R, void *param) +void RAD_ActFlagSector(rad_trigger_t *R, void *param) { - s_airlesssector_t *t = (s_airlesssector_t *) param; + s_flagsector_t *t = (s_flagsector_t *) param; int i; for (i=0; i < numsectors; i++) { if (sectors[i].tag != t->tag) continue; - sectortype_c *originalSpecial = P_LookupSectorType(sectors[i].props.type); - - sectors[i].props.special = new sectortype_c; - if (originalSpecial != NULL) - sectors[i].props.special->CopyDetail(*originalSpecial); + if (sectors[i].props.special == NULL) + sectors[i].props.special = new sectortype_c; + else + { + // Duplicate special so original special type is not modified + sectortype_c *specialCopy = new sectortype_c; + specialCopy->CopyDetail(*sectors[i].props.special); + sectors[i].props.special = specialCopy; + } if (t->enable) - sectors[i].props.special->special_flags = (sector_flag_e)((int)sectors[i].props.special->special_flags | (int)SECSP_AirLess); + sectors[i].props.special->special_flags = (sector_flag_e)((int)sectors[i].props.special->special_flags | (int)t->flag); else - sectors[i].props.special->special_flags = (sector_flag_e)((int)sectors[i].props.special->special_flags & ~(int)SECSP_AirLess); + sectors[i].props.special->special_flags = (sector_flag_e)((int)sectors[i].props.special->special_flags & ~(int)t->flag); } } @@ -1544,11 +1548,15 @@ void RAD_ActDamageSector(rad_trigger_t *R, void *param) { if (sectors[i].tag != t->tag) continue; - sectortype_c *originalSpecial = P_LookupSectorType(sectors[i].props.type); - - sectors[i].props.special = new sectortype_c; - if (originalSpecial != NULL) - sectors[i].props.special->CopyDetail(*originalSpecial); + if (sectors[i].props.special == NULL) + sectors[i].props.special = new sectortype_c; + else + { + // Duplicate special so original special type is not modified + sectortype_c *specialCopy = new sectortype_c; + specialCopy->CopyDetail(*sectors[i].props.special); + sectors[i].props.special = specialCopy; + } sectors[i].props.special->damage = specialTemplate->damage; } diff --git a/source_files/edge/rad_act.h b/source_files/edge/rad_act.h index b1537fdf0..baa48ea9b 100644 --- a/source_files/edge/rad_act.h +++ b/source_files/edge/rad_act.h @@ -63,9 +63,9 @@ void RAD_ActTeleportToStart(rad_trigger_t *R, void *param); void RAD_ActReplaceWeapon(rad_trigger_t *R, void *param); void RAD_ActWeaponEvent(rad_trigger_t *R, void *param); void RAD_ActReplaceThing(rad_trigger_t *R, void *param); -void RAD_ActAirlessSector(rad_trigger_t *R, void *param); void RAD_ActDamageSector(rad_trigger_t *R, void *param); void RAD_ActDragSector(rad_trigger_t *R, void *param); +void RAD_ActFlagSector(rad_trigger_t *R, void *param); void RAD_ActFrictionSector(rad_trigger_t *R, void *param); void RAD_ActGravitySector(rad_trigger_t *R, void *param); void RAD_ActViscositySector(rad_trigger_t *R, void *param); diff --git a/source_files/edge/rad_defs.h b/source_files/edge/rad_defs.h index 2bb6d49ae..752a05912 100644 --- a/source_files/edge/rad_defs.h +++ b/source_files/edge/rad_defs.h @@ -298,16 +298,19 @@ typedef struct s_fogsector_s } s_fogsector_t; -// Sector airless change -typedef struct s_airlesssector_s +// Sector special flag change +typedef struct s_flagsector_s { // sector tag int tag = 0; - // should the airless flag be set? + // special flag to set/unset + sector_flag_e flag = SECSP_None; + + // should the flag be set? bool enable = true; } -s_airlesssector_t; +s_flagsector_t; // Sector parameter changed by copying from another sector type typedef struct s_sectortypecopy_s diff --git a/source_files/edge/rad_pars.cc b/source_files/edge/rad_pars.cc index d585c4e6a..bbad0b6bd 100644 --- a/source_files/edge/rad_pars.cc +++ b/source_files/edge/rad_pars.cc @@ -2224,21 +2224,42 @@ static void RAD_ParseReplaceThing(param_set_t& pars) AddStateToScript(this_rad, 0, RAD_ActReplaceThing, thingarg); } -static void RAD_ParseAirlessSector(param_set_t& pars) +static void RAD_ParseFlagSector(param_set_t& pars) { - // AirlessSector + // FlagSector - s_airlesssector_t *seca; - seca = new s_airlesssector_t; + s_flagsector_t *secf; + secf = new s_flagsector_t; - RAD_CheckForInt(pars[1], &seca->tag); + RAD_CheckForInt(pars[1], &secf->tag); - if (seca->tag == 0) - RAD_Error("%s: Invalid tag number: %d\n", pars[0], seca->tag); + if (secf->tag == 0) + RAD_Error("%s: Invalid tag number: %d\n", pars[0], secf->tag); + + if (DDF_CompareName(pars[2], "AIRLESS") == 0) + secf->flag = SECSP_AirLess; + else if (DDF_CompareName(pars[2], "PROPORTIONAL") == 0) + secf->flag = SECSP_Proportional; + else if (DDF_CompareName(pars[2], "PUSH_ALL") == 0) + secf->flag = SECSP_PushAll; + else if (DDF_CompareName(pars[2], "PUSH_CONSTANT") == 0) + secf->flag = SECSP_PushConstant; + else if (DDF_CompareName(pars[2], "REVERB_SFX") == 0) + secf->flag = SECSP_ReverbSFX; + else if (DDF_CompareName(pars[2], "SUBMERGED_SFX") == 0) + secf->flag = SECSP_SubmergedSFX; + else if (DDF_CompareName(pars[2], "SWIMMING") == 0) + secf->flag = SECSP_Swimming; + else if (DDF_CompareName(pars[2], "VACUUM_SFX") == 0) + secf->flag = SECSP_VacuumSFX; + else if (DDF_CompareName(pars[2], "WHOLE_REGION") == 0) + secf->flag = SECSP_WholeRegion; + else + RAD_Error("%s: Invalid special sector flag: %s\n", pars[0], pars[2]); - seca->enable = CheckForBoolean(pars[2]); + secf->enable = CheckForBoolean(pars[3]); - AddStateToScript(this_rad, 0, RAD_ActAirlessSector, seca); + AddStateToScript(this_rad, 0, RAD_ActFlagSector, secf); } static void RAD_ParseDamageSector(param_set_t& pars) @@ -2456,9 +2477,9 @@ static const rts_parser_t radtrig_parsers[] = {2, "REPLACE_WEAPON", 3,3, RAD_ParseReplaceWeapon}, {2, "WEAPON_EVENT", 3,3, RAD_ParseWeaponEvent}, {2, "REPLACE_THING", 3,3, RAD_ParseReplaceThing}, - {2, "AIRLESS_SECTOR", 3,3, RAD_ParseAirlessSector}, {2, "DAMAGE_SECTOR", 3,3, RAD_ParseDamageSector}, {2, "DRAG_SECTOR", 3,4, RAD_ParseDragSector}, + {2, "FLAG_SECTOR", 4,4, RAD_ParseFlagSector}, {2, "FRICTION_SECTOR", 3,4, RAD_ParseFrictionSector}, {2, "GRAVITY_SECTOR", 3,4, RAD_ParseGravitySector}, {2, "VISCOSITY_SECTOR", 3,4, RAD_ParseViscositySector}, From 1f4fa6a6d5411c09210e3383544b7704bdcaacf6 Mon Sep 17 00:00:00 2001 From: Ambroise Garel <47314805+akaAgar@users.noreply.github.com> Date: Wed, 11 Oct 2023 14:23:26 +0200 Subject: [PATCH 3/4] Added PUSH_*_SECTOR RTS command, fixed minor problems in rad_defs.h Command format is : - PUSH_ANGLE_SECTOR [ABSOLUTE] - PUSH_SPEED_SECTOR [ABSOLUTE] --- source_files/edge/rad_act.cc | 64 +++++++++++++++++++++++++++++++++++ source_files/edge/rad_act.h | 2 ++ source_files/edge/rad_defs.h | 18 ++++++++-- source_files/edge/rad_pars.cc | 54 +++++++++++++++++++++++++++++ 4 files changed, 136 insertions(+), 2 deletions(-) diff --git a/source_files/edge/rad_act.cc b/source_files/edge/rad_act.cc index db9c6d8e3..a22eb9a53 100644 --- a/source_files/edge/rad_act.cc +++ b/source_files/edge/rad_act.cc @@ -55,6 +55,8 @@ static style_c *rts_tip_style; +extern cvar_c r_doubleframes; + // current tip slots drawtip_t tip_slots[MAXTIPSLOT]; @@ -1626,5 +1628,67 @@ void RAD_ActViscositySector(rad_trigger_t *R, void *param) } } +void RAD_ActPushAngleSector(rad_trigger_t *R, void *param) +{ + s_pushsector_t *t = (s_pushsector_t *) param; + int i; + + for (i=0; i < numsectors; i++) + { + if (sectors[i].tag != t->tag) continue; + + if (sectors[i].props.special == NULL) + sectors[i].props.special = new sectortype_c; + else + { + // Duplicate special so original special type is not modified + sectortype_c *specialCopy = new sectortype_c; + specialCopy->CopyDetail(*sectors[i].props.special); + sectors[i].props.special = specialCopy; + } + + if (t->relative) + sectors[i].props.special->push_angle += FLOAT_2_ANG(t->amount); + else + sectors[i].props.special->push_angle = FLOAT_2_ANG(t->amount); + + float mul = sectors[i].props.special->push_speed / 100.0f; + sectors[i].props.push.x = M_Cos(sectors[i].props.special->push_angle) * mul; + sectors[i].props.push.y = M_Sin(sectors[i].props.special->push_angle) * mul; + sectors[i].props.push.z = sectors[i].props.special->push_zspeed / (r_doubleframes.d ? 89.2f : 100.0f); + } +} + +void RAD_ActPushSpeedSector(rad_trigger_t *R, void *param) +{ + s_pushsector_t *t = (s_pushsector_t *) param; + int i; + + for (i=0; i < numsectors; i++) + { + if (sectors[i].tag != t->tag) continue; + + if (sectors[i].props.special == NULL) + sectors[i].props.special = new sectortype_c; + else + { + // Duplicate special so original special type is not modified + sectortype_c *specialCopy = new sectortype_c; + specialCopy->CopyDetail(*sectors[i].props.special); + sectors[i].props.special = specialCopy; + } + + if (t->relative) + sectors[i].props.special->push_speed += t->amount; + else + sectors[i].props.special->push_speed = t->amount; + + float mul = sectors[i].props.special->push_speed / 100.0f; + sectors[i].props.push.x = M_Cos(sectors[i].props.special->push_angle) * mul; + sectors[i].props.push.y = M_Sin(sectors[i].props.special->push_angle) * mul; + sectors[i].props.push.z = sectors[i].props.special->push_zspeed / (r_doubleframes.d ? 89.2f : 100.0f); + } +} + //--- editor settings --- // vi:ts=4:sw=4:noexpandtab diff --git a/source_files/edge/rad_act.h b/source_files/edge/rad_act.h index baa48ea9b..890a2f538 100644 --- a/source_files/edge/rad_act.h +++ b/source_files/edge/rad_act.h @@ -68,6 +68,8 @@ void RAD_ActDragSector(rad_trigger_t *R, void *param); void RAD_ActFlagSector(rad_trigger_t *R, void *param); void RAD_ActFrictionSector(rad_trigger_t *R, void *param); void RAD_ActGravitySector(rad_trigger_t *R, void *param); +void RAD_ActPushAngleSector(rad_trigger_t *R, void *param); +void RAD_ActPushSpeedSector(rad_trigger_t *R, void *param); void RAD_ActViscositySector(rad_trigger_t *R, void *param); #endif /*__RAD_ACT_H__*/ diff --git a/source_files/edge/rad_defs.h b/source_files/edge/rad_defs.h index 752a05912..e8521b50f 100644 --- a/source_files/edge/rad_defs.h +++ b/source_files/edge/rad_defs.h @@ -324,7 +324,7 @@ typedef struct s_sectortypecopy_s s_sectortypecopy_t; // Sector value change using a relative or absolute float parameter (used for drag, friction, gravity and viscosity) -typedef struct s_floatsector_t +typedef struct s_floatsector_s { // sector tag int tag = 0; @@ -335,7 +335,21 @@ typedef struct s_floatsector_t // is the change relative? bool relative = true; } -s_frictionsector_t; +s_floatsector_t; + +// Sector push angle/speed change +typedef struct s_pushsector_s +{ + // sector tag + int tag = 0; + + // push angle or speed + float amount = 0; + + // is the change relative? + bool relative = true; +} +s_pushsector_t; // Enable/Disable typedef struct s_enabler_s diff --git a/source_files/edge/rad_pars.cc b/source_files/edge/rad_pars.cc index bbad0b6bd..6d7f2bf3d 100644 --- a/source_files/edge/rad_pars.cc +++ b/source_files/edge/rad_pars.cc @@ -2360,6 +2360,58 @@ static void RAD_ParseGravitySector(param_set_t& pars) AddStateToScript(this_rad, 0, RAD_ActGravitySector, secf); } +static void RAD_ParsePushAngleSector(param_set_t& pars) +{ + // PushAngleSector + // PushAngleSector ABSOLUTE + + s_pushsector_t *secp; + secp = new s_pushsector_t; + + RAD_CheckForInt(pars[1], &secp->tag); + + if (secp->tag == 0) + RAD_Error("%s: Invalid tag number: %d\n", pars[0], secp->tag); + + RAD_CheckForFloat(pars[2], &secp->amount); + + if (pars.size() >= 4) + { + if (DDF_CompareName(pars[3], "ABSOLUTE") == 0) + secp->relative = false; + else + RAD_WarnError("%s: expected 'ABSOLUTE' but got '%s'.\n", pars[0], pars[3]); + } + + AddStateToScript(this_rad, 0, RAD_ActPushAngleSector, secp); +} + +static void RAD_ParsePushSpeedSector(param_set_t& pars) +{ + // PushSpeedSector + // PushSpeedSector ABSOLUTE + + s_pushsector_t *secp; + secp = new s_pushsector_t; + + RAD_CheckForInt(pars[1], &secp->tag); + + if (secp->tag == 0) + RAD_Error("%s: Invalid tag number: %d\n", pars[0], secp->tag); + + RAD_CheckForFloat(pars[2], &secp->amount); + + if (pars.size() >= 4) + { + if (DDF_CompareName(pars[3], "ABSOLUTE") == 0) + secp->relative = false; + else + RAD_WarnError("%s: expected 'ABSOLUTE' but got '%s'.\n", pars[0], pars[3]); + } + + AddStateToScript(this_rad, 0, RAD_ActPushSpeedSector, secp); +} + static void RAD_ParseViscositySector(param_set_t& pars) { // ViscositySector @@ -2482,6 +2534,8 @@ static const rts_parser_t radtrig_parsers[] = {2, "FLAG_SECTOR", 4,4, RAD_ParseFlagSector}, {2, "FRICTION_SECTOR", 3,4, RAD_ParseFrictionSector}, {2, "GRAVITY_SECTOR", 3,4, RAD_ParseGravitySector}, + {2, "PUSH_ANGLE_SECTOR", 3,4, RAD_ParsePushAngleSector}, + {2, "PUSH_SPEED_SECTOR", 3,4, RAD_ParsePushSpeedSector}, {2, "VISCOSITY_SECTOR", 3,4, RAD_ParseViscositySector}, // old crud From dca22e97841cea99228e83dd6bce8ac267e283e9 Mon Sep 17 00:00:00 2001 From: Ambroise Garel <47314805+akaAgar@users.noreply.github.com> Date: Wed, 11 Oct 2023 14:34:45 +0200 Subject: [PATCH 4/4] Can now use sector type 0 to disable damage with DAMAGE_SECTOR --- source_files/edge/rad_act.cc | 2 ++ source_files/edge/rad_pars.cc | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/source_files/edge/rad_act.cc b/source_files/edge/rad_act.cc index a22eb9a53..b5ff72c93 100644 --- a/source_files/edge/rad_act.cc +++ b/source_files/edge/rad_act.cc @@ -1545,6 +1545,8 @@ void RAD_ActDamageSector(rad_trigger_t *R, void *param) int i; sectortype_c *specialTemplate = P_LookupSectorType(t->sourceSpecialType); + if (specialTemplate == NULL) + specialTemplate = new sectortype_c; for (i=0; i < numsectors; i++) { diff --git a/source_files/edge/rad_pars.cc b/source_files/edge/rad_pars.cc index 6d7f2bf3d..fa00cfd0a 100644 --- a/source_files/edge/rad_pars.cc +++ b/source_files/edge/rad_pars.cc @@ -2276,7 +2276,7 @@ static void RAD_ParseDamageSector(param_set_t& pars) RAD_CheckForInt(pars[2], §->sourceSpecialType); - if (P_LookupSectorType(sect->sourceSpecialType) == NULL) + if ((sect->sourceSpecialType != 0 ) && (P_LookupSectorType(sect->sourceSpecialType) == NULL)) RAD_Error("%s: Invalid special sector type: %d\n", pars[0], sect->sourceSpecialType); AddStateToScript(this_rad, 0, RAD_ActDamageSector, sect);