Aller au contenu

Photo

Using OR logic with EffectDamageReduction


  • Veuillez vous connecter pour répondre
6 réponses à ce sujet

#1
mogromon

mogromon
  • Members
  • 41 messages
Hi,

I know the OR logic can be used while modifying Damage Reduction in the toolset, but I was wondering, it there is any way to do it via EffectDamageReduction or even ItemPropertyDamageReduction

Thx.

#2
Morbane

Morbane
  • Members
  • 1 883 messages
Without building a testing scenario for myself, it is difficult to offer any help. Have you tried any scripts but found they didn't work - if you did - mayhap you could post those and we can take a look.

#3
mogromon

mogromon
  • Members
  • 41 messages
I've been using this code, just put it at the start of any spell script, and remember to removed it when the tests conclude.

void main()
{
object oTarget = OBJECT_SELF;
function1(oTarget, 1);
return;
}

void function1(object oTarget, int nType)//EffectInsane();
{
if(nType > 6)
return;
string sTemp;
effect eTemp;
switch (nType)
{
case 1: eTemp = EffectDamageReduction(10, 1, 0, DR_TYPE_DMGTYPE);
//eTemp2 = EffectDamageReduction(10, 1, 0, DR_TYPE_DMGTYPE);
//eTemp = EffectLinkEffects(eTemp, eTemp2);
sTemp = "Damage Resistance: piercing";
break;
case 2: eTemp = EffectDamage(15, DAMAGE_TYPE_PIERCING);
//eTemp = EffectLinkEffects(eTemp2, eTemp);
sTemp = "Piercing Damage";
break;
case 3: eTemp = EffectDamage(15, DAMAGE_TYPE_SLASHING);
//eTemp = EffectFrightened();
sTemp = "Slashing";
break;
case 4: eTemp = EffectDamage(15, DAMAGE_TYPE_BLUDGEONING);
sTemp = "Bludgeoning";
break;
case 5: eTemp = EffectDamage(15, DAMAGE_TYPE_ALL);
sTemp = "All";
break;
case 6: eTemp = EffectDamage(15, DAMAGE_TYPE_FIRE);
sTemp = "Fire";
break;
}
if(nType == 1)
{
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eTemp, oTarget, 70.0f);
//ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eTemp2, oTarget, 70.0f);
}
else
{
ApplyEffectToObject(DURATION_TYPE_INSTANT, eTemp, oTarget);
}
FloatingTextStringOnCreature("Applied Effect: "+sTemp,GetFirstPC());
nType = nType + 1;
DelayCommand(5.0f, function1(oTarget, nType));//originally 60
}

if I apply 2 EffectDamageReduction, all of the effectDamage (Physical) are affected, but if i use & , like EffectDamage(15, 2 & 4) and it was damagereduction was set to be bypassed by Piercing and Slashing damage, it's bypassed. I didnt test "OR" logic with EffectDamage, but after that discover I started adding conditional to the parameter in EffectDamageReduction but the only one that had an interesting result was when I used EffectDamageReduction(10, 0 || 2 , 0, DR_TYPE_DMGTYPE) (Bludgeoning or slashing bypass the reduction) but this didnt work like that, instead Piercing damage bypassed the damage (no clue Why)

I've used |, &, and && (Damage Reduction) but only one of the parameters seems to work.

I've also found that EffectDamageReduction uses IP_CONST_DAMAGETYPE_* not DAMAGE_TYPE_* fot the constant in the second parameter.

#4
Morbane

Morbane
  • Members
  • 1 883 messages
Those logic operators dont work like that - you cant say EffectDamage(d20() & d6(), DAMAGE_TYPE_*
In that case you would just use a "+"

The "||" (or) "&&" (and) are mainly used for determining TRUE/FALSE statements not to declare a value or the like.

#5
The Fred

The Fred
  • Members
  • 2 516 messages
It wouldn't make sense to say "d20() & d6()", but the DAMAGE_TYPE_* constants *are* bit-based ones, so it's perfectly OK to write "DAMAGE_TYPE_FIRE & DAMAGE_TYPE_COLD". Note however that I think & means "OR" in this situation and | would do nothing. That sounds kinda ridiculous, but if you think about it each damage type is a power of two and if you | them you'd get 0.

(
To quickly go over bitwise stuff:
0 || 2 = 1. This is a boolean comparison, not a bitwise operator, and 2 is non-zero so it's treated as "TRUE". "0 || 2" means "TRUE OR FALSE" so it's TRUE, which is 1.

0 | 2 = 2. Bitwise OR gives you a result which has the same bits as either of the two inputs. 0 is just 0 so it has no effect. Thus you get whatever you put in. If you did something like "4 | 2" you'd get 6 (4 + 2), 2 | 2 = 2 (because both have the 2 bit), 3 | 2 = 3 (because 3 = 2 + 1 so the 2 is already turned on and so 3 | 2 is just 3) etc.

0 & 2 = 0. Bitwise AND is just the same, it's bitwise so it compared the powers of 2, but it's AND. 0 has no positive bits so 0 & anything is just 0 (just like 0 && anything is just 0). Because this is bitwise AND, rather than bitwise OR, you ofc only get the bits which are on in both numbers. Therefore 2 & anything equals 2 only if the other number has a 2 in, otherwise nothing e.g. 3&2=2, 6&2=2, 2&2=2, 2&4=0, 2&8=0, 2&12=0, etc.
)

However, I'm not sure things like damage resistance respect that (and if you try and inflict a composite damage type on someone, it just comes up as "physical").

I should also point out that you're saying "damage reduction", but that has nothing to do with damage type. Damage reduction as termed by the engine is only for physical damage; damage resistance

#6
painofdungeoneternal

painofdungeoneternal
  • Members
  • 1 799 messages
I do dimly remember something about this, and it was a bug kaedrin took advantage of, in that an invalid damage type made the character do damage per the weapon type used, which he used for enlarge and applying damage. Basically the game is not as capable as you are hoping, if it does work as you describe its sheer coincidence.

What you are describing is not really OR logic, it's setting bits, and it gets confusing because of the terms. You are creating values, not doing logic. Here is some information on how bitwise math works.

It is very good to do testing, to see what the game can do, but from experience i can say that you need to leave idealism behind, assume unless you do it yourself its not going to work exactly as you want.

#7
mogromon

mogromon
  • Members
  • 41 messages
yeap, you're correct pain, did some extra tests and it bypasses damagereduction but not following the rules, like you said it must become invalid damage. A shame that there are weapons that can have two damage types but can't be done anywhere else, same with damagereduction, i would be cool they'd implemented that via scripts. Maybe use a custom item that doesnt need to be equip to give the bonus to the player could be the answer.

The Fred wrote...

I should also point out that you're saying "damage reduction", but that has nothing to do with damage type. Damage reduction as termed by the engine is only for physical damage; damage resistance


Doing my tests I'm sure the damagereduction, if the second parameter is a physical damage type (per IP_CONST_DAMAGETYPE_*), is bypassed by that physical damage type. So you can have Damage Reduction 10/piercing, meaning that only a piercing weapon will do full damage. Damage Resistance is the one that gives feedback but doesnt work for physical damage types. Thx for the head'up useful information the bits stuff, will make sure to take it in consideration next time I decide to try to modify something.

Modifié par mogromon, 12 octobre 2011 - 11:53 .