Posts | ||
---|---|---|
Some C coding confusion | Locked | |
Thread Options | ||
|
Sep 30 2004 Anchor | |
Inflictor is a projectile or in melee attacks it's the creature object. Source is the creature object shooting the projectile or the melee attacker. Target is obiviously the object to be kicked.
The last line is confusing me. If I'm correct, ! means no. So when there is no source or source is not a player or the source type is not MT_NAMREPAER, then it will kick the target. |
||
|
Sep 30 2004 Anchor | |
i donno exactly where this comes from but just looking at this code i've seen one thing that is strange, and i guess is wrong. you've got ! has precedence over == and thus it would yield '1' if the source->type is '0' and '0' if the type is non '0'. then it's compared to the value of MT_NAMREPAER. i don't think you intended this. try once donno if tha helps but this just jumped into my eyes seeing it. EDIT: or better source->type != MT_NAMREPAER Edited by: Dragonlord |
||
|
Sep 30 2004 Anchor | |
Thanks, I think I'll try those better ones for the MT_NAMREPAER but those 2 first ones in the line are confusing... |
||
|
Sep 30 2004 Anchor | |
!source is clear. this is used to avoid a SEGV (segmentation fault) which would occur if source contains 'NULL' and you would try to read values from it. so if source is 'NULL' you don't check any further (as it is true already at that place) i donno what this should be usefull in the end to accept a kick if the source is 'NULL' so it might be not what is intended. so i assume the entire last row is kinda cranked up as it doesn't make sense. let's try to see if I can guess what is meant (yep, i've no idea of the SDK you use there so let's try). 1) logically only a source can cause a kick as empty air doesn't kick. so in this case if the source is 'NULL' we should not kick. this would give us '&& source' 2) player should not be able to kick. so this brings us to the following: '&& !source->player' 3) finally the type should not be MT_NAMREPAER because he can not kick (if i understood right). Thus we end up with the last condition '&& (source->type != MT_NAMREPAER)' so build all together I would try this one then: // Kick the target before the armor saves damage |
||
|
Sep 30 2004 Anchor | |
Player should be able to cause a kick to his targets(and he is), but in the code it shows the opposite. |
||
|
Sep 30 2004 Anchor | |
&& source->player /* no kick by moster */ if players only can kick. if both can drop this line entirely. |
||
Sep 30 2004 Anchor | ||
see all you gotta do is just get some dishwasher detergent and mix it with vineger and bam there you have it... A PERFECT LINE OF CODE... okay don't try that its not the perfect line but it really is a mediocre line of code... I admire the coders out there... --
|
||
|
Sep 30 2004 Anchor | |
what was that suppost to mean... *grin* |
||
Sep 30 2004 Anchor | ||
Just tryin to help out... lol.... IM NOT EVEN MAKING A MOD RIGHT NOW lol --
|
||
|
Sep 30 2004 Anchor | |
btw, is there a difference in 0.25 and 0,25? |
||
Sep 30 2004 Anchor | ||
...yea one has a comma... thats an outsiders point of view --
|
||
|
Sep 30 2004 Anchor | |
0.25 is a double value, '0,25' on the other hand is really bad as ',' is a special separation character. |
||
|
Sep 30 2004 Anchor | |
|
Oct 1 2004 Anchor | |
compiler error as the ',' is used as a delimiter to designate a list of items like in the following: int a, b=5, c; |
||
|
Oct 1 2004 Anchor | |
If I want "appower" to use 0.25 or some other similar value, do I use this then "double appower;"? When I want appower to be zero, do I make it zero this way:"appower = 0.0;" or this way:"appower = 0;"? |
||
|
Oct 1 2004 Anchor | |
c/c++ uses auto-casting. this means that a value of type char/short/int/float are automatically casted to double if your variable uses double as its type. so in fact you can use both ways without problems. and about float/double. the only difference is that with float as variable type you need to cast yourself as c/c++ considers decimal values to be double by default thus: |
||
Oct 1 2004 Anchor | ||
Err.. double isn't useless my child BTW... I hate all languages that have ambiguous types, or whatever you would call them. You know like in Javascript 'var i;' could be an integer, float, string anything. I hate that. Just thought I'd say that...... ! --
|
||
|
Oct 1 2004 Anchor | |
double is as said double precision... but if you know a bit math and how the computer stores the floating point values then it's not really a blast to use double. better refine your calculations to take into account the unpreciseness of floating point values. what you call 'ambigious' types are soft typed systems like Python, mostly scripting languages, and this principle is rather powerfull. the entire GenToo is build upon Python. c is (like my language) strongly typed which has advantages and disadvantages... one obviously beeing to force a class/function to obey to certain 'types'. both systems are good and hating soft typed systems makes you miss a lot of good stuff... especially if you work with a powerfull system like linux then soft typed systems are the big deal (i just say /bin/bash ;=) ). |
||
Oct 1 2004 Anchor | ||
I will never enjoy a 'soft typed system' as you call them. And I've never heard of 'GenToo' And Dragonlord my child, regardless of whether you learned about floating point values in school yesterday or not, the doubles are more precise. They aren't just throwing memory usage away. :=P --
|
Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.