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.


Topics - wrightmat

Pages: [1] 2 3
1
Development / NPC routines
« on: December 06, 2017, 04:41:41 am »
Hey all,

I've been thinking recently about how to create more interesting NPC routines in Lua without it being too complicated. Right now I'm on the idea of passing routines as a table from the NPC script to another scripts that parses it and stores it to be executed on the regular. I'm a little fuzzy on the details though, so I thought I'd throw my thoughts here!

Code: Lua
  1. local routine = { [08]="to_shop", [10]="to_house", [13]="to_mill" }
  2. function entity:on_created()
  3.   self:set_routine(self, routine)
  4. end
Here is where I thought about encoding the routine as a nested table - with time (hours) in brackets and waypoint entity in quotes. Then I can parse that table out to get the individual parts of the routine.

Code: Lua
  1.   for k,v in pairs(routine) do
  2.     game:add_routine(k, npc:get_name(), v)
  3.   end

I think my next step would be to create a new table, or several tables, organized by hour so the game easily parse the correct table at the correct time (the add_routine routine I'm playing around with up there). If this table contains the entity name and waypoint entity name, then the movement should be able to be created pretty easily.

My main issue right now is the structure/format of the routine tables organized by time. I'm not an expert on Lua tables and I'm not sure how to make this without a bunch of if/then statements which would be best to avoid.

Anyway, I'd love to hear thoughts on the idea, and especially the execution thereof!

2
General discussion / PC Gamer article
« on: September 18, 2017, 07:49:53 pm »
PC Gamer did an awesome little article on our own Christopho and his excellent engine, Solarus! If you haven't seen it, I highly recommend the read!  :D

http://www.pcgamer.com/zeldas-most-dedicated-fan-game-developers-built-an-engine-anyone-can-use/

Great to see good work recognized, and we all know that Christopho has done some great work with Solarus!

3
Bugs & Feature requests / "normal" video mode is at 2x
« on: June 02, 2017, 04:31:33 am »
It appears, and the API confirms, that the "normal" video mode actually stretches the image by a factor of 2. Is it possible to just have the game run un-stretched? If there's not currently, I really think this should be added as a feature soon. Currently it would be pretty much impossible to use higher resolution resources when making games.

4
Development / Enemies not piling up
« on: May 26, 2017, 02:36:48 am »
In my game my enemies have a bad habit of "piling up" on each other, which makes it much easier to kill several of them with one hit. I was trying to avoid this with the code below, but I've now traced the code to some random crashes I've been having, so I need to take it out. I'd still like to find a way to not have the enemies pile up, and my guess is this was a stupid way in the first place and there's some obvious answer I've missed. So, my hope is the community can save me from my own stupidity again :)

 
Code: Text
  1. function enemy:on_collision_enemy(other_enemy, other_sprite, my_sprite)
  2.   if enemy:is_traversable() then
  3.     enemy:set_traversable(false)
  4.     sol.timer.start(200, function() enemy:set_traversable(true) end)
  5.   end
  6. end

5
Bugs & Feature requests / text surface fade_in and fade_out?
« on: April 07, 2017, 03:53:55 pm »
When I create a text surface, I can draw it near a custom entity by using draw_visual from on_post_draw, but when I try to apply a fade_in or fade_out to that surface (which the api says is general to all drawables) it doesn't seem to do anything. Is this a bug? Has anyone else tried this and succeeded?

6
Development / Equipment items as a class
« on: October 13, 2016, 03:08:59 pm »
I've been thinking about equipment items and if it would be possible to extend them to work more like a class in an RPG, so you could give custom stats and such to items. The ultimate extension would be to allow for a sort of crafting system where you could customize the item and it would be saved with the custom stats and sprite.

My thought is this should be possible by creating an item script for each type of item, say a sword or dagger or axe, then using variants to cover the different sprites. Then I'm wondering if it's possible to create a function in the item script that's called after item_create that passes and sets the stats and saves the item. The condition I see is that you'd still only be able to have one type of each item, or at least one variant, right?

Any other interesting ideas anyone has about extending the built in items? Or is this something that's better handled by ditching the built in items and using custom entities?

7
Development / Is there a way to tell when the map is scrolling?
« on: October 05, 2016, 03:25:21 pm »
I'd like a script to detect when the map is undergoing a scrolling transition - is that possible? This may be related to Solarus issue #989 (https://github.com/solarus-games/solarus/issues/989), but my screen overlay for map tone scrolls with the map when the hero hits the teletransporter. This is not the desired behavior since all of the lights that I've drawn on the surface move when they should stay stationary. My contingency plan is to disable drawing of those lights at the moment of screen scrolling, but I can't figure out if that's possible.

8
Bugs & Feature requests / Video/hardware acceleration
« on: August 22, 2016, 02:18:24 pm »
Is there a way from code or settings to disable video/hardware acceleration by default? It looks like you can do it from the launcher, but I'd like to not give the option and just disable it for my game by default if possible. Thanks!

9
Development / Failed to create software surface
« on: July 31, 2016, 01:52:18 am »
I'm using a modified version of Satoh's code that was posted at http://forum.solarus-games.org/index.php/topic,676.15.html to make the day/night system I had work with the new blend modes introduced in 1.5. It uses the map metatable to force a night overlay to drawn on all maps when it's night time. The problem is that after 10 to 15 minutes of game play at night (an overlay with blend modes being drawn) my game crashes with the fatal error "Failed to create software surface". I'm assuming that my code is just inefficient and the repeated re-drawing is causing memory issues, but I'm not sure how to improve it. Hopefully someone here will have an idea that can help me improve me code! And thanks for looking!

Code: Text
  1.   function map_metatable:on_draw(dst_surface)
  2.     local game = self:get_game()
  3.     local hour_of_day = (time_counter / 3000)
  4.     -- Put the night (or sunrise or sunset) overlay on any outdoor map if it's night time.
  5.     if (hour_of_day >= 19.6 or hour_of_day <= 7.4) and
  6.     (game:is_in_outside_world() or (self:get_world() == "dungeon_2" and self:get_id() == "20") or
  7.           (self:get_world() == "dungeon_2" and self:get_id() == "21") or (self:get_world() == "dungeon_2" and self:get_id() == "22")) then
  8.       local x,y = game:get_map():get_camera():get_position()
  9.       local w,h = game:get_map():get_camera():get_size()
  10.      
  11.       if draw_counter >= 15 then
  12.         shadow:clear()
  13.         if hour_of_day >= 19.6 and hour_of_day < 20 then
  14.           t[1] = 255; t[2] = 255; t[3] = 255
  15.           -- Dusk
  16.           if t[1] >= 2 then
  17.             t[1] = t[1] - 2 -- Red: Goal is 0 (fade to black, which is the same as fading in for this blend mode)
  18.           else
  19.             game:set_value("time_of_day", "night")
  20.             game:set_value("hour_of_day", 20)
  21.           end
  22.           if t[2] >= 3 then
  23.             t[2] = t[2] - 3 -- Green: Goal is 0
  24.           else
  25.             game:set_value("time_of_day", "night")
  26.             game:set_value("hour_of_day", 20)
  27.           end
  28.           if t[3] >= 4 then
  29.             t[3] = t[3] - 4 -- Blue: Goal is 0
  30.           else
  31.             game:set_value("time_of_day", "night")
  32.             game:set_value("hour_of_day", 20)
  33.           end
  34.           shadow:fill_color(t)
  35.         elseif hour_of_day >= 20 and hour_of_day <= 21 then
  36.           -- Sunset
  37.           if t[1] >= 32 then t[1] = t[1] - 3 end -- Red: Goal is 32 (from 255)
  38.           if t[2] >= 64 then t[2] = t[2] - 2 end -- Green: Goal is 64 (from 255)
  39.           if t[3] >= 128 then t[3] = t[3] - 1 end  -- Blue: Goal is 128 (from 255)
  40.           shadow:fill_color(t)
  41.         elseif hour_of_day >= 6 and hour_of_day <= 7 then
  42.           -- Sunrise
  43.           t[1] = (182*(hour_of_day-6))+18 -- Red: Goal is 182 (from 32)
  44.           t[2] = (62*(hour_of_day-6))+66 -- Green: Goal is 126 (from 64)
  45.           t[3] = (37*(1-(hour_of_day-6)))+87 -- Blue: Goal is 91 (from 128)
  46.           shadow:fill_color(t)
  47.         elseif hour_of_day > 7 and hour_of_day <= 7.4 then
  48.           -- Dawn
  49.           if t[1] <= 253 then
  50.             t[1] = t[1] + 2 -- Red: Goal is 255 (fade to white, which is the same as fading out for this blend mode)
  51.           else
  52.             game:set_value("time_of_day", "day")
  53.             game:set_value("hour_of_day", 7.5)
  54.           end
  55.           if t[2] <= 252 then
  56.             t[2] = t[2] + 3 -- Green: Goal is 255
  57.           else
  58.             game:set_value("time_of_day", "day")
  59.             game:set_value("hour_of_day", 7.5)
  60.           end
  61.           if t[3] <= 251 then
  62.             t[3] = t[3] + 4 -- Blue: Goal is 255
  63.           else
  64.             game:set_value("time_of_day", "day")
  65.             game:set_value("hour_of_day", 7.5)
  66.           end
  67.           shadow:fill_color(t)
  68.         else
  69.           -- Night
  70.           shadow:fill_color({32,64,128,255})
  71.           game:set_value("time_of_day", "night")
  72.         end
  73.        
  74.         lights:clear()
  75.         for e in game:get_map():get_entities("torch_") do
  76.           if e:get_sprite():get_animation() == "lit" and e:get_distance(game:get_hero()) <= 250 then
  77.             local xx,yy = e:get_position()
  78.             local sp = sol.sprite.create("entities/torch_light")
  79.             sp:set_blend_mode("blend")
  80.             sp:draw(lights, xx-32, yy-32)
  81.          end
  82.         end
  83.         for e in game:get_map():get_entities("night_") do
  84.           if e:is_enabled() and e:get_distance(game:get_hero()) <= 250 then
  85.             local xx,yy = e:get_position()
  86.             local sp = sol.sprite.create("entities/torch_light")
  87.             sp:set_blend_mode("blend")
  88.             sp:draw(lights, xx-24, yy-24)
  89.           end
  90.         end
  91.         for e in game:get_map():get_entities("lava_") do
  92.           if e:is_enabled() and e:get_distance(game:get_hero()) <= 250 then
  93.             local xx,yy = e:get_position()
  94.             local sp = sol.sprite.create("entities/torch_light_tile")
  95.             sp:set_blend_mode("blend")
  96.             sp:draw(lights, xx-8, yy-8)
  97.           end
  98.         end
  99.         for e in game:get_map():get_entities("warp_") do
  100.           if e:is_enabled() and e:get_distance(game:get_hero()) <= 200 then
  101.             local xx,yy = e:get_position()
  102.             local sp = sol.sprite.create("entities/torch_light_tile")
  103.             sp:set_blend_mode("blend")
  104.             sp:draw(lights, xx-16, yy-16)
  105.           end
  106.         end
  107.         for e in game:get_map():get_entities("poe") do
  108.           if e:is_enabled() and e:get_distance(game:get_hero()) <= 200 then
  109.             local xx,yy = e:get_position()
  110.             local sp = sol.sprite.create("entities/torch_light")
  111.             sp:set_blend_mode("blend")
  112.             sp:draw(lights, xx-32, yy-32)
  113.           end
  114.         end
  115.         -- Slowly drain magic when using lantern.
  116.         if magic_counter >= 50 then
  117.           game:remove_magic(1)
  118.           magic_counter = 0
  119.         end
  120.         if not game:is_suspended() then magic_counter = magic_counter + 1 end
  121.         draw_counter = 0
  122.       end
  123.       draw_counter = draw_counter + 1
  124.  
  125.       if game:has_item("lamp") and game:get_magic() > 0 then
  126.         local xx, yy = game:get_map():get_entity("hero"):get_position()
  127.         local sp = sol.sprite.create("entities/torch_light_hero")
  128.         sp:set_blend_mode("blend")
  129.         sp:draw(lights, xx-64, yy-68)
  130.       end
  131.  
  132.       lights:draw_region(x,y,w,h,shadow,x,y)
  133.       shadow:draw_region(x,y,w,h,dst_surface)
  134.     end
  135.   end

10
Bugs & Feature requests / Universal Windows App
« on: June 26, 2016, 08:40:46 pm »
I'm wondering if it would be possible in a future release (1.6?) to enable the Solarus engine as a Universal Windows App (UWA), which should allow games to be run on XBox One as well as Windows 10. It looks like it would require SDL version 2.0.4 (not sure what Solarus is using currently) and development in Visual Studio 2015. I just think it would be really cool to be able to play our games on XBox!

https://msdn.microsoft.com/en-us/library/hh875012.aspx

11
Development / Hole into teletransporter
« on: June 17, 2016, 04:42:16 pm »
In the past, I was able to place a teletransporter over a hole so that when the hero fell into the hole, he was transported to a new map. This no longer appears to work in 1.5dev - was this intentional? Is it possible to get the old behavior back?

Also Christopho, I was wondering if there was any estimate on the release of 1.5? I wanted to release the full version of my game soon, but wanted it to run on Solarus 1.5

Thanks!

12
Bugs & Feature requests / Flying enemies and walls
« on: April 14, 2016, 02:48:15 pm »
I have enemies where I've set enemy:set_obstacle_behavior("flying") and enemy:set_layer_independent_collisions(true) that are traversing walls that are set to block enemies - is this the expected behavior? Is there a way I can change this if it is?

13
I get multiple "libpng warning: iCCP: known incorrect sRGB profile" errors when displaying a menu. I'm guessing this is related to my pause_submenus.png file, but the error does not specify. I also haven't been able to manipulate the image to eliminate the error - I use gimp, and have searched the internet for solutions to no avail. Anyone have any insight into this?

In a future version, can the engine at least specify the file that's throwing the error?

14
Development / Expanding item_1 and item_2 commands
« on: February 09, 2016, 01:41:48 am »
I'm thinking it should be possible, probably using metatables, to expand the item_1 and item_2 commands and include item_3 and even item_4, for when more items are needed. But I'm wondering, does modifying the metatable of existing functions expand them or overwrite them? For example, would the code below work? If not, I could create a custom function similar to each of the built-in ones for each of the item slot functions.

Code: Lua
  1. local game_metatable = sol.main.get_metatable("game")
  2. function game_metatable:get_item_assigned(slot)
  3.   if slot == 2 then
  4.     return game:get_value("slot_2_item")
  5.   elseif slot == 3 then
  6.     return game:get_value("slot_3_item")
  7.   end
  8. end
  9.  

I'm also not 100% sure how the button mapping part would work. Is game:get/set_command_keyboard_binding() expandable or configurable?

Just brainstorming and wanted others' thoughts...

15
Development / Fading out overlay in different map
« on: December 13, 2015, 09:23:49 pm »
I have a surface that I'm using as an overlay, but it only exists on two maps. What I'd like to have happen is that when you enter one of the two maps, the overlay fades in (it's fog, so it's for effect) and then when you leave, it fades out. I can get the fade in to work just fine. I've tried to use the teletransport:on_activated event to call the fade_out, but so far I can't get it to work. I'm assuming the surface is automatically attached to the map because when you leave the map, the surface overlay immediately disappears. Is it possible to have this fade out instead?

Pages: [1] 2 3