Questions about referee

Those of you guys who need more info and questions about the referee feel free to ask here! But before you do that, please review this topic before asking questions. And if the system is broken, it is recommended to contact the staff, as they know more about handling system issues about referees. Enjoy!

Can someone teach me how to use for loops in coffee script? Because whenever I try to do a for loop in coffee script it says “Unhandled Error: Type Error: Cannot read property “length” of undefined” when I try to run the following referee code:

{
  setUpLevel: ->
    @wizard = @world.getThangByID("Wizard")
    @hero.maxSpeed = 100
  summonMeteorShower: ->
    @XList = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]
    @YList = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]
    @radiusList = [5, 6, 7, 8, 9, 10]
    @world.rand.shuffle(@XList)
    @world.rand.shuffle(@Ylist)
    @world.rand.shuffle(@radiusList)
    @Iterate = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]
    targetx = @XList[0]
    targety = @Ylist[0]
    radius = @radiusList[0]
    for x in @Iterate
      for y in @Iterate
        posx = 4*x
        posy = 4*y
        if ((posx-targetx)^2 + (posy-targety)^2) > (radius)^2
          b = @instabuild("boulder", posx, posy)
          b.pos.z = 100
          b.velocity.z = -50
          b.keepTrackedProperty("pos")
          b.keepTrackedProperty("velocity")
          b.shooter = @wizard
          b.launchType = "attack"
  onFirstFrame: ->
    @Cooldown5 = 0
    @Cooldown4 = 1
    @Cooldown3 = 2
    @Cooldown2 = 3
    @Cooldown1 = 4
    @Launch = 5
  chooseAction: ->
    if @world.age > @Cooldown5
      @wizard.say(@icontext.five)
      @Cooldown5 += 7
    if @world.age > @Cooldown4
      @wizard.say(@icontext.four)
      @Cooldown4 += 7
    if @world.age > @Cooldown3
      @wizard.say(@icontext.three)
      @Cooldown3 += 7
    if @world.age > @Cooldown2
      @wizard.say(@icontext.two)
      @Cooldown2 += 7
    if @world.age > @Cooldown1
      @wizard.say(@icontext.one)
      @Cooldown1 += 7
    if @world.age > @Launch
      @wizard.say(@icontext.launch)
      @summonMeteorShower()
      @Launch += 7
}

Oh…My…Gosh, that looks extremely confusing. I’m afraid I can’t help, at all. :open_mouth:

@world.rand.shuffle(@Ylist)
Here is your problem. @Ylist is undefined because the right name is @YList

@Bryukh yeah that’s definitely a problem. However, it seems like it’s not my only problem :sob: it still doesn’t work… :frowning:
Here’s my code now: (it’s under a tab so my posts aren’t too long

My Code
{
  setUpLevel: ->
    @wizard = @world.getThangByID("Wizard")
    @hero.maxSpeed = 100
  summonMeteorShower: ->
    @XList = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]
    @YList = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]
    @radiusList = [5, 6, 7, 8, 9, 10]
    @world.rand.shuffle(@XList)
    @world.rand.shuffle(@YList)
    @world.rand.shuffle(@radiusList)
    @Iterate = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]
    targetx = @XList[0]
    targety = @YList[0]
    radius = @radiusList[0]
    for x in @Iterate
      for y in @Iterate
        posx = 4*x
        posy = 4*y
        if ((posx-targetx)^2 + (posy-targety)^2) > (radius)^2
          b = @instabuild("boulder", posx, posy)
          b.pos.z = 100
          b.velocity.z = -50
          b.keepTrackedProperty("pos")
          b.keepTrackedProperty("velocity")
          b.shooter = @wizard
          b.launchType = "attack"
  onFirstFrame: ->
    @Cooldown5 = 0
    @Cooldown4 = 1
    @Cooldown3 = 2
    @Cooldown2 = 3
    @Cooldown1 = 4
    @Launch = 5
  chooseAction: ->
    if @world.age > @Cooldown5
      @wizard.say(@icontext.five)
      @Cooldown5 += 7
    if @world.age > @Cooldown4
      @wizard.say(@icontext.four)
      @Cooldown4 += 7
    if @world.age > @Cooldown3
      @wizard.say(@icontext.three)
      @Cooldown3 += 7
    if @world.age > @Cooldown2
      @wizard.say(@icontext.two)
      @Cooldown2 += 7
    if @world.age > @Cooldown1
      @wizard.say(@icontext.one)
      @Cooldown1 += 7
    if @world.age > @Launch
      @wizard.say(@icontext.launch)
      @summonMeteorShower()
      @Launch += 7
}

The code isn’t enough to answer your question. What do you mean “doesn’t work”? Some error or something else?

Unable to load level… I don’t know what doesn’t work.

Edit: Nevermind. I opened the developer console and it says @instabuild needs object, but got string instead, then I realized I need to have boulder in my buildables, so I added that and the level finally loaded :smiley:

The problem is: There’s suppose to be a “safety circle”. The boulders are supposed to fall everywhere except for within the safety circle.

for x in @Iterate
      for y in @Iterate
        posx = 4*x
        posy = 4*y
        if ((posx-targetx)^2 + (posy-targety)^2) > (radius)^2
          b = @instabuild("boulder", posx, posy)
          b.pos.z = 100
          b.velocity.z = -50
          b.keepTrackedProperty("pos")
          b.keepTrackedProperty("velocity")
          b.shooter = @wizard
          b.launchType = "attack"

This part of the code controls the launching of the boulders.

Isn’t if ((posx-targetx)^2 + (posy-targety)^2) > (radius)^2 supposed to make boulders only spawn outside of the circle?

Also, the boulders do no damage for some reason. The wizard has infinite attack damage. It’s supposed to kill the hero…

The boulder doesn’t have any, the wizard does because the boulder is completely different and doesn’t have any connection with the wizard since the game itself is shooting them

@Chaboi_3000 but I said b.shooter = @wizard

But you didn’t say what it does when it touches a target

The wizard’s attack damage is 9001. I said b.launchtype = “attack”. Shouldn’t that define what happens when it hits a target?

Try asking @Bryukh, he’s better at this than me.

Bryukh is currently offline, it seems like…

Yeah, it’s 1:41 AM at his timezone

Oh I just noticed the huge time gap between the posts

Try to check the referee in the level blind-distance. Or save your level and let me check it. There could be several possible issues, It’s hard to say without additional info.

1 Like

Boulders aren’t missiles so they don’t use their shooter attackDamage. Add Shell component to the boulder template.

1 Like

@Bryukh okay I’ve saved the level. I added the thangTemplate: “Shell” to the boulder in the existence.Builds part of the referee. I’m not sure if that’s what you meant by adding the Shell component to the boulder template…

Anyway, it seems like the boulders still aren’t doing any damage… You can take a look and see if anything’s wrong via the link: https://codecombat.com/editor/level/meteor-strike

If you are using a template for buildables then you need a thang which will be a template. I’ve added Boulder and set friendlyFire true for this. Check version history for my last changes.