Objective gameplay problem..

Discuss programming in the QuakeC language.
Post Reply
drm_wayne
Posts: 232
Joined: Sat Feb 11, 2012 5:47 pm

Objective gameplay problem..

Post by drm_wayne »

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

Re: Objective gameplay problem..

Post by Spike »

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

Re: Objective gameplay problem..

Post by frag.machine »

+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)
drm_wayne
Posts: 232
Joined: Sat Feb 11, 2012 5:47 pm

Re: Objective gameplay problem..

Post by drm_wayne »

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:
gnounc
Posts: 428
Joined: Mon Apr 06, 2009 6:26 am

Re: Objective gameplay problem..

Post by gnounc »

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.
ceriux
Posts: 2230
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Re: Objective gameplay problem..

Post by ceriux »

i dont think you could do it that way anyways could you? wouldnt it be if (currentobj == x) ?
Ghost_Fang
Posts: 336
Joined: Thu Nov 12, 2009 4:37 am

Re: Objective gameplay problem..

Post by Ghost_Fang »

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;

};
Post Reply