Somebody can teach me to jass? i need patience

S

shadowvzs

Guest
and? x y is coordinate in screen because is real?

bump!

i need answers :D
and i have more question in progress :)
first these jass's good, or i need fixing it? these jass's and what i post last time with item and different wing type dropping?
JASS:
function RemovePlayer10 takes nothing returns nothing
local group g
local unit u
set g = GetUnitsInRectOfPlayer(GetPlayableMapRect(), Player(9))
loop
      set u = FirstOfGroup(g)
      exitwhen u==null
      call GroupRemoveUnit(g,u)
      call RemoveUnit( u )
endloop 
set g = null
set u = null
endfunction


how can i do tinki3 creep revivel system in jass with player 11,hostile?
or if i use every unit on entire map then same time ?
JASS:
function CreepLocation takes nothing returns nothing
local group g
local unit u
local integer i
set i = 0
set g = GetUnitsInRectAll(GetEntireMapRect()) <---- there player 11 and hostile or i must use again a loop and dont clear the integer value? i need best solution
loop
      set u = FirstOfGroup(g)
      exitwhen u==null
      set i = i + 1
      call GroupRemoveUnit(g,u)
      set udg_CreepX<i> = GetUnitX(u)
      set udg_CreepY<i> = GetUnitY(u)
endloop 
set i = null
set g = null
set u = null
endfunction</i></i>

this good?
JASS:
function ReSpawn takes nothing returns nothing
    local integer a = GetUnitUserData(GetDyingUnit())
    local real x = udg_CreepX[a]
    local real y = udg_CreepY[a]
    local location loc = GetUnitLoc(GetTriggerUnit())
    local effect   e   = AddSpecialEffectLoc( &quot;Objects\\Spawnmodels\\Undead\\UndeadDissipate\\UndeadDissipate.mdl&quot;, loc )
    call DestroyEffect(e)
    call TriggerSleepAction( 8.00 )
    call TriggerSleepAction( ( ( I2R(GetUnitLevel(GetTriggerUnit())) + 1.00 ) / 2.00 ) )
    call CreateNUnitsAtLoc( 1, GetUnitTypeId(GetTriggerUnit()), GetOwningPlayer(GetTriggerUnit()), OffsetLocation(GetRectCenter(GetEntireMapRect()), x, y), GetRandomDirectionDeg() )
    call RemoveLocation(loc)
    call SetUnitUserData( GetLastCreatedUnit(), GetUnitUserData(GetTriggerUnit()) )
    call SetUnitAnimation( GetLastCreatedUnit(), &quot;birth&quot; )
    set x = 0    
    set y = 0    
    set a = 0    
    set loc = null    
    set e = null
endfunction
 

Prometheus

Everything is mutable; nothing is sacred
Reaction score
591
And also you should never start to learn JASS by converting triggers like this.. As when you convert loops, groups and forces, WE makes them so complicated.
I beg to differ
I began my path of JASS by converting triggers and optimizing them a bit, like the conditions.

As for your trigger, the 1st one.
JASS:
function RemovePlayer10 takes nothing returns nothing
    local group g = CreateGroup()
    local unit u
    local integer p
    local integer q = 1
    set g = GetUnitsInRectOfPlayer(GetPlayableMapRect(), Player(9))
    set p = CountUnitsInGroup(g)
    loop
    exitwhen p &gt; q
        set u = FirstOfGroup(g)
        call GroupRemoveUnit(g, u)
        call RemoveUnit( u )
        set p = p + 1
    endloop
    call DestroyGroup(g)
    set g = null
    set u = null
endfunction
 
S

shadowvzs

Guest
I beg to differ
I began my path of JASS by converting triggers and optimizing them a bit, like the conditions.

As for your trigger, the 1st one.
JASS:
function RemovePlayer10 takes nothing returns nothing
    local group g = CreateGroup()
    local unit u
    local integer p
    local integer q = 1
    set g = GetUnitsInRectOfPlayer(GetPlayableMapRect(), Player(9))
    set p = CountUnitsInGroup(g)
    loop
    exitwhen p &gt; q
        set u = FirstOfGroup(g)
        call GroupRemoveUnit(g, u)
        call RemoveUnit( u )
        set p = p + 1
    endloop
    call DestroyGroup(g)
    set g = null
    set u = null
endfunction

i dont know why but dont work(but i think if in unit group have 4 unit then always greater then 0 [p =4, q=0, and exit when p >q])

JASS:
function RemovePlayer10 takes nothing returns nothing
local group g = CreateGroup()
local unit u
local integer i = 1
set g = GetUnitsInRectOfPlayer(GetEntireMapRect(), Player(9))
set i = CountUnitsInGroup(g)
loop
      exitwhen i &lt; 1
      set u = FirstOfGroup(g)
      call GroupRemoveUnit(g,u)
      call RemoveUnit( u )
      set i = i - 1
endloop 
call DestroyGroup(g)
set g = null
set u = null
endfunction


thx because i learn something in every jass :)

i dont found instruction for playergroup but this is good or i can fix?:
JASS:
function Dialog takes nothing returns nothing
    local integer i = 0
    local integer nr = 0
    local string array s
    set s[0] = &quot;Human&quot;
    set s[1] = &quot;Night Elf&quot;
    set s[2] = &quot;Blood Elf&quot;
    set s[3] = &quot;Orc&quot;
    set s[4] = &quot;Golem&quot;
    call DialogClearBJ( udg_N )
    call DialogSetMessageBJ( udg_N, &quot;Nation&quot; )
loop
    exitwhen nr &gt; 4
    call DialogAddButtonBJ( udg_N, s[nr] )
    set udg_Nation_Button[nr] = GetLastCreatedButtonBJ()
    set nr = nr + 1
endloop
loop
        exitwhen i &gt; 12
if ( GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING ) then
     if ( GetPlayerController(Player(i)) == MAP_CONTROL_USER ) then
        call DialogDisplayBJ( true, udg_N, Player(i) )
     endif
endif
set i = i + 1
endloop 
endfunction
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
Remember that most BJs are bad. It is good to have an anti-bj code such as this:
JASS:
function Dialog takes nothing returns nothing
    local integer i = 0
    local integer nr = 0
    local string array s
    set s[0] = &quot;Human&quot;
    set s[1] = &quot;Night Elf&quot;
    set s[2] = &quot;Blood Elf&quot;
    set s[3] = &quot;Orc&quot;
    set s[4] = &quot;Golem&quot;
    call DialogClear( udg_N )
    call DialogSetMessage( udg_N, &quot;Nation&quot; )
    loop
        exitwhen nr &gt; 4 
        set udg_Nation_Button[nr] = DialogAddButton( udg_N, s[nr], 0 )
        set nr = nr + 1
    endloop
    loop
        exitwhen i &gt; 12
        if ( GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING ) then
            if ( GetPlayerController(Player(i)) == MAP_CONTROL_USER ) then
                call DialogDisplay(Player(i), udg_N, true)
            endif
        endif
        set i = i + 1
    endloop
endfunction


I also cleaned it up a bit. ;)
 
S

shadowvzs

Guest
Remember that most BJs are bad. It is good to have an anti-bj code such as this:
I also cleaned it up a bit. ;)

ohh thx, only problem when i convert to jass everything in bj, why use trigger everywhere bj commands?
where i can know whats sequence have a normal command without bj because
JASS:
call DialogDisplay(Player(i), udg_N, true

here was changed player and boolen location
JASS:
call DialogDisplayBJ( true, udg_N, Player(i)

JASS:
        set udg_Nation_Button[nr] = DialogAddButton( udg_N, s[nr], 0 )
there have a 0 when i add to variable directly
JASS:
  call DialogAddButtonBJ( udg_N, s[nr] )
    set udg_Nation_Button[nr] = GetLastCreatedButtonBJ()
 

Doom-Angel

Jass User (Just started using NewGen)
Reaction score
167
i don't think there is realy an answer for why the order is changed or things are just without a few things....
if u wanna realy check why u lost the 0 then u go to the jass craft and see for urself what actions the BJ contain - some are just calling another function with a different order in the arguments and some are more complicated and do a few actions to do what u think is a one simple call
e.g: (call BJDebugMsg)
JASS:
function BJDebugMsg takes string msg returns nothing
    local integer i = 0
    loop
        call DisplayTimedTextToPlayer(Player(i),0,0,60,msg)
        set i = i + 1
        exitwhen i == bj_MAX_PLAYERS
    endloop
endfunction

i hope u understand what it actually does in this loop
and i hope u understand my explanation
 
S

shadowvzs

Guest
i don't think there is realy an answer for why the order is changed or things are just without a few things....
if u wanna realy check why u lost the 0 then u go to the jass craft and see for urself what actions the BJ contain - some are just calling another function with a different order in the arguments and some are more complicated and do a few actions to do what u think is a one simple call
e.g: (call BJDebugMsg)
JASS:
function BJDebugMsg takes string msg returns nothing
    local integer i = 0
    loop
        call DisplayTimedTextToPlayer(Player(i),0,0,60,msg)
        set i = i + 1
        exitwhen i == bj_MAX_PLAYERS
    endloop
endfunction

i hope u understand what it actually does in this loop
and i hope u understand my explanation

dont really , sry, my failing. because bj_Maxplayer is a constans, and i dont have only quick basic (little) knowleadge and there if i use a constans faster then a variable, or the problem is when i use this
JASS:
call DialogDisplayBJ( true, udg_N, Player(i)
then i use a call again where have
JASS:
call DialogDisplay(Player(i), udg_N, true)
?
 

Doom-Angel

Jass User (Just started using NewGen)
Reaction score
167
JASS:
function DialogDisplayBJ takes boolean flag, dialog whichDialog, player whichPlayer returns nothing
    call DialogDisplay(whichPlayer, whichDialog, flag)
endfunction

the BJ one is making a call for the Dialog Display which is making a longer way while u can call the simple "call DialogDisplay(whichPlayer, whichDialog, flag)" which will save u all this and i dunno why the BJ take the arguments in a different order but i don't think it matter since that u should just follow the natives and stop using BJs.

btw what do u mean: "because bj_Maxplayer is a constans"?
what do u mean by constans?
 
S

shadowvzs

Guest
JASS:
function DialogDisplayBJ takes boolean flag, dialog whichDialog, player whichPlayer returns nothing
    call DialogDisplay(whichPlayer, whichDialog, flag)
endfunction

the BJ one is making a call for the Dialog Display which is making a longer way while u can call the simple "call DialogDisplay(whichPlayer, whichDialog, flag)" which will save u all this and i dunno why the BJ take the arguments in a different order but i don't think it matter since that u should just follow the natives and stop using BJs.

btw what do u mean: "because bj_Maxplayer is a constans"?
what do u mean by constans?

this is clear, if i use bj thing then +1 call but sometime i cannot find in jass craft same command without bj, exemple:
JASS:
    if ( UnitHasItemOfTypeBJ(whichUnit, udg_SaveLoad_Items<i>) == true ) then</i>
 
S

shadowvzs

Guest
JASS:
function UnitHasItemOfTypeBJ takes unit whichUnit, integer itemId returns boolean
    return GetInventoryIndexOfItemTypeBJ(whichUnit, itemId) &gt; 0
endfunction

look only for the call itself in this case it's the: "UnitHasItemOfTypeBJ" and u will find it easly

okey but if i searched i found this, again a bj function :/
JASS:

function GetInventoryIndexOfItemTypeBJ takes unit whichUnit, integer itemId returns integer
    local integer index
    local item    indexItem

    set index = 0
    loop
        set indexItem = UnitItemInSlot(whichUnit, index)
        if (indexItem != null) and (GetItemTypeId(indexItem) == itemId) then
            return index + 1
        endif

        set index = index + 1
        exitwhen index &gt;= bj_MAX_INVENTORY
    endloop
    return 0
endfunction
 

Doom-Angel

Jass User (Just started using NewGen)
Reaction score
167
yep Bj's are complex sometimes like this one and u are gonna make it as this BJ does to reach the same effect i suggest to just stay with the BJ to save trouble (depends on what u try to reach to and would it realy save u trouble)
 
S

shadowvzs

Guest
yep Bj's are complex sometimes like this one and u are gonna make it as this BJ does to reach the same effect i suggest to just stay with the BJ to save trouble (depends on what u try to reach to and would it realy save u trouble)

i have trouble :D
i dont know why dont work, in map have 12 item type and when i pick up a item r and w = 0 when i pick second item r and w = 1 when i pick up a item type what i dont have in saveload_item array[1-10] and dont have in inventory but r = 1, w = 0, why?
JASS:
function DID takes unit whichUnit, item whichItem returns nothing
    local integer i = 1 
    local integer p = 1
    local integer w = 0
    local integer r = 0
    local string s = &quot;You cannot hold in your inventory 2 item in same type or wing type&quot;
    
loop
   exitwhen i &gt; 6
        if ( ( GetItemTypeId(whichItem) == GetItemTypeId(UnitItemInSlot(whichUnit, i)) ) ) then
            set r =  r + 1 
        endif 
     loop
        exitwhen p &gt; 10  
//        call DisplayTextToPlayer( GetOwningPlayer(whichUnit), 0 ,0 , I2S(p) )        
             if ( ( udg_SaveLoad_Items[p] == GetItemTypeId(UnitItemInSlot(whichUnit, i)) ) ) then
                 set w = w + 1
             endif
       set p = p + 1
     endloop
call DisplayTextToPlayer( GetOwningPlayer(whichUnit), 0 ,0 , I2S(w))
call DisplayTextToPlayer( GetOwningPlayer(whichUnit), 0 ,0 , I2S(r))
   set i = i + 1
   set p = 1
endloop
     if (GetBooleanOr(( r &gt; 0), w &gt; 1)) then 
        call UnitRemoveItemSwapped( whichItem, whichUnit ) 
        call DisplayTextToPlayer( GetOwningPlayer(whichUnit), 0 ,0 , s )
     endif

set i = 0
set r = 0
set w = 0
set p = 0
set s = null
endfunction


what i want?
for i = 1 to 6 (hero inventory slot)
if this item type have in hero more times then r = (number of this item type in hero inventory)
for p = 1 to 10
if this itemtypr(hero, hisimventory slot (i) = udg_itemtypes(i)) then w = w + 1
end for
end for

if w > 1 or r > 1 then drop hero manipulated item
 
S

shadowvzs

Guest
bump

pls somebody tell me what is it the problem in last post?
 

Doom-Angel

Jass User (Just started using NewGen)
Reaction score
167
well i think this part:
JASS:
     if (GetBooleanOr(( r &gt; 0), w &gt; 1)) then 
        call UnitRemoveItemSwapped( whichItem, whichUnit ) 
        call DisplayTextToPlayer( GetOwningPlayer(whichUnit), 0 ,0 , s )
     endif

set i = 0
set r = 0
set w = 0
set p = 0
set s = null
endfunction

this what u need to do:
JASS:
     if (( r &gt; 0) or (w &gt; 1)) then 
        call UnitRemoveItem( whichUnit ,whichItem) 
        call DisplayTextToPlayer( GetOwningPlayer(whichUnit), 0 ,0 , s )
     endif
endfunction

u don't need to null integers or null string,boolean,code,reals and etc' (i don't remember them all :p)
 
S

shadowvzs

Guest
why don work this jass trigger if i bought this item and i am player 1?

JASS:
function Trig_Buy_Good_Point_Conditions takes nothing returns boolean
    if ( not ( GetItemTypeId(GetSoldItem()) == &#039;I01B&#039; ) ) then
        return false
    endif
    return true
endfunction

function Trig_Buy_Good_Point_Actions takes nothing returns nothing
    local integer i = GetConvertedPlayerId(GetOwningPlayer(GetBuyingUnit()))
    local multiboarditem mbitem 
    set udg_GoodBadPoints<i> = ( udg_GoodBadPoints<i> + 1 )
                    set mbitem = MultiboardGetItem(GetLastCreatedMultiboard(), i - 1, 3 - 1)
                    call MultiboardSetItemValue(mbitem, R2S(udg_GoodBadPoints<i>))
                    call MultiboardReleaseItem(mbitem)
set mbitem = null
endfunction

//===========================================================================
function InitTrig_Buy_Good_Point takes nothing returns nothing
    local integer index = 0
    set gg_trg_Buy_Good_Point = CreateTrigger(  )
    loop
        set index = index + 1
        call TriggerRegisterPlayerUnitEvent(gg_trg_Buy_Good_Point, Player(index), EVENT_PLAYER_UNIT_SELL_ITEM, null)
        exitwhen index == 8
    endloop
    call TriggerAddCondition( gg_trg_Buy_Good_Point, Condition( function Trig_Buy_Good_Point_Conditions ) )
    call TriggerAddAction( gg_trg_Buy_Good_Point, function Trig_Buy_Good_Point_Actions )
endfunction

</i></i></i>
 

Doom-Angel

Jass User (Just started using NewGen)
Reaction score
167
try this:
JASS:
function Trig_Buy_Good_Point_Conditions takes nothing returns boolean
    return (GetItemTypeId(GetSoldItem()) == &#039;I01B&#039; )
endfunction

function Trig_Buy_Good_Point_Actions takes nothing returns nothing
    local integer i = GetPlayerId(GetOwningPlayer(GetBuyingUnit()))
    local multiboarditem mbitem 
    set udg_GoodBadPoints<i> = ( udg_GoodBadPoints<i> + 1 )
                    set mbitem = MultiboardGetItem(GetLastCreatedMultiboard(), i - 1, 3 - 1)
                    call MultiboardSetItemValue(mbitem, R2S(udg_GoodBadPoints<i>))
                    call MultiboardReleaseItem(mbitem)
set mbitem = null
endfunction

//===========================================================================
function InitTrig_Buy_Good_Point takes nothing returns nothing
    local integer index = 0
    set gg_trg_Buy_Good_Point = CreateTrigger(  )
    loop
        set index = index + 1
        call TriggerRegisterPlayerUnitEvent(gg_trg_Buy_Good_Point, Player(index), EVENT_PLAYER_UNIT_SELL_ITEM, null)
        exitwhen index == 8
    endloop
    call TriggerAddCondition( gg_trg_Buy_Good_Point, Condition( function Trig_Buy_Good_Point_Conditions ) )
    call TriggerAddAction( gg_trg_Buy_Good_Point, function Trig_Buy_Good_Point_Actions )
endfunction</i></i></i>

since GetConverted is suited for GUI and in GUI player number is +1 from his real number so u can kinda say it's a BJ since it basically call the real player id and add 1 to it
 
S

shadowvzs

Guest
try this:
JASS:
function Trig_Buy_Good_Point_Conditions takes nothing returns boolean
    return (GetItemTypeId(GetSoldItem()) == &#039;I01B&#039; )
endfunction

function Trig_Buy_Good_Point_Actions takes nothing returns nothing
    local integer i = GetPlayerId(GetOwningPlayer(GetBuyingUnit()))
    local multiboarditem mbitem 
    set udg_GoodBadPoints<i> = ( udg_GoodBadPoints<i> + 1 )
                    set mbitem = MultiboardGetItem(GetLastCreatedMultiboard(), i - 1, 3 - 1)
                    call MultiboardSetItemValue(mbitem, R2S(udg_GoodBadPoints<i>))
                    call MultiboardReleaseItem(mbitem)
set mbitem = null
endfunction

//===========================================================================
function InitTrig_Buy_Good_Point takes nothing returns nothing
    local integer index = 0
    set gg_trg_Buy_Good_Point = CreateTrigger(  )
    loop
        set index = index + 1
        call TriggerRegisterPlayerUnitEvent(gg_trg_Buy_Good_Point, Player(index), EVENT_PLAYER_UNIT_SELL_ITEM, null)
        exitwhen index == 8
    endloop
    call TriggerAddCondition( gg_trg_Buy_Good_Point, Condition( function Trig_Buy_Good_Point_Conditions ) )
    call TriggerAddAction( gg_trg_Buy_Good_Point, function Trig_Buy_Good_Point_Actions )
endfunction</i></i></i>

since GetConverted is suited for GUI and in GUI player number is +1 from his real number so u can kinda say it's a BJ since it basically call the real player id and add 1 to it


nothing :/ dont add to goodpoint nothging, i think the something with event or condition have, removed the bj in event because i found in jass editor what i need :/ TriggerRegisterAnyUnitEventBJ
i changed to:
JASS:
    local integer index = 0
    set gg_trg_Buy_Good_Point = CreateTrigger(  )
    loop
        set index = index + 1
        call TriggerRegisterPlayerUnitEvent(gg_trg_Buy_Good_Point, Player(index), EVENT_PLAYER_UNIT_SELL_ITEM, null)
        exitwhen index == 8
    endloop


i try change set index line to second inside the loop and call the first but dont work the trigger.
generic event, units buy item from shop,condition type of item what i wrote....
 
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