| 09-02-2007, 04:58 AM | #1 |
I'm trying to use Daelin's armor detection system http://www.wc3campaigns.net/showthread.php?t=85631 In the post he mentions that a certain part of his system causes a crash with anything that uses DamageTargetUnit in a EVENT_UNIT_DAMAGED. He says he fixed it by putting in some protector lines of code. I get crashes as soon as a unit takes damage. The only thing I did was copied the header code from his map into mine. It's important to note that I am using Shadow 1500's damage detection and reduction system as well. Does anyone know what's going on here? Thanks ahead of time. |
| 09-02-2007, 05:42 AM | #2 |
Humm... does it crash once a unit takes ANY kind of damage or trigger damage? |
| 09-02-2007, 01:53 PM | #3 |
Any unit takes any kind of damage. |
| 09-02-2007, 07:09 PM | #4 |
Have you tried isolating the problem to a function or 2 if you can post it here and I can help ya. If ya cant do that post what you have so far at least. |
| 09-03-2007, 01:35 AM | #5 |
Ok, I reloaded the trigger code and it works fine now. The only problem, is that implementation of my spell using the system is not working. My spell is supposed to create charges that will ignore a unit's armor on attack. When I test in Vex's editor, it tells me that there is a divide by 0 error in this function of the armor system. JASS://DETECT UNIT'S ARMOR function GetUnitArmor takes unit whichUnit returns real local real life = GetWidgetLife(whichUnit) local real reduction local integer ID local boolean b if (whichUnit!=null and life>=0.405) then set ID = Armor_ID() set b = IsUnitInvulnerable(whichUnit) call UnitAddAbility(whichUnit, 'allz') call UnitAddAbility(whichUnit, ID) if b==true then call SetUnitInvulnerable(whichUnit, false) endif call ADS_UnitDamageTarget (whichUnit, whichUnit, 16.00, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL) if b==true then call SetUnitInvulnerable(whichUnit, true) endif set reduction = (16.00-(life-GetWidgetLife(whichUnit)))/16.00 call UnitRemoveAbility(whichUnit, 'allz') call UnitRemoveAbility(whichUnit, ID) call SetWidgetLife(whichUnit, life) return (50*reduction/(3.00-(3.00*reduction)))-30.00 else return 0.00 endif endfunction I can only see 2 places that divide, and don't see how they can be 0. It's important to note that my ability in question uses the event EVENT_PLAYER_UNIT_ATTACKED. But in Daelin's test map, his spell trigger uses EVENT_UNIT_SPELLCAST without a problem. |
| 09-03-2007, 01:45 AM | #6 |
if reduction is = 1 it could be a /0 error try to just temporally remove that and see if it still errors. Also try just for kicks try removing the /16.00 if the other thing doesn't work |
| 09-03-2007, 02:58 AM | #7 |
Changing reduction to a flat number works. For the sake of simplicity, I changed it to 15.99. The thing is that, the unit will still not ignore armor against a foe w/20 armor, but when i change "reduction" in the function to say, 0.9, then it will do more damage. (0.9 means the damage is reduced 90%, so attacks do 9x more dmg). It seems like the "reduction" part of it is just not computing things correctly. I thought that taking the unit's life before adding the HP buff would skew the numbers (it records the starting life as 100, the 50 HP bonus is added, the unit is damaged for 16, and the final HP is 134. The reduction would be -34%.) So i redeclared the units life after the ability was added, but it still fails to ignore the unit's armor. -------------------------------------------------------------------------------------------- EDIT:After 4 hours of tweaking I finally got Daelin's armor system to work with Shadow 1500's damage modification and detection system. Here's what I found: Using any function from Daelin's armor system, or "DamageUnitTarget" within the damage detection system causes a crash. So, getting this ability to work with UNIT_EVENT_ATTACKED requires a trigger separate from the detection system. In the separate trigger, any variables obtainable from the armor system (armor #, armor type...) must be stored and used here. Those numbers can then be used in the damage system. For instance, when my unit has a buff and attacks, the attacked unit's armor is stored to a global variable. In the damage detection trigger, I use the function GetFullDamage(unit, armor) using the global variable "armor". Since GetFullDamage is just a number crunch, it doesn't crash the game. From there I just used DamageModify(DamageNoArmor) using the damage modification system by Shadow 1500. |
