Pages: [1]
  Print  
Author Topic: Programming issue: adding a timer  (Read 2716 times)
WarMocK
Ok i've posted twice!


Cakes 0
Posts: 2


« on: February 16, 2014, 06:08:18 am »

Hello everyone,
I started working with OA's code some time ago (only programmed tools and user interfaces for Linux on C/C++ basis so far), and I'd like to try something with the weapons.
Specifically, I want to change the gauntlet's "scanning" attack into a sequence of 3 strikes, with a 300 ms intervall, to change the weapon into a sword. Furthermore, I want to add a delay for firing the grenade launcher to simulate the usage of a hand grenade. The problem is: I don't know how to tell the system to wait for a specific time after the fire button has been pressed before the projectile entity is spawned or the hitscan from the gauntlet is executed. You guys got any advise for me? That'd be awesome.

Thanks in advance. :3
Logged
Suicizer
Member
Member
*

Cakes 2
Posts: 398


WWW
« Reply #1 on: February 16, 2014, 07:14:23 am »

My advice; learn to write in C++.
Logged

I'm good at everything but can't do anything...
Neon_Knight
In the year 3000
***

Cakes 49
Posts: 3653


Trickster God.


« Reply #2 on: February 16, 2014, 08:35:51 am »

I've sent a PM to the codeguys. They'll drop here, I guess.

EDIT: You should consider this subforum: http://openarena.ws/board/index.php?board=59.0
« Last Edit: February 16, 2014, 08:38:47 am by Neon_Knight » Logged


"Level Designers are 1 part architect, 1 part artist, 1 part game designer, and 1 part beta tester!" Cliff Bleszinski
Want to contribute? Read this.
stigmha
Nub


Cakes 0
Posts: 24


Bit by bit


WWW
« Reply #3 on: February 17, 2014, 02:40:04 am »

Hi, I am currently out traveling so I am bit limited on resources and time... but here it goes. I think it might be a good idea for you to read up on quake Entities and to run through ioquake3's modding tutorials. Then you should spend some time digging into the implementation of the other weapons and learn how they're implemented.
Logged
WarMocK
Ok i've posted twice!


Cakes 0
Posts: 2


« Reply #4 on: February 17, 2014, 12:26:18 pm »

Alright, found a solution that works, at least in terms of delaying the shot:

I recycled the kamikaze timer a bit, and created a timer that is triggered by the weapon fire function normally, but uses a blank entity that executes the firing effect after a given amount of milliseconds. Tested it with rocket fire and now with lightning fire, looks pretty awesome when you fire 3 rockets in a row, and melting down a foe with 3 lightning bolts ain't too bad either.  Grin

in g_combat.c:
Code:
void Gauntlet_Timer( gentity_t *self, int delay ) {
gentity_t *ent;

ent = G_Spawn();
ent->classname = "gauntlet timer";
VectorCopy(self->s.pos.trBase, ent->s.pos.trBase);
ent->r.svFlags |= SVF_NOCLIENT;
ent->think = FireTheGauntlet;
ent->nextthink = level.time + delay;
}

and

Code:
void FireTheGauntlet( gentity_t *ent ) {
Weapon_LightningFire( ent );
G_FreeEntity(ent);
}

In g_weapon.c, I modified the gauntlet case to:
Code:
case WP_GAUNTLET:
Weapon_LightningFire( ent );
Gauntlet_Timer ( ent, 300 );
Gauntlet_Timer ( ent, 600 );
break;
Only issue I have now is that the spawn vector isn't updated for the fire sequences after the initial shot, which almost made me blow up myself as the second and third rocket exploded inside me.^^
Need to figure that one out tonight, or whenever I feel like coding again.
Logged
Pages: [1]
  Print  
 
Jump to: