HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Could use JASS help

01-24-2007, 06:30 PM#1
Tastingo
I don't really know JASS, but I'm helping someone with an ability that everytime anyone under the aura kills a unit the killing unit loses x defense.

I have a variable called INTSpellsArray which is an integer array and it tells how much defense each player loses. I was wondering if someone could create me a jass script that decreases the defense of the killing unit by INTSpellsArray [Player number of owner of killing unit]. I don't want to edit the map with World Editor Unlimted because my friend doesn't have it so I tried using all the variables from it and all the jass script, but for some reason it wasn't working. I made sure I had all the functions and etc.
01-24-2007, 09:07 PM#2
Av3n
Post your functions then

-Av3n
01-24-2007, 10:18 PM#3
Tastingo
I don't think I have it anymore because it wasn't working and replaced it with all the functions to see if maybe one of the functions couldn't call another because of placement. I can't check because its at my other house, but do you think you could help make one from scratch?
01-24-2007, 10:53 PM#4
Tastingo
I couldn't find it so i copied and pasted all over again, yes I know there is not a event; all i need is the action checked. I also have udg_zz_BnsBit created within the globals, and have the spells Advanced - Armor Bonus.

Gui Trigger:
Trigger:
Custom Script: call ChangeDefense( GetKillingUnitBJ(), false, udg_INTSpellsArray[GetConvertedPlayerId(GetOwningPlayer(GetKillingUnitBJ()))] )

JASS Functions: (These are all created in the all JASS section)
Collapse JASS:
function Ix takes integer x, integer y returns integer
return(x*12+y)
endfunction
function GetBonus takes unit who,integer t returns integer
local integer array bit
local integer i=1
local integer bonus=0
set bit[0]=1
loop
set bit[i]=bit[i-1]*2
exitwhen i==11
set i=i+1
endloop
set i=i+1
loop
if (UnitRemoveAbilityBJ(udg_zz_BnsBit[Ix(t,i)],who)==true) then
call UnitAddAbilityBJ(udg_zz_BnsBit[Ix(t,i)],who)
set bonus=bonus+bit[i]
endif
exitwhen i==0
set i=i-1
endloop
return (bonus)
endfunction
function ClearBonus takes unit who,integer t returns nothing
local integer i=0
loop
call UnitRemoveAbilityBJ(udg_zz_BnsBit[Ix(t,i)],who)
exitwhen i==11
set i=i+1
endloop
endfunction
function SetBonus takes integer amount,unit who,integer t returns boolean
local integer bonus=amount
local integer array bit
local integer i=1
set bit[0]=1
loop
set bit[i]=bit[i-1]*2
exitwhen i==11
set i=i+1
endloop
call ClearBonus(who,t)
loop
if (bonus>=bit[i]) then
call UnitAddAbilityBJ(udg_zz_BnsBit[Ix(t,i)],who)
set bonus=bonus-bit[i]
endif
exitwhen i==0
set i=i-1
endloop
return (amount<=4095 and t<=3 and t>=0 and amount>=0 and who!=null)
endfunction
function AddBonus takes integer amount,unit who,integer t returns boolean
return SetBonus((GetBonus(who,t)+amount),who,t)
endfunction
function ChangeDefense takes unit U, boolean Increase, integer Zahl returns nothing
if not Increase then
set Zahl = 0 - Zahl
endif
call AddBonus(Zahl,U,1)
endfunction
01-24-2007, 10:55 PM#5
Hydrolisk
Well, all I can say is persuade this person to get WEU! That is THE MOST easiest way. Basically, the trigger would look like this.

TRIGGER: Event: A unit is dies.
Condition: Killing unit has buff (YOUR BUFF).
Action (As I said before, persuade him/her to use WEU. No harm done.): Set Killing unit's armour to Killing unit's armour subtracted by (X).

I'll just say this one last time, convince your friend to get WEU. I can't think of any reason not to use it, since it's quite superior.
01-24-2007, 11:13 PM#6
Tastingo
I have kept trying to and he says no for some odd reason, anyway does anyone think they could help me by checking all my functions?