| 10-23-2006, 04:41 PM | #1 |
I am currently searching for bugs in my DamageQualityEngine: It starts bugging when used DQ() [DamageQuality] and HQ() [Heal Quality] multiple times. JASS:function GetDamageFactor takes unit u,attacktype a, damagetype d returns real local real hp=GetWidgetLife(u) local real mana=GetUnitState(u,UNIT_STATE_MANA) local real r local unit c=GetACaster() call SetUnitXY(c,GetUnitX(u),GetUnitY(u)) call SetUnitOwner(c,GetOwningPlayer(u),false) call UnitRemoveAbility(c,'Aloc') //Otherwise the units would flee like crazy set r=hp if (hp<1.) then call SetWidgetLife(u,1.) set r=1. endif call UnitDamageTarget(c,u,0.1,true,false,a,d,null) call RecicleCaster(c) if (mana>GetUnitState(u,UNIT_STATE_MANA)) then //Unit had mana shield,return 1 and restore mana too. call SetUnitState(u,UNIT_STATE_MANA,mana) set r=1. else set r=(r-GetWidgetLife(u))*10. endif call SetWidgetLife(u,hp) set c=null return r endfunction function DQ takes nothing returns integer set udg_BTJint[0]=0 set udg_BTJint[6]=0 set udg_BTJint[21]=0 set udg_BTJint[36]=0 set udg_BTJint[40]=0 set udg_BTJint[88]=0 return 0 endfunction function HQ takes nothing returns integer set udg_BTJint[0]=1 set udg_BTJint[50]=0 set udg_BTJint[65]=0 set udg_BTJint[80]=0 set udg_BTJint[84]=0 set udg_BTJint[89]=0 return 0 endfunction function Self takes nothing returns integer set udg_BTJint[88+udg_BTJint[0]]=udg_BTJint[88+udg_BTJint[0]]+1 return 0 endfunction function OnlyVisible takes nothing returns integer set udg_BTJint[88+udg_BTJint[0]]=udg_BTJint[88+udg_BTJint[0]]+2 return 0 endfunction function OnlyDeadState takes nothing returns integer set udg_BTJint[88+udg_BTJint[0]]=udg_BTJint[88+udg_BTJint[0]]+4 return 0 endfunction function IgnoreDeadState takes nothing returns integer set udg_BTJint[88+udg_BTJint[0]]=udg_BTJint[88+udg_BTJint[0]]+8 return 0 endfunction function Trees takes nothing returns integer set udg_BTJint[88+udg_BTJint[0]]=udg_BTJint[88+udg_BTJint[0]]+16 return 0 endfunction function DamageType takes attacktype at,damagetype dt returns integer local integer i=udg_BTJint[0]*44 set udg_BTJint[1+i]=H2I(at) set udg_BTJint[2+i]=H2I(dt) set udg_BTJint[88+udg_BTJint[0]]=udg_BTJint[88+udg_BTJint[0]]+32 return 0 endfunction function FactorAEN takes real a, real e,real n returns integer local integer i=udg_BTJint[0]*44 set udg_BTJint[3+i]=r2int(a) set udg_BTJint[4+i]=r2int(e) set udg_BTJint[5+i]=r2int(n) set udg_BTJint[88+udg_BTJint[0]]=udg_BTJint[88+udg_BTJint[0]]+64 return 0 endfunction function FactorType takes unittype t,real f returns integer local integer i=udg_BTJint[0]*44 set udg_BTJint[7+i+udg_BTJint[6+i]*2]=H2I(t) set udg_BTJint[8+i+udg_BTJint[6+i]*2]=r2int(f) set udg_BTJint[6+i]=udg_BTJint[6+i]+1 if udg_BTJint[6+i]==1 then set udg_BTJint[88+udg_BTJint[0]]=udg_BTJint[88+udg_BTJint[0]]+128 endif return 0 endfunction function AbilityFactor takes integer a,real f returns integer local integer i=udg_BTJint[0]*44 set udg_BTJint[22+i+udg_BTJint[21+i]*2]=a set udg_BTJint[23+i+udg_BTJint[21+i]*2]=r2int(f) set udg_BTJint[21+i]=udg_BTJint[21+i]+1 if udg_BTJint[21+i]==1 then set udg_BTJint[88+udg_BTJint[0]]=udg_BTJint[88+udg_BTJint[0]]+256 endif return 0 endfunction function OnlyType takes unittype t returns integer local integer i=udg_BTJint[0]*44 set udg_BTJint[37+i+udg_BTJint[36+i]]=H2I(t) set udg_BTJint[36+i]=udg_BTJint[36+i]+1 if udg_BTJint[36+i]==1 then set udg_BTJint[88+udg_BTJint[0]]=udg_BTJint[88+udg_BTJint[0]]+512 endif return 0 endfunction function OnlyAbility takes integer a returns integer local integer i=udg_BTJint[0]*44 set udg_BTJint[41+i+udg_BTJint[40+i]]=a set udg_BTJint[40+i]=udg_BTJint[40+i]+1 if udg_BTJint[40+i]==1 then set udg_BTJint[88+udg_BTJint[0]]=udg_BTJint[88+udg_BTJint[0]]+1024 endif return 0 endfunction function GetTreatFactorQ takes unit owner,unit u,integer q,integer i returns real local integer a local integer v local real f=1.00 local boolean b=false local boolean e=false //call Test("---------------------------------------") //call Test("|cffff0000"+GetUnitName(u)+"|r") // -> HQ index = DQ index + 44 => => HQ index = 44 ; DQ index 0 => DQ q index =88 HQ q index = 89 //only abi [max x3] -> i=i+3+1=i+4 look upwards if q>=1024 then set q=q-1024 set a=udg_BTJint[40+i] set v=i loop set e=true set b= GetUnitAbilityLevel(u,udg_BTJint[41+v])>0 exitwhen b set a=a-1 exitwhen (a<=0) set v=v+1 endloop if e and not b then //call Test("only abi !!") return 0.00 endif set b=false set e=false //call Test("only abi"+R2S(f)) endif //only types [max x3] -> i=i+3+1=i+4 look upwards if q>=512 then set q=q-512 set a=udg_BTJint[36+i] set v=i loop set e=true set b= IsUnitType(u,ConvertUnitType(udg_BTJint[37+v])) exitwhen b set a=a-1 exitwhen (a<=0) set v=v+1 endloop if e and not b then //call Test("only types !!") return 0.00 endif set b=false set e=false //call Test("only types "+R2S(f)) endif //factorabilities [max x7] -> i=i+2*7+1=i+15 look upwards if q>=256 then set q=q-256 set a=udg_BTJint[21+i] set v=i loop if GetUnitAbilityLevel(u,udg_BTJint[22+v])>0 then set f=f*int2r(udg_BTJint[23+v]) exitwhen (f==0.0) endif set a=a-1 exitwhen (a<=0) set v=v+2 endloop //call Test("factor abi "+R2S(f)) endif //factortypes [max x7] -> i=i+2*7+1=i+15 look upwards if q>=128 then set q=q-128 set a=udg_BTJint[6+i] set v=i loop if IsUnitType(u,ConvertUnitType(udg_BTJint[7+v])) then set f=f*int2r(udg_BTJint[8+v]) exitwhen (f==0.0) endif set a=a-1 exitwhen (a<=0) set v=v+2 endloop //call Test("factor type "+R2S(f)) endif //FactorAEN if q>=64 then set q=q-64 if IsUnitAlly(u,GetOwningPlayer(owner)) then set f=f*int2r(udg_BTJint[3+i]) elseif IsUnitEnemy(u,GetOwningPlayer(owner)) then set f=f*int2r(udg_BTJint[4+i]) else set f=f*int2r(udg_BTJint[5+i]) endif //call Test("AEN "+R2S(f)) if f==0.0 then return 0.0 endif endif //damagefactor if q>=32 then set q=q-32 set f=f*GetDamageFactor(u,ConvertAttackType(udg_BTJint[1+i]),ConvertDamageType(udg_BTJint[2+i])) //call Test("damage factor "+R2S(f)) endif //trees if q>=16 then set q=q-16 endif if q>=8 then //no matter dead or not set q=q-8 elseif q>=4 then //only dead state units set q=q-4 if GetWidgetLife(u)>0.405 then //call Test("dead stuff [only dead] !!") return 0.0 endif elseif GetWidgetLife(u)<=0.405 then //only living units (standard) //call Test("dead stuff [standard] !!") return 0.0 endif //only visible if q>=2 then set q=q-2 if not ( IsUnitVisible(u,GetOwningPlayer(owner)) and IsUnitVisible(u,Player(13)) ) then return 0. endif //call Test("visible "+R2S(f)) endif //selfdamager if q>=1 then set q=q-1 //call Test("self") elseif owner==u then //call Test("self !!") return 0.00 endif //call Test("final factor f=="+R2S(f)) return f endfunction function UnitTreatUnitQ takes unit u,unit t,real a,integer q returns integer local real f=0. if udg_BTJint[88]>0 then set f=GetTreatFactorQ(u,t,udg_BTJint[88],0) endif if f!=0. then if a!=0. then call UnitDamageTarget(u,t,(f*a),true,false,null,null,null) endif return 1 elseif udg_BTJint[89]>0 then set f=GetTreatFactorQ(u,t,udg_BTJint[89],44) if f!=0. then if a!=0. then call SetWidgetLife(t,(f*a)+GetWidgetLife(t)) endif return 2 endif endif return 0 endfunction Thx for every answer or suggestion. hx for the GetDamageFactor function and the first idea of "DamageOptions" to Vexorian. |
| 10-23-2006, 04:47 PM | #2 |
can you elaborate on what you mean by bugging? |
| 10-23-2006, 04:51 PM | #3 |
Damaging units which were excluded or other confusing stuff, but no crashes, no lag/leakage. EDIT: For Example: JASS:function LiquidFire_Q takes nothing returns integer return DQ()+DamageType(ATTACK_TYPE_CHAOS,DAMAGE_TYPE_FIRE)+AbilityFactor('A080',0)+FactorType(UNIT_TYPE_STRUCTURE,0.5)+Trees()+HQ()+OnlyAbility('A080')+AbilityFactor('A080',0.5) endfunction This Q determines to heal fire-guys @ 50% of the initial damage, aswell damaging structures only 50%. But when 'bugging', fire-elements get damaged aswell !? |
| 10-24-2006, 09:54 AM | #4 |
I think it is not that hard to understand the code,... so plx, if you understood the code, and did not find any logical reasons why the code should bug out, post. |
