• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Item various Problems

Status
Not open for further replies.
Hi guys, i am making triggers about items (armors in this case) but they don't work and i make no idea why... Apparently everything is fine and JassCraft points no errors ... Could anyone please tell what is wrong with this scrips ?? because i don't know ...

1st script:
JASS:
function SpikedArmor_Conds takes nothing returns boolean
    local integer stunchance = 7
    return GetRandomInt(1, 100) <= stunchance and IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) and GetInventoryIndexOfItemTypeBJ(GetTriggerUnit(), 'I019') > 0 and IsUnitType(GetAttacker(), UNIT_TYPE_MELEE_ATTACKER)
endfunction
//======================================================================================================================================================================================================================
function SpikedArmor_Acts takes nothing returns nothing
    local unit victim = GetTriggerUnit()
    local unit attacker = GetAttacker()
    local unit dummy = CreateUnit( GetOwningPlayer(victim), 'h01H', GetUnitX(attacker), GetUnitY(attacker), 0)
    call UnitAddAbility(dummy, 'A04L')
    call IssueTargetOrder(dummy, "thunderblot", attacker)
    call UnitApplyTimedLife(dummy, 'BTLF', 2.5)
    set victim = null
    set attacker = null
    set dummy = null  
endfunction
//===========================================================================
function InitTrig_Spiked_Armor takes nothing returns nothing
    local trigger SpikedArmor = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( SpikedArmor, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( SpikedArmor, Condition( function SpikedArmor_Conds ) )
    call TriggerAddAction( SpikedArmor, function SpikedArmor_Acts )
    set SpikedArmor = null
endfunction

This is a simple script... When a unit gets attacked and if the attacker is melle, the attacked unit is a hero and if the hero has the item, the hero will have 7% chances to stun the attacker .... However this don't seem to be working at all and it really annoys me because i don't find this script difficult, not can i find any mistakes ...

2nd script:
JASS:
function StrenghtArmor_Conds takes nothing returns boolean
    local integer STchance = 7
    return GetRandomInt(1, 100) <= STchance and IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) and GetInventoryIndexOfItemTypeBJ(GetTriggerUnit(), 'I01A') > 0
endfunction
//======================================================================================================================================================================================================================
function StrenghtArmor_Acts takes nothing returns nothing
    local unit victim = GetTriggerUnit()
    local effect ef = AddSpecialEffectTarget("Abilities\\Spells\\Human\\DivineShield\\DivineShieldTarget.mdl", victim, "origin")
    call SetUnitState(victim, UNIT_STATE_MAX_LIFE, (GetWidgetLife(victim) + 150))
    call DestroyEffect(ef)
    call TriggerSleepAction(10.0)
    call SetUnitState(victim, UNIT_STATE_MAX_LIFE, (GetWidgetLife(victim) - 150))
    set ef = null
    set victim = null    
endfunction
//===========================================================================
function InitTrig_Strenght_Armor takes nothing returns nothing
    local trigger StrenghtArmor = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( StrenghtArmor, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( StrenghtArmor, Condition( function StrenghtArmor_Conds ) )
    call TriggerAddAction( StrenghtArmor, function StrenghtArmor_Acts )
    set StrenghtArmor = null
endfunction

This armor is similar to the other. If a hero with this item is attacked, he has 7% chance of gaining 150 hp for 10 seconds ... However it does NOT work .. so i don't know what i am doing wrong ..

3rd script:
JASS:
function MultiOrb_Conds takes nothing return boolean
    local integer MOchance = 10
    return GetRandomInt(1, 100) <= MOchance and IsUnitType(GetAttacker()), UNIT_TYPE_HERO == true and GetInventoryIndexOfItemTypeBJ(GetAttacker(), 'I00C') > 0
endfunction
//===========================================================================
function MultiOrb_Acts takes nothing returns nothing
    local unit vic = GetTriggerUnit()
    local unit att = GetAttacker()
    local unit dum
    local effect ef 
    if IsUnitType(vic, ConvertUnitType(2)) == true then
        set dum = CreateUnit( GetOwningPlayer(att), 'h01H', GetUnitX(vic), GetUnitY(vic), 0)
        call UnitApplyTimedLife(dum, 'BTLF', 3.00)
        call UnitAddAbility(dum, 'A03U')
        call IssueTargetOrder(dum, "thunderbolt", vic)
    elseif IsUnitType(vic, ConvertUnitType(2)) == false and IsUnitType(vic, ConvertUnitType(15)) == true then
        set dum = CreateUnit( GetOwningPlayer(att), 'h01H', GetUnitX(vic), GetUnitY(vic), 0)
        call UnitApplyTimedLife(dum, 'BTLF', 3.00)
        call UnitAddAbility(dum, 'A03T')
        call IssueTargetOrder(dum, "slow", vic)
    elseif IsUnitType(vic, ConvertUnitType(2)) == false and IsUnitType(vic, ConvertUnitType(15)) == false then 
        set ef = AddSpecialEffectTarget("Abilities\\Spells\\Human\\Heal\\HealTarget.mdl", att, "chest")
        call UnitDamageTarget(att, vic, 100, true, false, ConvertAttackType(5), ConvertDamageType(26), null)
        call SetUnitState(att, UNIT_STATE_LIFE, GetUnitState(att, UNIT_STATE_MAX_LIFE)*RMaxBJ(0, GetRandomReal(5.00, 10.00))*0.01)
        call DestroyEffect(ef)
    endif
    set vic = null
    set att = null
    set dum = null
    set ef = null
endfunction
//===========================================================================
function InitTrig_Multi_Orb takes nothing returns nothing
    local trigger MultiOrb = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( MultiOrb, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( MultiOrb, Condition( function MultiOrb_Conds ) )
    call TriggerAddAction( MultiOrb, function MultiOrb_Acts )
    set MultiOrb = null
endfunction

Now this last one is the Multi Orb, it gives the hero a chance to do multiple effects depending on the unit type when attacking. if the unit is a structure, the hero freezes it, if it it mechanical, it slows it and finally if it is organic it deals 100 bonus damage and heal 5 to 10% of his life.
It works in GUI but here when i place this script in the program it says i have 32 errors ... and i don't know why ...

Can anyone please tell what is wrong with these 3 scripts ?
 
Last edited:
Level 40
Joined
Dec 14, 2005
Messages
10,532
When you're debugging, try putting all your chances to 100%.

#3 also has a syntax error; you close the bracket for IsUnitType before UNIT_TYPE_HERO instead of after it.

Also, ==true is not needed except in very special circumstances (something to do with the last boolean comparison in a boolexpr being IsUnitType)

Also, 'blah == false' is alot cleaner written as 'not blah'

Also, for multi orb

A) use the bj globals (UNIT_TYPE_BLAH) instead of ConvertUnitType; variables are faster

B) Elseif only fires if the previous if/elseif doesn't, so you don't need to make sure the previous if/elseif's conditions were false.

StrengthArmor; natives don't allow you to change max states. Check out SetUnitMaxState by Blade.dk

SpikedArmor; try adding an ==true after IsUnitType(GetAttacker(),UNIT_TYPE_MELEE_ATTACKER) (it's that nasty boolexpr thing I was talking about earlier, as far as I know)
 
PurplePoot said:
When you're debugging, try putting all your chances to 100%.

#3 also has a syntax error; you close the bracket for IsUnitType before UNIT_TYPE_HERO instead of after it.

werrmmmmm i don't understand what you mean with these 2 paragraphs.

About Strenght Armor and the Spiked armor i understood what you mean and i will fix them as soon as possible.

About multiorb well that is kind of messy =s .... but i will find a way to fix it, thx by the replly.

------------------------------------------------------------------------

OK, now here are the changes i made.

Spiked armor:
JASS:
function SpikedArmor_Conds takes nothing returns boolean
    local integer stunchance = 7
    return GetRandomInt(1, 100) <= stunchance and IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO)==true and GetInventoryIndexOfItemTypeBJ(GetTriggerUnit(), 'I019') > 0 and IsUnitType(GetAttacker(), UNIT_TYPE_MELEE_ATTACKER) ==true
endfunction
//======================================================================================================================================================================================================================
function SpikedArmor_Acts takes nothing returns nothing
    local unit victim = GetTriggerUnit()
    local unit attacker = GetAttacker()
    local unit dummy = CreateUnit( GetOwningPlayer(victim), 'h01H', GetUnitX(attacker), GetUnitY(attacker), 0)
    call UnitAddAbility(dummy, 'A04L')
    call IssueTargetOrder(dummy, "thunderblot", attacker)
    call UnitApplyTimedLife(dummy, 'BTLF', 2.5)
    set victim = null
    set attacker = null
    set dummy = null  
endfunction
//===========================================================================
function InitTrig_Spiked_Armor takes nothing returns nothing
    local trigger SpikedArmor = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( SpikedArmor, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( SpikedArmor, Condition( function SpikedArmor_Conds ) )
    call TriggerAddAction( SpikedArmor, function SpikedArmor_Acts )
    set SpikedArmor = null
endfunction

i did that "==true" stuff but it still doesn't work =(

Strenght Armor:
JASS:
function StrenghtArmor_Conds takes nothing returns boolean
    local integer STchance = 7
    return GetRandomInt(1, 100) <= STchance and IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) and GetInventoryIndexOfItemTypeBJ(GetTriggerUnit(), 'I01A') > 0
endfunction
//======================================================================================================================================================================================================================
function StrenghtArmor_Acts takes nothing returns nothing
    local unit victim = GetTriggerUnit()
    local effect ef = AddSpecialEffectTarget("Abilities\\Spells\\Human\\DivineShield\\DivineShieldTarget.mdl", victim, "origin")
    local integer php = GetWidgetLife(victim) + 150
    local integer lhp = GetWidgetLife(victim) - 150
    call SetUnitMaxState(victim, UNIT_STATE_MAX_LIFE, php)
    call TriggerSleepAction(10.0)
    call DestroyEffect(ef)
    call SetUnitMaxState(victim, UNIT_STATE_MAX_LIFE, lhp)
    set ef = null
    set victim = null    
endfunction
//===========================================================================
function InitTrig_Strenght_Armor takes nothing returns nothing
    local trigger StrenghtArmor = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( StrenghtArmor, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( StrenghtArmor, Condition( function StrenghtArmor_Conds ) )
    call TriggerAddAction( StrenghtArmor, function StrenghtArmor_Acts )
    set StrenghtArmor = null
endfunction

After reading the tutorial and studding the map i did everything correctly, but the result was over 467 errors and an unknown function.

Multi Orb:
JASS:
function MultiOrb_Conds takes nothing returns boolean
    local integer MOchance = 10
    return GetRandomInt(1, 100) <= MOchance and IsUnitType(GetAttacker()), UNIT_TYPE_HERO) and GetInventoryIndexOfItemTypeBJ(GetAttacker(), 'I00C') > 0
endfunction
//===========================================================================
function MultiOrb_Acts takes nothing returns nothing
    local unit vic = GetTriggerUnit()
    local unit att = GetAttacker()
    local unit dum
    local effect ef 
    if IsUnitType(vic, UNIT_TYPE_STRUCTURE) == true then
        set dum = CreateUnit( GetOwningPlayer(att), 'h01H', GetUnitX(vic), GetUnitY(vic), 0)
        call UnitApplyTimedLife(dum, 'BTLF', 3.00)
        call UnitAddAbility(dum, 'A03U')
        call IssueTargetOrder(dum, "thunderbolt", vic)
    endif
    if IsUnitType(vic, UNIT_TYPE_STRUCTURE) == false and IsUnitType(vic, UNIT_TYPE_MECHANICAL) == true then
        set dum = CreateUnit( GetOwningPlayer(att), 'h01H', GetUnitX(vic), GetUnitY(vic), 0)
        call UnitApplyTimedLife(dum, 'BTLF', 3.00)
        call UnitAddAbility(dum, 'A03T')
        call IssueTargetOrder(dum, "slow", vic)
    endif
    if IsUnitType(vic, UNIT_TYPE_STRUCTURE) == false and IsUnitType(vic, UNIT_TYPE_MECHANICAL) == false then 
        set ef = AddSpecialEffectTarget("Abilities\\Spells\\Human\\Heal\\HealTarget.mdl", att, "chest")
        call UnitDamageTarget(att, vic, 100, true, false, ConvertAttackType(5), ConvertDamageType(26), null)
        call SetUnitState(att, UNIT_STATE_LIFE, GetUnitState(att, UNIT_STATE_MAX_LIFE)*RMaxBJ(0, GetRandomReal(5.00, 10.00))*0.01)
        call DestroyEffect(ef)
    endif
    set vic = null
    set att = null
    set dum = null
    set ef = null
endfunction
//===========================================================================
function InitTrig_Multi_Orb takes nothing returns nothing
    local trigger MultiOrb = CreateTrigger()
    local integer index = 0
    loop 
        exitwhen index == 16
        call TriggerRegisterPlayerUnitEvent(MultiOrb, Player(index), EVENT_PLAYER_UNIT_ATTACKED, null)
        set index = index + 1
    endloop
    call TriggerAddCondition( MultiOrb, Condition( function MultiOrb_Conds ) )
    call TriggerAddAction( MultiOrb, function MultiOrb_Acts )
    set MultiOrb = null
endfunction

Solve 31 errors when i replaced "return" by "returns" in the first line ... still i have errors i make no idea where they come form ..
 
Last edited by a moderator:
Level 40
Joined
Dec 14, 2005
Messages
10,532
werrmmmmm i don't understand what you mean with these 2 paragraphs.

About Strenght Armor and the Spiked armor i understood what you mean and i will fix them as soon as possible.

About multiorb well that is kind of messy =s .... but i will find a way to fix it, thx by the replly.

For the first line, I meant that you should make all your % chances to 100% when you're debugging a %chance spell, so that it's easier to test.

For the second line, I meant that IsUnitType(GetAttacker()), UNIT_TYPE_HERO == true should be IsUnitType(GetAttacker(), UNIT_TYPE_HERO)

----------------------------------------------------------------------------------------

Are you sure you copied all the SetUnitMaxState functions (SetUnitMaxState and whatever the other function is), plus put them above the script you're trying to use them from (like in the header of the map, for example)?

For SpikedArmor, you should probably just make sure all your rawcodes are correct and your orderstring is correct, because it doesn't look like there're any other errors.
 
Well, about Spiked armor that is what i first thought - that the rawcodes are wrong but after checking them 5 times i jumped the to the conclusion that they were ok ... Than i thought "perhaps my dummy spell has mana cost" but it didn't.. and after that i thought "perhaps it is not checking the dependencies as it should" but it also is checking them ... so blarg screw it there is now way for me to do this spell, so i will start from zero, make it in GUI, convert it into JASS and optimize the script as best as i can.

About the Strength Armor, well, yes blarg too because i think i did everything ok ....

I placed this code on my maps header:
JASS:
constant function MaxStateModifierId takes unitstate u returns integer
    if u == UNIT_STATE_MAX_LIFE then
        return 'A04S' // Rawcode of the Max Life Modifier ability.
    elseif u == UNIT_STATE_MAX_MANA then
        return 'A04T' // Rawcode of the Max Mana Modifier ability.
    endif
    return 0
endfunction

function SetUnitMaxState takes unit whichUnit, unitstate whichUnitState, integer newVal returns boolean
    local integer c = newVal-R2I(GetUnitState(whichUnit, whichUnitState))
    local integer i = MaxStateModifierId(whichUnitState)
    if i == 0 then
        return false
    endif
    if c > 0 then
        loop
            exitwhen c == 0
            call UnitAddAbility(whichUnit, i)
            if c >= 100 then
                set c = c - 100
                call SetUnitAbilityLevel(whichUnit, i, 4)
            elseif c >= 10 then
                set c = c - 10
                call SetUnitAbilityLevel(whichUnit, i, 3)
            else
                set c = c - 1
                call SetUnitAbilityLevel(whichUnit, i, 2)
            endif
            call UnitRemoveAbility(whichUnit, i)
        endloop
    elseif c < 0 then
        set c = -c
        loop
            exitwhen c == 0
            call UnitAddAbility(whichUnit, i)
            if c >= 100 then
                set c = c - 100
                call SetUnitAbilityLevel(whichUnit, i, 7)
            elseif c >= 10 then
                set c = c - 10
                call SetUnitAbilityLevel(whichUnit, i, 6)
            else
                set c = c - 1
                call SetUnitAbilityLevel(whichUnit, i, 5)
            endif
            call UnitRemoveAbility(whichUnit, i)
        endloop
    endif
    return true
endfunction
Like the instructions said, than after that i copy-paste the abilities and changed their raw codes like the instructions ... than after that i placed my script which is:
JASS:
function StrenghtArmor_Conds takes nothing returns boolean
    local integer STchance = 7
    return GetRandomInt(1, 100) <= STchance and IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) and GetInventoryIndexOfItemTypeBJ(GetTriggerUnit(), 'I01A') > 0
endfunction
//======================================================================================================================================================================================================================
function StrenghtArmor_Acts takes nothing returns nothing
    local unit victim = GetTriggerUnit()
    local effect ef = AddSpecialEffectTarget("Abilities\\Spells\\Human\\DivineShield\\DivineShieldTarget.mdl", victim, "origin")
    local integer php = GetWidgetLife(victim) + 150
    local integer lhp = GetWidgetLife(victim) - 150
    call SetUnitMaxState(victim, UNIT_STATE_MAX_LIFE, php)
    call TriggerSleepAction(10.0)
    call DestroyEffect(ef)
    call SetUnitMaxState(victim, UNIT_STATE_MAX_LIFE, lhp)
    set ef = null
    set victim = null    
endfunction
//===========================================================================
function InitTrig_Strenght_Armor takes nothing returns nothing
    local trigger StrenghtArmor = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( StrenghtArmor, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( StrenghtArmor, Condition( function StrenghtArmor_Conds ) )
    call TriggerAddAction( StrenghtArmor, function StrenghtArmor_Acts )
    set StrenghtArmor = null
endfunction
and the final result was not 467 compilation errors but it was 457 compilation errors ...

i will read the instructions my 3rd time read them all over again to see if i am doing something wrong but i really don't think i am .....

About the MultiOrb well, i just never debugged a %spell b4 and i can't find any tutorials in this site that show people how those kind of spells work ... my best shot was when i found WyrmLord writing the OmniSlash spell from dota ... and that spell isn't even close to what i want .. so i am kina bad now =S
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
If you want to post your map, I could fix the Strength Armor thing, but it looks like it should work to me.

So MultiOrb still doesn't work? It compiles fine for me

JASS:
function MultiOrb_Conds takes nothing returns boolean
    local integer MOchance = 10
    return GetRandomInt(1, 100) <= MOchance and IsUnitType(GetAttacker(), UNIT_TYPE_HERO) and GetInventoryIndexOfItemTypeBJ(GetAttacker(), 'I00C') > 0
endfunction
//===========================================================================
function MultiOrb_Acts takes nothing returns nothing
    local unit vic = GetTriggerUnit()
    local unit att = GetAttacker()
    local unit dum
    local effect ef 
    if IsUnitType(vic, UNIT_TYPE_STRUCTURE) == true then
        set dum = CreateUnit( GetOwningPlayer(att), 'h01H', GetUnitX(vic), GetUnitY(vic), 0)
        call UnitApplyTimedLife(dum, 'BTLF', 3.00)
        call UnitAddAbility(dum, 'A03U')
        call IssueTargetOrder(dum, "thunderbolt", vic)
    endif
    if IsUnitType(vic, UNIT_TYPE_STRUCTURE) == false and IsUnitType(vic, UNIT_TYPE_MECHANICAL) == true then
        set dum = CreateUnit( GetOwningPlayer(att), 'h01H', GetUnitX(vic), GetUnitY(vic), 0)
        call UnitApplyTimedLife(dum, 'BTLF', 3.00)
        call UnitAddAbility(dum, 'A03T')
        call IssueTargetOrder(dum, "slow", vic)
    endif
    if IsUnitType(vic, UNIT_TYPE_STRUCTURE) == false and IsUnitType(vic, UNIT_TYPE_MECHANICAL) == false then 
        set ef = AddSpecialEffectTarget("Abilities\\Spells\\Human\\Heal\\HealTarget.mdl", att, "chest")
        call UnitDamageTarget(att, vic, 100, true, false, ConvertAttackType(5), ConvertDamageType(26), null)
        call SetUnitState(att, UNIT_STATE_LIFE, GetUnitState(att, UNIT_STATE_MAX_LIFE)*RMaxBJ(0, GetRandomReal(5.00, 10.00))*0.01)
        call DestroyEffect(ef)
    endif
    set vic = null
    set att = null
    set dum = null
    set ef = null
endfunction
//===========================================================================
function InitTrig_Multi_Orb takes nothing returns nothing
    local trigger MultiOrb = CreateTrigger()
    local integer index = 0
    loop 
        exitwhen index == 16
        call TriggerRegisterPlayerUnitEvent(MultiOrb, Player(index), EVENT_PLAYER_UNIT_ATTACKED, null)
        set index = index + 1
    endloop
    call TriggerAddCondition( MultiOrb, Condition( function MultiOrb_Conds ) )
    call TriggerAddAction( MultiOrb, function MultiOrb_Acts )
    set MultiOrb = null
endfunction
 
wermmm .... mmm well apparently my multiorb trigger is 100% equal to yours but i have 4 errors in it ... your trigger has 0 ... will i ever understand ...

About strength armor werrmm ... i really don't fell free enough to post my project here ... it is about 4mb and I've been making it my last 3-4 years -.- so i kinda afraid of people stealing my map ... =s
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
wermmm .... mmm well apparently my multiorb trigger is 100% equal to yours but i have 4 errors in it ... your trigger has 0 ... will i ever understand ...
You had an extra bracket in a weird place... hard to notice, but it matters

About strength armor werrmm ... i really don't fell free enough to post my project here ... it is about 4mb and I've been making it my last 3-4 years -.- so i kinda afraid of people stealing my map ... =s
Kay, no problem, I can understand (I'm careful with my maps often, too)
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
If you really want, you could email it to me at P u r p l e P o o t (at gmail . com)

(All the weirdness with the spacing, not showing the correct @, etc, etc, is for anti-email-grabbing-bot purposes)

However, I really can't see why that wouldn't compile...

EDIT: Won't be necessary, the compile error was actually in your code. Here's a fix (you forgot to R2I the 'GetWidgetLife's).

EDIT EDIT: Updated this, you would their max life to their max life + their current life + 150. It shouldl be MAX + 150 or MAX -150, yes? If so, use the SECOND code snippet instead.

EDIT EDIT EDIT: see code in post below
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
Shiite, don't use what was posted above. I made a bug, then I tried to edit it but I got one of those server is busy messages. Use this--

JASS:
function StrenghtArmor_Conds takes nothing returns boolean
    local integer STchance = 7
    return GetRandomInt(1, 100) <= STchance and IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) and GetInventoryIndexOfItemTypeBJ(GetTriggerUnit(), 'I01A') > 0
endfunction
//======================================================================================================================================================================================================================
function StrenghtArmor_Acts takes nothing returns nothing
    local unit victim = GetTriggerUnit()
    local effect ef = AddSpecialEffectTarget("Abilities\\Spells\\Human\\DivineShield\\DivineShieldTarget.mdl", victim, "origin")
    call SetUnitMaxState(victim, UNIT_STATE_MAX_LIFE, R2I(GetUnitState(victim,UNIT_STATE_MAX_LIFE)) + 150)
    call TriggerSleepAction(10.0)
    call DestroyEffect(ef)
    call SetUnitMaxState(victim, UNIT_STATE_MAX_LIFE, R2I(GetUnitState(victim,UNIT_STATE_MAX_LIFE)) - 150)
    set ef = null
    set victim = null    
endfunction
//===========================================================================
function InitTrig_Strenght_Armor takes nothing returns nothing
    local trigger StrenghtArmor = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( StrenghtArmor, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( StrenghtArmor, Condition( function StrenghtArmor_Conds ) )
    call TriggerAddAction( StrenghtArmor, function StrenghtArmor_Acts )
    set StrenghtArmor = null
endfunction
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
Add in some Debug messages, (before SetUnitMaxState, after SetUnitMaxState, in the condition func, etc....) to see if it even fires. The best function to do this with is BJDebugMsg (It's a bj, but you're debugging so no one cares)

JASS:
function BJDebugMsg takes string msg returns nothing
    local integer i = 0
    loop
        call DisplayTimedTextToPlayer(Player(i),0,0,60,msg)
        set i = i + 1
        exitwhen i == bj_MAX_PLAYERS
    endloop
endfunction
//example use
call BJDebugMsg("Hello World!")
//will print "Hello World"

Oh, and if you want to display booleans within a string (hint hint check if the user has the item according to the trigger hint hint), the fastest way is IntegerTertiaryOp (bj again, same story as BJDebugMsg)

JASS:
function IntegerTertiaryOp takes boolean flag, integer valueA, integer valueB returns integer
    if flag then
        return valueA
    else
        return valueB
    endif
endfunction
//example use
call BJDebugMsg(I2S(IntegerTertiaryOp(GetInventoryIndexOfItemTypeBJ(GetTriggerUnit(), 'I01A') > 0,1,0)))
//will print 0 if you don't have the item, 1 if you do.
 
Ok Here is what i did:
JASS:
function StrenghtArmor_Conds takes nothing returns boolean
    local integer STchance = 7
    return GetRandomInt(1, 100) <= STchance and IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) and GetInventoryIndexOfItemTypeBJ(GetTriggerUnit(), 'I01A') > 0
endfunction
//======================================================================================================================================================================================================================
function StrenghtArmor_Acts takes nothing returns nothing
    local unit victim = GetTriggerUnit()
    local effect ef = AddSpecialEffectTarget("Abilities\\Spells\\Human\\DivineShield\\DivineShieldTarget.mdl", victim, "origin")
    call BJDebugMsg("1")
    call SetUnitMaxState(victim, UNIT_STATE_MAX_LIFE, 150)
    call BJDebugMsg("2")
    call TriggerSleepAction(10.0)
    call BJDebugMsg("3")
    call DestroyEffect(ef)
    call BJDebugMsg("4")
    call SetUnitMaxState(victim, UNIT_STATE_MAX_LIFE, -150)
    call BJDebugMsg("5")
    set ef = null
    set victim = null    
endfunction
//===========================================================================
function InitTrig_Strenght_Armor takes nothing returns nothing
    local trigger StrenghtArmor = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( StrenghtArmor, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( StrenghtArmor, Condition( function StrenghtArmor_Conds ) )
    call TriggerAddAction( StrenghtArmor, function StrenghtArmor_Acts )
    set StrenghtArmor = null
endfunction

But when i experiment it, there is just no text ... i think that the trigger isn't even fired ... why ??

Another thing, do you remember my spiked's armor script??? with no errors but it didn't work ?? i just converted it into GUI and guess what .. it does work now ... weird hã ?
 
Level 13
Joined
Nov 22, 2006
Messages
1,260
Yeah, the trigger didn't fire, of course.

The only reasons I can think of is that:

  1. when you were testing, GetRandomInt(1, 100) didn't return an integer that was <= STchance
  2. the attacked unit wasn't a hero
  3. the attacked unit didn't have the corresponding item

Didn't PurplePoot said that maybe you can remove the chance temporarily?
 
Guys i managed my way to fix all the problems with the spiked armor and with the multi orb (problem was that my caster got killed every time he was using the orb and no1 know why, but i already fixed that).
Now the problem is the Str Armor. I already removed the conditions thus making the script work on every unit who gets attacked. And what happened is that without the conditions the spell overloaded the binary game system thus making random numbers appear in the screen, which caused a conflict with all other item abilities, killing immediately all units you got attacked and adding to them a permanent Shield of Invulnerability animation.

Sivernon says that i must have a huge error in the scrip, but me and purplepoot can«t find it ... so here it is:

JASS:
function StrenghtArmor_Conds takes nothing returns boolean
    local integer STchance = 7
    return GetRandomInt(1, 100) <= STchance and IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) and GetInventoryIndexOfItemTypeBJ(GetTriggerUnit(), 'I01A') > 0
endfunction
//======================================================================================================================================================================================================================
function StrenghtArmor_Acts takes nothing returns nothing
    local unit victim = GetTriggerUnit()
    local effect ef = AddSpecialEffectTarget("Abilities\\Spells\\Human\\DivineShield\\DivineShieldTarget.mdl", victim, "origin")
    call BJDebugMsg("1")
    call SetUnitMaxState(victim, UNIT_STATE_MAX_LIFE, 150)
    call BJDebugMsg("2")
    call TriggerSleepAction(10.0)
    call BJDebugMsg("3")
    call DestroyEffect(ef)
    call BJDebugMsg("4")
    call SetUnitMaxState(victim, UNIT_STATE_MAX_LIFE, -150)
    call BJDebugMsg("5")
    set ef = null
    set victim = null    
endfunction
//===========================================================================
function InitTrig_Strenght_Armor takes nothing returns nothing
    local trigger StrenghtArmor = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( StrenghtArmor, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( StrenghtArmor, Condition( function StrenghtArmor_Conds ) )
    call TriggerAddAction( StrenghtArmor, function StrenghtArmor_Acts )
    set StrenghtArmor = null
endfunction

Any solutions please ?
 
It still doesn't work .. why ?

JASS:
function StrenghtArmor_Conds takes nothing returns boolean
    local integer STchance = 7
    return GetRandomInt(1, 100) <= STchance and IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) and GetInventoryIndexOfItemTypeBJ(GetTriggerUnit(), 'I01A') > 0
endfunction
//======================================================================================================================================================================================================================
function StrenghtArmor_Acts takes nothing returns nothing
    local unit victim = GetTriggerUnit()
    local effect ef = AddSpecialEffectTarget("Abilities\\Spells\\Human\\DivineShield\\DivineShieldTarget.mdl", victim, "origin")
    call BJDebugMsg("1")
    call SetUnitMaxState(victim, UNIT_STATE_MAX_LIFE, R2I(GetUnitState(victim,UNIT_STATE_MAX_LIFE)+150))
    call BJDebugMsg("2")
    call TriggerSleepAction(10.0)
    call BJDebugMsg("3")
    call DestroyEffect(ef)
    call BJDebugMsg("4")
    call SetUnitMaxState(victim, UNIT_STATE_MAX_LIFE, R2I(GetUnitState(victim,UNIT_STATE_MAX_LIFE)-150))
    call BJDebugMsg("5")
    set ef = null
    set victim = null    
endfunction
//===========================================================================
function InitTrig_Strenght_Armor takes nothing returns nothing
    local trigger StrenghtArmor = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( StrenghtArmor, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( StrenghtArmor, Condition( function StrenghtArmor_Conds ) )
    call TriggerAddAction( StrenghtArmor, function StrenghtArmor_Acts )
    set StrenghtArmor = null
endfunction

Any help ?
 
Level 5
Joined
Jan 15, 2007
Messages
199
i think purplepoot said once that you have to do something special for a line like this if it uses IsUnitType, also you never detroy the effect, add call DestroyEffect( ef ) before the set ef = null
 
Anyway here is a small part of the comment i wanted you to see:
Flame_Phoenix said:
I strongly remember being sad because i felt my work was being ignored and that people just didn't want to see what i had done, thus moderating about the possibility of removing the whole tutorial. I even commented that in this forum.
If not by purplepoot's sudden and unexpected comment, i would have never done this tutorial. He is the main reason why i finished posting it.

I say this among with hard critics to the other moderators ... This is what i think ....

Anyway, any other ideas for the Str Armor ?
 
MUHAHAHAHHA it finally works !!! YES IT WORKS !!!
All those numbers were the Bjdebug messages the computer was making random (don't know why it was random, just found out 5 secs ago) , the main problem was the rawcode .... which was in conflict because it was wrong ...
Still, I feel happy and errmm stupid ... yes stupid ... Well, happy because i finally solved the dam problem and stupid because it was such a simple problem ...

Anyway txh =)
 
Status
Not open for further replies.
Top