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..b5ff72c93 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]; @@ -903,6 +905,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 +1513,184 @@ void RAD_ActReplaceThing(rad_trigger_t *R, void *param) } +void RAD_ActFlagSector(rad_trigger_t *R, void *param) +{ + s_flagsector_t *t = (s_flagsector_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->enable) + 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)t->flag); + } +} + +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); + if (specialTemplate == NULL) + specialTemplate = new sectortype_c; + + 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; + } + + 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; + } +} + +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 ea73f24a9..890a2f538 100644 --- a/source_files/edge/rad_act.h +++ b/source_files/edge/rad_act.h @@ -63,7 +63,14 @@ 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_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_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 4702da758..e8521b50f 100644 --- a/source_files/edge/rad_defs.h +++ b/source_files/edge/rad_defs.h @@ -298,6 +298,59 @@ typedef struct s_fogsector_s } s_fogsector_t; +// Sector special flag change +typedef struct s_flagsector_s +{ + // sector tag + int tag = 0; + + // special flag to set/unset + sector_flag_e flag = SECSP_None; + + // should the flag be set? + bool enable = true; +} +s_flagsector_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_s +{ + // sector tag + int tag = 0; + + // float amount + float amount = 0; + + // is the change relative? + bool relative = true; +} +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 137e1e50f..fa00cfd0a 100644 --- a/source_files/edge/rad_pars.cc +++ b/source_files/edge/rad_pars.cc @@ -2224,6 +2224,220 @@ static void RAD_ParseReplaceThing(param_set_t& pars) AddStateToScript(this_rad, 0, RAD_ActReplaceThing, thingarg); } +static void RAD_ParseFlagSector(param_set_t& pars) +{ + // FlagSector + + s_flagsector_t *secf; + secf = new s_flagsector_t; + + RAD_CheckForInt(pars[1], &secf->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]); + + secf->enable = CheckForBoolean(pars[3]); + + AddStateToScript(this_rad, 0, RAD_ActFlagSector, secf); +} + +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 ((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); +} + +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_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 + // 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 +2529,14 @@ 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, "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, "PUSH_ANGLE_SECTOR", 3,4, RAD_ParsePushAngleSector}, + {2, "PUSH_SPEED_SECTOR", 3,4, RAD_ParsePushSpeedSector}, + {2, "VISCOSITY_SECTOR", 3,4, RAD_ParseViscositySector}, // old crud {2, "SECTORV", 4,4, RAD_ParseMoveSector},