• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

AddBuff System 2.1

This bundle is marked as useful / simple. Simplicity is bliss, low effort and/or may contain minor bugs.
==================================================
IF YOU USE MY SYSTEM IN YOUR MAP WRITE ME IN CREDIT!
==================================================

This system add buff to your unit:)

[jass=code]
library buf initializer initbuffs

globals

integer array Buff //only one=)

endglobals

function buffs takes location l, unit d, integer s returns nothing
local unit b

set b = CreateUnitAtLoc(Player(PLAYER_NEUTRAL_PASSIVE), 'h000', l, 0.00)

call UnitAddAbility(b, Buff)
call IssueTargetOrder( b, "bloodlust", d )
call TriggerSleepAction (0.3)//necessary in order to dummy had cast ability
call RemoveUnit(b) //remove dummy
call RemoveLocation(l)
set d = null
set l = null
endfunction

function dispel takes unit u returns nothing //remove all buffs
call UnitRemoveBuffs(u, true, true)
endfunction

function initbuffs takes nothing returns nothing //init all buffs
set Buff[1] = 'A000'
set Buff[2] = 'A001'
set Buff[3] = 'A002'
endfunction
endlibrary
[/code]


Keywords:
buff, system, add, dispel, spell, spel, jass, OxygenD.
Contents

Add buff system 2.1c (Map)

Reviews
The system is quite simple, too simple. Better buff systems exist. The dispel function is not needed since it is just a wrapper for the native function.

Moderator

M

Moderator

Maker, 18th Oct 2011

The system is quite simple, too simple. Better buff systems exist.

The dispel function is not needed since it is just a wrapper for the native function.
 
Level 10
Joined
Aug 21, 2010
Messages
316
Use native not BJ
And next time you say that the JASS,then let it be JASS.Thus this is nothing

Since I use the buff system that is based on completely different principles than this(much more advanced and efficient),I must admit that I do not like something like this,but since you are using this system I think that your work should go in this direction.

JASS:
function Real_SafeX takes real xx returns real
	local real r=GetRectMinX(bj_mapInitialPlayableArea)+50
	if(xx<r)then
		return r
	endif
	set r=GetRectMaxX(bj_mapInitialPlayableArea)-50
	if(xx>r)then
		return r
	endif
	return xx
endfunction

function Real_SafeY takes real yy returns real
	local real r=GetRectMinY(bj_mapInitialPlayableArea)+50
	if(yy<r)then
		return r
	endif
	set r=GetRectMaxY(bj_mapInitialPlayableArea)-50
	if(yy>r)then
		return r
	endif
	return yy
endfunction

function Unit_CreateDummy takes player id,integer unitid,real x,real y,real facing returns unit
        set udg_j_spellCaster=CreateUnit(id,unitid,x,y,facing)
        return udg_j_spellCaster
endfunction

function Unit_CreateDummySingle takes player p,integer unitid,real x,real y,real facing,integer abilid,integer level,string order,unit target,real interval,real height returns unit  
        if (x!=0) then
             set x=Real_SafeX(x)
        endif
        if (y!=0) then
             set y=Real_SafeY(y)
        endif
        set udg_j_spellCaster=Unit_CreateDummy(p,unitid,x,y,facing)
        call UnitAddAbility(udg_j_spellCaster,abilid)
        call SetUnitAbilityLevel(udg_j_spellCaster,abilid,level)
        call IssueTargetOrderById(udg_j_spellCaster,OrderId(order),target)
        call UnitAddAbility(udg_j_spellCaster,'Aloc')
        call SetUnitPathing(udg_j_spellCaster,false)
        call SetUnitFlyHeight(udg_j_spellCaster,height,0)
        call UnitApplyTimedLife(udg_j_spellCaster,'BTLF',interval)
        return udg_j_spellCaster   
endfunction
//Ahh Necessary evil!!!
function Unit_DummyPreloadAbility takes player whichPlayer,integer unitid,integer abilid returns nothing
        set udg_j_spellCaster=Unit_CreateDummySingle(whichPlayer,unitid,0,0,0,abilid,0,"",null,0,0)
//If you set up UnitApplyTimedLife the greater value of 0  for example Unit_CreateDummySingle(whichPlayer,unitid,0,0,0,abilid,0,"",null,1,0)
	  call UnitRemoveAbility(udg_j_spellCaster,abilid)
//then these last two functions do not need
        call KillUnit(udg_j_spellCaster)
	call RemoveUnit(udg_j_spellCaster)
endfunction

I have used this system 3-4 years ago and from experience can tell you that there are much better ways of doing the buff system,but never mind, maybe in this case this is not such a bad solution(try, test, and you will see perhaps this is crap and maybe not...who knows?)
And next time put a DESCRIPTION and CODE

JASS:
function buffs takes location l, unit d, integer s returns nothing
local unit b
call CreateNUnitsAtLoc( 1, 'h000', Player(0), l, 0.00 )
set b = GetLastCreatedUnit()
call UnitAddAbilityBJ( udg_Buff[s], b )
call IssueTargetOrderBJ( b, "bloodlust", d )
call PolledWait (0.5)
call RemoveUnit(b)
set d = null
set l = null
endfunction

Very limited functions everything is within a function.
There is no possibility to directly manipulate with more units, players,integers,orders and so on.
For example, What if someone would want to use a different unit,integer or anything else?
In your case it would have to change everything inside the function.Then it can not be a system.Next time when you work on a system think about it.
Maybe I was too critical, but nothing personal, I just point out how the system should work.That's why I put this simple code.
This code is not perfect but it may well serve(If nothing else, at least as an example)
 
Last edited:
Level 2
Joined
Nov 22, 2010
Messages
21
hey, your test map just crashes... i dl-ed, and found that i already have 1.7something version (which was crashing as well).

now, provided that IS working, i may have need for it (tired of manually making dummy casters), am willing to write array manually (even that is kinda place where mistake can happen - now, how did i numbered the 'frenzy amplified', oh yes, its buff[45])

but - if i go check array codes for each spell, or do a printout or whatever, i may as well look its code in ability editor, and call function with it? maybe save whole array adding thing? may be useful for users who have 100+ buffs already in map, and manual making of array is... well time-taking and unnecessary

isn't removebuffs in gui already?

and i don't pretend to really understand this:
call IssueTargetOrder( b, "bloodlust", d )

but, isn't bloodlust affecting friends/allies only? is it potential problem?

please, take this a an constructive critique from a potential user
 
Top