Forum

Player falling through map (brushwork)

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Player falling through map (brushwork)

Postby ScatterBox » Thu Apr 10, 2014 7:25 am

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!
User avatar
ScatterBox
 
Posts: 50
Joined: Sun Oct 13, 2013 7:53 pm

Re: Player falling through map (brushwork)

Postby Spike » Thu Apr 10, 2014 11:55 am

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.
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: Player falling through map (brushwork)

Postby frag.machine » Thu Apr 10, 2014 9:38 pm

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)
User avatar
frag.machine
 
Posts: 2090
Joined: Sat Nov 25, 2006 1:49 pm

Re: Player falling through map (brushwork)

Postby Zop » Tue Jun 24, 2014 2:41 am

I'm wondering about other.owner.origin... I can't tell from this code, but perhaps you want other.origin?
Zop
 
Posts: 5
Joined: Mon Apr 21, 2014 10:41 pm

Re: Player falling through map (brushwork)

Postby Spike » Tue Jun 24, 2014 3:34 am

other.origin + trace_endpos
and that. that's a wtf too.
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: Player falling through map (brushwork)

Postby Cobalt » Tue Jun 24, 2014 6:11 am

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.
User avatar
Cobalt
 
Posts: 445
Joined: Wed Jun 10, 2009 2:58 am
Location: New England, USA


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest