Aller au contenu

Photo

Odd compiler error (unknown state in compiler) - Solved


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

#1
DodgeMoreLightning

DodgeMoreLightning
  • Members
  • 30 messages
tl;dr: your float constants that are less than 0 should start with a 0. Type 0.15f instead of .15f. Read my frantic flailing below for a chuckle.






Getting weird errors in the complier for reasons I don't understand. I made a duplicate of talent_singletarget.nss to play around with using the toolset right-click menu command "duplicate." I proceed to jump straight down to case ABILITY_TALENT_MIGHTY _BLOW and start playing with the damage, writing two lines.

        case ABILITY_TALENT_MIGHTY_BLOW:
        {
            object oWeapon  = GetItemInEquipSlot(INVENTORY_SLOT_MAIN, stEvent.oCaster);


            float nStrength = GetCreatureProperty(stEvent.oCaster, PROPERTY_ATTRIBUTE_STRENGTH ,PROPERTY_VALUE_CURRENT); // Curtesy of SuperD

            // if the attack hit
            int nResult = Combat_GetAttackResult(stEvent.oCaster, stEvent.oTarget, oWeapon, 10.0f, stEvent.nAbility);
            if (IsCombatHit(nResult) == TRUE)
            {
                if (nResult == COMBAT_RESULT_HIT)
                {
                    nResult = COMBAT_RESULT_CRITICALHIT;
                }
                float fDamage = Combat_Damage_GetAttackDamage(stEvent.oCaster, stEvent.oTarget, oWeapon, nResult, 0.0f);
                
                /*
                DML says: Let strength scale the damage. 1% damage per point of strength. It is MIGHTY blow, after all.
                 */
                fDamage = fDamage;// * (1.0f + .01f * (float)nStrength);


                // apply impact
                eEffect = EffectImpact(fDamage, oWeapon,0, stEvent.nAbility);
                Combat_HandleAttackImpact(stEvent.oCaster, stEvent.oTarget, nResult, eEffect);

                if (IsCreatureSpecialRank(stEvent.oTarget) == FALSE)
                {
                    eEffect = Effect(EFFECT_TYPE_HEAVY_IMPACT);
                    ApplyEffectOnObject(EFFECT_DURATION_TYPE_INSTANT, eEffect, stEvent.oTarget, 0.0f, stEvent.oCaster, stEvent.nAbility);
                }
            }

            break;
        }



The two red lines are the ones I added. The second line, as you can see, has a comment dead center: essentially it does nothing but annoy the compiler into giving me "E: 16:38:36 - dmltalent_singletarget.nss - dmltalent_singletarget.nss(704): Unknown state in compiler". Commenting out the second line (that is, fDamage = fDamage) lets the compiler skip right past it to the other errors I've made such as fKillshotRatio = .15f; and other unoffensive things of that nature. I'm not sure what's wrong here, but it feels like I'm missing something really simple.

Modifié par DodgeMoreLightning, 02 janvier 2010 - 01:38 .


#2
SuperD-710

SuperD-710
  • Members
  • 130 messages
You did the typecasting wrong. Gotta use IntToFloat(), or just grab the strength in float in the first place.



Use GetCreatureProperty().



I agree the toolset compiler isn't exactly great at providing feedback.

#3
DodgeMoreLightning

DodgeMoreLightning
  • Members
  • 30 messages
Ah, thanks for that help. Small problem. The Compiler is catching on the line that says fDamage = fDamage. The other line it lets go. It also catches on a line that says "fKillshotRatio = .15f;" I feel like I'm doing the same thing wrong twice, but I wouldn't have a clue what's wrong with fDamage = fDamage;.


Following SuperD's advice about using GetCreatureProperty (much cleaner - thanks again), the line fDamage = fDamage * (1.0f + .01f * nStrength); gives an unknown state in compiler error. When commented back to fDamage = fDamage, the complier gleefully skips over it and catches my other errors. Example:


        case ABILITY_TALENT_CRITICAL_STRIKE:
        {
            object oWeapon  = GetItemInEquipSlot(INVENTORY_SLOT_MAIN, stEvent.oCaster);

            // if the attack hit
            int nResult = Combat_GetAttackResult(stEvent.oCaster, stEvent.oTarget, oWeapon, 5.0f, stEvent.nAbility);
            if (IsCombatHit(nResult) == TRUE)
            {
                // automatic critical
                if (nResult == COMBAT_RESULT_HIT)
                {
                    nResult = COMBAT_RESULT_CRITICALHIT;
                }

                /*
                ELW says: This talent is underwhelming because it's so close to Mighty Blow on double the cooldown.
                 Unless you're facing a boss where you'd really need it, in which case it's worse.

                 Instead, it'll work on everything, just at various levels of health. Default is 20% life.

                */
                int nRank = GetCreatureRank(stEvent.oTarget);
                float fMaxHealth = GetMaxHealth(stEvent.oTarget);
                float fCurrentHealth = GetCurrentHealth(stEvent.oTarget);
                float fDamage;
                float fHealthRatio = fCurrentHealth/fMaxHealth;
                float fKillshotRatio;// = CRITICAL_STRIKE_DEATHBLOW_PERCENTAGE; //.20


                /*
                Based upon the rank, we'll set the life ratio in which an enemy will get instagibbed.
                 Bosses and Players are defaulted to 20%.
                */
                switch (nRank)
                {
                    case CREATURE_RANK_ELITE_BOSS:
                    {
                        fKillshotRatio = .15f; // Kill elite bosses at 15 percent life.
                        break;
                    }
                    case CREATURE_RANK_CRITTER:
                    case CREATURE_RANK_WEAK_NORMAL:
                    case CREATURE_RANK_NORMAL:
                    {
                        fKillshotRatio = .45f;
                        break;
                    }
                    case CREATURE_RANK_LIEUTENANT:
                    {
                        fKillshotRatio = .35f
                        break;
                    }
                    default:
                    {
                        fKillshotRatio = .2f;
                        break;
                    }
                }

... other stuff. Purple text is the line that catches, everything below float fDamage; I added. (yes, the GetCreatureRank was there, but the result unused).

Modifié par DodgeMoreLightning, 02 janvier 2010 - 01:16 .


#4
Axe_Murderer

Axe_Murderer
  • Members
  • 279 messages
Write 0.2 instead of .2 you can't leave the leading zero out.