Quake3World.com Forums
     Programming Discussion
        Parametric weapon


Post new topicReply to topic
Login | Profile | | FAQ | Search | IRC




Print view Previous topic | Next topic 
Topic Starter Topic: Parametric weapon

Veteran
Veteran
Joined: 17 May 2011
Posts: 159
PostPosted: 09-16-2014 04:59 AM           Profile Send private message  E-mail  Edit post Reply with quote


Hello !

I actually also posted this message at the ioquake3 forum, I'm adding it here at the same time :)

I'm currently working on a dirty game prototype for a contest, and I might need a bit of help !

in my game, the player handles only one weapon, but it's characteristics will change as he picks up and plugs in some items.
Here are the 5 parameters :
- precision / spread
- number of bullets ( from one to 'x', so you can create some kind of shotgun)
- power + speed
- reload time
- heat / cool-off speed

these parameters are basically ints, maybe floats, I don't know yet.

Concretely, since I'm short on time, I was going to modify the machinegun to make it the "host" of this weapon ...
... And that's it, I don't know where to go to continue !

Obviously these parameters have to be shared by client and server. In which struct should I host it ? Will putting it in gentity_t->entityState_t would be good ?

I'll later have to manage an inventory for the player, I think that kind of data could be in the same place ...

I'm sure I'll have other questions coming ><

Thanks for reading, and sorry for my ignorance :)

cheers !



_________________
My blog - My portfolio
---------------------
MJDM2 - DmeatSP01 - DmeatSP02


Top
                 

Commander
Commander
Joined: 22 Jul 2011
Posts: 139
PostPosted: 10-02-2014 10:16 AM           Profile Send private message  E-mail  Edit post Reply with quote


Hello, I don't know exactly how to do it but I'll try to help.

Perhaps there is no need to add variables as they will be items and if I remember correctly they are stored in inventory (playerState_t).

As for changing the MG, check out FireWeapon, inside it there is a call to a function for each weapon, I would copy and edit Butllet_Fire.

By the way, what contest is it?




Top
                 

Veteran
Veteran
Joined: 17 May 2011
Posts: 159
PostPosted: 10-09-2014 12:21 PM           Profile Send private message  E-mail  Edit post Reply with quote


Hello ! Sorry for the inertia !
I was actually quite panicked when I posted this message, as I just finished that big part of my game about the level generation I couldn't plan calmly what I was going to do.

So 3 weeks later, I made some progress on that subject. The parametric weapon is basically implemented. I've let down the heat management for the moment. The inventory system is working but the UI of it is not ready.

UglyFoot wrote:
Perhaps there is no need to add variables as they will be items and if I remember correctly they are stored in inventory (playerState_t).


Using existing variables in playerstate means recycling the stats[], persistant[], powerups[] and ammo[] arrays, which might have been fine but I prefer building my own systems whithout damaging or deleting the existing ones ... So I added stuff to the playerstate :
- The weapon's parameters (float precision, float power, int bullets, float reloadtime, and float heat)
- The weapon's installed item slots (array of 6 ints)
- The player's inventory (array of 16 ints)

I had to modify qcommon/msg.c to get this data across the network, and it seams to work ! I struggled a lot during the past 48 hours and the final implementation isn't very good looking but it works :)

UglyFoot wrote:
As for changing the MG, check out FireWeapon, inside it there is a call to a function for each weapon, I would copy and edit Butllet_Fire.


Yup, so what I did was to add a new weapon and make it the default spawning weapon for the player. Then I plugged a custom 'fire' function that uses the machinegun's 'bullet_fire' function. When there are multiple bullets to be fired, I just use this function multiple times. I haven't stress-tested that yet, but since the shotgun is coded quite differently for network reasons, I could have problems in the future.

UglyFoot wrote:
By the way, what contest is it?


It's a french contest taking place for the "TGS" (which means Toulouse game Show, not Tokyo game show). There is Frédéric Raynal among the Judges !


I made some nice progress today, but I'm already stuck on a new thing : I added a function that drops items from the inventory, and it seems to work fine server side, but client side the dropped item seems not synchronized, or actually it is sometime synchronized the first time, but the next drops are invisible and there is no sound / feedback icon when I pick them up (but they do get picked up server-side, I can tell from my G_Printfs inside my pickup function).

Have you or someone used a lot the "drop_item" functions ? Right now I'm clueless :)



_________________
My blog - My portfolio
---------------------
MJDM2 - DmeatSP01 - DmeatSP02


Top
                 

Veteran
Veteran
Joined: 17 May 2011
Posts: 159
PostPosted: 10-10-2014 01:57 AM           Profile Send private message  E-mail  Edit post Reply with quote


I made some progress by freeing unused entities, but things are still somehow random. I can drop an item, but if I pick it up and drop it again it's absent from cgame, it seams.



_________________
My blog - My portfolio
---------------------
MJDM2 - DmeatSP01 - DmeatSP02


Top
                 

Veteran
Veteran
Joined: 17 May 2011
Posts: 159
PostPosted: 10-10-2014 04:17 AM           Profile Send private message  E-mail  Edit post Reply with quote


Solved.



What happened ?

Well, Since my items can be collected only once and don't respawn, I use the G_FreeEntity function. But used it too early, right before the EV_ITEM_PICKUP is sent in the Touch_Item function in g_items.c. Now I free the entity right after and everything works fine. Yay ! Actually, I don't know how it could work once in a while before.

Now, I have to plug in the inventory to my inventory screen. I'm crossing fingers to hope I won't run into strange problems :)



_________________
My blog - My portfolio
---------------------
MJDM2 - DmeatSP01 - DmeatSP02


Top
                 

Commander
Commander
Joined: 22 Jul 2011
Posts: 139
PostPosted: 10-10-2014 07:04 AM           Profile Send private message  E-mail  Edit post Reply with quote


Good :up: :)




Top
                 

Veteran
Veteran
Joined: 17 May 2011
Posts: 159
PostPosted: 10-10-2014 07:19 AM           Profile Send private message  E-mail  Edit post Reply with quote


Thanks for the support :)

I'm looking for somethin, but I'm not sure if it exists :
Is it possible to access cg from ui ? I've seen some Cvar read / write functions (trap_Cvar_VariableValue and trap_Cvar_SetValue). I could maybe write my own thing, but it sounds risky :)



_________________
My blog - My portfolio
---------------------
MJDM2 - DmeatSP01 - DmeatSP02


Top
                 

Commander
Commander
Joined: 22 Jul 2011
Posts: 139
PostPosted: 10-10-2014 07:30 AM           Profile Send private message  E-mail  Edit post Reply with quote





Top
                 

Veteran
Veteran
Joined: 17 May 2011
Posts: 159
PostPosted: 10-11-2014 12:19 AM           Profile Send private message  E-mail  Edit post Reply with quote


Thanks for the link, it's a good read !

I've skipped some details, but I haven't seen anything that I want, for the moment.

What I need is some information stored in cg.predictedPlayerState, not in a Cvar.

I'll continue scratching :)



_________________
My blog - My portfolio
---------------------
MJDM2 - DmeatSP01 - DmeatSP02


Top
                 

Veteran
Veteran
Joined: 17 May 2011
Posts: 159
PostPosted: 10-12-2014 07:42 AM           Profile Send private message  E-mail  Edit post Reply with quote


Okay so Things work as I want using Cvars and the various trap functions. It's a little bit heavy code wise, but nevermind.

I have a new question !

In a menu, is it possible to handle right mouse button to do something ?
Left mouse buttons triggers 'QM_ACTIVATED' event by default and executes the button's callback function.

I could handle some special key event using the *.menu.key function, but it's not related to the currently active item of the menu, it seems.



_________________
My blog - My portfolio
---------------------
MJDM2 - DmeatSP01 - DmeatSP02


Top
                 

Commander
Commander
Joined: 22 Jul 2011
Posts: 139
PostPosted: 10-15-2014 01:28 PM           Profile Send private message  E-mail  Edit post Reply with quote


My conclusion is the same as you. There are two events besides QM_ACTIVATED but they are triggered when the mouse moves over or away. I would try to do it without the right button.




Top
                 

Veteran
Veteran
Joined: 17 May 2011
Posts: 159
PostPosted: 10-17-2014 04:21 AM           Profile Send private message  E-mail  Edit post Reply with quote


I actually managed to handle the right mouse click in a menu !

I added a "callback2" function pointer in the menucommon_s struck, and somehow plugged it in and it works !

I managed to accomplish my objectives and I now have somewhat of a game ! I'll make a video soon to share :)



_________________
My blog - My portfolio
---------------------
MJDM2 - DmeatSP01 - DmeatSP02


Top
                 

Commander
Commander
Joined: 22 Jul 2011
Posts: 139
PostPosted: 10-22-2014 01:39 PM           Profile Send private message  E-mail  Edit post Reply with quote


Good, I'm surprised that it worked but it's good to know :)




Top
                 

Veteran
Veteran
Joined: 17 May 2011
Posts: 159
PostPosted: 10-29-2014 02:18 AM           Profile Send private message  E-mail  Edit post Reply with quote


(I can't find the 'new topic' button ! is this normal ?)

Alright I'm on my final rush on this project, I hope I'll make it :)

I have a question :
For the moment, I've been using playerState_t to store my inventory and other stuff.

To balance the game, I've decided to split it into rounds. A game takes place in 3 rounds. I want the player to start the next round with all the stats, health and inventory he had previously.

What I tried to do is to set the inventory to empty only when a player connects and when he dies.
The inventory is cleared and reset when the player dies (this works). But when I tried to init the values inside the 'ClientConnect' function (in g_client.c) (which has the handy 'firstTime' variable), things get done (each inventory slot is set to -1), but when I check after I spawn, it has actually changed to 0.

This works when I place the initialization in the 'clientBegin' function, But this means the inventory gets reset when I move on to the next round of the game.

So, in order to keep all the info I want, should I move everything into ClientPersistant_t or CLientSession_t ?



_________________
My blog - My portfolio
---------------------
MJDM2 - DmeatSP01 - DmeatSP02


Top
                 

The hell good boy
The hell good boy
Joined: 22 Jun 2011
Posts: 1922
PostPosted: 10-29-2014 03:43 AM           Profile   Send private message  E-mail  Edit post Reply with quote


D-Meat wrote:
(I can't find the 'new topic' button ! is this normal ?)

Post topic would do the job. It is right under user controls links and under list of topics or under list of posts next to post reply button. Do you see that?



_________________
[ Websites | Facebook | Twitter | YouTube | Instagram ]
When you feel the worst, turn to the sun and all the shadows will fall behind you.” - John Lennon


Top
                 

Veteran
Veteran
Joined: 17 May 2011
Posts: 159
PostPosted: 10-29-2014 04:20 AM           Profile Send private message  E-mail  Edit post Reply with quote


CZghost wrote:
D-Meat wrote:
(I can't find the 'new topic' button ! is this normal ?)

Post topic would do the job. It is right under user controls links and under list of topics or under list of posts next to post reply button. Do you see that?


Ah, got it when I'm reading a topic. But there's none when I'm looking at the topic list ! (in any category).



_________________
My blog - My portfolio
---------------------
MJDM2 - DmeatSP01 - DmeatSP02


Top
                 

The hell good boy
The hell good boy
Joined: 22 Jun 2011
Posts: 1922
PostPosted: 10-29-2014 04:43 AM           Profile   Send private message  E-mail  Edit post Reply with quote


Attachment:
q3w_post-topic.jpg
q3w_post-topic.jpg [ 22.99 KB | Viewed 10906 times ]

Here



_________________
[ Websites | Facebook | Twitter | YouTube | Instagram ]
When you feel the worst, turn to the sun and all the shadows will fall behind you.” - John Lennon


Top
                 

Veteran
Veteran
Joined: 17 May 2011
Posts: 159
PostPosted: 10-29-2014 05:17 AM           Profile Send private message  E-mail  Edit post Reply with quote


:tard: sorry :tard: :puke: :dork:

back to topic now :)



_________________
My blog - My portfolio
---------------------
MJDM2 - DmeatSP01 - DmeatSP02


Top
                 

Veteran
Veteran
Joined: 17 May 2011
Posts: 159
PostPosted: 10-29-2014 07:15 AM           Profile Send private message  E-mail  Edit post Reply with quote


D-Meat wrote:
So, in order to keep all the info I want, should I move everything into ClientPersistant_t or CLientSession_t ?


Moved what I needed to ClientSession_t (ent->client->sess). Everything works fine. Yay !



_________________
My blog - My portfolio
---------------------
MJDM2 - DmeatSP01 - DmeatSP02


Top
                 
Quake3World.com | Forum Index | Programming Discussion


Post new topic Reply to topic


cron
Quake3World.com
© ZeniMax. Zenimax, QUAKE III ARENA, Id Software and associated trademarks are trademarks of the ZeniMax group of companies. All rights reserved.
This is an unofficial fan website without any affiliation with or endorsement by ZeniMax.
All views and opinions expressed are those of the author.