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

#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 [NEED HELP] Locked down Xonotic build for use in schools? Shaun_Dark_Lord 9 3,120 08-22-2023, 02:59 AM
Last Post: Shaun_Dark_Lord
Rainbow What's your favorite color? Or which color you use in game? Kotangens 1 1,562 09-01-2022, 06:52 PM
Last Post: ballerburg9005
Question Quake Expo qwertyuiop924 5 5,471 06-17-2016, 07:08 PM
Last Post: qbism
  Teamspeak and/or mumble servers to use for Xonotic? rocknroll237 7 10,622 06-06-2013, 05:18 AM
Last Post: Smilecythe
Question Close quarters combat argument: Xonotic vs Quake W4RP1G 14 20,578 10-13-2012, 04:41 AM
Last Post: Smilecythe
Bug Does anyone actually use the laser alt-fire? W4RP1G 20 17,087 04-08-2012, 12:35 PM
Last Post: ==Troy==
  [Poll] How often do you use Rocket Launcher's Alt Fire? Loafers 9 9,540 04-05-2012, 07:38 AM
Last Post: Majki
Information Quake Expo 2011 Chip 13 12,866 06-20-2011, 09:38 AM
Last Post: Cortez666
  Use Xfire and share Xonotic! Exitium 13 16,706 05-09-2011, 02:13 PM
Last Post: BARTUC

Forum Jump:


Users browsing this thread:
1 Guest(s)

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