Author Topic: Missing Results in Loops  (Read 327 times)

Legacy_Rubies

  • Hero Member
  • *****
  • Posts: 508
  • Karma: +0/-0
Missing Results in Loops
« on: May 08, 2011, 06:01:42 am »


               Another problem that I only recently noticed again (after thinking I'd fixed it) concerns this script that deals the base damage, and bonus damage properties on an item. It seemed to completely disappear for a long time, but after some very minor edits to support shields and ranged weapons, the script is back to occasionally ignoring some properties.

For example, a 1dx dagger with +Sonic damage and +Negative damage, out of 3 attacks, might return any of the following:

x physical, x sonic, x negative

x physical, x negative

x sonic, x negative

I assume this is because of a lack of delays between each function, and perhaps I should be using structs instead.


// -----------------------------------------------------------------------------//
// OnEquipped script that records data about the currently equipped weapon's damage.

// Deals damage info on oPC in slot nSlot.
// slot 0 is the base damage, while slots 1+ are from item properties.
//
// nType is the code from baseitems.2da for slot 0, and an IP_CONST_DAMAGETYPE_*
// constant otherwise.
// nDice is the number of dice rolled.
// nSides is the number of sides of the dice rolled.

// Inflicts all damage found on the item to the target, modified by nDamageModifier.
void DealDamage(int IsBaseDamage, object oPC, object oTarget, int nDamageType, int nNumberOfDie, int nDamagePerDie, int nDamageModifier, int nAddedDamage);
void DealDamage(int IsBaseDamage, object oPC, object oTarget, int nDamageType, int nNumberOfDie, int nDamagePerDie, int nDamageModifier, int nAddedDamage)
{
// If it's flat damage, make sure it's flat, otherwise XdX.

    int nBaseDamage, nTotalDamage;

    if (nNumberOfDie >= 1)
    {
    nBaseDamage = nNumberOfDie*Random(nDamagePerDie+1);
    }

    else
    {
    nBaseDamage = 1*nDamagePerDie;
    }

// Final calculations.

    if (IsBaseDamage = 1)
    {
    nTotalDamage = (nBaseDamage * nDamageModifier) + nAddedDamage;
    }

    else if (IsBaseDamage = 0)
    {
    nTotalDamage = nBaseDamage;
    }

    AssignCommand(oPC, ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectDamage(nTotalDamage, nDamageType), oTarget));
}


// Deals damage info on oPC about any item properties oWeapon may have.
void GetWeaponBonusDamage(object oPC, object oTarget, object oWeapon, int nDamageModifier, int nAddedDamage);
void GetWeaponBonusDamage(object oPC, object oTarget, object oWeapon, int nDamageModifier, int nAddedDamage)
{
    int nType, nDice, nSides, nCost; // Set and used in the loop.

    // Loop through the item properties.
    itemproperty iProp = GetFirstItemProperty(oWeapon);
    while (GetIsItemPropertyValid(iProp) )
    {
        // Look for damage bonuses.
        if (GetItemPropertyType(iProp) == ITEM_PROPERTY_DAMAGE_BONUS)
        {
            // Get info about the damage bonus.
            nCost = GetItemPropertyCostTableValue(iProp);
            nType = GetItemPropertySubType(iProp);
            nDice = StringToInt(Get2DAString("iprp_damagecost", "NumDice", nCost));
            nSides = StringToInt(Get2DAString("iprp_damagecost", "Die", nCost));

                switch(nType) // Convert it into a correctly usable damage type.
                {
                case 0: nType = DAMAGE_TYPE_BLUDGEONING; break;// Bludgeoning
                case 1: nType = DAMAGE_TYPE_PIERCING; break;// Piercing
                case 2: nType = DAMAGE_TYPE_SLASHING; break;// Slashing
                case 3: nType = DAMAGE_TYPE_BLUDGEONING; break;// Unused subdual,
                //convert to Bludgeoning
                case 4: nType = DAMAGE_TYPE_BLUDGEONING; break;// Unused physical,
                //convert to Bludgeoning
                case 5: nType = DAMAGE_TYPE_MAGICAL; break;// Magical
                case 6: nType = DAMAGE_TYPE_ACID; break;// Acid
                case 7: nType = DAMAGE_TYPE_COLD; break;// Cold
                case 8: nType = DAMAGE_TYPE_DIVINE; break;// Divine
                case 9: nType = DAMAGE_TYPE_ELECTRICAL; break;// Electrical
                case 10: nType = DAMAGE_TYPE_FIRE; break;// Fire
                case 11: nType = DAMAGE_TYPE_NEGATIVE; break;// Negative
                case 12: nType = DAMAGE_TYPE_POSITIVE; break;// Positive
                case 13: nType = DAMAGE_TYPE_SONIC; break;// Sonic
                }

            // Record this info.
            DealDamage(0, oPC, oTarget, nType, nDice, nSides, nDamageModifier, nAddedDamage);
        }
        // Update the loop.
        iProp = GetNextItemProperty(oWeapon);
    }
}



// Deals damage info about oWeapon on oPC.
void GetWeaponBaseDamage(object oPC, object oTarget, object oWeapon, int nDamageModifier, int nAddedDamage);
void GetWeaponBaseDamage(object oPC, object oTarget, object oWeapon, int nDamageModifier, int nAddedDamage)
{
    // Get the info from the .2da file.
    int nBaseItem = GetBaseItemType(oWeapon);
    int nType = StringToInt(Get2DAString("baseitems", "WeaponType", nBaseItem));
    int nDice = StringToInt(Get2DAString("baseitems", "NumDice", nBaseItem));
    int nSides = StringToInt(Get2DAString("baseitems", "DieToRoll", nBaseItem));

        // Convert it into a correctly usable damage type.
        switch(nType)
        {
        case 0: nType = DAMAGE_TYPE_PIERCING; break;// Piercing
        case 1: nType = DAMAGE_TYPE_PIERCING; break;// Piercing
        case 2: nType = DAMAGE_TYPE_BLUDGEONING; break;// Bludgeoning
        case 3: nType = DAMAGE_TYPE_SLASHING; break;// Slashing
        case 4: nType = DAMAGE_TYPE_PIERCING; break;// Piercing+Slashing - Disabled
        case 5: nType = DAMAGE_TYPE_BLUDGEONING; break;// Bludgeoning+Piercing - Disabled
        }

    // Deal the info.
    DealDamage(1, oPC, oTarget, nType, nDice, nSides, nDamageModifier, nAddedDamage);
    GetWeaponBonusDamage(oPC, oTarget, oWeapon, nDamageModifier, nAddedDamage);
}

// Deals damage info to oTarget from oPC about any item properties oWeapon may have.
void CalculateDamage(object oPC, object oTarget, object oWeapon, int nDamageModifier, int nAddedDamage);
void CalculateDamage(object oPC, object oTarget, object oWeapon, int nDamageModifier, int nAddedDamage)
{
GetWeaponBaseDamage(oPC, oTarget, oWeapon, nDamageModifier, nAddedDamage);
}

//void main(){}

               
               

               


                     Modifié par Rubies, 08 mai 2011 - 05:03 .
                     
                  


            

Legacy__Guile

  • Hero Member
  • *****
  • Posts: 1308
  • Karma: +0/-0
Missing Results in Loops
« Reply #1 on: May 08, 2011, 06:47:58 am »


               Would you be using cache on this script?
               
               

               
            

Legacy_Rubies

  • Hero Member
  • *****
  • Posts: 508
  • Karma: +0/-0
Missing Results in Loops
« Reply #2 on: May 08, 2011, 07:30:04 am »


               I haven't manually made any caching changes so it uses the standard caching (with the exception that the 2DA cache stores 12, not 10 entries, but I rather doubt that changes anything!).
               
               

               


                     Modifié par Rubies, 08 mai 2011 - 06:33 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Missing Results in Loops
« Reply #3 on: May 08, 2011, 03:16:23 pm »


               After a Quick look at the script, I have seen only one error in this section here. 
 

Rubies wrote...

// If it's flat damage, make sure it's flat, otherwise XdX.

    int nBaseDamage, nTotalDamage;

    if (nNumberOfDie >= 1)
    {
    nBaseDamage = nNumberOfDie*Random(nDamagePerDie+1);
    }

    else
    {
    nBaseDamage = 1*nDamagePerDie;
    }



nBaseDamage = nNumberOfDie*Random(nDamagePerDie+1);

Random(nDamagePerDie+1), is rolling a number between 0 and nDamagePerDie+1. 

i think you wanted. 

 nBaseDamage = nNumberOfDie*(Random(nDamagePerDie)+1);
 
to roll a number between 1 and  nDamagePerDie then multiply by nNumberOfDie.
 
Let me know if that does not take care of the problem. 
L8
               
               

               
            

Legacy_Rubies

  • Hero Member
  • *****
  • Posts: 508
  • Karma: +0/-0
Missing Results in Loops
« Reply #4 on: May 08, 2011, 06:48:49 pm »


               Always nice to get things fixed, so thanks for that! I'm afraid it didn't fix the problem of damage being missing, though.

I'm using a 1d4 dagger with +1d4 Negative damage and +5 Sonic damage.

'Posted
               
               

               


                     Modifié par Rubies, 08 mai 2011 - 05:52 .
                     
                  


            

Legacy_Rubies

  • Hero Member
  • *****
  • Posts: 508
  • Karma: +0/-0
Missing Results in Loops
« Reply #5 on: May 08, 2011, 07:11:32 pm »


               To try and isolate this issue a bit more, I added several debug strings into the script, namely:

    FloatingTextStringOnCreature(IntToString(nTotalDamage)+"+"+IntToString(nDamageType), OBJECT_SELF, FALSE);
    FloatingTextStringOnCreature(IntToString(nNumberOfDie)+"+"+IntToString(nDamagePerDie), OBJECT_SELF, FALSE);
    FloatingTextStringOnCreature(IntToString(nDamageModifier)+"+"+IntToString(nAddedDamage), OBJECT_SELF, FALSE);

It appears that the entire GetWeaponBonusDamage function just doesn't fire sometimes. When I get two damage results, I only get two sets of information, too. This -doesn't- happen when there is only one item property, but does when there's two or more.
               
               

               
            

Legacy_Rubies

  • Hero Member
  • *****
  • Posts: 508
  • Karma: +0/-0
Missing Results in Loops
« Reply #6 on: May 09, 2011, 02:07:27 pm »


               Fixed this! It appears to have been another script that ran at the same time to check for modified item properties, but I'm sure my bad Random code was responsible too. '<img'>
               
               

               


                     Modifié par Rubies, 09 mai 2011 - 01:08 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Missing Results in Loops
« Reply #7 on: May 09, 2011, 03:22:42 pm »


               Another thing you may want to take into account,  The Item may have the NO DAMAGE Item property on it.   In which case you nee to either dump the damage from the BaseItem(standard system)  or dump all physcial damage.

I did have a few questions of things that just did not make since to me in the script.   For one the header has it as an OnEquip script. Two Some of the comments say record damage when you are dealing it.   I was thinking of making a couple suggestions, If you where just useing this to deal the damage.  .
               
               

               
            

Legacy_Rubies

  • Hero Member
  • *****
  • Posts: 508
  • Karma: +0/-0
Missing Results in Loops
« Reply #8 on: May 09, 2011, 06:10:52 pm »


               This first scripts takes all item properties, as well as base damage, and inflicts them as damage. It is intended to be a solution to our list of feats that use alternative damage methods, but should still base their damage on the main weapon. It works by calling the following function, for example, in our Frenzied Strike code:

---


#include "core_attack"
#include "core_damage"

void main()
{
    object oMainhand = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, OBJECT_SELF);
    object oTarget = GetSpellTargetObject();

    int nAttackRoll = RollFakeAttackRoll(OBJECT_SELF, oTarget);

    if (nAttackRoll = 20) // Critical Hit
    {
    CalculateDamage(OBJECT_SELF, oTarget, oMainhand, 2, GetAbilityModifier(ABILITY_STRENGTH, OBJECT_SELF));
    }

    else if (nAttackRoll >= 1) // Hit
    {
    CalculateDamage(OBJECT_SELF, oTarget, oMainhand, 1, GetAbilityModifier(ABILITY_STRENGTH, OBJECT_SELF));
    }

    else // Miss
    {
    }
}

---

The "core_damage" script is the piece of code in the earlier post.

There are some small issues with the code at the moment, which are namely its lack of size damage modifiers for two-handed weapons, and the like.

I wouldn't worry about modifiers like Holy Avenger, No Damage, etc, because they've all been replaced by special item properties that fire on their own accord, and therefore don't affect the use of this script.

The alternative is to base the amount of damage returned as the amount as a buff of some kind. For example, our "Shield Counter" feat gives the Fighter a Damage Shield effect that returns the amount of 'damage' on their shield (represented by a Bludgeoning or Piercing item property on it).

---


#include "core_shield"

void main()
{
int nDamage = DamageAmount(OBJECT_SELF, GetItemInSlot(INVENTORY_SLOT_LEFTHAND), 1);
effect eDamageShield = EffectDamageShield(nDamage-1, DAMAGE_BONUS_1, DAMAGE_TYPE_BLUDGEONING);
effect eVFX = EffectVisualEffect(VFX_DUR_DEATH_ARMOR, FALSE);

effect eEffect = EffectLinkEffects(eVFX, eDamageShield);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect, OBJECT_SELF, 12.0);
}

---

The "core_shield" script is the following:

---


int DamageAmount(object oPC, object oWeapon, int nDamageModifier);
int DamageAmount(object oPC, object oWeapon, int nDamageModifier)
{
    int nType, nDice, nSides, nCost; // Set and used in the loop.

    // Loop through the item properties.
    itemproperty iProp = GetFirstItemProperty(oWeapon);
    while (GetIsItemPropertyValid(iProp) )
    {
        // Look for damage bonuses.
        if (GetItemPropertyType(iProp) == ITEM_PROPERTY_DAMAGE_BONUS)
        {
            // Get info about the damage bonus.
            nCost = GetItemPropertyCostTableValue(iProp);
            nType = GetItemPropertySubType(iProp);
            nDice = StringToInt(Get2DAString("iprp_damagecost", "NumDice", nCost));
            nSides = StringToInt(Get2DAString("iprp_damagecost", "Die", nCost));

            switch(nType) // Convert it into a correctly usable damage type.
            {
            case 0: nType = DAMAGE_TYPE_BLUDGEONING; break;// Bludgeoning
            case 1: nType = DAMAGE_TYPE_PIERCING; break;// Piercing
            case 2: nType = DAMAGE_TYPE_SLASHING; break;// Slashing
            case 3: nType = DAMAGE_TYPE_BLUDGEONING; break;// Unused subdual, convert to Bludgeoning
            case 4: nType = DAMAGE_TYPE_BLUDGEONING; break;// Unused physical, convert to Bludgeoning
            case 5: nType = DAMAGE_TYPE_MAGICAL; break;// Magical
            case 6: nType = DAMAGE_TYPE_ACID; break;// Acid
            case 7: nType = DAMAGE_TYPE_COLD; break;// Cold
            case 8: nType = DAMAGE_TYPE_DIVINE; break;// Divine
            case 9: nType = DAMAGE_TYPE_ELECTRICAL; break;// Electrical
            case 10: nType = DAMAGE_TYPE_FIRE; break;// Fire
            case 11: nType = DAMAGE_TYPE_NEGATIVE; break;// Negative
            case 12: nType = DAMAGE_TYPE_POSITIVE; break;// Positive
            case 13: nType = DAMAGE_TYPE_SONIC; break;// Sonic
            }

        iProp = GetNextItemProperty(oWeapon);
        }
    }

    int nBaseDamage, nTotalDamage;

    if (nDice <= 1)
    {
    nBaseDamage = nSides;
    }

    else
    {
    nBaseDamage = nDice*Random(nSides+1);
    }

    nTotalDamage = nBaseDamage * nDamageModifier;

    return nTotalDamage;
}

//void main(){}

---

The comments were left over from when the script used to store damage as a series of integers, and is likely just me being poor at keeping up with the changes I make. '<img'>
               
               

               


                     Modifié par Rubies, 09 mai 2011 - 05:25 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Missing Results in Loops
« Reply #9 on: May 10, 2011, 12:42:52 am »


               looks like you should double check old random checks in the mod.  the last script you posted has the same error.  

nBaseDamage = nDice*Random(nSides+1);
should be:
nBaseDamage = nDice*(Random(nSides)+1);

I would also suggest rolling each die instead of just multiplying by nDice.  I know the game engine does it that way, It just never felt right to me though.  rolling 3d8 should be rolling 3 dice. Not rolling one and taking three times its value.   My Opinion anyway.  if you wanted to roll each die you could do it this way in one line.

do nBaseDamage += Random(nDamagePerDie)+1; while( nDice--);

On the applying of the damage in the first include.   It seems like a lot of assigned commands in applying the damage.   If you made sure that the script was running on oPC (your attacker), and it looks like they are since you are useing OBJECT_SELF to feed your functions.  You can get rid of the AssignCommand,  Rewrite the void DealDamage function to return an effect instead of doing the damge.   eg. effect GetDamageEffect. This way you could link all you damage effects and apply them all at once, instead of in serval applications.   It would just cut down on some of the overhead that the module has to keep track of.  As stated above though, you would hace to make sure that your script was running on the attacking object to do it that way.  

Just a few thoughts.   I may have more but need to do some testing first.
               
               

               
            

Legacy_Rubies

  • Hero Member
  • *****
  • Posts: 508
  • Karma: +0/-0
Missing Results in Loops
« Reply #10 on: May 10, 2011, 03:04:59 am »


               Both scripts were based on the same chunk of code so I'm not too surprised they had the same issue - thanks for pointing it out, nevertheless!

Never thought of doing the random code in that way and it's interesting! '<img'>

I'm not sure I entirely understand the DealDamage rewrite you referred to, though!
               
               

               
            

Legacy_Rubies

  • Hero Member
  • *****
  • Posts: 508
  • Karma: +0/-0
Missing Results in Loops
« Reply #11 on: May 11, 2011, 03:45:00 pm »


               

On the applying of the damage in the first include.   It seems like a
lot of assigned commands in applying the damage. If you made sure that
the script was running on oPC (your attacker), and it looks like they
are since you are useing OBJECT_SELF to feed your functions.


Yep, you're right there - the script runs on the PC using a spell or usable feat.

You can
get rid of the AssignCommand,  Rewrite the void DealDamage function to
return an effect instead of doing the damge.   eg. effect
GetDamageEffect. This way you could link all you damage effects and
apply them all at once, instead of in serval applications.   It would
just cut down on some of the overhead that the module has to keep track
of.  As stated above though, you would hace to make sure that your
script was running on the attacking object to do it that way.


If I understand that right, you mean having a struct or a function that returns the total damage and damage type, and then pass them through to the DealDamage function in turn? 
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Missing Results in Loops
« Reply #12 on: May 12, 2011, 01:13:10 am »


               

Rubies wrote...

If I understand that right, you mean having a struct or a function that returns the total damage and damage type, and then pass them through to the DealDamage function in turn? 


What I meant was to have your functions return effects or already linked effects.  This way you can apply your entire damage amount at once.  Instead of several uses of the ApplyEffect function.   this will also open the functions up to be more usefull in other scripts.  

I changed things a little bit so you can see what I meant.  Of cource I am not verry good at changing comments either. So a lot of the old comments will just not make since.

The strange formating was just so some of the long functions would not wrape

// -----------------------------------------------------------------------------//
// OnEquipped script that records data about the currently equipped weapon's damage.

// Deals damage info on oPC in slot nSlot.
// slot 0 is the base damage, while slots 1+ are from item properties.
//
// nType is the code from baseitems.2da for slot 0, and an IP_CONST_DAMAGETYPE_*
// constant otherwise.
// nDice is the number of dice rolled.
// nSides is the number of sides of the dice rolled.

// Deals damage info to oTarget from oPC about any item properties oWeapon may have.
void CalculateDamage(object oPC, object oTarget, object oWeapon, int nDamageModifier, int nAddedDamage);

// Deals damage info about oWeapon on oPC.
effect GetWeaponBaseDamage(object oPC, object oTarget, object oWeapon, int nDamageModifier, int nAddedDamage);

// Deals damage info on oPC about any item properties oWeapon may have.
effect GetWeaponBonusDamage(object oPC, object oTarget, object oWeapon, int nDamageModifier, int nAddedDamage);

 // Gets the Damage effect, modified by nDamageModifier.
effect GetDamageEffect(int IsBaseDamage, object oPC, object oTarget, int nDamageType, int nNumberOfDie, int nDamagePerDie, int nDamageModifier, int nAddedDamage);
 

// Deals damage info to oTarget from oPC about any item properties oWeapon may have.
void CalculateDamage(object oPC, object oTarget, object oWeapon, int nDamageModifier, int nAddedDamage)
{
   effect eBase=GetWeaponBaseDamage(oPC, oTarget, oWeapon, nDamageModifier, nAddedDamage);
   effect eBonus=GetWeaponBonusDamage(oPC,oTarget,oWeapon,nDamageModifier,nAddedDamage);
   effect eTotal = EffectLinkEffects(eBonus ,eBase);
   ApplyEffectToObject(DURATION_TYPE_INSTANT, eTotal, oTarget);
}
 


// Deals damage info about oWeapon on oPC.
effect GetWeaponBaseDamage(object oPC, object oTarget, object oWeapon, int nDamageModifier, int nAddedDamage)
{
    // Get the info from the .2da file.
    int nBaseItem = GetBaseItemType(oWeapon);
    int nType = StringToInt(Get2DAString("baseitems", "WeaponType", nBaseItem));
    int nDice = StringToInt(Get2DAString("baseitems", "NumDice", nBaseItem));
    int nSides = StringToInt(Get2DAString("baseitems", "DieToRoll", nBaseItem));


        // Convert it into a correctly usable damage type.
        switch(nType)
        {
        case 0: nType = DAMAGE_TYPE_PIERCING; break;// Piercing
        case 1: nType = DAMAGE_TYPE_PIERCING; break;// Piercing
        case 2: nType = DAMAGE_TYPE_BLUDGEONING; break;// Bludgeoning
        case 3: nType = DAMAGE_TYPE_SLASHING; break;// Slashing
        case 4: nType = DAMAGE_TYPE_PIERCING; break;// Piercing+Slashing - Disabled
        case 5: nType = DAMAGE_TYPE_BLUDGEONING; break;// Bludgeoning+Piercing - Disabled
        }

    // Deal the info.
    return GetDamageEffect(1, oPC, oTarget, nType, nDice,
                           nSides, nDamageModifier, nAddedDamage);
 
}
 

// Deals damage info on oPC about any item properties oWeapon may have.
effect GetWeaponBonusDamage(object oPC, object oTarget, object oWeapon, int nDamageModifier, int nAddedDamage)
{
    int nType, nDice, nSides, nCost,nNotFirstPass; // Set and used in the loop.
    effect eDamage;
    // Loop through the item properties.
    itemproperty iProp = GetFirstItemProperty(oWeapon);
    while (GetIsItemPropertyValid(iProp) )
    {
        // Look for damage bonuses.
        if (GetItemPropertyType(iProp) == ITEM_PROPERTY_DAMAGE_BONUS)
        {
            // Get info about the damage bonus.
            nCost = GetItemPropertyCostTableValue(iProp);
            nType = GetItemPropertySubType(iProp);
            nDice = StringToInt(Get2DAString("iprp_damagecost", "NumDice", nCost));
            nSides = StringToInt(Get2DAString("iprp_damagecost", "Die", nCost));

            // Convert it into a correctly usable damage type.
            if (nType > 2) nType +=  -2;
            nType = 1<<nType;


            // Record this info.
            if (nNotFirstPass) eDamage= EffectLinkEffects
                                        (
                                            GetDamageEffect
                                            (
                                               0,  // Prams forGetDamageEffect
                                               oPC,
                                               oTarget,
                                               nType,
                                               nDice,
                                               nSides,
                                               nDamageModifier,
                                               nAddedDamage
                                             ),
                                             eDamage
                                          );

            else
            {
               eDamage =GetDamageEffect
                        (
                           0,             // Prams forGetDamageEffect
                           oPC,
                           oTarget,
                           nType,
                           nDice,
                           nSides,
                           nDamageModifier,
                           nAddedDamage
                         );
                nNotFirstPass = 1;
            }
        }
        // Update the loop.
        iProp = GetNextItemProperty(oWeapon);
    }
    return eDamage;
}
 


// .
effect GetDamageEffect(int IsBaseDamage, object oPC, object oTarget, int nDamageType, int nNumberOfDie, int nDamagePerDie, int nDamageModifier, int nAddedDamage)
{
// If it's flat damage, make sure it's flat, otherwise XdX.

    int nBaseDamage, nTotalDamage;

    if (nNumberOfDie >= 1)
    {
       do nBaseDamage += Random(nDamagePerDie)+1; while( nNumberOfDie--);
    }

    else
    {
       nBaseDamage = 1*nDamagePerDie;
    }

// Final calculations.


    nTotalDamage  =  nBaseDamage;
    nTotalDamage += IsBaseDamage * ((nDamageModifier-1) * nBaseDamage + nAddedDamage);
    return EffectDamage(nTotalDamage, nDamageType);
}
 


//void main(){}
               
               

               
            

Legacy_Rubies

  • Hero Member
  • *****
  • Posts: 508
  • Karma: +0/-0
Missing Results in Loops
« Reply #13 on: May 12, 2011, 04:39:01 am »


               I'll go through the script tomorrow when I'm less distracted by tiredness - thanks! '<img'>