Page 1 of 1

RandomTree ExplosionGenerators

Posted: 27 Jun 2007, 04:09
by Argh
Basically, I think that ExplosionGenerators need randomized trees, so that we can have more variation per event, instead of all of the randomizations being a single event.

How would it work? Like CExpGenSpawner, RandomTree would allow game designers to call up seperate ExplosionGenerators, but with different functionality:

Code: Select all

[randomtree_example_code_ARGH01]
	{
		class=CRandomTree;
		[properties]
		{
		percentile=10, 50, 40;
		explosionGenerator1=custom:ARGH_RANDOM01;
		explosionGenerator2=custom:ARGH_RANDOM02;
		explosionGenerator3=custom:ARGH_RANDOM03;
		}
	water=1;
	air=1;
	ground=1;
	count=30;
	}
percentile would be a series of comma-delimited numbers, adding up to 100. Each entry specifies the chance of a given event happening.

explosionGeneratorX would be used X times, where X = the number of entries in percentile.

Simple, eh? It really shouldn't be that hard to code (just push the explosionGeneratorX entries to an array, get a random number between 1 and 100, see where it falls, play the Generator), and it'd allow for a lot of really cool randomization!

Posted: 27 Jun 2007, 07:49
by theHive
my major suggestion would be not to make the numbers add up to 100, why not make them as a ratio? so 1, 3 would be the same as 25, 75

Posted: 27 Jun 2007, 13:15
by Guessmyname
When I read the title, I thought you wanted trees to burn using a random selection of Explosion Generators... oops...

Other than that, I can see this being very useful, especially to make sure that a certain weapon's explosions don't all look the same.

Posted: 28 Jun 2007, 01:50
by Argh
Well, if my freed-from-source ExplosionGenerators becomes what we get... and we get this... well, let's just say that forest fires could become a lot more interesting to watch. Among other things :-)

I don't like the ratio idea, myself, no offense intended.

Almost anybody would understand the idea of making numbers add up to 100% probability. The ratio idea would cause endless stupid questions from modders, and would be no more useful, at a practical level.

Posted: 28 Jun 2007, 03:04
by AF
Actually the ratio idea closes a hole in your own idea that could be a problem..

For example say I say 20% of the time I want explosion A and 70% of the tim explosion B. What about the extra 10%? Theres no definition as to what todo then is there?

Whereas using the ratio I can use percentages or whatever system I want.

Your own idea falls flat when you want to define more than 100 explosions or want something more specific than 1%

Posted: 28 Jun 2007, 05:25
by Argh
But, er... why would you want more than 100 explosions, or less than 1%? I mean... I'm sorry, but I just don't see anybody with that much free time to burn. Not to mention how slowly it'd probably run, if it had to look at that large of an array...

Posted: 28 Jun 2007, 05:26
by Snipawolf
Guessmyname wrote:When I read the title, I thought you wanted trees to burn using a random selection of Explosion Generators... oops...

Other than that, I can see this being very useful, especially to make sure that a certain weapon's explosions don't all look the same.
You're not the only one >.>

Posted: 28 Jun 2007, 07:39
by KDR_11k
Argh wrote:But, er... why would you want more than 100 explosions, or less than 1%? I mean... I'm sorry, but I just don't see anybody with that much free time to burn. Not to mention how slowly it'd probably run, if it had to look at that large of an array...
Yeah but maybe you want a 0.5% chance on something? Why not just use floats that add up to 1 or as AF said, ratios? The advantage of ratios is that there is no invalid combination whereas percentages would require that you adjust all values accordingly if you change one.

Posted: 28 Jun 2007, 08:10
by Snipawolf
Well, if you want to bring that in it, why don't we add "critical" explosions..

Bigger AOE, more damage, etc..

Whats the point in having a 1/200 chance for a special explosion, but the expl itself does nothing special itself..

Posted: 28 Jun 2007, 08:15
by Argh
I can see doing 0.3001, 0.6999, and having the final total have to equal 1.0... that'd make everybody who's really concerned about absolute precision happy, and still be simple for anybody to use.

I don't see any point in the ratios, though- it'd just cause massive confusion, like the dir system, and it'd be less clean mathematically anyhow- think about the size of the ratio problem, and how it'd have to be ordered, in order to result in correct figures, every time the event fired. I'd just make it so that if the events didn't all add up to 1.0, or were higher than 1.0 then if > A + B + C, etc., then C is chosen... simpler and cleaner, and easier to debug when making the generators, too.

Posted: 28 Jun 2007, 09:51
by theHive
Argh wrote:...
I don't see any point in the ratios, though- it'd just cause massive confusion, like the dir system, and it'd be less clean mathematically anyhow- think about the size of the ratio problem, and how it'd have to be ordered,|
...
huh? mathematically you calculate the sum once, store it, then run the same routine as your one, but a random number between 1 and x rather than 1 and 100

Posted: 28 Jun 2007, 09:59
by zwzsg
Dividing by the sum won't cost major CPU hogs, you known. Normalising allow everybody to use the unit he's most familiar with, fractions of 1 for one, percentile for another, etc... forcing the sum to add to a certain number would add massive confusion and massive math dirtyness because then what happens when the sum doesn't add up becomes unclear. Just let coders code it to be normalised, but keep thinking of it as percentile that must add up.

But of course I am just the idiot for not acknowledging your awesome wisdom on hard core engine optimisation and math purity. :roll:

Posted: 28 Jun 2007, 10:16
by Tobi
Ratios is better because it reduces a reason to give errors/warnings (if percentages don't add up), and with ratios you can still do percentages if you insist on that (by just making it add up to 100), while the other way round doesn't work.

Posted: 28 Jun 2007, 12:28
by AF
Ratios is more mathematically appropriate imo

And even if the user thinks its percentiles but gets it wrong, the ratio system accounts for that and they get what they wanted anyway.

Posted: 28 Jun 2007, 22:20
by Torrasque
Ratio is better because you can still make the 100% method.
With the 100% method, you don't have any choice.

Posted: 29 Jun 2007, 02:16
by Argh
:roll:

I don't care... by all means, ratios... just build the darn thing, so that I can build the ExplosionGenerators.