Author Topic: Need help making a Redead AI that acts similar to Ocarina of time  (Read 328 times)

Diarandor

  • Hero Member
  • *****
  • Posts: 1008
  • Cats are cool! (ΦωΦ)
    • View Profile
Re: Need help making a Redead AI that acts similar to Ocarina of time
« Reply #30 on: September 14, 2018, 12:11:48 am »
Could you post the last code, so that it can be reviewed for new possible advices? That will help beginners who read your code too.

EDIT: and I forgot: congrats! you completed the challenge! XD
“If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you.”

Akamatsu

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Need help making a Redead AI that acts similar to Ocarina of time
« Reply #31 on: September 14, 2018, 12:39:38 am »
Code: Lua
  1. local enemy = ...
  2. local game = enemy:get_game()
  3. local map = enemy:get_map()
  4. local hero = map:get_hero()
  5. local sprite = enemy:create_sprite("enemies/Redead2")
  6. local movement
  7. local IsPlayerFrozen = false
  8.  
  9.  
  10. function enemy:on_created()
  11.  
  12. movement = sol.movement.create("target")
  13.  
  14.   enemy:set_life(8)
  15.  
  16.   enemy:set_damage(10)
  17.  
  18. end
  19.  
  20.  
  21.  
  22.  
  23.  
  24. function enemy:on_restarted()
  25.  
  26. sol.timer.start(self, 3000, function() sol.audio.play_sound("Redead/RedeadMoan") end)
  27.  
  28. self:get_sprite():set_animation("immobilized")
  29.  
  30. enemy:check_hero()
  31.  
  32. end
  33.  
  34.  
  35.  
  36. function enemy:check_hero()
  37.  
  38.    if self:get_distance(hero) <= 80 then
  39.  
  40.    movement = sol.movement.create("target")
  41.  
  42.    self:get_sprite():set_animation("walking")
  43.  
  44.    movement:set_speed(28)
  45.  
  46.    movement:start(enemy)
  47.  
  48. end
  49. sol.timer.start(self, 1000, function() self:check_hero() end)
  50.  
  51. if self:get_distance(hero) <= 80 then
  52.  
  53. if IsPlayerFrozen == false then
  54.  
  55.    sol.timer.start(self, 3000, function() hero:freeze() end)
  56.  
  57.    IsPlayerFrozen = true
  58.  
  59. end
  60.  
  61. end
  62.  
  63. if self:get_distance(hero) <= 80 then
  64.  
  65. if IsPlayerFrozen == true then
  66.  
  67.    sol.timer.start(self, 5000, function() hero:unfreeze() end)
  68.  
  69.     IsPlayerFrozen = false
  70. end
  71. end
  72. end
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81. function enemy:on_dying()
  82.  
  83. sol.audio.play_sound("Redead/RedeadDie")
  84.  
  85. end

Akamatsu

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Need help making a Redead AI that acts similar to Ocarina of time
« Reply #32 on: September 14, 2018, 12:51:23 am »
Also I'm always looking for help with my project if anyone is interested it's quite a large scale for one person i'll be showing off screenshots and such at a later point once I feel things are up to my standards I could always use another person on the project no matter what you can do.

I'll be sure to give a special thank you to Diarandor and Max

Diarandor

  • Hero Member
  • *****
  • Posts: 1008
  • Cats are cool! (ΦωΦ)
    • View Profile
Re: Need help making a Redead AI that acts similar to Ocarina of time
« Reply #33 on: September 14, 2018, 01:52:36 am »
I think that lines 57 and 69 should go inside their timers above. Otherwise, if the enemy is restarted (and therefore all timers stopped), your enemy will break its behavior, as you can check if I'm not wrong. (Even if the hero is frozen, the enemy could be hurt by the boomerang or other thing, and so restarted too.)
“If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you.”

Akamatsu

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Need help making a Redead AI that acts similar to Ocarina of time
« Reply #34 on: September 14, 2018, 02:43:19 am »
That's a good idea never thought about that.

Max

  • Full Member
  • ***
  • Posts: 155
    • View Profile
Re: Need help making a Redead AI that acts similar to Ocarina of time
« Reply #35 on: September 14, 2018, 04:43:22 am »
Also I'm always looking for help with my project if anyone is interested it's quite a large scale for one person.

Just a little more unsolicited advice- if your game is large for one person, it's probably too large for you to finish. Just speaking for the experience of seeing many projects fail. If you're okay with not finishing, great, keep going as long as you can. But if you want to continue learning and developing more games, make a smaller one first. You'll learn WAY more doing a few small games that you would one big one.

Either way, good luck.

Akamatsu

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Need help making a Redead AI that acts similar to Ocarina of time
« Reply #36 on: September 14, 2018, 08:22:43 pm »
I've always done projects by myself for the most part I just spend 1-2 years working on it.

there is only 1 game I have worked on with a team and that's SCP containment Breach

I normally pick things up pretty fast so I'm not to worried but if somebody has the free time to help I will not complain.