Renendaru
(Evol)ution is nothing without love.
I suppose he means separate buffs, which are annotated by a higher level in the description, which is purely aesthetics. Most people copy the same buff over and all.
I'm still thinking carefully about how to add them in a maintainable way. I don't intend to rush it.I'd love to see this updated with some of the things viikuna was talking about.![]()
When you cast a spell like Frost Nova on a unit it get's the Frost Nova buff and when you mouse over the buff the tooltip tells you what level it is, like what level of Frost Nova you were hit with. And that goes for every spell and aura that leaves a buff.Depends what you mean by levels. Can you give an example?
I wouldn't call it purely aesthetic. It is something visual but I can be more helpful than that. If I'm playing against a level 5 Lich and I can't see what abilities enemy heroes have learned, all I know is that he could have level 3 Frost Nova. Then I see him cast Frost Armor on himself, and Dark Ritual for mana. I select his hero and put my mouse over his Frost Armor buff and it says level 3. Now I know he has put 3 skill points into Frost Armor and I saw him use Dark Ritual so I know he put at least 1 into that skill so then I know he either doesn't have Frost Nova or it is level 1.I suppose he means separate buffs, which are annotated by a higher level in the description, which is purely aesthetics. Most people copy the same buff over and all.
That's already possible using struct members.Also, if you want a buff to do something different (like maybe just some kind of multiplier) depending on the level you could have 1 spell 1 buff and check the level of the buff and handle everything the same way instead of creating a bunch of copies of the same buff with the only difference being 1 value somewhere in the code.
The problem is what if a unit is targetted by both level 2 and level 3 of a buff, and the order they wear off, etc. I need to design carefully, it'll take some time.I think adding levels to buffs should be an easy thing to do. It uses Slow Aura to apply buffs right? A method like setLevel on the BuffStruct could just set the level of the Slow Aura which would automatically set the level of the buff and getLevel could return the level of the buff.
Oh, I know that. I was refering to the way Kenny suggested, creating copies of the buffs where the only difference is the level in the tooltip. Then there would be lots of duplicated code.That's already possible using struct members.
scope SilenceResistance initializer Init
private function Action takes nothing returns nothing
local unit u=GetBuffedUnit()
local buff b=GetTriggerBuff()
local bufftype t=GetBuffType(b)
local buff b2=UnitGetBuffOfType(u,SILENCE_RESISTANCE_BUFF )
if IsBuffTypeInClass(t,BUFF_CLASS_SILENCE) and b2 != 0 then
call SetBuffDuration(b,GetBuffDuration(b)*Multiplier(GetBuffLevel(b2)))
endif
set u=null
endfunction
private function Init takes nothing returns nothing
call OnBuffAdd( Action )
endfunction
endscope
That's inherantly flawed - who says buffs have durations? What about auras, or invisibilities where they're removed on attack? Also, there is a better way of doing it:I requests something like this
Actually, it's really great to have someone else using and commenting on stuff. It helps keep in mind what I might like to do in the future and how I should support flexibility in my systems.Jesus4Lyf is probably getting sick of me. I just think CasterStruct BuffStruct and Status are so awesome I want to use them + Damage for all my spells so I'm trying to learn how to use them all to do what I want.
// seek
mybuff instance;
function seek(BuffStruct i){
if (i.getType()==mybuff.typeid)
instance = i;
}
public function GetUnitBuff(unit who)->mybuff{
BuffList[who].forEachBuff(BUFF_ALIGNMENT_NEGATIVE,seek);
return instance;
}
// mybuff = some buff
// both <instance>.getType() and <struct>.typeid are normal vJass features, and not Zinc-only-features
.....
real xPos[10]; // 10 being maximum number of stacks
real yPos[10];
integer end[10];
integer stacks=0;
private method periodic(){
integer i;
for (1<=i<=stacks){
if (end<i>==T32_Tick){
SetUnitX(unit,xPos<i>);
SetUnitY(unit,yPos<i>);
if (stacks>1){ // update stacks
xPos<i>=xPos[stacks];
yPos<i>=yPos[stacks];
end<i>=end[stacks];
stacks-=1;
} else {
break();
stopPeriodic();
destroy();
}
}
}
}
implement T32x
method onApply(){
mybuff f = GetUnitBuff(unit);
if (f!=0){
destroy();
this=f;
stacks+=1;
xPos[stacks]=GetUnitX(unit);
yPos[stacks]=GetUnitY(unit);
end[stacks]=T32_Tick+R2I(10.0*FPS);
} else {
stacks+=1;
xPos[1]=GetUnitX(unit);
yPos[1]=GetUnitY(unit);
end[1]=T32_Tick+R2I(10.0*FPS);
startPeriodic();
}
}
</i></i></i></i></i></i>
//! runtextmacro BuffType("BuffTaunt")
//! runtextmacro SetBuffName("Taunted")
//! runtextmacro SetBuffAlignment("NEGATIVE")
//! runtextmacro SetBuffTooltip("This unit is being Taunted; it has reduced armor.")
//! runtextmacro SetBuffIcon("ReplaceableTextures\\CommandButtons\\BTNDaggerOfEscape.blp")
//! runtextmacro BuffStruct()
integer armorPenalty
method onApply takes nothing returns nothing
call Status[.unit].modArmorBonus(-.armorPenalty)
endmethod
method onRemove takes nothing returns nothing
call Status[.unit].modArmorBonus(.armorPenalty)
endmethod
//! runtextmacro EndBuff()
scope AbilityWarriorTaunt
// == Configuration ==
globals
private constant integer ABILID = 'A09W'
// Armor penalty amount
private constant integer ARMOR_PENALTY = 5
// Armor penalty duration
private constant real DURATION_BASE = 5
endglobals
// == End of Config ==
// ================================================================
private struct Spell extends SpellStruct
implement SpellStruct
method onEffect takes nothing returns nothing
local BuffTaunt b = BuffTaunt.create(targetUnit)
set b.armorPenalty = ARMOR_PENALTY
call b.destroyTimed(DURATION_BASE)
call IssueTargetOrder(targetUnit, "attack", caster)
endmethod
private static method onInit takes nothing returns nothing
set thistype.abil = ABILID
endmethod
endstruct
endscope
That all looks OK to me. Do you have a demo map?Am I doing something wrong?
Isn't it strange..?Well, it seems to work now. The create(null) thing works too. Maybe because I restarted NewGen?
It's probably just closing and reopening the map.Yeah, just tested this now with another buff. The buff works, but looks like the object data for the buff icon isn't created until you save the map, and restart NewGen. I am using the Test Map button, btw.
That's inherantly flawed - who says buffs have durations? What about auras, or invisibilities where they're removed on attack?
Oops, yeah, meant to say this.It's probably just closing and reopening the map.