Errors and code...

martix

There is no spoon
Reaction score
49
Save errors and code...

Today I tried to make a function that give me the armor of a given unit.
The problems however started when I tried to test it... newgen began giving me all sorts of strange errors when I tried to save the map.
Errors like access violations/bad pointers for jasshelper and war3.exe/storm.dll start errors and "Unrecognized PJASS (syntax) errors"
From my tests, its seems my code breaks something. And I do not know whats wrong with it. So... help?!
http://www.wc3campaigns.net/showthread.php?t=101346 - Vex's Log Lib
JASS:
library GetArmor requires Logarithm 
    function GetUnitArmor takes unit whichUnit returns real
        local real Armor
        local real OldHp = GetUnitState(whichUnit,UNIT_STATE_LIFE)
        local real NewHp
        local real MaxLife = GetUnitState(whichUnit, UNIT_STATE_MAX_LIFE)
        local real DamageTaken
        local real DamageCheck = 0.001 * MaxLife
        local boolean HealCheck = (OldHp < MaxLife-(0.002*MaxLife))        
        if HealCheck == false then
            call UnitDamageTarget(whichUnit, whichUnit, DamageCheck, true, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
            set NewHp = GetUnitState(whichUnit, UNIT_STATE_LIFE)
            set DamageTaken = OldHp-NewHp
            call SetUnitState(whichUnit, UNIT_STATE_LIFE, OldHp)
            if DamageTaken<=DamageCheck then
                set Armor = ((50.00 * ((DamageCheck - DamageTaken) / DamageCheck)) / (3.00 + (3.00 * ((DamageCheck - DamageTaken) / DamageCheck))))
            else
                set Armor = (-1.00 * (Log(2.00-((DamageCheck - DamageTaken) / DamageCheck))/(Log(0.94))))
            endif
            return Armor
        else
            call SetUnitState(whichUnit, UNIT_STATE_LIFE, OldHp+ 0.002*MaxLife)
            call UnitDamageTarget(whichUnit, whichUnit, DamageCheck, true, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
            set NewHp = GetUnitState(whichUnit, UNIT_STATE_LIFE)
            set DamageTaken = OldHp+0.001*MaxLife-NewHp
            call SetUnitState(whichUnit, UNIT_STATE_LIFE, OldHp)
            if DamageTaken<=DamageCheck then
                set Armor = ((50.00 * ((DamageCheck - DamageTaken) / DamageCheck)) / (3.00 + (3.00 * ((DamageCheck - DamageTaken) / DamageCheck))))
            else
                set Armor = (-1.00 * (Log(2.00-((DamageCheck - DamageTaken) / DamageCheck))/(Log(0.94))))
            endif
            return Armor
        endif
    endfunction
endlibrary

I'm not even sure about the concept I am using. If anyone has better ideas, go ahead and tell me :)
 

T.s.e

Wish I was old and a little sentimental
Reaction score
133
Unrecognized Pjass Errors have nothing to do with your code. I used to get them no matter what I did, but then they mysteriously vanished as I updated NewGen. I would recommend reinstalling NewGen.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top