Skip to content

Current questions and answers regarding the map editor.

User Avatar
#3503
Auto-translated
Rhenish, if simplified to the extreme, without animations and monster movements, it would be something like this:
Trigger(NEW_DAY_TRIGGER, 'NewDay');

-- here we list all the monsters that can attack
attacking_mummy_array = {'mummy01', 'mummy02'};

function NewDay()
  if(not IsObjectExists('HERO_NAME')) then return end
  local hero_x, hero_y, hero_f = GetObjectPosition('HERO_NAME');
  for i, mummy in attacking_mummy_array do
    if(IsObjectExists(mummy)) then
      local monster_x, monster_y, monster_f = GetObjectPosition(mummy);
      local diff_x = hero_x - monster_x;
      local diff_y = hero_y - monster_y;

      if( (sqrt((diff_x * diff_x) + (diff_y * diff_y)) <= 6) and (hero_f == monster_f)) then
        MakeHeroInteractWithObject('HERO_NAME', mummy);
        break
      end
    end
  end
end
upd: Oops, I was late with the advice. upd: Added a check for existence.