Player falling through map (brushwork)

Discuss programming in the QuakeC language.
Post Reply
ScatterBox
Posts: 50
Joined: Sun Oct 13, 2013 7:53 pm

Player falling through map (brushwork)

Post by ScatterBox »

Hello all. :) I'm back with another problem unfortunately...

I've been having a weird bug that I cannot seem to fix with my mod. Whenever a certain function happens (code below) the player literally just falls through the map.. it's like a wall breach in Call of Duty (sorry for the bad reference) or something weird like that.. Here's what I have setup code wise. One thing that might be good to note is this mod is a Slender mod for PSP.

What I'm trying to do is make it to where when the player looks at the monster (Slenderman in this case) it calls a function called "slender_spotted" which teleports the monster forward by a certain amount. (and plays a sound and reduces the players health as well)

Here's the code that checks to see if the player is looking at the monster:

Code: Select all

void () iseeslendy =
{
	local   entity  head;
	
	if (self.view_ofs == '0 0 0')
                return;         // intermission or finale
   if (self.deadflag)
                return;

   head = findradius(self.origin, 256);

      while (head)
        {
                if (head.classname == "slender")
                {
                     if ((visible(head)) && (infront(head)) && (self.health > 0))
                        {
                                spotted = 1;
                        }
                }
                head = head.chain;
        }
				
}
Here's the function that the code above calls if spotted = 1:

Code: Select all

void() slender_spotted =
{
	if(spotted_time > time || self.health <= 0)
	{
		return;
	}else
	{
		makevectors(other.v_angle);
		traceline (other.owner.origin , (other.owner.origin+(v_forward * 100)) , FALSE , other);
		sound (self, CHAN_WEAPON, "misc/screme.wav", 1, ATTN_STATIC);
		setorigin(other,other.origin + trace_endpos);
		sprint (self, "Slender teleported successfully!!!!!!!!1111ONEONEONE11!\n");
		self.health = self.health - 10;
		spotted_time = time + 12;
	}
}
Sorry for the sloppy code.. it's a bit of a rough draft I guess you could say... XD

Anyways, what happens is slender_spotted gets called and both the monster and the player fall under the map, I do see the sprint when this happens, so I know it's the teleporting that causes it, which doesn't make sense to the slightest to me. Anyone know why this could be happening? Thanks for the help as always!
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Re: Player falling through map (brushwork)

Post by Spike »

traceline isn't enough.
ideally use tracebox instead, then you know you won't enter inside the player.
if your engine of choice is shit, then you can use droptofloor instead, and revert the teleport on failure.
frag.machine
Posts: 2126
Joined: Sat Nov 25, 2006 1:49 pm

Re: Player falling through map (brushwork)

Post by frag.machine »

Also, try adding '0 0 1' to the destination origin. It may help.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
Zop
Posts: 5
Joined: Mon Apr 21, 2014 10:41 pm

Re: Player falling through map (brushwork)

Post by Zop »

I'm wondering about other.owner.origin... I can't tell from this code, but perhaps you want other.origin?
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Re: Player falling through map (brushwork)

Post by Spike »

other.origin + trace_endpos
and that. that's a wtf too.
Cobalt
Posts: 445
Joined: Wed Jun 10, 2009 2:58 am
Location: New England, USA
Contact:

Re: Player falling through map (brushwork)

Post by Cobalt »

Most likely the 2 entities are sharing the same space together after the setorigin is performed....which means the models have different sizes at least in their absmin_x / absmax_x values. Any sharing of an ent's bounding box with another solid will result in the ent(s) dropping out of the world model , unless the engine has an "unstick" cvar, such as Darkplaces.


I guess other.owner is the other entity that "other" is suppose to be trasported against. Assuming the trace only takes place facing the front of the 2 entities, we ought to be able to get away with just adjusting the _x value of the new origin.

Code: Select all

}else
   {
      local vector adj;
      makevectors(other.v_angle);
      traceline (other.owner.origin , (other.owner.origin+(v_forward * 100)) , FALSE , other);
      sound (self, CHAN_WEAPON, "misc/screme.wav", 1, ATTN_STATIC);
      adj = trace_endpos;
      adj_x = trace_endpos_x - (other.maxs_x * 0.5); // Position other's .origin its maximum width from its own origin from the endpos 
      setorigin(other,other.origin + (adj - 2)); // Add a buffer cushion , usually 1-2 Quake units just to be safe
      sprint (self, "Slender teleported successfully!!!!!!!!1111ONEONEONE11!\n");
      self.health = self.health - 10;
      spotted_time = time + 12;
   }


Oops, made a boo boo. absmax is the actual coordinates with respect to world, so actually you use the ents .maxs_x * 0.5 ...updated.
Post Reply