Forum

Gui in Game Shop

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Gui in Game Shop

Postby thommoboy » Sat Jan 07, 2012 8:40 am

i was wondering if i could grab some help i already have the impulses and other stuff set up i just don't know how to do a in game gui/hud popup to purchace items
thommoboy
 
Posts: 95
Joined: Mon Nov 21, 2011 6:35 am

Re: Gui in Game Shop

Postby Baker » Sat Jan 07, 2012 6:27 pm

Although this is "possible" with DarkPlaces or FTEQW (and only those engines), it lies in the nearly impossible category. And definitely impossible unless accumulating a few years of determined QuakeC experience.

Helpful threads on the idea of this:

viewtopic.php?t=1560

The Feral mod, using quite a bit of CSQC with DarkPlaces:

http://quake-1.com/quakec-gallery/feral.rar (You'll have to read the read me on the controls.)

But again, for all practical purposes ... it isn't really "possible" by any reasonable definition of the word.
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: Gui in Game Shop

Postby ceriux » Sun Jan 08, 2012 7:32 am

you could do a hack like thing and display it with v_wep? just make it go into chase active, change the angles of the cam on your engine (im assuming psp?) (if you cant do that there's a lot of camera tutorials, and threads around for qc) and do it that way, just make them not be able to move till self.menu = 0, then reset the players normal movement and impulses to normal. im assuming for your impulses you are using a seperate impulse list?
User avatar
ceriux
 
Posts: 2223
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Re: Gui in Game Shop

Postby Baker » Sun Jan 08, 2012 8:22 am

I think Ceriux is saying draw that screen on the wall in hidden part of the map and make the camera be there and change the impulses to do different things.

Interesting idea, really. Very hacky and maybe a little cheesy, but only you would know how crappily you cheated.

Then again, the Kurok title scene looks fine. And that title scene is actually a demo playing in a small map but you have to actually start dissecting the mod to come to that conclusion as no one would ever guess that.
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: Gui in Game Shop

Postby thommoboy » Mon Jan 09, 2012 2:12 am

that would be good any links or tips on how i could do it.

also how would it work having an in map gui style thing any examples?
thommoboy
 
Posts: 95
Joined: Mon Nov 21, 2011 6:35 am

Re: Gui in Game Shop

Postby Baker » Mon Jan 09, 2012 2:37 am

You know how to place a weapon in a map, right?

{
"classname" "weapon_rocketlauncher"
"origin" "-531 1962 -156"
}

The QuakeC makes it so that if you walk over the floating rocket launcher, it adds it to your inventory.

Make yourself some purchase_rocketlauncher entities in QuakeC that is a copy of the weapon_rocketlauncher code except that it subtracts your $$$ or whatever and teleports you away or changes the level or whatever. If you are able to do that, then you could make that entity into a display on the wall. You'll have do a lot of working through the mechanics and learning about mapping and triggers to make it happen.
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: Gui in Game Shop

Postby thommoboy » Mon Jan 09, 2012 2:49 am

can you code an example for me i sort of get what your talking about but how would i link it so that worldcraft could read it?
thommoboy
 
Posts: 95
Joined: Mon Nov 21, 2011 6:35 am

Re: Gui in Game Shop

Postby thommoboy » Mon Jan 09, 2012 3:03 am

okay ive got it how do i trigger an impulse using a button?
thommoboy
 
Posts: 95
Joined: Mon Nov 21, 2011 6:35 am

Re: Gui in Game Shop

Postby Baker » Mon Jan 09, 2012 3:26 am

Code: Select all
void() weapon_rocketlauncher =
{
   precache_model ("progs/g_rock2.mdl");
   setmodel (self, "progs/g_rock2.mdl");
   self.weapon = 3;
   self.netname = "Rocket Launcher";
   self.touch = weapon_touch;
   setsize (self, '-16 -16 0', '16 16 56');
   StartItem ();
};


This function in items.qc sets weapon_touch to be to what occurs if you touch the entity (the weapon_rocketlauncher entity).

Duplicate it like this ...

Code: Select all
void() purchase_rocketlauncher =
{
   precache_model ("progs/g_rock2.mdl");
   setmodel (self, "progs/g_rock2.mdl");
   self.effects = EF_BRIGHTFIELD; // Put an effect on this entity so is not mistaken for regular rocket launcher pickup
   self.weapon = 3;
   self.netname = "Rocket Launcher";
   self.touch = purchase_touch;  // Changed from weapon_touch to purchase_touch
   setsize (self, '-16 -16 0', '16 16 56');
   StartItem ();
};


Add purchase_touch below the weapon_touch function (why? So the QuakeC compiler already knows about this function so later when it finds your purchase_rocketlauncher entity that references "purchase_touch", it will already know what a "purchase_touch" is.)

Code: Select all
void() purchase_touch =
{
   local   float   newitem, cost;

   if (!(other.flags & FL_CLIENT)) // If a non-client touches this (like a monster or something else, get out!)  This is only for players
      return;

   if (self.classname == "weapon_rocketlauncher")
   {
      if (other.items & IT_ROCKET_LAUNCHER) // "other" is the player that touched entity.  If player's items include a rocketlauncher already, get out!
         return;
      
      new = IT_ROCKET_LAUNCHER; // Set new weapon to add to inventory as rocket launcher
      cost = 5;
   }

// If we got here, you have a new item.  Play a sound.

   sound (other, CHAN_ITEM, "weapons/pkup.wav", 1, ATTN_NORM);
   stuffcmd (other, "bf\n"); // Flash the client's screen a little so they know something happened

   other.items = other.items | new;
   other.health = other.health - cost; // Remove 5 health for obtaining rocket launcher.  Change this however you see fit, but I guess player is donating blood right now ;)

   activator = other; // Next 2 lines of code are necessary for entity / trigger functionality expected from all entities.
   SUB_UseTargets();            // fire all targets / killtargets

};


Who knows ... the above code might even work. If it does, placing a "purchase_rocketlauncher" entity in a map would appear as a rocket launcher with a field around it and grabbing it would cost 5 health. Change 5 to whatever value and change other.health to whatever your $$$ field is. But this would get you started with the idea ...
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: Gui in Game Shop

Postby Baker » Mon Jan 09, 2012 3:36 am

thommoboy wrote:can you code an example for me i sort of get what your talking about but how would i link it so that worldcraft could read it?


That is expanding the scope way too far. Worldcraft has a definition file .fgd and you will have to open that in notepad and add any entity classes you make in there. Mostly find weapon_rocketlauncher and carefully creating a duplicate within the text file and renaming to purchase_rocketlauncher where applicable and then saving it. Be sure to back it up first.

To learn about buttons work (on the left side near the button there is a link called "buttons") under "Complex Entities":

http://www.quake-1.com/wc16a-tutorial/

There are other mapping tutorials here: http://www.bspquakeeditor.com/tutorials.php

Without any of my own personal reference material available, I can't remember how you setup a button to trigger as I don't map often, it is easy but I don't have any of my stuff available (it might be a "trigger_touch" or "trigger_push" and setting the target to purchase_touch but again I don't map enough for it to be hardwired into my head and I think I'm off a bit in these last 2 sentences.. You'd have to change the QuakeC just a little eliminating " if (self.classname == "weapon_rocketlauncher")" since a button will not have weapon_rocketlauncher as the classname.

Maybe someone else can explain.
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: Gui in Game Shop

Postby thommoboy » Mon Jan 09, 2012 5:56 am

i get and error
unknown value purchase_touch


and for the purchase_touch does it go directly under the above code?
thommoboy
 
Posts: 95
Joined: Mon Nov 21, 2011 6:35 am

Re: Gui in Game Shop

Postby Baker » Mon Jan 09, 2012 12:33 pm

You need that purchase_touch function ABOVE purchase_rocketlauncher (anywhere above). That way QuakeC knows what a purchase_touch is when it hits that code.

/There is an alternate solution to the error but I don't want to muddy the water.
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: Gui in Game Shop

Postby Spirit » Mon Jan 09, 2012 2:30 pm

thommoboy wrote:okay ive got it

How about you share your findings or experiences with other people then? Think about how nice it would be for you if others had encountered your problems and then posted their solutions.
Improve Quaddicted, send me a pull request: https://github.com/SpiritQuaddicted/Quaddicted-reviews
Spirit
 
Posts: 1031
Joined: Sat Nov 20, 2004 9:00 pm

Re: Gui in Game Shop

Postby gnounc » Mon Jan 09, 2012 7:33 pm

Baker wrote:Make yourself some purchase_rocketlauncher entities in QuakeC that is a copy of the weapon_rocketlauncher code except that it subtracts your $$$ or whatever and teleports you away


It is dangerous to go alone. Here, take this.
User avatar
gnounc
 
Posts: 424
Joined: Mon Apr 06, 2009 6:26 am


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest