JASS Anti-KS System

exge

New Member
Reaction score
15
here is my code, pls help.. the items dropped cant be picked up
Code:
function Trig_attack_mob_Conditions takes nothing returns boolean
    //return GetOwningPlayer(GetAttackedUnitBJ()) == Player(PLAYER_NEUTRAL_AGGRESSIVE)
    return true
endfunction

function Trig_attack_mob_Actions takes nothing returns nothing
local unit mob = GetAttackedUnitBJ()
local unit atk = GetAttacker()
local player atkplayer = GetOwningPlayer(atk)
if GetUnitUserData(mob) == null then
call SetUnitUserData( mob, GetConvertedPlayerId(atkplayer))
else
call DoNothing()
endif
set mob = null
set atk = null
set atkplayer = null
endfunction

//===========================================================================
function InitTrig_attack_mob takes nothing returns nothing
    set gg_trg_attack_mob = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_attack_mob, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( gg_trg_attack_mob, Condition( function Trig_attack_mob_Conditions ) )
    call TriggerAddAction( gg_trg_attack_mob, function Trig_attack_mob_Actions )
endfunction
Code:
function Trig_mob_die_Actions takes nothing returns nothing
local unit deadmob = GetDyingUnit()
local unit killunit = GetKillingUnit()
local player killer = GetOwningPlayer(killunit)
local location deadmobloc = GetUnitLoc(deadmob)
call dropitem('rag1',deadmob,100)
if GetUnitUserData(deadmob) == GetConvertedPlayerId(killer) then
//===Unit matches
call AddHeroXPSwapped( ( 500 / GetHeroLevel(killunit) + 250), killunit, true )
else
//===NOT matching
call AddHeroXPSwapped( -( 500 / GetHeroLevel(killunit) + 250), killunit, true )
endif
set deadmob = null
set killunit = null
set killer = null
call RemoveLocation(deadmobloc)
endfunction

//===========================================================================
function InitTrig_mob_die takes nothing returns nothing
    set gg_trg_mob_die = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_mob_die, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddAction( gg_trg_mob_die, function Trig_mob_die_Actions )
endfunction
Code:
function Trig_aq_item_Actions takes nothing returns nothing
local unit aqitemunit = GetManipulatingUnit()
local item dropped = GetManipulatedItem()
if GetItemUserData(dropped) == (GetUnitUserData(aqitemunit)) then
call DoNothing()
else
call UnitRemoveItemSwapped(dropped, aqitemunit)
endif
endfunction

//===========================================================================
function InitTrig_aq_item takes nothing returns nothing
    set gg_trg_aq_item = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_aq_item, EVENT_PLAYER_UNIT_PICKUP_ITEM )
    call TriggerAddAction( gg_trg_aq_item, function Trig_aq_item_Actions )
endfunction

Code:
function dropitem takes integer itemid, unit deadmob, integer chance returns nothing
if GetRandomInt(1, 100) <= chance then
call CreateItemLoc(itemid, GetUnitLoc(deadmob))
call SetItemUserData(GetLastCreatedItem(), GetUnitUserData(deadmob))
endif
//call DisplayTextToForce(GetPlayersAll(), I2S(GetUnitUserData(deadmob)))
endfunction
 
T

the.Seeker

Guest
I don't know why you're making things so complicated. It could be so much easier.

Code:
Hero Attacked
    Events
        Unit - myHero1 Is attacked
        Unit - myHero2 Is attacked
        Unit - myHero3 Is attacked
        ...
        (any other heroes for which this is supposed to work)
    Conditions
        (Custom value of (Attacking unit)) Equal to 0
        (any other necessary conditions to limit this to creeps only)
    Actions
        Unit - Set the custom value of (Attacking unit) to (Player number of (Owner of (Attacked unit)))

Code:
Unit Dies
    Events
        Unit - A unit Dies
    Conditions
        (Custom value of (Triggering unit)) Greater than or equal to 1
        (Custom value of (Triggering unit)) Less than or equal to 12
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Random integer number between 1 and 100) Less than or equal to 15
            Then - Actions
                -------- create an item here as drop --------
                Item - Create Claws of Attack +3 at (Position of (Triggering unit))
                Item - Set the custom value of (Last created item) to (Custom value of (Triggering unit))
            Else - Actions
                Do nothing
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Custom value of (Triggering unit)) Equal to (Player number of (Owner of (Killing unit)))
            Then - Actions
                -------- add Xp --------
            Else - Actions
                -------- subtract Xp --------

Code:
Item is Picked Up
    Events
        Unit - A unit Acquires an item
    Conditions
        (Custom value of (Item being manipulated)) Greater than or equal to 1
        (Custom value of (Item being manipulated)) Less than or equal to 12
        (Custom value of (Item being manipulated)) Not equal to (Player number of (Owner of (Hero manipulating item)))
    Actions
        Hero - Drop (Item being manipulated) from (Hero manipulating item)
 

exge

New Member
Reaction score
15
i know how to do it in gui, i was just testing it in jass...im still learning it :D JASS i mean
 

emjlr3

Change can be a good thing
Reaction score
395
your GUI JASS hurts my eyes and I refuse to read it

what are you trying to accomplish here?
 

exge

New Member
Reaction score
15
im trying to make the jass version of
Unit attacked - set custom value of attacked unit to player no of attacking unit
unit die - make item, set item custom value to custom value of dying unit
aquire item - if custom value of item == player number of hero man item

edit:nvm i got it...
 

emjlr3

Change can be a good thing
Reaction score
395
so u want the last person who attacked the unit's owner to get the gold for the kill, as well as be the only one allowed to pick up the item dropped?

well, then just like what you said, makes enough sense to me, though this does not stop kill stealking, just stealing of dropped items
 
General chit-chat
Help Users

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top