Create an account


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Xplosives so reliable: How do I do rand(); or use it in quake C?

#1
I would like to hack the explosive weapons abit. They are very reliable: every pressure trigger always works 100 percent of the time.

I would like to add a: x = rand(int(99)); if (x > 3) { (Normal explode stuff) } else { prints"oops nade/rocket didn't go off!). But i don't know the exact syntax and good practices for this in quakeC.

Another idea I had, a more difficult one, is to add fragmentaries to the grenade launcher projectile(s), that means spawing new projectiles (I guess low velocity ballistics bullets) in random directions. So this means I need rand, and I guess a foreach (untill x amount of bullets have been shot in all directions), and set how hard the bullets will hurt, plus a toggle to turn this feature on/off.

Hmm, maybe I should look at the shotgun code and use that with a mega huge spread (what is 360 degree spread in all directions?).
Code:
    RadiusDamage (self, self.realowner, autocvar_g_balance_grenadelauncher_primary_damage, autocvar_g_balance_grenadelauncher_primary_edgedamage, autocvar_g_balance_grenadelauncher_primary_radius, world, autocvar_g_balance_grenadelauncher_primary_force, self.projectiledeathtype, other);


    //Frags
    if (autocvar_g_balance_grenadelauncher_primary_frag_bullets > 0) {
    float    sc;
    float    ammoamount;
    float    bullets;
    float    d;
    float    f;
    float    spread;
    float    bulletspeed;
    float    bulletconstant;
    
    bullets = autocvar_g_balance_grenadelauncher_primary_frag_bullets;
    d = autocvar_g_balance_grenadelauncher_primary_frag_damage;
    f = autocvar_g_balance_grenadelauncher_primary_frag_force;
    spread = autocvar_g_balance_grenadelauncher_primary_frag_spread;
    bulletspeed = autocvar_g_balance_grenadelauncher_primary_frag_speed;
    bulletconstant = autocvar_g_balance_grenadelauncher_primary_frag_bulletconstant;
    
    W_SetupShot (self, autocvar_g_antilag_bullets && bulletspeed >= autocvar_g_antilag_bullets, 5, "weapons/shotgun_fire.wav", CH_WEAPON_A, d * bullets);
    for (sc = 0;sc < bullets;sc = sc + 1)
        fireBallisticBullet(w_shotorg, w_shotdir, spread, bulletspeed, 5, d, 0, f, WEP_GRENADE_LAUNCHER, 0, 1, bulletconstant);
    endFireBallisticBullet();
    }
    //
    
    remove (self);
}

Didn't work, messed with the initial nade firing instead, trying without the W_SetupShot call now.

#2
I suggest you read the existing source code, and perhaps the QC intro for the basics.

http://dev.xonotic.org/projects/xonotic/..._to_QuakeC
[Image:http://i.imgur.com/4XODR.png]640K ought to be enough for anybody.
     ― Linux Torvalds

#3
Damn, I dunno then :/

How do I get one projectile to spawn another when it xplodes?
Trying this now: (changint w_shotorg to self, hopefully that means the projectile)
for (sc = 0;sc < bullets;sc = sc + 1)
fireBallisticBullet(self, w_shotdir, spread, bulletspeed, 5, d, 0, f, WEP_GRENADE_LAUNCHER, 0, 1, bulletconstant);
//endFireBallisticBullet();
in function W_Grenade_Explode (line 9),
w_grenadelauncher.qc:46: error: type mismatch on parm 1 - (entity should be vector)
w_common.qc:359: fireBallisticBullet is defined here
in function w_glauncher (line 6),

Damn, it's not happening
Sad

#4
oh well, w_shotorg judging by its name it's quite probably a vector whereas self is an entity

always take a look at the definition of functions, variables, global, etc; if you're using the wrong types the code just won't compile

#5
(09-26-2011, 04:21 PM)mand1nga Wrote: oh well, w_shotorg judging by its name it's quite probably a vector whereas self is an entity

That is the single best description of MikeeUSA that I have heard so far. Thank you for that.
"Yes, there was a spambot some time ago on these forums." - aa



Possibly Related Threads...
Thread Author Replies Views Last Post
Question Quake Expo qwertyuiop924 5 2,394 06-17-2016, 07:08 PM
Last Post: qbism
Question Close quarters combat argument: Xonotic vs Quake W4RP1G 14 13,574 10-13-2012, 04:41 AM
Last Post: Smilecythe
Information Quake Expo 2011 Chip 13 7,893 06-20-2011, 09:38 AM
Last Post: Cortez666

Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum software by © MyBB original theme © iAndrew 2016, remixed by -z-