My Help me with Jass Thread

Joker(Div)

Always Here..
Reaction score
86
ok i was messing around with Jasscraft, and i was trying to make a simple jass trigger, but this keep coming up and idk what to do
Code:
function Trig_NewTrigger_Conditions takes nothing returns boolean
if ( IsUnitType(GetSpellAbilityUnit(), UNIT_TYPE_HERO ) == true ) then
    return true
endif
    return true
endfunction

function Trig_NewTrigger_Actions takes nothing returns nothing
  
endfunction

//==== Init Trigger NewTrigger ====
function InitTrig_NewTrigger takes nothing returns nothing
    set gg_trg_NewTrigger = CreateTrigger()
    call TriggerRegister (gg_trg_NewTrigger, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition(gg_trg_NewTrigger, Condition(function Trig_NewTrigger_Conditions))
    call TriggerAddAction(gg_trg_NewTrigger, function Trig_NewTrigger_Actions)
endfunction
Line 15: Undeclared variable: gg_NewTrigger
Line 15: Undeclared function TriggerRegister
 

SFilip

Gone but not forgotten
Reaction score
634
> Line 15: Undeclared variable: gg_NewTrigger
JassCraft can't detect trigger variables which are created automatically. just ignore this.

> Line 15: Undeclared function TriggerRegister
ummm you used TriggerRegister which doesn't exist as a function. you should probably use TriggerRegisterAnyUnitEventBJ instead.
 

SFilip

Gone but not forgotten
Reaction score
634
exactly. it simply adds the EVENT_PLAYER_UNIT_SPELL_EFFECT (starts the effect of an ability) for every player (thus the BJ - normal function would be unit owned by player event).
 

Chocobo

White-Flower
Reaction score
409
Joker(Div) said:
can someone explain how to use Unit Groups? like the loop actions

To use it : call ForGroup( group, functioncode callback)

Example

Code:
set bj_wantDestroyGroup = true
call ForGroup(GetUnitsOfTypeIdAll('Hpal'),function Indicator)

function Indicator takes nothing returns nothing
call AddIndicator( GetEnumUnit(), 100, 0, 0, 0)
 

SFilip

Gone but not forgotten
Reaction score
634
alternate solution (most likely better since it allows you to put a wait)

Code:
    local group g = GetUnitsOfTypeIdAll('Hpal')
    local unit u
    loop
        set u = FirstOfGroup(g)
        exitwhen u == null
        call GroupRemoveUnit(g, u)
        <do something with u here>
    endloop
    call DestroyGroup(g)

and btw chocobo...bj_wantDestroyGroup only works with ForGroupBJ.
 

Joker(Div)

Always Here..
Reaction score
86
my WE has gone wierd. The gui is being checked like a jass and its coming up with a whole bunch of messed up jass, which WE made itself. What is wrong with it?
 

SFilip

Gone but not forgotten
Reaction score
634
compile error i guess...any screenshots?
 

Joker(Div)

Always Here..
Reaction score
86
Ok
25170Untitled-1.png





also,
Code:
function Trig_Hero_Dies_Conditions takes nothing returns boolean
    if ( not ( IsUnitType(GetDyingUnit(), UNIT_TYPE_HERO) == true ) ) then
        return false
    endif
    if ( not ( IsUnitType(GetKillingUnitBJ(), UNIT_TYPE_HERO) == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_Hero_Dies_Actions takes nothing returns nothing
    local string array base
    local string base[1] = ( "|c00ff0000" + ( GetPlayerName(Player(0)) + "|r" ) )
    local string base[2] = ( "|c000000ff" + ( GetPlayerName(Player(1)) + "|r" ) )
    local string base[3] = ( "|c0000ffff" + ( GetPlayerName(Player(2)) + "|r" ) )
    local string base[4] = ( "|c00800080" + ( GetPlayerName(Player(3)) + "|r" ) )
    local string base[5] = ( "|c00ffff00" + ( GetPlayerName(Player(4)) + "|r" ) )
    local string base[6] = ( "|c00ff8000" + ( GetPlayerName(Player(5)) + "|r" ) )
    call DisplayTextToForce( GetPlayersAll(), ( base[GetConvertedPlayerId(GetOwningPlayer(GetDyingUnit()))] + ( " has been pwned by " + base[GetConvertedPlayerId(GetOwningPlayer(GetKillingUnitBJ()))] + " and stole 100 gold! " ) ) )
    call AdjustPlayerStateBJ( 100, GetOwningPlayer(GetKillingUnitBJ()), PLAYER_STATE_RESOURCE_GOLD )
    call AdjustPlayerStateBJ( -100, GetOwningPlayer(GetDyingUnit()), PLAYER_STATE_RESOURCE_GOLD )
endfunction
//===========================================================================
function InitTrig_Hero_Dies takes nothing returns nothing
    set gg_trg_Hero_Dies = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Hero_Dies, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( gg_trg_Hero_Dies, Condition( function Trig_Hero_Dies_Conditions ) )
    call TriggerAddAction( gg_trg_Hero_Dies, function Trig_Hero_Dies_Actions )
endfunction
thats got serveral errors idk how to fix :( and i didnt null the string b/c idk how
 

emjlr3

Change can be a good thing
Reaction score
395
the only thing wrong with that, other then the obvious un optimization, is that, u declare each of your string variables

local string array s, is all the declaration you need

after that

its just

set s[1] =
set s[2] =

etc.
 

emjlr3

Change can be a good thing
Reaction score
395
i suggest, if you have not already, to read Daelin's JASS tut that explains about optimizing functions

for ex.

Code:
function Trig_Hero_Dies_Conditions takes nothing returns boolean
    if ( not ( IsUnitType(GetDyingUnit(), UNIT_TYPE_HERO) == true ) ) then
        return false
    endif
    if ( not ( IsUnitType(GetKillingUnitBJ(), UNIT_TYPE_HERO) == true ) ) then
        return false
    endif
    return true
endfunctio

could be
Code:
function Trig_Hero_Dies_Conditions takes nothing returns boolean
    return IsUnitType(GetDyingUnit(), UNIT_TYPE_HERO) == true and IsUnitType(GetKillingUnit(), UNIT_TYPE_HERO) == true 
endfunction

i removed you bj killing unit function, and made it smaller in general, and faster

other then that

bj functions are worthless(ex. , AdjustPlayerStateBJ )

search JASS Craft for the bj function, and it shows you the natives it is made up of
 
D

dadads

Guest
If World Editor says "expected a name" for a function declaration, then it could mean you've got a double function declaration

i.e. Check if you got the "Trig_Instant_Repair_Conditions" function declared twice.

Code:
local string base[1] = ( "|c00ff0000" + ( GetPlayerName(Player(0)) + "|r" ) )
    local string base[2] = ( "|c000000ff" + ( GetPlayerName(Player(1)) + "|r" ) )
    local string base[3] = ( "|c0000ffff" + ( GetPlayerName(Player(2)) + "|r" ) )
    local string base[4] = ( "|c00800080" + ( GetPlayerName(Player(3)) + "|r" ) )
    local string base[5] = ( "|c00ffff00" + ( GetPlayerName(Player(4)) + "|r" ) )
    local string base[6] = ( "|c00ff8000" + ( GetPlayerName(Player(5)) + "|r" ) )
I suggest that this block of code should not be used.
Instead, you can make a function which changes the names of all players to a colored one, and then you could simply use GetPlayerName
That way, you would simplify most of the functions which will require showing colored player names and there would be no more local string initializations (as shown above) at each function you would use.
Here's a function which replaces all player names to colored ones
Code:
//Sets initial player names
function init_playerNames takes nothing returns nothing
    local string array colors
    local integer a = 0
    local player p
    set colors[0] = "|c00ff0000"
    set colors[1] = "|c000000ff"
    set colors[2] = "|c0018e7bd"
    set colors[3] = "|c00520084"
    set colors[4] = "|c00ffff00"
    set colors[5] = "|c00ff8a08"
    set colors[6] = "|c0018be00"
    set colors[7] = "|c00e759ad"
    set colors[8] = "|c00949694"
    set colors[9] = "|c007bbef7"
    set colors[10] = "|c00086142"
    set colors[11] = "|c004a2800"
    loop
        exitwhen a > 11
        set p = Player(a)
        call SetPlayerName(p,colors[a] + GetPlayerName(Player(a)) + "|r")
        set colors[a] = null
        set p = null
        set a = a + 1
    endloop
endfunction

Anyways
I've tried to fix that code, here's the result (with local variable nulling included):
Code:
function Trig_Hero_Dies_Conditions takes nothing returns boolean
    return IsUnitType(GetDyingUnit(), UNIT_TYPE_HERO) and IsUnitType(GetKillingUnit(), UNIT_TYPE_HERO)
endfunction

function Trig_Hero_Dies_Actions takes nothing returns nothing
    local string array base
    local unit u = GetKillingUnit()
    local player p = GetOwningPlayer(u)
    local integer i = GetPlayerId(p)
    local integer j
    set base[0] = ("|c00ff0000"+(GetPlayerName(Player(0))+"|r"))
    set base[1] = ("|c000000ff"+(GetPlayerName(Player(1))+"|r"))
    set base[2] = ("|c0000ffff"+(GetPlayerName(Player(2))+"|r"))
    set base[3] = ("|c00800080"+(GetPlayerName(Player(3))+"|r"))
    set base[4] = ("|c00ffff00"+(GetPlayerName(Player(4))+"|r"))
    set base[5] = ("|c00ff8000"+(GetPlayerName(Player(5))+"|r"))
    set u = GetDyingUnit()
    set p = GetOwningPlayer(u)
    set j = GetPlayerId(p)
    call DisplayTextToForce(bj_FORCE_ALL_PLAYERS,base[i] + " has just pwned " + base[j] + " and stole 100 gold! ")
    call AdjustPlayerStateBJ(-100,p,PLAYER_STATE_RESOURCE_GOLD)
    set u = GetKillingUnit()
    set p = GetOwningPlayer(u)
    call AdjustPlayerStateBJ(100,p,PLAYER_STATE_RESOURCE_GOLD)
    set u = null
    set p = null
    set base[0] = null
    set base[1] = null
    set base[2] = null
    set base[3] = null
    set base[4] = null
    set base[5] = null
endfunction
//===========================================================================
function InitTrig_Hero_Dies takes nothing returns nothing
    set gg_trg_Hero_Dies = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Hero_Dies,EVENT_PLAYER_UNIT_DEATH)
    call TriggerAddCondition(gg_trg_Hero_Dies,Condition(function Trig_Hero_Dies_Conditions ))
    call TriggerAddAction(gg_trg_Hero_Dies,function Trig_Hero_Dies_Actions)
endfunction
Probably your error was in lines declaring variables such as "local string base[0] = ("|c00ff0000"+(GetPlayerName(Player(0))+"|r"))" when the same variable has already been declared previously in "local string array base"

I've tried it in a test map of mine, and it works (World Editor does not give me those errors). If WE still gives you errors, then it is not because of this code.
 

emjlr3

Change can be a good thing
Reaction score
395
Joker(Div) said:
can someone tell me how to null arrays and why my map has over 2000 errors (scroll up) ?

say you got an array

local location array l

to null one of them

just

set l[#] = null

simple
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/
  • The Helper The Helper:
    I think we need to add something to the bottom of the front page that shows the Headline News forum that has a link to go to the News Forum Index so people can see there is more news. Do you guys see what I am saying, lets say you read all the articles on the front page and you get to the end and it just ends, no kind of link for MOAR!

      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