Here is the original line.
EffectDamageIncrease(DAMAGE_BONUS_1, DAMAGE_TYPE_FIRE);
I would like to have more dynamic control over the damage bonus value though and would like to substitute the '1' with a variable.
And I'm not sure the syntax for this here.
I've tried.
eEffect = EffectDamageIncrease(DAMAGE_BONUS_ + n, DAMAGE_TYPE_FIRE);
I've also tried
string oNum = IntToString(n);
eEffect = EffectDamageIncrease(DAMAGE_BONUS_ + n, DAMAGE_TYPE_FIRE);
and
eEffect = EffectDamageIncrease("DAMAGE_BONUS_ "+ n, DAMAGE_TYPE_FIRE);
So what am I missing?
Syntax assistance.. simple question
Débuté par
Buddywarrior
, mai 25 2012 06:33
#1
Posté 25 mai 2012 - 06:33
#2
Posté 25 mai 2012 - 06:45
Ill have to look at the values of the constants later, to see if they are linear or not. After that I can give you a better solution.
But to answer your question. What you are missing is that the Lable DAMAGE_BONUS_1 is a Lable for a constant number. The lable is used by the compiler to produce the compiled code. Once you are at Run Time, The script simply does not know what DAMAGE_BONUS_1 means. The lables have all been replaced with there values in the compiled code.
But to answer your question. What you are missing is that the Lable DAMAGE_BONUS_1 is a Lable for a constant number. The lable is used by the compiler to produce the compiled code. Once you are at Run Time, The script simply does not know what DAMAGE_BONUS_1 means. The lables have all been replaced with there values in the compiled code.
#3
Posté 25 mai 2012 - 07:52
Depending on how much of a bonus you want to add you could do it like
eEffect = EffectDamageIncrease(DAMAGE_BONUS_ 1 + n, DAMAGE_TYPE_FIRE);
This would work for values of 0 to 4 (producing bonuses of 1 - 5).
The constants are not linear (values 6-16 are for DAMAGE_BOUNUS_1d4, _1d6...)
They pick up linearly again at DAMAGE_BONUS_6 = 16. Something like this would work for values
of extra damage from 0 to 19 (resulting in 1 to 20 points of damage bonus). It would also be worth
a comment in the code so you know where that DAMAGE_BONUS_11 comes from.
(alternatively you subtract 5 from n in second part and start from DAMAGE_BONUS_6).
if (n >=0 && n <5)
eEffect = EffectDamageIncrease(DAMAGE_BONUS_ 1 + n, DAMAGE_TYPE_FIRE);
else if (n < 20)
eEffect = EffectDamageIncrease(DAMAGE_BONUS_ 11 + n, DAMAGE_TYPE_FIRE);
eEffect = EffectDamageIncrease(DAMAGE_BONUS_ 1 + n, DAMAGE_TYPE_FIRE);
This would work for values of 0 to 4 (producing bonuses of 1 - 5).
The constants are not linear (values 6-16 are for DAMAGE_BOUNUS_1d4, _1d6...)
They pick up linearly again at DAMAGE_BONUS_6 = 16. Something like this would work for values
of extra damage from 0 to 19 (resulting in 1 to 20 points of damage bonus). It would also be worth
a comment in the code so you know where that DAMAGE_BONUS_11 comes from.
(alternatively you subtract 5 from n in second part and start from DAMAGE_BONUS_6).
if (n >=0 && n <5)
eEffect = EffectDamageIncrease(DAMAGE_BONUS_ 1 + n, DAMAGE_TYPE_FIRE);
else if (n < 20)
eEffect = EffectDamageIncrease(DAMAGE_BONUS_ 11 + n, DAMAGE_TYPE_FIRE);
Modifié par meaglyn, 25 mai 2012 - 07:53 .
#4
Posté 25 mai 2012 - 08:02
And here is the list of constants from "nwscript":
int DAMAGE_BONUS_1 = 1;
int DAMAGE_BONUS_2 = 2;
int DAMAGE_BONUS_3 = 3;
int DAMAGE_BONUS_4 = 4;
int DAMAGE_BONUS_5 = 5;
int DAMAGE_BONUS_1d4 = 6;
int DAMAGE_BONUS_1d6 = 7;
int DAMAGE_BONUS_1d8 = 8;
int DAMAGE_BONUS_1d10 = 9;
int DAMAGE_BONUS_2d6 = 10;
int DAMAGE_BONUS_2d8 = 11;
int DAMAGE_BONUS_2d4 = 12;
int DAMAGE_BONUS_2d10 = 13;
int DAMAGE_BONUS_1d12 = 14;
int DAMAGE_BONUS_2d12 = 15;
int DAMAGE_BONUS_6 = 16;
int DAMAGE_BONUS_7 = 17;
int DAMAGE_BONUS_8 = 18;
int DAMAGE_BONUS_9 = 19;
int DAMAGE_BONUS_10 = 20;
int DAMAGE_BONUS_11 = 21;
int DAMAGE_BONUS_12 = 22;
int DAMAGE_BONUS_13 = 23;
int DAMAGE_BONUS_14 = 24;
int DAMAGE_BONUS_15 = 25;
int DAMAGE_BONUS_16 = 26;
int DAMAGE_BONUS_17 = 27;
int DAMAGE_BONUS_18 = 28;
int DAMAGE_BONUS_19 = 29;
int DAMAGE_BONUS_20 = 30;
So as an example if we did...:
int iDamage = d4();
effect eDamage = EffectDamageIncrease(iDamage, DAMAGE_TYPE_FIRE);
...it would give us a random bonus damage of 1 - 4. But you'll notice the constants don't line up with their counterparts. If we wanted a damage bonus of 20 for example then iDamage would have to = 30. Or if you said int iDamage = 6; you wouldn't really get a bonus of 6, it would be 1d4. So if you are looking for a way to do something like d20 and actually get a 1 through 20 bonus you would need to write your own function. Something like so maybe:
int ConvertDamageBonusInt(int iInt)
{
int iReturn;
if (iInt > 0 && iInt <= 30)
{
if (iInt > 5)
iReturn +=10;
else
iReturn = iInt;
return iReturn;
}
return -1;
}
int DAMAGE_BONUS_1 = 1;
int DAMAGE_BONUS_2 = 2;
int DAMAGE_BONUS_3 = 3;
int DAMAGE_BONUS_4 = 4;
int DAMAGE_BONUS_5 = 5;
int DAMAGE_BONUS_1d4 = 6;
int DAMAGE_BONUS_1d6 = 7;
int DAMAGE_BONUS_1d8 = 8;
int DAMAGE_BONUS_1d10 = 9;
int DAMAGE_BONUS_2d6 = 10;
int DAMAGE_BONUS_2d8 = 11;
int DAMAGE_BONUS_2d4 = 12;
int DAMAGE_BONUS_2d10 = 13;
int DAMAGE_BONUS_1d12 = 14;
int DAMAGE_BONUS_2d12 = 15;
int DAMAGE_BONUS_6 = 16;
int DAMAGE_BONUS_7 = 17;
int DAMAGE_BONUS_8 = 18;
int DAMAGE_BONUS_9 = 19;
int DAMAGE_BONUS_10 = 20;
int DAMAGE_BONUS_11 = 21;
int DAMAGE_BONUS_12 = 22;
int DAMAGE_BONUS_13 = 23;
int DAMAGE_BONUS_14 = 24;
int DAMAGE_BONUS_15 = 25;
int DAMAGE_BONUS_16 = 26;
int DAMAGE_BONUS_17 = 27;
int DAMAGE_BONUS_18 = 28;
int DAMAGE_BONUS_19 = 29;
int DAMAGE_BONUS_20 = 30;
So as an example if we did...:
int iDamage = d4();
effect eDamage = EffectDamageIncrease(iDamage, DAMAGE_TYPE_FIRE);
...it would give us a random bonus damage of 1 - 4. But you'll notice the constants don't line up with their counterparts. If we wanted a damage bonus of 20 for example then iDamage would have to = 30. Or if you said int iDamage = 6; you wouldn't really get a bonus of 6, it would be 1d4. So if you are looking for a way to do something like d20 and actually get a 1 through 20 bonus you would need to write your own function. Something like so maybe:
int ConvertDamageBonusInt(int iInt)
{
int iReturn;
if (iInt > 0 && iInt <= 30)
{
if (iInt > 5)
iReturn +=10;
else
iReturn = iInt;
return iReturn;
}
return -1;
}
Modifié par GhostOfGod, 25 mai 2012 - 09:11 .
#5
Posté 25 mai 2012 - 08:59
try:
#include "x2_inc_itemprop"
and then:
eEffect = EffectDamageIncrease(IPGetDamageBonusConstantFromNumber(n), DAMAGE_TYPE_FIRE);
int
#include "x2_inc_itemprop"
and then:
eEffect = EffectDamageIncrease(IPGetDamageBonusConstantFromNumber(n), DAMAGE_TYPE_FIRE);
int
#6
Posté 26 mai 2012 - 12:53
The example function I posted above has an error. I can't edit it via my phone but this:
iReturn +=10;
Should be:
iReturn = iInt + 10;
Sorry.
EDIT: What Lightfoot said below.
iReturn +=10;
Should be:
iReturn = iInt + 10;
Sorry.
EDIT: What Lightfoot said below.
Modifié par GhostOfGod, 26 mai 2012 - 07:06 .
#7
Posté 26 mai 2012 - 02:16
Your function has one more small error Ghost,
if (iInt > 0 && iInt <= 30)
There is no damage bonus for 30 hp, I think you wanted a 20 there.
unless you are doing it for clairty or readability there is also not reason to define a second var, the one already defined is more then enough.
int ConvertDamageBonusInt(int iInt)
{
if (iInt > 0 && iInt <= 20)
{
if (iInt > 5) iInt +=10;
return iInt;
}
return -1;
}
Back to the original question.
Buddy, has your question as to why this:
eEffect = EffectDamageIncrease(DAMAGE_BONUS_ + n, DAMAGE_TYPE_FIRE);
does not work been answered well enough?
if (iInt > 0 && iInt <= 30)
There is no damage bonus for 30 hp, I think you wanted a 20 there.
unless you are doing it for clairty or readability there is also not reason to define a second var, the one already defined is more then enough.
int ConvertDamageBonusInt(int iInt)
{
if (iInt > 0 && iInt <= 20)
{
if (iInt > 5) iInt +=10;
return iInt;
}
return -1;
}
Back to the original question.
Buddy, has your question as to why this:
eEffect = EffectDamageIncrease(DAMAGE_BONUS_ + n, DAMAGE_TYPE_FIRE);
does not work been answered well enough?
Modifié par Lightfoot8, 26 mai 2012 - 02:24 .
#8
Posté 27 mai 2012 - 10:51
Yes it has! Sorry for the delay in replying to this. Thank you all kindly!





Retour en haut






