Forum

Objective gameplay problem..

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Objective gameplay problem..

Postby drm_wayne » Wed May 22, 2013 10:18 pm

Im trying to get objective based singleplayer to work, the level exit is blocked by a
func_episodewall and should go away when the player found at least 6 objectives...

but for some reasons this didnt work...
Can anybody help?

in my custom defs2 there is

Code: Select all
float currentobjs;


The pickup:

Code: Select all
void() OBJ_Pickup =
{   
   currentobjs = currentobjs + 1;  // adds one Objective
   sprint(other, "You collected ");
   sprint(other, "a Ojective!\n");
   sound(other, CHAN_AUTO, "pickup_medikit.wav", 1, ATTN_NORM);
   stuffcmd (other, "bf\n");
   remove(self);
};

void() obj_book =
{
   Precache_Set ("progs/pickups/book.mdl");
   self.netname = "OBJ_Book";
   self.touch   = player_touch;
   self.th_action = OBJ_Pickup;
   self.solid = SOLID_BBOX;
    setsize(self, '-11 -11 0', '11 11 55');
};


an the func_episodewall:

Code: Select all
void() func_episodewall =
{
   
   setmodel (self, self.model);
   self.angles = '0 0 0';
   self.solid = SOLID_BSP;
   self.movetype = #MOVETYPE_PUSH;

  if (currentobjs = currentobjs == 6) // if we have found 6 of them
   remove(self);                         // go away...
};
User avatar
drm_wayne
 
Posts: 232
Joined: Sat Feb 11, 2012 5:47 pm

Re: Objective gameplay problem..

Postby Spike » Wed May 22, 2013 11:51 pm

tbh, just have your pickups trigger some trigger_counter. and have the trigger_counter killtarget some func_wall.

conditions inside spawnfunctions other than to check the fields the mapper specified are generally pointless. anything that checks other entities inside the spawn function itself is stupid, as the entities that it refers to are not always going to have been spawned yet.
what your code is trying to do is check to see if the player has grabbed any items before any players are even on the map. and ONLY before there are players on the map. you'd need a think function... or you can just use the trigger mechanism that I already mentioned.
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: Objective gameplay problem..

Postby frag.machine » Thu May 23, 2013 12:27 am

+1 to the trigger_count approach.
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: Objective gameplay problem..

Postby drm_wayne » Thu May 23, 2013 4:16 am

im adding a thinkfunction...

I dont have triggers in the game (only a trigger_command for fog) because everything is coded from scratch, the qc doesnt have anything from the old quake qc :o :wink:
User avatar
drm_wayne
 
Posts: 232
Joined: Sat Feb 11, 2012 5:47 pm

Re: Objective gameplay problem..

Postby gnounc » Thu May 23, 2013 6:33 am

drm_wayne wrote:I dont have triggers in the game

I believe Spike meant this:
Code: Select all
       currentobjs = currentobjs + 1;  // adds one Objective

which you were doing already.

and he suggested you move

Code: Select all
  if (currentobjs = currentobjs == 6) // if we have found 6 of them
   remove(self);   


from func_episodewall's spawning function

to void() OBJ_Pickup()

changing where it says self of course, to accurately point to the func_wall.




though I WOULD like to ask about:
Code: Select all
  if (currentobjs = currentobjs == 6) // if we have found 6 of them


is that assignment intentional?
I'm doubting it is.

-best of luck.
User avatar
gnounc
 
Posts: 424
Joined: Mon Apr 06, 2009 6:26 am

Re: Objective gameplay problem..

Postby ceriux » Thu May 23, 2013 2:17 pm

i dont think you could do it that way anyways could you? wouldnt it be if (currentobj == x) ?
User avatar
ceriux
 
Posts: 2223
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Re: Objective gameplay problem..

Postby Ghost_Fang » Tue May 28, 2013 2:44 am

Your func_episodewall is only checking to see if currentobjs is 6 upon spawning.
Give it a think:


Code: Select all
void() CheckObjectives =
{
  if (currentobjs = currentobjs == 6)
   remove(self);                       
  self.think = CheckObjectives;
  self.nextthink = time + 0.1;          //Check once a frame
};

void() func_episodewall =
{
   
   setmodel (self, self.model);
   self.angles = '0 0 0';
   self.solid = SOLID_BSP;
   self.movetype = #MOVETYPE_PUSH;
   self.think = CheckObjecttives;
   self.nextthink = time + 0.1;

};
Ghost_Fang
 
Posts: 336
Joined: Thu Nov 12, 2009 4:37 am


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest