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

Added eight new RTS commands related to sector editing #583

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
2 changes: 1 addition & 1 deletion source_files/edge/r_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
182 changes: 182 additions & 0 deletions source_files/edge/rad_act.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@

static style_c *rts_tip_style;

extern cvar_c r_doubleframes;

// current tip slots
drawtip_t tip_slots[MAXTIPSLOT];

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
9 changes: 8 additions & 1 deletion source_files/edge/rad_act.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__*/

Expand Down
53 changes: 53 additions & 0 deletions source_files/edge/rad_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Loading