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 - SyF

Pages: [1]
1
Hello guys,
I want to know if is it possible to disable the dying sound when an enemy is killed ?

Because, when I kick the boss, I "remove_life" the enemies around in the same time. And in this way, the sound is played for each in the same time (and it is horrible for my ears  ;D).

Do you have any idea ?

2
Development / [Solved] Sprites not visible when entities created
« on: March 26, 2020, 08:15:39 pm »
Hello guys, it is been a long time I don't write in this forum ;)

I've got a problem when I create a boss with separated parts. I successed to create all these parts one by one with no issue (for example function "3A. create_shoulder" in the "boss2_crane" file) ... But I want to optimise my script with the new function "03. create_part_boss".

However, when I use this function, the sprite of these part are not visible in the map.
But, thanks to my print, I know these entities are created.

Do you have any idea ?

PS:
The scripts are attached (sorry for the franglish  ;D )

3
Development / [Solved] Create a new "attack_consequence"
« on: April 28, 2017, 12:16:07 pm »
Hi  ;D
I create a new item: the pickaxe. It allows the hero to destroy some specifics entities and enemies. I want to know if it is possible to add a new kind of "attack_consequence" (as lign 26).
The principe is to attack a specific enemy class with the pickaxe to destroy their armor and, after, kill them with the sword.

enemy script:
Code: (lua) [Select]
local enemy = ...
local game = enemy:get_game()
local map = enemy:get_map()
local hero = map:get_hero()
local body_sprite
local movement
local shield_remove

-- Properties
local life = 2
local damage = 2
local speed = 24
local speed_faster = speed + speed/2

-----------------------------------------
-- Proprieties of the enemy with shield
local function shield_mode()
  body_sprite:set_animation("walking_rock")
  enemy:set_push_hero_on_sword(true)
  enemy:set_attack_consequence("sword", "protected")
  movement = sol.movement.create("target")
  movement:set_target(hero)
  movement:set_speed(speed)
  movement:start(enemy)

  enemy:set_attack_consequence("pickaxe","custom")-- ??

end

-----------------------------------------
-- Proprieties of the enemy without shield
local function normal_mode()
  shield_remove = true
  body_sprite:set_animation("walking")
  movement = sol.movement.create("random")
  enemy:set_push_hero_on_sword(false)
  enemy:set_default_attack_consequences()
  movement:set_speed(speed_faster)
  movement:start(enemy)
end

-----------------------------------------
-- When the enemy is hit by a pickaxe
function enemy:on_custom_attack_received(attack,sprite)
 normal_mode()
end

-----------------------------------------
function enemy:on_created()
  body_sprite = enemy:create_sprite("enemies/" .. enemy:get_breed())
  enemy:set_life(life)
  enemy:set_damage(damage)
  shield_remove = false
end

-----------------------------------------
function enemy:on_restarted()
  if shield_remove == false then
    shield_mode()
  else
    normal_mode()
  end
end

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

4
Development / [Solved] Create a custom switch
« on: April 05, 2017, 03:40:30 pm »
Hi everyone,
I would like to create a custom switch. In fact, I have an idea but I prefer ask if there is a better way to script it.
This is my idea: The hero throws a boomerang and activate the switch (which keeps the item). After the switch animation, the boomerang returns to the hero and something happens (for example, opening a door).

I already create a custom entity for the switch and it works when I throw my boomerang. Now, I need to indicate in the game that this custom entity is a switch, because I want to use the function "switch:on_activated" and the other.

Does someone have an idea ?

----------------------------------------------------
Switch code :
Code: (lua) [Select]
local entity = ...

function entity:on_created()
  entity:set_size(32, 24)
  entity:set_origin(16, 21)
  entity:set_traversable_by(false)
  entity:set_drawn_in_y_order(true)
end

entity:add_collision_test("touching", function(entity, other_entity)

  local type = other_entity:get_type()
  local switch_state = entity:get_sprite():get_animation()
    local check = type == "boomerang" and switch_state == "stop_off"

  if check then
    entity:get_sprite():set_animation("activated")
    sol.timer.start(1000, function()
      sol.audio.play_sound("secret")
      entity:get_sprite():set_animation("stop_on")
      entity:clear_collision_tests()
      end)
  end
end)
States :
  # stop_off : the switch is not activated
  # activated : the switch is beins activated (loop animation)
  # stop_on : the switch is activated and unusable

Boomerang code:
Code: (lua) [Select]
local item = ...

function item:on_created()
  item:set_savegame_variable("possession_boomerang")
  item:set_assignable(true)
end

function item:on_using()
  local hero = item:get_map():get_hero()
  hero:start_boomerang(64,160,"boomerang","entities/boomerang")
end

5
Development / [Solved] Insert sprite before creating an enemy
« on: March 18, 2017, 10:09:46 am »
Hi, I manage my first boss. Now, I try to make a cutscene when the boss arrives. The only thing I have to do is insert the animation called "appeared" in the code.
I tried to write "enemy:get_sprite():set_animation("appeared")" in the function "enemy:on_created" but it didn't work (lign 78). The sprite of the boss blinked.
I tried also to use the function "enemy:on_post_draw()", without success.

Someone know how to insert a sprite at the creation of an entity ?

Code: (lua) [Select]
local behavior = {}

function behavior:create(enemy, properties)

local game = enemy:get_game()
local map = enemy:get_map()
local hero = enemy:get_map():get_hero()
local max_life = properties.life
local time = properties.interval_minion
local body_sprite = enemy:create_sprite("enemies/" .. enemy:get_breed())

-------------------------------------------------------------
------- Floor explosion
local function explosion_plaque(name_plaque)
  for plaque in map:get_entities(name_plaque) do 
    local plaque_x, plaque_y, plaque_layer = plaque:get_center_position()
      map:create_explosion({x= plaque_x, y = plaque_y, layer = plaque_layer})
      plaque:set_enabled(false)
  end
  sol.audio.play_sound("explosion")
end

-------------------------------------------------------------
-- Stop the timer and update the state of the boss
local function end_timer_monster()
  local time_left = properties.number_minion * time + 50
  sol.timer.start(enemy, time_left, function()
    sol.timer.stop_all(enemy)
    forme_boss_base()
    end)
end

-------------------------------------------------------------
--- Normal state of the boss
function forme_boss_base()
    enemy:set_attack_consequence("sword", 1)
    body_sprite:set_animation("walking")
    enemy:set_can_attack(true)

    local move = sol.movement.create(properties.movement_ground)
      move:set_speed(properties.speed_ground)
      move:start(enemy)
end

-------------------------------------------------------------
--- Flying state of the boss
function forme_boss_fly()
    enemy:set_attack_consequence("sword", "ignored")
    body_sprite:set_animation("flying")
    enemy:set_can_attack(false)

    local move = sol.movement.create(properties.movement_fly)
      move:set_speed(properties.speed_fly)
      move:start(enemy)
  end_timer_monster()
  sol.timer.start(enemy, time, function()
    local boss_x, boss_y, boss_layer = enemy:get_position()
    local boss_direction = enemy:get_direction4_to(hero)
      map:create_enemy{
        breed = "tentacle",
        layer = boss_layer,
        x = boss_x,
        y = boss_y,
        direction = boss_direction,
        }
  return true
  end)
end

-------------------------------------------------------------
-- Creation of the boss
function enemy:on_created()
  enemy:set_life(max_life)
  enemy:set_damage(properties.damage)
  enemy:set_hurt_style("boss")
  enemy:set_attack_consequence("explosion", "ignored")
  local flying_mode = false
  body_sprite:set_animation("appeared") -- Problem ??
end

-------------------------------------------------------------
-- Indicate when the boss changes this state
function enemy:on_hurt()
  local less_life = enemy:get_life()
    if less_life == 8  then
      flying_mode = true
      explosion_plaque("plaque_spike_1_")
    elseif less_life == 4 then
      flying_mode = true
      explosion_plaque("plaque_spike_2_")
    else
      flying_mode = false
    end
end

-------------------------------------------------------------
-- When the boss moves
function enemy:on_restarted()
    if flying_mode == true then
      forme_boss_fly()
    else
      forme_boss_base()
    end
end

-------------------------------------------------------------
-- Change the sprite when the boss moves
function enemy:on_movement_changed(movement)
  local direction4 = movement:get_direction4()
  body_sprite:set_direction(direction4)
end

-------------------------------------------------------------
-- When the boss is dead
function enemy:on_dead()
game: set_value("defeated_boss",1)
map:open_doors("door_boss_")
end

end -- End of Behavior
return behavior

6
Bugs & Feature requests / [Solved] Bug with "get_facing_entity" ?
« on: March 13, 2017, 11:38:57 am »
Hi,
I'm on th version 1.5.2 and I create an item to allow the hero to walk on specific grounds (spikes, lava...). I managed to create a custom entity and the hero can walk on it.
Now I just want the entity to be created only on there specific grounds.
I use the function "get_facing_entity" (lign 66) to get the entity in front of the hero and my variable got the delicious name "0x063b4a08" (or something like that).

Do you know if it is a bug or not ?

My code:
Code: (lua) [Select]
local item = ...
local game = item:get_game()
---------------------------------------
function item:on_created()
  self:set_savegame_variable("slim_stick")
  self:set_assignable(true)
end
---------------------------------------
function item:on_obtaining()
  game:set_item_assigned(1,self)
end
---------------------------------------
local function enabled_custom(name_ent) --Timer on custom entity
  local map = item:get_map()
  local custo_ent = map:get_entity(name_ent)
  sol.timer.start(5000, function()
    custo_ent:set_enabled(false)
    end)
end
---------------------------------------
function item:on_using()
local map = item:get_map()
local hero = map:get_hero()

-- Coordinates Hero
  local hero_x, hero_y, hero_layer = hero:get_position()
  local direction = hero:get_direction()

-- Slim position
  local slim_x, slim_y

if direction == 0 then
    slim_x = hero_x + 24
    slim_y = hero_y
  elseif direction == 1 then
    slim_x = hero_x
    slim_y = hero_y - 24
  elseif direction == 2 then
    slim_x = hero_x - 24
    slim_y = hero_y
  elseif direction == 3 then
    slim_x = hero_x
    slim_y = hero_y  + 24
  end

-- Slim creation
local tai_hitbox = 48
spot_slim = map:create_custom_entity{
    name = "slim",
    layer = hero_layer,
    x = slim_x,
    y = slim_y,
    width = tai_hitbox,
    height = tai_hitbox,
    direction = direction,
    sprite = "entities/spot_slim"
    }

-- Bigger hitbox
spot_slim:set_origin(tai_hitbox/2, tai_hitbox/2)

-- Ground modification
spot_slim:set_modified_ground("traversable")

-- Test to determinate the type of the ground in front of the hero
local ground_entity = hero:get_facing_entity()
  print(ground_entity)

-- End of the function
local name_slim = spot_slim:get_name()
  item:set_finished()
enabled_custom(name_slim)
end

7
Bugs & Feature requests / [Solved] Problem to upgrade to version 1.5.2
« on: March 07, 2017, 04:38:34 pm »
Hi !
I also create a game with Solarus. From the beginning, I worked on the version 1.4.5 and I want to pass on the latest. I downloaded the version 1.5.2 and, when I want to upgrade, I got this message box (In attachment).

Someone knows how to fix it ?


Pages: [1]