- Joined
- Nov 13, 2006
- Messages
- 1,814
what i mean under this?
i want handle custom softstats like life steal, critical strike, reflect etc what i use with variable+dds
i mean here stats like this with integer variable array:
Critical[unit custom value] = 1 //its mean in set damage trigger unit have 1% chance for critical strike
look like this, example i got a unit with custom value 69, so Critical[69] = 1
thats ok but i want make dummy channel based ability later what temporary increase the stat lets say with 10 for a short duration (like ability level * 5 +10 second)
i dont have any problem with makeing ability or something like that because in my older orpg template i used this kinda buff, i just need opinion about this is enough sufficient for handle the buffs?
in test map in test triggers have leak but thats only temporary for testing the core
its run every second, atm checking this way: loop1 units and loop2 all buff from unit in loop1
u can ask why need 2 loop for this? because this way easier remove buffs from a specific unit only after his custom value number also easier to detect if a buff exist already
adding buff type to unit: test solution, if atleast 1 unit selected then type in chat a number and we will add that number to unit buff, duration is 15 sec and value is random, if value lower than 0 then we consider it like debuff
if buff type already exist on unit then we dont add it
Clear buff with pressing ESC key
i want handle custom softstats like life steal, critical strike, reflect etc what i use with variable+dds
i mean here stats like this with integer variable array:
Critical[unit custom value] = 1 //its mean in set damage trigger unit have 1% chance for critical strike
look like this, example i got a unit with custom value 69, so Critical[69] = 1
thats ok but i want make dummy channel based ability later what temporary increase the stat lets say with 10 for a short duration (like ability level * 5 +10 second)
i dont have any problem with makeing ability or something like that because in my older orpg template i used this kinda buff, i just need opinion about this is enough sufficient for handle the buffs?
in test map in test triggers have leak but thats only temporary for testing the core
its run every second, atm checking this way: loop1 units and loop2 all buff from unit in loop1
u can ask why need 2 loop for this? because this way easier remove buffs from a specific unit only after his custom value number also easier to detect if a buff exist already
JASS:
function RemoveUnitBuff takes integer cv, integer bc returns integer
local integer bt = LoadInteger(udg_Buff_Table, cv, bc)
local integer bv
local integer tl
local integer a = bt
set bt = LoadInteger(udg_Buff_Table, cv, udg_Buff_Count[cv])
set tl = LoadInteger(udg_Buff_Table, cv, - bt)
set bv = LoadInteger(udg_Buff_Table, -cv, -bt)
if bc != udg_Buff_Count[cv] then
call SaveInteger(udg_Buff_Table, cv, bc, bt) // save buff type from last record
call SaveInteger(udg_Buff_Table, -cv, -bt, bv) // save buff value from last record
call SaveInteger(udg_Buff_Table, cv, - bt, tl) // save buff timer from last record
set bc = bc - 1
endif
call SaveInteger(udg_Buff_Table, cv, -a, 0)
call SaveInteger(udg_Buff_Table, -cv, -a, 0) // reset buff value
call SaveInteger(udg_Buff_Table, cv, udg_Buff_Count[cv], 0) // reset buff type
set udg_Buff_Count[cv] = udg_Buff_Count[cv] - 1
return bc
endfunction
function RemoveUnitBuffs takes integer i returns nothing
local integer cv = udg_Buff_List[i]
local integer bc = udg_Buff_Count[cv]
loop
exitwhen bc == 0
call RemoveUnitBuff(cv, bc)
set bc = bc - 1
endloop
if i != udg_Buff_Max then
set udg_Buff_List[i] = udg_Buff_List[udg_Buff_Max]
endif
set udg_Buff_List[udg_Buff_Max] = 0
endfunction
function Trig_Timer_Actions takes nothing returns nothing
local integer i = 1
local integer cv // custom value
local integer bt // buff type
local integer bc // buff count
local integer tl // second left from timer
local integer bv
if udg_Buff_Max > 0 then
loop
exitwhen i > udg_Buff_Max
set cv = udg_Buff_List[i]
if GetWidgetLife(udg_UDexUnits[cv]) > 0.3 then
set bc = 1
loop
exitwhen bc > udg_Buff_Count[cv]
set bt = LoadInteger(udg_Buff_Table, cv, bc)
set bv = LoadInteger(udg_Buff_Table, -cv, -bt)
set tl = LoadInteger(udg_Buff_Table, cv, - bt) - 1
if tl < 1 or udg_Buff_Purge[cv] == 3 or (udg_Buff_Purge[cv] == 1 and bv > 0) or (udg_Buff_Purge[cv] == 2 and bv < 0) then
call DisplayTextToForce( GetPlayersAll(), "|cffffff00"+GetUnitName(udg_UDexUnits[cv]) + ":|r buff type |cff0000ff" + I2S(bt) + ", buffs on unit " + I2S(udg_Buff_Count[cv]) + ", current buff is:" + I2S(bc)+" buff amount "+I2S(bv) + " expired or removed|r" )
set bc = RemoveUnitBuff(cv, bc)
else
call SaveInteger(udg_Buff_Table, cv, - bt, tl)
call DisplayTextToForce( GetPlayersAll(), "|cffffff00"+GetUnitName(udg_UDexUnits[cv]) + ":|r buff type |cffaaaaff" + I2S(bt) + "|r " + ", buffs on unit "+ I2S(udg_Buff_Count[cv]) +" buff amount " + I2S(bc) + " buff value "+I2S(bv)+ ", left |cffff4444" + I2S(tl) + "|r second" )
endif
set bc = bc + 1
endloop
set udg_Buff_Purge[cv] = 0 //set purge off to unit
if udg_Buff_Count[cv] == 0 then
call DisplayTextToForce( GetPlayersAll(), "|cffffff00"+GetUnitName(udg_UDexUnits[cv]) + ":|r all buff expired" )
if i != udg_Buff_Max then
set udg_Buff_List[i] = udg_Buff_List[udg_Buff_Max]
endif
set udg_Buff_List[udg_Buff_Max] = 0
set udg_Buff_Max = udg_Buff_Max - 1
set bc = - 1
endif
else
call DisplayTextToForce( GetPlayersAll(), "|cffffff00"+GetUnitName(udg_UDexUnits[cv]) + ":|r i am died, lost all buff")
call RemoveUnitBuffs(i)
set udg_Buff_Max = udg_Buff_Max - 1
if udg_Buff_Max == 0 then
call DisplayTextToForce( GetPlayersAll(), "disable the trigger" )
call DisableTrigger( gg_trg_Timer )
endif
endif
set i = i + 1
endloop
else
call DisplayTextToForce( GetPlayersAll(), "disable the trigger="+I2S(udg_Buff_Max) )
call DisableTrigger( GetTriggeringTrigger() )
endif
endfunction
//===========================================================================
function InitTrig_Timer takes nothing returns nothing
set gg_trg_Timer = CreateTrigger( )
call TriggerRegisterTimerEvent(gg_trg_Timer, 1.00, true)
call TriggerAddAction( gg_trg_Timer, function Trig_Timer_Actions )
endfunction
adding buff type to unit: test solution, if atleast 1 unit selected then type in chat a number and we will add that number to unit buff, duration is 15 sec and value is random, if value lower than 0 then we consider it like debuff
if buff type already exist on unit then we dont add it
JASS:
function Trig_Add_buff_to_unit_Conditions takes nothing returns boolean
return S2I(GetEventPlayerChatString()) > 0
endfunction
function Trig_Add_buff_to_unit_Actions takes nothing returns nothing
local integer bt = S2I(GetEventPlayerChatString()) //buff type id (1-....)
local integer bv = GetRandomInt(-999,999) //buff value it is random
local unit u = GroupPickRandomUnit(GetUnitsSelectedAll(GetTriggerPlayer()))
local integer cv = GetUnitUserData(u)
//we check if timer run out (then add the new buff) or no (change the existing buff)
if LoadInteger( udg_Buff_Table, cv, -bt ) == 0 then
call DisplayTextToForce( GetPlayersAll(), "Added a new buff to |cffffff00"+GetUnitName(u)+"|r buff type is "+I2S(bt)+", buff value is "+I2S(bv))
if udg_Buff_Count[cv] == 0 then
set udg_Buff_Max = ( udg_Buff_Max + 1 )
set udg_Buff_List[udg_Buff_Max] = cv
endif
set udg_Buff_Count[cv] = udg_Buff_Count[cv] + 1
call SaveInteger(udg_Buff_Table, cv, udg_Buff_Count[cv], bt)
call SaveInteger(udg_Buff_Table, -cv, -bt, bv)
call SaveInteger(udg_Buff_Table, cv, -bt, 15)
else
call DisplayTextToForce( GetPlayersAll(), "Updated buff on |cffffff00"+GetUnitName(u)+"|r (buff type is "+I2S(bt)+", buff value is "+I2S(bv)+")")
call SaveInteger(udg_Buff_Table, -cv, -bt, bv)
call SaveInteger(udg_Buff_Table, cv, -bt, 15) //reset the timer
endif
if ( udg_Buff_Max == 1 ) then
call EnableTrigger( gg_trg_Timer )
else
endif
endfunction
//===========================================================================
function InitTrig_Add_buff_to_unit takes nothing returns nothing
set gg_trg_Add_buff_to_unit = CreateTrigger( )
call TriggerRegisterPlayerChatEvent( gg_trg_Add_buff_to_unit, Player(0), "", true )
call TriggerAddCondition( gg_trg_Add_buff_to_unit, Condition( function Trig_Add_buff_to_unit_Conditions ) )
call TriggerAddAction( gg_trg_Add_buff_to_unit, function Trig_Add_buff_to_unit_Actions )
endfunction
Clear buff with pressing ESC key
-
Clear buffs
-
Events
- Player - Player 1 (Red) skips a cinematic sequence
- Conditions
-
Actions
- Set UG = (Units currently selected by (Triggering player))
- Set rnd = (Random integer number between 0 and 3)
- Set Buff_Purge[(Custom value of (Random unit from UG))] = rnd
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- rnd Equal to 0
-
Then - Actions
- Game - Display to (All players) the text: player: dont remove...
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- rnd Equal to 1
-
Then - Actions
- Game - Display to (All players) the text: player: remove posi...
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- rnd Equal to 2
-
Then - Actions
- Game - Display to (All players) the text: player: remove nega...
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- rnd Equal to 3
-
Then - Actions
- Game - Display to (All players) the text: player: remove all ...
- Else - Actions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
Events
Attachments
Last edited: