Need help making a Redead AI that acts similar to Ocarina of time

Started by Akamatsu, September 09, 2018, 05:05:48 PM

Previous topic - Next topic
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."

Code (lua) Select

local enemy = ...
local game = enemy:get_game()
local map = enemy:get_map()
local hero = map:get_hero()
local sprite = enemy:create_sprite("enemies/Redead2")
local movement
local IsPlayerFrozen = false


function enemy:on_created()

movement = sol.movement.create("target")

  enemy:set_life(8)

  enemy:set_damage(10)

end





function enemy:on_restarted()

sol.timer.start(self, 3000, function() sol.audio.play_sound("Redead/RedeadMoan") end)

self:get_sprite():set_animation("immobilized")

enemy:check_hero()

end



function enemy:check_hero()

   if self:get_distance(hero) <= 80 then

   movement = sol.movement.create("target")

   self:get_sprite():set_animation("walking")

   movement:set_speed(28)

   movement:start(enemy)

end
sol.timer.start(self, 1000, function() self:check_hero() end)

if self:get_distance(hero) <= 80 then

if IsPlayerFrozen == false then

   sol.timer.start(self, 3000, function() hero:freeze() end)

   IsPlayerFrozen = true

end

end

if self:get_distance(hero) <= 80 then

if IsPlayerFrozen == true then

   sol.timer.start(self, 5000, function() hero:unfreeze() end)

    IsPlayerFrozen = false
end
end
end








function enemy:on_dying()

sol.audio.play_sound("Redead/RedeadDie")

end

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

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."


Quote from: Akamatsu 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.

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.

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.

@Max Sorry about this being a bit off topic and all but is their a way I can contact you to share some stuff with you?
I sent you that message forever ago the one you replied to I've got some stuff to discuss with you in private  ;D

do you have steam/Discord?


Yeah, sorry about that again, I never received an email about the message and although I check the forum like daily, I'd never noticed the small message icon -_-

I do have a discord! I just don't really know how to use it, lol.

Add me on discord Akamatsu#5130 shouldn't be to hard to figure out how i've got some stuff I'd like to share with you in private and get your thoughts or opinions.

I also was able to get a script to work that we talked about but it's sort of limited for now I can explain more in detail on their.