Killing system

usf

New Member
Reaction score
0
hi, this is my first post in this forum ...
is this a right way to make a streak ?

JASS:
scope x initializer InitTrig_Kill_system

globals
    private integer array x
    private integer id = GetPlayerId(GetOwningPlayer(GetKillingUnit()))
endglobals

function Kill_system_Conditions takes nothing returns boolean
    return IsUnitType(GetTriggerUnit() , UNIT_TYPE_HERO)
endfunction

function Kill_system_Actions takes nothing returns nothing
    set x[id] = x[id] + 1
    
    if x[id]==3 then
    call StartSound( gg_snd_Killing_Spree )
    
    elseif x[id]==4 then
    call StartSound( gg_snd_Dominating )
    
    elseif x[id]==5 then
    call StartSound( gg_snd_MegaKill )
    
    elseif x[id]==6 then
    call StartSound( gg_snd_Unstoppable )
    
    elseif x[id]==7 then
    call StartSound( gg_snd_WhickedSick )
    
    elseif x[id]==8 then
    call StartSound( gg_snd_MonsterKill )
    
    elseif x[id]==9 then
    call StartSound( gg_snd_GodLike )
    
    elseif x[id]>9then
    call StartSound( gg_snd_HolyShit )
    
    endif
    
endfunction

//===========================================================================
function InitTrig_Kill_system takes nothing returns nothing
    local trigger Kill_system = CreateTrigger(  )
    set x[id] = 0
    call TriggerAddAction( Kill_system, function Kill_system_Actions )
    call TriggerAddCondition( Kill_system, Condition (function Kill_system_Conditions) )
    call TriggerRegisterAnyUnitEventBJ( Kill_system, EVENT_PLAYER_UNIT_DEATH)
endfunction

endscope


sry i forgot privates b4 functions
 

Ashlebede

New Member
Reaction score
43


Make that a local ; variables in global blocks are only declared once.



Also, you should reset the streak for the owner of the dying unit... (if it's like in DotA, where streaks are ended when the hero dies)

JASS:
set id = GetPlayerId(GetOwningPlayer(GetTriggerUnit()))
set x[id] = 0


Also, if it's a DotA, you don't want to trigger it if the killing unit belongs to a computer player (let's say brown or dark green)

JASS:

scope x initializer InitTrig_Kill_system

globals
    private integer array x
endglobals

function Kill_system_Conditions takes nothing returns boolean
    return IsUnitType(GetTriggerUnit() , UNIT_TYPE_HERO)
endfunction

function Kill_system_Actions takes nothing returns nothing
    local integer id = GetPlayerId(GetOwningPlayer(GetKillingUnit()))
if id!=10 and id!=11 then
    set x[id] = x[id] + 1
    
    if x[id]==3 then
    call StartSound( gg_snd_Killing_Spree )
    
    elseif x[id]==4 then
    call StartSound( gg_snd_Dominating )
    
    elseif x[id]==5 then
    call StartSound( gg_snd_MegaKill )
    
    elseif x[id]==6 then
    call StartSound( gg_snd_Unstoppable )
    
    elseif x[id]==7 then
    call StartSound( gg_snd_WhickedSick )
    
    elseif x[id]==8 then
    call StartSound( gg_snd_MonsterKill )
    
    elseif x[id]==9 then
    call StartSound( gg_snd_GodLike )
    
    elseif x[id]>9then
    call StartSound( gg_snd_HolyShit )
    
    endif
endif

    set id = GetPlayerId(GetOwningPlayer(GetTriggerUnit()))
    set x[id] = 0
    
endfunction

//===========================================================================
function InitTrig_Kill_system takes nothing returns nothing
    local trigger Kill_system = CreateTrigger(  )
    call TriggerAddAction( Kill_system, function Kill_system_Actions )
    call TriggerAddCondition( Kill_system, Condition (function Kill_system_Conditions) )
    call TriggerRegisterAnyUnitEventBJ( Kill_system, EVENT_PLAYER_UNIT_DEATH)
endfunction

endscope


That should work. :thup:

Edit: Forgot one line:

JASS:
set x[id] = 0


Should be called at map init in a loop.

JASS:
    local integer i = 0
loop
        exitwhen i==10
    set x<i> = 0
    set i = i + 1
endloop</i>


Of course, since x is private, it's a bit more complex.
 

usf

New Member
Reaction score
0
can i get set these privates in another trigger ? and how ?
also is the x[id]!=10 and 11 you mean the neutral hostile and passive?
anyway thanks very much, that was very helpful :) +rep ofc
 

Ashlebede

New Member
Reaction score
43
Players 12 and 11 are brown and dark green (let's say those two are the computer players on your map). Since this is an array, we have to do "Player index - 1" to find their index in the array. So player 12 & 11 are # 11 & 10 here.

And for the privates... I think the simple way to make them is either using normal globals (CTRL+B) and setting their default value within that menu (they would then need udg_ as a prefix) or making the global public (maybe declaring it in a library) and making that loop in a "map initialization" trigger outside the scope.

You would then need 2 triggers ; this trigger and one to call at map initialization. The triggers would then become :

JASS:
library GLOBALS
    globals
        integer array KillCounter
    endglobals
endlibrary


function Trig_Map_Init_Actions takes nothing returns nothing
        local integer i = 0
    loop
            exitwhen i==10
        set KillCounter<i> = 0
        set i = i + 1
    endloop
endfunction

//===========================================================================
function InitTrig_Map_Init takes nothing returns nothing
    set gg_trg_Map_Init = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Map_Init, function Trig_Map_Init_Actions )
endfunction</i>


JASS:
scope x initializer InitTrig_Kill_system

function Kill_system_Conditions takes nothing returns boolean
    return IsUnitType(GetTriggerUnit() , UNIT_TYPE_HERO)
endfunction

function Kill_system_Actions takes nothing returns nothing
    local integer id = GetPlayerId(GetOwningPlayer(GetKillingUnit()))
if id!=10 and id!=11 then
    set KillCounter[id] = KillCounter[id] + 1
    
    if KillCounter[id]==3 then
    call StartSound( gg_snd_Killing_Spree )
    
    elseif KillCounter[id]==4 then
    call StartSound( gg_snd_Dominating )
    
    elseif KillCounter[id]==5 then
    call StartSound( gg_snd_MegaKill )
    
    elseif KillCounter[id]==6 then
    call StartSound( gg_snd_Unstoppable )
    
    elseif KillCounter[id]==7 then
    call StartSound( gg_snd_WhickedSick )
    
    elseif KillCounter[id]==8 then
    call StartSound( gg_snd_MonsterKill )
    
    elseif KillCounter[id]==9 then
    call StartSound( gg_snd_GodLike )
    
    elseif KillCounter[id]&gt;9then
    call StartSound( gg_snd_HolyShit )
    
    endif
endif

    set id = GetPlayerId(GetOwningPlayer(GetTriggerUnit()))
    set KillCounter[id] = 0
    
endfunction

//===========================================================================
function InitTrig_Kill_system takes nothing returns nothing
    local trigger Kill_system = CreateTrigger(  )
    call TriggerAddAction( Kill_system, function Kill_system_Actions )
    call TriggerAddCondition( Kill_system, Condition (function Kill_system_Conditions) )
    call TriggerRegisterAnyUnitEventBJ( Kill_system, EVENT_PLAYER_UNIT_DEATH)
endfunction

endscope


I put the globals inside a library, in case the Map Init trigger is after Kill System.

Edit : I personnally wouldn't trust the "Initializer" from the first line, but I don't know that much about vJASS.

-Ashlebede

P.S.: Woot! My very first rep! =D
 

xAnaMorphine

Active Member
Reaction score
43
Players 12 and 11 are brown and dark green (let's say those two are the computer players on your map). Since this is an array, we have to do "Player index - 1" to find their index in the array. So player 12 & 11 are # 11 & 10 here.

And for the privates... I think the simple way to make them is either using normal globals (CTRL+B) and setting their default value within that menu (they would then need udg_ as a prefix) or making the global public (maybe declaring it in a library) and making that loop in a "map initialization" trigger outside the scope.

I put the globals inside a library, in case the Map Init trigger is after Kill System.

Edit : I personnally wouldn't trust the "Initializer" from the first line, but I don't know that much about vJASS.

-Ashlebede

P.S.: Woot! My very first rep! =D

Let's say you do not have Computers in your Map...
Would the Trigger look like this?
JASS:
library GLOBALS
    globals
        integer array KillCounter
    endglobals
endlibrary


function Trig_Map_Init_Actions takes nothing returns nothing
        local integer i = 0
    loop
            exitwhen i==10
        set KillCounter<i> = 0
        set i = i + 1
    endloop
endfunction

//===========================================================================
function InitTrig_Map_Init takes nothing returns nothing
    set gg_trg_Map_Init = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Map_Init, function Trig_Map_Init_Actions )
endfunction</i>


JASS:
scope x initializer InitTrig_Kill_system

function Kill_system_Conditions takes nothing returns boolean
    return IsUnitType(GetTriggerUnit() , UNIT_TYPE_HERO)
endfunction

function Kill_system_Actions takes nothing returns nothing
    local integer id = GetPlayerId(GetOwningPlayer(GetKillingUnit()))

    set KillCounter[id] = KillCounter[id] + 1
    
    if KillCounter[id]==3 then
    call StartSound( gg_snd_Killing_Spree )
    
    elseif KillCounter[id]==4 then
    call StartSound( gg_snd_Dominating )
    
    elseif KillCounter[id]==5 then
    call StartSound( gg_snd_MegaKill )
    
    elseif KillCounter[id]==6 then
    call StartSound( gg_snd_Unstoppable )
    
    elseif KillCounter[id]==7 then
    call StartSound( gg_snd_WhickedSick )
    
    elseif KillCounter[id]==8 then
    call StartSound( gg_snd_MonsterKill )
    
    elseif KillCounter[id]==9 then
    call StartSound( gg_snd_GodLike )
    
    elseif KillCounter[id]&gt;9then
    call StartSound( gg_snd_HolyShit )
    
    endif
endif

    set id = GetPlayerId(GetOwningPlayer(GetTriggerUnit()))
    set KillCounter[id] = 0
    
endfunction

//===========================================================================
function InitTrig_Kill_system takes nothing returns nothing
    local trigger Kill_system = CreateTrigger(  )
    call TriggerAddAction( Kill_system, function Kill_system_Actions )
    call TriggerAddCondition( Kill_system, Condition (function Kill_system_Conditions) )
    call TriggerRegisterAnyUnitEventBJ( Kill_system, EVENT_PLAYER_UNIT_DEATH)
endfunction

endscope
 

Ashlebede

New Member
Reaction score
43
Just the loop in the first trigger would need change. The "exitwhen i==10" means we exit when it reaches player 11 (dark green). Then it would become "exitwhen i==12". That's it.

JASS:
loop
        exitwhen i==12
    set KillCounter<i> = 0
    set i = i + 1
endloop</i>


Edit : Just noticed, in second trigger:

JASS:
elseif KillCounter[id]&gt;9then
    call StartSound( gg_snd_HolyShit )
    
    endif
endif


Should become

JASS:

elseif KillCounter[id]&gt;9then
    call StartSound( gg_snd_HolyShit )
    
    endif


Since the second "endif" was for the computer player check.
 

xAnaMorphine

Active Member
Reaction score
43
Just the loop in the first trigger would need change. The "exitwhen i==10" means we exit when it reaches player 11 (dark green). Then it would become "exitwhen i==12". That's it.

JASS:
loop
        exitwhen i==12
    set KillCounter<i> = 0
    set i = i + 1
endloop</i>


Edit : Just noticed, in second trigger:

JASS:
elseif KillCounter[id]&gt;9then
    call StartSound( gg_snd_HolyShit )
    
    endif
endif


Should become

JASS:

elseif KillCounter[id]&gt;9then
    call StartSound( gg_snd_HolyShit )
    
    endif


Since the second "endif" was for the computer player check.


You sure I do not need to remove this line?
JASS:
if id!=10 and id!=11 then
 

Ashlebede

New Member
Reaction score
43
You do need to remove it. It wasn't there in the trigger you showed, though. D=

JASS:
scope x initializer InitTrig_Kill_system

function Kill_system_Conditions takes nothing returns boolean
    return IsUnitType(GetTriggerUnit() , UNIT_TYPE_HERO)
endfunction

function Kill_system_Actions takes nothing returns nothing
    local integer id = GetPlayerId(GetOwningPlayer(GetKillingUnit()))

    set KillCounter[id] = KillCounter[id] + 1
    
    if KillCounter[id]==3 then
    call StartSound( gg_snd_Killing_Spree )
    
    elseif KillCounter[id]==4 then
    call StartSound( gg_snd_Dominating )
    
    elseif KillCounter[id]==5 then
    call StartSound( gg_snd_MegaKill )
    
    elseif KillCounter[id]==6 then
    call StartSound( gg_snd_Unstoppable )
    
    elseif KillCounter[id]==7 then
    call StartSound( gg_snd_WhickedSick )
    
    elseif KillCounter[id]==8 then
    call StartSound( gg_snd_MonsterKill )
    
    elseif KillCounter[id]==9 then
    call StartSound( gg_snd_GodLike )
    
    elseif KillCounter[id]&gt;9then
    call StartSound( gg_snd_HolyShit )
    
    endif
endif

    set id = GetPlayerId(GetOwningPlayer(GetTriggerUnit()))
    set KillCounter[id] = 0
    
endfunction

//===========================================================================
function InitTrig_Kill_system takes nothing returns nothing
    local trigger Kill_system = CreateTrigger(  )
    call TriggerAddAction( Kill_system, function Kill_system_Actions )
    call TriggerAddCondition( Kill_system, Condition (function Kill_system_Conditions) )
    call TriggerRegisterAnyUnitEventBJ( Kill_system, EVENT_PLAYER_UNIT_DEATH)
endfunction

endscope


It showed this script. o_O
 

xAnaMorphine

Active Member
Reaction score
43
You do need to remove it. It wasn't there in the trigger you showed, though. D=

JASS:
scope x initializer InitTrig_Kill_system

function Kill_system_Conditions takes nothing returns boolean
    return IsUnitType(GetTriggerUnit() , UNIT_TYPE_HERO)
endfunction

function Kill_system_Actions takes nothing returns nothing
    local integer id = GetPlayerId(GetOwningPlayer(GetKillingUnit()))

    set KillCounter[id] = KillCounter[id] + 1
    
    if KillCounter[id]==3 then
    call StartSound( gg_snd_Killing_Spree )
    
    elseif KillCounter[id]==4 then
    call StartSound( gg_snd_Dominating )
    
    elseif KillCounter[id]==5 then
    call StartSound( gg_snd_MegaKill )
    
    elseif KillCounter[id]==6 then
    call StartSound( gg_snd_Unstoppable )
    
    elseif KillCounter[id]==7 then
    call StartSound( gg_snd_WhickedSick )
    
    elseif KillCounter[id]==8 then
    call StartSound( gg_snd_MonsterKill )
    
    elseif KillCounter[id]==9 then
    call StartSound( gg_snd_GodLike )
    
    elseif KillCounter[id]&gt;9then
    call StartSound( gg_snd_HolyShit )
    
    endif
endif

    set id = GetPlayerId(GetOwningPlayer(GetTriggerUnit()))
    set KillCounter[id] = 0
    
endfunction

//===========================================================================
function InitTrig_Kill_system takes nothing returns nothing
    local trigger Kill_system = CreateTrigger(  )
    call TriggerAddAction( Kill_system, function Kill_system_Actions )
    call TriggerAddCondition( Kill_system, Condition (function Kill_system_Conditions) )
    call TriggerRegisterAnyUnitEventBJ( Kill_system, EVENT_PLAYER_UNIT_DEATH)
endfunction

endscope


It showed this script. o_O

Yep, I edited it out. Just to make sure.

P.S: I get more and more familiar to this Jass :>
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top