Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - wrightmat

Pages: 1 ... 14 15 [16]
226
Development / Re: Help: Enemy disappearing
« on: March 20, 2014, 01:38:22 am »
Christopho- no luck on the optimization distance trick, thanks though.

Renkineko- I did double check the sprite, but I always could have missed something!

https://github.com/wrightmat/zbom/blob/master/data/sprites/enemies/gohma.png

227
Development / Re: HUD Script: Small Keys (ALBW Style)
« on: March 20, 2014, 12:11:26 am »
Good call, thanks!

228
Development / HUD Script: Small Keys (ALBW Style)
« on: March 19, 2014, 02:18:49 am »
If anyone's interested, I modified the small keys script provided by christopho in zsdx to display the keys in a manner more consistent with A Link Between Worlds rather than A Link to the Past. By that, I mean that keys are displayed as a number of small icons (consistent with the number of keys obtained) rather than a small key icon and a number.

Code: [Select]
-- Allows small keys to be displayed on maps with small keys enabled.
-- Done in ALBW style, a key icon is shown for each key obtained (no counter or icon)

local small_keys = {}

function small_keys:new(game)
  local object = {}
  setmetatable(object, self)
  self.__index = self

  object:initialize(game)
  return object
end

function small_keys:initialize(game)
  local nb_keys_displayed = 0

  self.game = game
  self.visible = false
  self.surface = sol.surface.create(80, 16)

  self:check()
  self:rebuild_surface()
end

function small_keys:check()
  local need_rebuild = false

  -- Check the number of small keys.
  if self.game:are_small_keys_enabled() then
    local nb_keys = self.game:get_num_small_keys()
    if nb_keys_displayed ~= nb_keys then
      need_rebuild = true
    end
  end

  local visible = self.game:are_small_keys_enabled()
  if visible ~= self.visible then
    self.visible = visible
    need_rebuild = true
  end

  -- Redraw the surface is something has changed.
  if need_rebuild then
    self:rebuild_surface()
  end

  -- Schedule the next check.
  sol.timer.start(self.game, 40, function()
    self:check()
  end)
end

function small_keys:rebuild_surface()
  self.surface:clear()
  if self.game:are_small_keys_enabled() then
    for i=0,self.game:get_num_small_keys()-1 do
      self.icon_img = sol.surface.create("hud/small_key.png")
      self.icon_img:draw(self.surface,i*14)
      if nb_keys_displayed ~= nil then
        nb_keys_displayed = nb_keys_displayed + 1
      else
        nb_keys_displayed = 1
      end
    end
  end
end

function small_keys:set_dst_position(x, y)
  self.dst_x = x
  self.dst_y = y
end

function small_keys:on_draw(dst_surface)
  if self.visible then
    local x, y = self.dst_x, self.dst_y
    local width, height = dst_surface:get_size()
    if x < 0 then
      x = width + x
    end
    if y < 0 then
      y = height + y
    end
    self.surface:draw(dst_surface, x, y)
  end
end

return small_keys

Feel free to use as you wish! I also modified hud/hud.lua to display the small keys at the bottom left above the rupees like they are in ALBW. The script also uses a small key icon of your choice in sprites/hud/small_key.png

229
Development / Help: Enemy disappearing
« on: March 19, 2014, 02:13:40 am »
Hoping for a little help on one of my bosses. For some reason he keeps disappearing when that's not what I'm intending with my script, so I must be missing something. It seems to happen primarily as he's finishing the "opening" phase.

Enemy script:
Code: [Select]
local enemy = ...

-- Gohma: Boss who has to be shot in the eye with an arrow to be hurt

function enemy:on_created()
  self:set_life(9)
  self:set_damage(2)
  self:create_sprite("enemies/gohma")
  self:set_hurt_style("boss")
  self:set_size(64, 32)
  self:set_origin(32, 29)
  self:set_attack_consequence("sword", "protected")
  self:get_sprite():set_animation("walking")
end

function enemy:check_action()
  local action = math.random(10)
  if self:get_life() > 6 then
    -- first phase: if less than three hits then mostly just move around (slowly), and create tektites
    local son_name = self:get_name().."_son"
    self:create_enemy{
      name = son_name,
      breed = "tektite_green",
      treasure_name = "heart"
    }
    if action >= 1 and action <= 7 then self:go(96) else self:blink() end
  elseif self:get_life() > 3 and self:get_life() <= 6 then
    -- second phase: if more than 3 but less than 6 hits then blink a lot more, and create tektites
    if action >= 1 and action <= 7 then self:blink() else self:go(96) end
    local son_name = self:get_name().."_son"
    self:create_enemy{
      name = son_name,
      breed = "tektite_green"
    }
  elseif self:get_life() < 3 and self:get_life() > 0 then
    -- final phase: if more than 6 hits then move a lot faster, and create tektites!
    if action >= 1 and action <= 6 then self:blink() else self:go(128) end
    local son_name = self:get_name().."_son"
    self:create_enemy{
      name = son_name,
      breed = "tektite_green"
    }
  end
  sol.timer.start(self, 100, function() self:open() end)
end

function enemy:go(speed)
  self:get_sprite():set_animation("walking")
  self:set_attack_consequence("arrow", 1)
  local m = sol.movement.create("random")
  m:set_speed(speed)
  m:set_max_distance(24)
  m:start(self)
end

function enemy:blink()
  self:set_attack_consequence("arrow", "protected")
  self:get_sprite():set_animation("blinking")
end

function enemy:open()
  self:set_attack_consequence("arrow", 1)
  self:get_sprite():set_animation("opening")
end

function enemy:on_restarted()
  self:get_sprite():set_animation("walking")
  self:check_action()
end

function enemy:on_obstacle_reached()
  self:check_action()
end

function enemy:on_animation_finished(sprite, animation)
  self:set_attack_consequence("arrow", "protected")
  if animation == "blinking" then
    self:get_sprite():set_animation("closed")
    sol.timer.start(self, random(6)*1000, function() self:open() end)
    self:go(64)
  elseif animation == "opening" then
    self:get_sprite():set_animation("walking")
    sol.timer.start(self, 1000, function() self:check_action() end)
  end
end

Sprite file:
Code: [Select]
animation{
  name = "walking",
  src_image = "enemies/gohma.png",
  frame_delay = 200,
  frame_to_loop_on = 0,
  directions = {
    { x = 0, y = 128, frame_width = 64, frame_height = 32, origin_x = 32, origin_y = 29, num_frames = 4 },
    { x = 0, y = 64, frame_width = 64, frame_height = 32, origin_x = 32, origin_y = 29, num_frames = 4 },
    { x = 0, y = 96, frame_width = 64, frame_height = 32, origin_x = 32, origin_y = 29, num_frames = 4 },
    { x = 0, y = 32, frame_width = 64, frame_height = 32, origin_x = 32, origin_y = 29, num_frames = 4 },
  },
}

animation{
  name = "shaking",
  src_image = "enemies/gohma.png",
  frame_delay = 100,
  frame_to_loop_on = 0,
  directions = {
    { x = 64, y = 128, frame_width = 64, frame_height = 32, origin_x = 32, origin_y = 29, num_frames = 2 },
    { x = 64, y = 64, frame_width = 64, frame_height = 32, origin_x = 32, origin_y = 29, num_frames = 2 },
    { x = 64, y = 96, frame_width = 64, frame_height = 32, origin_x = 32, origin_y = 29, num_frames = 2 },
    { x = 64, y = 32, frame_width = 64, frame_height = 32, origin_x = 32, origin_y = 29, num_frames = 2 },
  },
}

animation{
  name = "hurt",
  src_image = "enemies/gohma.png",
  frame_delay = 100,
  frame_to_loop_on = 0,
  directions = {
    { x = 256, y = 32, frame_width = 64, frame_height = 32, origin_x = 32, origin_y = 29, num_frames = 4 },
    { x = 256, y = 32, frame_width = 64, frame_height = 32, origin_x = 32, origin_y = 29, num_frames = 4 },
    { x = 256, y = 32, frame_width = 64, frame_height = 32, origin_x = 32, origin_y = 29, num_frames = 4 },
    { x = 256, y = 32, frame_width = 64, frame_height = 32, origin_x = 32, origin_y = 29, num_frames = 4 },
  },
}

animation{
  name = "closed",
  src_image = "enemies/gohma.png",
  frame_delay = 200,
  frame_to_loop_on = 0,
  directions = {
    { x = 256, y = 0, frame_width = 64, frame_height = 32, origin_x = 32, origin_y = 29, num_frames = 4 },
    { x = 256, y = 0, frame_width = 64, frame_height = 32, origin_x = 32, origin_y = 29, num_frames = 4 },
    { x = 256, y = 0, frame_width = 64, frame_height = 32, origin_x = 32, origin_y = 29, num_frames = 4 },
    { x = 256, y = 0, frame_width = 64, frame_height = 32, origin_x = 32, origin_y = 29, num_frames = 4 },
  },
}

animation{
  name = "blinking",
  src_image = "enemies/gohma.png",
  frame_delay = 150,
  directions = {
    { x = 0, y = 0, frame_width = 64, frame_height = 32, origin_x = 32, origin_y = 29, num_frames = 3 },
    { x = 0, y = 0, frame_width = 64, frame_height = 32, origin_x = 32, origin_y = 29, num_frames = 3 },
    { x = 0, y = 0, frame_width = 64, frame_height = 32, origin_x = 32, origin_y = 29, num_frames = 3 },
    { x = 0, y = 0, frame_width = 64, frame_height = 32, origin_x = 32, origin_y = 29, num_frames = 3 },
  },
}

animation{
  name = "opening",
  src_image = "enemies/gohma.png",
  frame_delay = 150,
  directions = {
    { x = 128, y = 0, frame_width = 64, frame_height = 32, origin_x = 32, origin_y = 29, num_frames = 2 },
    { x = 128, y = 0, frame_width = 64, frame_height = 32, origin_x = 32, origin_y = 29, num_frames = 2 },
    { x = 128, y = 0, frame_width = 64, frame_height = 32, origin_x = 32, origin_y = 29, num_frames = 2 },
    { x = 128, y = 0, frame_width = 64, frame_height = 32, origin_x = 32, origin_y = 29, num_frames = 2 },
  },
}

animation{
  name = "immobilized",
  src_image = "enemies/gohma.png",
  directions = {
    { x = 0, y = 128, frame_width = 64, frame_height = 32, origin_x = 32, origin_y = 29 },
    { x = 0, y = 64, frame_width = 64, frame_height = 32, origin_x = 32, origin_y = 29 },
    { x = 0, y = 96, frame_width = 64, frame_height = 32, origin_x = 32, origin_y = 29 },
    { x = 0, y = 32, frame_width = 64, frame_height = 32, origin_x = 32, origin_y = 29 },
  },
}

230
Hmmm... I'll triple check my system config - I just thought I'd check with you too!

231
I went to compile the newest code, and all the sudden I'm getting a cmake error about not being able to find OpenAL which I didn't get yesterday when I compiled older code. I double-checked and my system does have libopenal installed.

Code: [Select]
-- Looking for include file pthread.h
-- Looking for include file pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE 
-- Found SDL2: /usr/local/lib/libSDL2main.a;/usr/local/lib/libSDL2.so;-lpthread (Required is at least version "2")
-- Found SDL2_image: /usr/include/SDL2 (found suitable version "2.0.0", minimum required is "2")
-- Found SDL2_ttf: /usr/local/include/SDL2 (found suitable version "2.0.12", minimum required is "2.0.12")
CMake Error at /usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:108 (message):
  Could NOT find OpenAL (missing: OPENAL_LIBRARY)
Call Stack (most recent call first):
  /usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:315 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-2.8/Modules/FindOpenAL.cmake:97 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:18 (find_package)


-- Configuring incomplete, errors occurred!

232
Bugs & Feature requests / Fatal: Non-empty stack after LuaContext::update()
« on: February 16, 2014, 07:45:22 pm »
Not sure if this is a bug in the engine or the fault of my script, but I get the error "Fatal: Non-empty stack after LuaContext::update()" when one of my enemies is on the screen after a few seconds. The enemy script is below:

Code: [Select]
local enemy = ...

-- Octorok: simple enemy who wanders and shoots rocks

local going_hero = false
local awaken = false
local timer

function enemy:on_created()
  self:set_life(1)
  self:set_damage(2)
  self:create_sprite("enemies/octorok_red")
  self:set_hurt_style("monster")
  self:set_pushed_back_when_hurt(true)
  self:set_push_hero_on_sword(false)
  self:set_size(16, 16)
  self:set_origin(8, 13)
end

function enemy:on_movement_changed(movement)
  local direction4 = movement:get_direction4()
  local sprite = self:get_sprite()
  sprite:set_direction(direction4)
end

function enemy:on_obstacle_reached(movement)
  if awaken and not going_hero then
    self:check_hero()
  end
end

function enemy:on_restarted()
  if not awaken then
    self:go_random()
  else
    self:go_hero()
  end
  self:check_hero()
end

function enemy:on_hurt()
  if timer ~= nil then
    timer:stop()
    timer = nil
  end
end

function enemy:check_hero()
  local hero = self:get_map():get_entity("hero")
  local _, _, layer = self:get_position()
  local _, _, hero_layer = hero:get_position()
  local near_hero = layer == hero_layer
    and self:get_distance(hero) < 100

  if awaken then
    if near_hero and not going_hero then
      self:go_hero()
    elseif not near_hero and going_hero then
      self:go_random()
    end
  elseif not awaken and near_hero then
    self:wake_up()
  end
  timer = sol.timer.start(self, 1000, function() self:check_hero() end)
end

function enemy:wake_up()
  self:stop_movement()
  local sprite = self:get_sprite()
  sprite:set_animation("shooting")
  local x, y, l = self:get_position()
  local sx, sy = 0
  if d == 0 then
    sx = x + 8
    sy = y
  end
  if d == 1 then
    sy = y - 8
    sx = x
  end
  if d == 2 then
    sx = x - 8
    sy = y
  end
  if d ==3 then
    sy = y +8
    sx = x
  end
  sol.timer.start(self, 1000, function()
    local rock = self:create_enemy{
      breed = "rock_small",
      x = sx,
      y = sy
    }
    rock:go(d)
    sol.timer.start(self, 2000, function()
      self:check_hero()
    end)
  end)
end

function enemy:go_random()
  local m = sol.movement.create("random")
  m:set_speed(32)
  m:start(self)
  d = m:get_direction4()
  going_hero = false
end

function enemy:go_hero()
  local m = sol.movement.create("target")
  m:set_speed(48)
  m:start(self)
  d = m:get_direction4()
  going_hero = true
end

233
Development / Re: Cryptic error
« on: February 05, 2014, 08:38:56 pm »
Updating SDL worked perfectly! You are a genius, thanks!

234
Development / Re: Cryptic error
« on: February 05, 2014, 05:41:41 pm »
Confirmed that it happens with zsdx as well. Is there something wrong on my system? Is there a way I can debug this?

235
Development / Re: Cryptic error
« on: February 05, 2014, 05:38:16 pm »
That worked wonderfully - thank you! I'm slowly getting my scripts converted over to the new syntax, and I'm finding it to be much more concise and logical. Great job and thanks again for everything you've done with this engine!


Another oddity I encountered, except this one is graphical.



When I enter a map larger than the current screen, and move the character out of the initial drawing region, it appears that all of those tiles are never drawn (see above). The entities and dynamic tiles appear to be, but not the static tiles. If I leave and re-enter this map, say in a different area, a new region is drawn but I can once again move out of the drawn region.




Here's an image from the editor of what the area should look like,


I'm running Solarus 1.2.0 with 2D acceleration on (even stranger, if I run with acceleration off, I get no display at all - only a black screen) on Ubuntu linux 13.10.

236
Bugs & Feature requests / Editor improvements
« on: February 04, 2014, 05:34:36 am »
Christopho- mad props on the recent improvements to the editor - there are some great things there that really speed up development. Using the improved editor got me thinking of additional improvement potential, so I thought I'd post some here rather than making a bunch of issues on github (I can do that if you prefer).
  • A small "x" on each tab (for maps or whatever) to close it would be a huge time savings when you have several tabs open.
  • It would be nice (if possible) to have a small "play" button next to any drop-down selector for music. Sometimes I forget which music I want and being able to listed to several in the editor would be a great help. Or at least allow us to listen to the music when selecting it from the left pane?
  • When changing the id of an item in the left selector pane, the current id could be the default in the dialog.
  • Holding "control" and using the mouse wheel could zoom the view.
  • Making some tweaks to make the editor more friendly to smaller resolutions would be helpful - I have a machine running at 1024x768 and there are times when I can't see everything in a dialog box. One example is the new "destructible" dialog - would it be possible to lay things out differently so the dialog isn't so big?

237
Development / Cryptic error
« on: February 04, 2014, 05:17:40 am »
I was hoping I'd be able to get some help decrypting this error, because I don't understand why I'm getting one. I'm getting the following when I run my game:
Error: Failed to load script 'maps/1': [string "maps/1.lua"]:14: malformed number near '.0.shop_mushroom_done_dialog_finished'

The script around that line is:
Code: [Select]
  if destination == "main_entrance_shop" and game:get_value("i2021") == 10 then
    game:start_dialog("crista.0.shop_mushroom.7", crista.0.shop_mushroom_done_dialog_finished)
  end

And the function being called:
Code: [Select]
local function crista.0.shop_mushroom_done_dialog_finished()
  game:set_value("i3001", game:get_value("i3001")+1)
  hero:start_treasure("trading", 2)
end

I'm guessing it's related to changes in 1.2.0, since I don't recall having an error when running an earlier version.

238
General discussion / Re: Welcome!
« on: August 11, 2013, 07:11:15 pm »
I think the description's a bit clearer now - sorry I didn't realize that was there!

239
General discussion / Re: Welcome!
« on: August 07, 2013, 01:58:28 am »
Yay! Thanks Christopho!

My suggestion: a board for the Solarus engine so we can come up with cool new lua scripts and what-not.

Pages: 1 ... 14 15 [16]