FlameThrower: Proposed Modification - Page 2

FlameThrower: Proposed Modification

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

User avatar
TechnoTone
Posts: 165
Joined: 23 Aug 2005, 22:02

Post by TechnoTone »

Argh wrote:I am apparantly too much of a C++ newbie to understand what an "overloaded function" is, or why it won't take "7 arguments".
An overloaded function is one that has multiple definitions, each with different parameters. So, you could have a function with 2 different definitions, one that accepts just a single string parameter and a second variant that accepts a string and an int parameter, for example.

The error you're getting means you are calling a function and providing 7 parameters to it but there is no definition for that function that accepts 7 parameters. Without knowing exactly what you've changed I can't help any more - plus I'm a c# delevoper not a C++ developer so I don't fully undersand the code anyway.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

Ah... so maybe the functions have the number of arguments that they support defined in the main WeaponDefHandler code, or something. It's gotta be something like that- and I have to call the variables color and color2, which are originally created by WeaponDefHandler... hmmm. Thank you for the explanation, that was a lot more useful, in two paragraphs, than anything I read online :P
User avatar
Das Bruce
Posts: 3544
Joined: 23 Nov 2005, 06:16

Post by Das Bruce »

Uhh, what line is the error on?
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

Wooooot!

I got it to compile. It turns out... I'm just stupid, and can't read. The problem was with FlameThrower.cpp, not FlameProjectile, which is what I was butting my head against :P

Sooooo... now to figure out if I can make this, ah... un-buggy... right now, I have a bright-red flame... it's not transitioning right, yet, and while it's taking a color, it's not taking my custom colors... more work needed...
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

Early days. Not quite where I want it... yet. But it's working :o

Image
Sheekel
Posts: 1391
Joined: 19 Apr 2005, 19:23

Post by Sheekel »

It looks good. But it doesnt look like a flamethrower. Could be a new weapon type though
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

It looks like something a wizard or mage would use as a magic weapon....
User avatar
Caydr
Omnidouche
Posts: 7179
Joined: 16 Oct 2004, 19:40

Post by Caydr »

Needs some random color deviation if that's possible.
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Post by KDR_11k »

Sparkles!

Call it a light magic tower and you're done :P.
User avatar
ILMTitan
Spring Developer
Posts: 410
Joined: 13 Nov 2004, 08:35

Post by ILMTitan »

Looks good, Argh. One note about C++ style. It is generally a good idea to put a space after commas in an argument list for much greater legibility.

Code: Select all

CFlameProjectile(const float3& pos,const float3& speed,const float3& spread,CUnit* owner,const DamageArray& damages,const float3& color,const float3& color2,WeaponDef *weaponDef,int ttl=50);
is easier to read as

Code: Select all

CFlameProjectile(const float3& pos, const float3& speed, const float3& spread, CUnit* owner, const DamageArray& damages, const float3& color, const float3& color2, WeaponDef *weaponDef, int ttl=50);
That said, you're doing good things.
User avatar
Das Bruce
Posts: 3544
Joined: 23 Nov 2005, 06:16

Post by Das Bruce »

Or even

Code: Select all

CFlameProjectile(const float3& pos,
                         const float3& speed,
                         const float3& spread, 
                         CUnit* owner,
                         const DamageArray& damages, 
                         const float3& color,
                         const float3& color2,
                         WeaponDef *weaponDef,
                         int ttl=50);
For uber readability.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

Almost there. A lot of pureblind stupidity on my part, but hey, who said that jumping into C++ without a manual and then trying to pull of a sophisticated visual effect in Spring would be easy?

Basically, I ran into several stumbling blocks. First was figuring out how variables are getting read into Spring by TDFParser.cpp. Second was figuring out how they get read by WeaponDefHandler.cpp, and then passed to a given Weapon ID. Lastly, I had to figure out how to make an elegant color-shifting algorithm.

What I have here is very elegant, and involves very few steps. I dunno if there's a more efficient way of achieving this goal, but I don't think so. While I was doing things, I also coded into the current WeaponDefHandler.cpp code a pair of default values... to preserve current FlameThrowers and keep backwards compatibility! This really wasn't very hard, once I knew what I was doing, but first I had to achieve a lot've hard-knocks experience with dead ends and various other bits of stupidity.

The final patch, therefore, modifies five files in the current source. I'll be releasing them as soon as I get done with my tweaking- mainly, I'm getting speed tweaked out to work well.

Here's a current sample of where this is at, though- as you can see, it's doing a shift from Green to Red, but not fast enough for the typical distances a FlameThrower uses:

Image

So... it's almost done. Just need to make sure it shifts a little faster. It uses very little code, and the code it is using is very fast, so I think it'll be accepted by the Spring devs.
User avatar
Machiosabre
Posts: 1474
Joined: 25 Dec 2005, 22:56

Post by Machiosabre »

not much of a flamethrower but it looks like great fireworks :lol:
User avatar
Das Bruce
Posts: 3544
Joined: 23 Nov 2005, 06:16

Post by Das Bruce »

Looking good. What variables can we controll? All of them I hope. :P
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

Don't worry. The defaults will look like a flamethrower. I just needed to get the final changes done so that it sorts the colors right. Right now, it's averaging them, and I need it to actually do a declining average. Almost got that problem solved, just need to proof it for divide-by-zero.

And you will be able to control the following(for now):

Texture1, RGBcolor, RGBcolor2, Size (this is the starting size), SizeGrowth, plus all of the variables used in common by all Weapons.
User avatar
Das Bruce
Posts: 3544
Joined: 23 Nov 2005, 06:16

Post by Das Bruce »

Just two colours? :?
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

Yes, but it will do a reducing average between them, which is better than the current version, which does three colors at static time intervals. IOW, it'll do a very smooth transition between two RGB values. Which is a lot better than what the current code does.

To add more colors, I'd have to add new categories to TDFParser, WeaponDefHandler, and other sections, and the chances of this getting rejected simply on the grounds that I'm a newbie and am probably screwing something up somewhere are pretty high ;) Keep in mind that no weapon in Spring has more than two control color values, currently. Adding new ones is fairly trivial, if you know what you're doing, but I'm proceeding very, very carefully here, after my initial mistakes. The code involved references a lot've other code that's pretty darn complicated- there are multiple layers involved.

Think of this as my baby-steps towards being able to do more complex things here.
User avatar
TechnoTone
Posts: 165
Joined: 23 Aug 2005, 22:02

Post by TechnoTone »

Out of curiosity - what dev environment are you using? Was it easy to set up?
User avatar
Das Bruce
Posts: 3544
Joined: 23 Nov 2005, 06:16

Post by Das Bruce »

TechnoTone wrote:Out of curiosity - what dev environment are you using? Was it easy to set up?
Can't say on the first one, but the second is a resounding no.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

VC++ Express Edition. And no, it wasn't easy to set up. Probably easy for coders, yes... for me, it was, as JC warned me, a "long road".
Post Reply

Return to “Engine”