Git Repos / fte_dogmode / qc / triggers / setstate.qc
Last update to this file was on 2024-06-15 at 19:50.
Show setstate.qc
//==============================================================================
// target_setstate
//==============================================================================
//======================================================================
// constants
//======================================================================
#ifdef SSQC
const float SETSTATE_STARTOFF = 1;
const float SETSTATE_CLOSEALLDOORS = 2;
const float SETSTATE_DONTRESETBUTTON = 4;
#endif
//======================================================================
// forward declarations
//======================================================================
#ifdef SSQC
// target_setstate
float(entity e) target_setstate_getestate;
void(entity e, float state, float flags) target_setstate_setestate;
void(string matchstring, .string matchfield, float state, float flags)
target_setstate_settarget;
void(float state) target_setstate_setalltargets;
void() target_setstate_use;
void() target_setstate_think_startoff;
void(entity e) target_setstate_init;
void() target_setstate;
#endif
//------------------------------------------------------------------------------
#ifdef SSQC
//----------------------------------------------------------------------
// target_setstate
//----------------------------------------------------------------------
// class target_setstate: base_trigger
// {
//--------------------------------------------------------------
float(entity e) target_setstate_getestate =
{
if (e.classtype == CT_FUNC_DOOR)
return e.estate;
else
return e.estate;
};
//--------------------------------------------------------------
void(entity e, float state, float flags) target_setstate_setestate =
{
float closealldoors = 0;
if (e.classtype == CT_FUNC_BUTTON)
{
if (state == STATE_ACTIVE)
func_button_unlock (e,
flags & SETSTATE_DONTRESETBUTTON);
else
func_button_lock (e);
}
else if (e.classtype == CT_FUNC_DOOR)
{
if (flags & SETSTATE_CLOSEALLDOORS)
closealldoors = 1;
if (state == STATE_ACTIVE)
func_door_estate_unlock (e, closealldoors);
else
func_door_estate_lock (e, closealldoors);
}
else
{
e.estate = state;
}
if (e.classgroup & CG_TRIGGER)
{
if (e.is_waiting > 0 && state == STATE_ACTIVE)
{
sub_runvoidas (e, sub_endwaiting);
}
}
// commented out in progs_dump 3 -- CEV
/*
if (e.touch && e.touch != __NULL__)
{
force_retouch = 2;
}
*/
};
//--------------------------------------------------------------
void(string matchstring, .string matchfield, float state, float flags)
target_setstate_settarget =
{
local entity t;
t = find (world, matchfield, matchstring);
while (t != world)
{
if (state == -1)
{
if (target_setstate_getestate(t)==STATE_ACTIVE)
target_setstate_setestate (t,
STATE_INACTIVE, flags);
else
target_setstate_setestate (t,
STATE_ACTIVE, flags);
}
else
{
target_setstate_setestate (t, state, flags);
}
t = find (t, matchfield, matchstring);
}
};
//--------------------------------------------------------------
void(float state) target_setstate_setalltargets =
{
if (self.target && self.target != "")
{
target_setstate_settarget (self.target, targetname,
state, self.spawnflags);
target_setstate_settarget (self.target, targetname2,
state, self.spawnflags);
target_setstate_settarget (self.target, targetname3,
state, self.spawnflags);
target_setstate_settarget (self.target, targetname4,
state, self.spawnflags);
}
if (self.target2 && self.target2 != "")
{
target_setstate_settarget (self.target2, targetname,
state, self.spawnflags);
target_setstate_settarget (self.target2, targetname2,
state, self.spawnflags);
target_setstate_settarget (self.target2, targetname3,
state, self.spawnflags);
target_setstate_settarget (self.target2, targetname4,
state, self.spawnflags);
}
if (self.target3 && self.target3 != "")
{
target_setstate_settarget (self.target3, targetname,
state, self.spawnflags);
target_setstate_settarget (self.target3, targetname2,
state, self.spawnflags);
target_setstate_settarget (self.target3, targetname3,
state, self.spawnflags);
target_setstate_settarget (self.target3, targetname4,
state, self.spawnflags);
}
if (self.target4 && self.target4 != "")
{
target_setstate_settarget (self.target4, targetname,
state, self.spawnflags);
target_setstate_settarget (self.target4, targetname2,
state, self.spawnflags);
target_setstate_settarget (self.target4, targetname3,
state, self.spawnflags);
target_setstate_settarget (self.target4, targetname4,
state, self.spawnflags);
}
};
//--------------------------------------------------------------
void() target_setstate_use =
{
local float state;
if (self.style == 1)
state = STATE_ACTIVE;
else if (self.style == 2)
state = STATE_INACTIVE;
else
state = -1;
target_setstate_setalltargets (state);
};
//--------------------------------------------------------------
// was setstate_startoff_think
//--------------------------------------------------------------
void() target_setstate_think_startoff =
{
if (self.spawnflags & SETSTATE_STARTOFF)
target_setstate_setalltargets (STATE_INACTIVE);
};
//--------------------------------------------------------------
void(entity e) target_setstate_init =
{
e.classname = "target_setstate";
e.classtype = CT_TARGET_SETSTATE;
e.use = target_setstate_use;
base_mapentity_init (e);
if (e.spawnflags & SETSTATE_STARTOFF)
{
// wait a bit while doors finish being set up
e.think = target_setstate_think_startoff;
e.nextthink = time + 0.2;
}
};
//--------------------------------------------------------------
void() target_setstate =
{
// new spawnflags for all entities -- iw
if (SUB_Inhibit())
return;
target_setstate_init (self);
};
// };
#endif
Return to the top of this page or return to the overview of this repo.
Log setstate.qc
Date | Commit Message | Author | + | - |
---|---|---|---|---|
2024-06-15 | Major update, committing as-is, will have bugs | cev | +6 | |
2024-03-24 | 2nd pass refactor, rework QC class structure | cev | +102 | -82 |
2024-01-09 | Continue OO / Class-based refactor | cev | +44 | -26 |
2023-12-09 | Start OO / class-based refactor, work on items | cev | +177 |
Return to the top of this page or return to the overview of this repo.