• 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.

[vJASS] improving this crap

Status
Not open for further replies.
Level 6
Joined
Apr 16, 2011
Messages
158
Ok I'll explain what I'm trying to do
My unit has three passive skill
I intend to make an ultimate than the opposite effect of each passive that it has.
The ultimate must interact with the level of passive and return to the opposite passive.
passives has 4 levels
Ultimate 3
passive should only interact until level 3
-
for this I did:
3 passive and 3 buff
3 passive unlike and 3 buff
I'm using SpellEffectEvent
-
I did this very precariously:
*with this system you can only update once ^ ^
*the second time I have no updates according to the level of buffs
*would be interesting to not use so many "if"
*another problem, the skills are added to my main unit, which becomes bad because it occupies space and takes the place of other spells
*I'm thinking how to do it right, without these problems


help me with what can,I'm confused :goblin_wtf:

JASS:
library NegativeSpirit initializer onInit uses SpellEffectEvent
globals
        private constant integer SPELL_MAIN = 'A00B' // spell
        private constant integer PASSIVE_ID_1 = 'A005' // Passive 1
        private constant integer PASSIVE_ID_2 = 'A004' // Passive 2
        private constant integer PASSIVE_ID_3 = 'A002' // Passive 3
        private constant integer NEGATIVE_ID_1 = 'A00C' // Negative Passive 1
        private constant integer NEGATIVE_ID_2 = 'A00D' // Negative Passive 2
        private constant integer NEGATIVE_ID_3 = 'A00E' // Negative Passive 3
    endglobals
       
    private function onCast takes nothing returns nothing
    local unit u = GetTriggerUnit()
    loop
    if GetUnitAbilityLevel(u, 'B001') > 0 then
    call UnitAddAbility(u, NEGATIVE_ID_1)
    call SetUnitAbilityLevel(u, NEGATIVE_ID_1, GetUnitAbilityLevel(u, PASSIVE_ID_1))
    endif
    if GetUnitAbilityLevel(u, 'B002') > 0 then
    call UnitAddAbility(u, NEGATIVE_ID_2)
    call UnitAddAbility(u, 'B003')
    call SetUnitAbilityLevel(u, NEGATIVE_ID_2, GetUnitAbilityLevel(u, PASSIVE_ID_2))
    endif
    if GetUnitAbilityLevel(u, 'B006') > 0 then
    call UnitAddAbility(u, NEGATIVE_ID_3)
    call SetUnitAbilityLevel(u, NEGATIVE_ID_3, GetUnitAbilityLevel(u,PASSIVE_ID_3))
    endif
    endloop
    set u = null
    endfunction
    
    private function onInit takes nothing returns nothing
        call RegisterSpellEffectEvent(SPELL_MAIN, function onCast)
    endfunction
    endlibrary
 
Last edited:
first you really need to improve your indentation, it hurts many eyes...

the loop is really useless, use array integers if you want to use loops...
JASS:
globals
   private integer array NEGATIVE_ID
   private integer array PASSIVE_ID
endglobals

//===you MUST call this function
private function Setup takes nothing returns nothing
   set NEGATIVE_ID[1] = 'A00C'
   set NEGATIVE_ID[2] = 'A00D'
   set NEGATIVE_ID[3] = 'A00E'
   //set passives as well...
endfunction

then...
JASS:
private function onCast takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local integer i = 0
    loop
       set i = i+1
       if GetUnitAbilityLevel(u, PASSIVE_ID[i]) > 0 then
         call UnitAddAbility(u, NEGATIVE_ID[i])
         call SetUnitAbilityLevel(u, NEGATIVE_ID[i], GetUnitAbilityLevel(u, PASSIVE_ID[i]))
      endif
      exitwhen i >= 3
    endloop 

endfunction
 
Level 13
Joined
May 11, 2008
Messages
1,198
main error stands out to me is this:
call RegisterSpellEffectEvent(SPELL_MAIN, function onCast)
above we found the line:
private constant integer SPELL_MAIN = 'A00B' // Passive skill
why is it a problem? a passive skill, your ultimate...this is not correct. you need an active skill.

you want to change the passive abilities of the hero? reverse them for a duration while the ultimate is in effect?

this may not be so hard with proper coding...but what you're doing with buffs and things does not make much sense to me.
 
Level 6
Joined
Apr 16, 2011
Messages
158
Dr Super Good:
in fact the effect should be like an aura steadily after the first time it was released


mckill2009:
that was what I wanted to do in jass and did not know how :)
but I have a doubt, I call the "Setup" where?

SanKakU:
SPELL_MAIN is an active skill, it happened that I started doing it as passive but later moved and forgot to take off when I posted the code.
 
Level 13
Joined
May 11, 2008
Messages
1,198
Dr Super Good:
in fact the effect should be like an aura steadily after the first time it was released


mckill2009:
that was what I wanted to do in jass and did not know how :)
but I have a doubt, I call the "Setup" where?

SanKakU:
SPELL_MAIN is an active skill, it happened that I started doing it as passive but later moved and forgot to take off when I posted the code.
JASS:
private function onInit takes nothing returns nothing
        call RegisterSpellEffectEvent(SPELL_MAIN, function onCast)
    endfunction
that is the setup function, i believe. just add the lines that set the variables to this function...unless you have an alternate function that declares the slots for your variable arrays.

he might've had in mind that you add those lines after you set your local variables, but that seems kinda dumb unless you need to change the variables from cast to cast.

a trick i do which might help you here is have event like when the hero learns a skill. then you can manipulate integers...i don't know why you check for buffs when you can check for the original abilities and remove them. then you should use a timer and reverse the process by removing the 'negative' abilities and adding the original ones.
 
Status
Not open for further replies.
Top