set g_maplist_check_waypoints 0 "when 1, maps are skipped if there currently are bots, but the map has no waypoints"
set samelevel 0 "when 1, always play the same level over and over again"
+set g_grab 0 "enables grabbing certain objects"
+
set g_cloaked 0 "display all players mostly invisible"
set g_player_alpha 1
set g_player_brightness 0 "set to 2 for brighter players"
float autocvar_g_trueaim_minrange;
float autocvar_g_debug_defaultsounds;
float autocvar_g_loituma;
+float autocvar_g_grab;
+float autocvar_g_grab_range;
float autocvar_g_sandbox_info;
string autocvar_g_sandbox_storage_name;
float autocvar_g_sandbox_storage_autosave;
{
BEGIN_CHEAT_FUNCTION();
- // Dragging can be used as either a cheat, or a tool for g_sandbox. If sv_cheats is active,
+ // Dragging can be used as either a cheat, or a function for some objects. If sv_cheats is active,
// the cheat dragging is used (unlimited pickup range and any entity can be carried), even if
- // g_sandbox is enabled. Is sv_cheats is disabled but g_sandbox is not, then sandbox dragging
- // is used (limited pickup range and only sandbox objects can be carried), grabbing itself
- // no longer being accounted as cheating. If both sv_cheats and g_sandbox are disabled, players
+ // g_grab is enabled. Is sv_cheats is disabled but g_grab is not, normal dragging is
+ // used (limited pickup range and only dragable objects can be carried), grabbing itself
+ // no longer being accounted as cheating. If both sv_cheats and g_grab are disabled, players
// attempting to grab objects are reported as trying to cheat.
switch(0)
{
default:
- if(self.BUTTON_DRAG && !cvar("g_sandbox"))
+ if(self.BUTTON_DRAG && !autocvar_g_grab)
{
- // consider dragging a cheat only if sandbox mode is disabled
+ // consider dragging a cheat only if g_grab is disabled
IS_CHEAT(0, 0, CHRAME_DRAG);
}
if(autocvar_sv_cheats)
{
// only use cheat dragging if cheats are enabled
crosshair_trace_plusvisibletriggers(self);
- if(Drag(trace_ent, TRUE) && !cvar("g_sandbox"))
+ if(Drag(trace_ent, TRUE) && !autocvar_g_grab)
DID_CHEAT();
}
break;
PrintWelcomeMessage();
+ // if the player is close enough to a dragable entity, they can grab it
+ if(autocvar_g_grab && !autocvar_sv_cheats) // cheat dragging is used instead
+ {
+ // drag is TRUE if the object can be picked up. While an object is being carried, the Drag() function
+ // must execute for it either way, otherwise it would cause bugs if it went out of the player's trace.
+ // This also makes sure that an object can only pe picked up if in range, but does not get dropped if
+ // it goes out of range while slinging it around.
+
+ float drag;
+ makevectors(self.v_angle);
+ WarpZone_TraceLine(self.origin + self.view_ofs, self.origin + self.view_ofs + v_forward * autocvar_g_sandbox_editor_distance_edit, MOVE_NORMAL, self);
+ if(trace_ent != world)
+ {
+ switch(trace_ent.grab)
+ {
+ case 0: // can't grab
+ break;
+ case 1: // owner can grab
+ if(trace_ent.owner == self || trace_ent.realowner == self)
+ drag = TRUE;
+ break;
+ case 2: // owner and team mates can grab
+ if(trace_ent.owner == self || trace_ent.realowner == self)
+ drag = TRUE;
+ if(!IsDifferentTeam(trace_ent.owner, self) || !IsDifferentTeam(trace_ent.realowner, self))
+ drag = TRUE;
+ break;
+ case 3: // anyone can grab
+ drag = TRUE;
+ break;
+ default:
+ break;
+ }
+ }
+ Drag(trace_ent, drag); // execute dragging
+ }
+
if(self.classname == "player") {
// if(self.netname == "Wazat")
// bprint(self.classname, "\n");
.float clip_size;
.float minelayer_mines;
+.float grab; // 0 = can't grab, 1 = owner can grab, 2 = owner and team mates can grab, 3 = anyone can grab
+
#define PROJECTILE_MAKETRIGGER(e) (e).solid = SOLID_CORPSE; (e).dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_CORPSE
// when doing this, hagar can go through clones
// #define PROJECTILE_MAKETRIGGER(e) (e).solid = SOLID_BBOX
pointparticles(particleeffectnum(strcat("impact_", self.material)), self.origin, '0 0 0', ceil(intensity * 10)); // allow a count from 1 to 10
}
+void sandbox_ObjectFunction_Think()
+{
+ if(autocvar_g_sandbox_editor_free < 2 && self.crypto_idfp)
+ self.grab = 1;
+ else
+ self.grab = 3;
+
+ self.nextthink = time;
+}
+
entity sandbox_ObjectEdit_Get(float permissions)
{
// returns the traced entity if the player can edit it, and world if not
e.skin = 0;
e.material = string_null;
e.touch = sandbox_ObjectFunction_Touch;
+ e.think = sandbox_ObjectFunction_Think;
+ e.nextthink = time;
//e.effects |= EF_SELECTABLE; // don't do this all the time, maybe just when editing objects?
if(!database)