![]() |
Xplosives so reliable: How do I do rand(); or use it in quake C? - Printable Version +- Xonotic Forums (https://forums.xonotic.org) +-- Forum: Community (https://forums.xonotic.org/forumdisplay.php?fid=6) +--- Forum: Xonotic - General (https://forums.xonotic.org/forumdisplay.php?fid=18) +--- Thread: Xplosives so reliable: How do I do rand(); or use it in quake C? (/showthread.php?tid=2190) |
Xplosives so reliable: How do I do rand(); or use it in quake C? - XonoxSeven - 09-26-2011 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); Didn't work, messed with the initial nade firing instead, trying without the W_SetupShot call now. RE: Xplosives so reliable: How do I do rand(); or use it in quake C? - Mr. Bougo - 09-26-2011 I suggest you read the existing source code, and perhaps the QC intro for the basics. http://dev.xonotic.org/projects/xonotic/wiki/Introduction_to_QuakeC RE: Xplosives so reliable: How do I do rand(); or use it in quake C? - XonoxSeven - 09-26-2011 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 ![]() RE: Xplosives so reliable: How do I do rand(); or use it in quake C? - mand1nga - 09-26-2011 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 RE: Xplosives so reliable: How do I do rand(); or use it in quake C? - PinkRobot - 09-27-2011 (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. |