Jump to content
Sign in to follow this  
[frl]myke

#define and math formula

Recommended Posts

Hi folks,

i'm doing something and i'm not sure if i did it correct. Don't say "try it out" as it will take some time unless the work will be ready even only for test, so i guess i get faster answers (also if it takes a few days) if i put it in here.

Basically it is about #define and based simple math formula with defines.

#define warheadHit	20
#define	warheadIndirectHit	8.5
#define	warheadIndirectHitRange	1
#define warhead	9.4


	hit = "warhead * warheadHit";
	indirectHit = "warhead * warheadIndirectHit";
	indirectHitRange = "warhead * warheadIndirectHitRange";

These are just small snippets so yes, i know there is class cfgAmmo stuff missing, but this is not the topic here so i've posted only the relevant parts.

As you see, i've defined some constants and used them to do simple multiplications with it. I just need to know if it's done correctly or not.

Thanks for your time and happy easter.:D

Share this post


Link to post
Share on other sites

Defines are not replaced inside strings that are double quoted.

I think it should either be:

hit = warhead * warheadHit;

or:

hit = __EVAL(warhead * warheadHit);

Edited by Sickboy

Share this post


Link to post
Share on other sites

Thanks Sickboy.

Could you explain the __EVAL a little more? I'm not familiar with this kind of programming and in the BIWIKI there isn't any useful (at least for me) explanation.

Share this post


Link to post
Share on other sites

__EVAL forces the line to be evaluated at preprocess time. That way your math expression gets interpreted and the result used instead.

Share this post


Link to post
Share on other sites

@TRexian

i knew this site but for me with no programming knowledge beyond sqs/sqf scripting and surplus not being native english, this page could be written in traditional chinese aswell.

Share this post


Link to post
Share on other sites

hehe

Would be cool if google translate could work on code... :D

Share this post


Link to post
Share on other sites
hehe

Would be cool if google translate could work on code... :D

haha, awesome idea :)

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×