How to make snake attack me when entering the room? Or any enemy? SOLVED!!!!

So i want any object/living with hostile to 1 or a flag as hostile to engage me in combat when entering a room and that object is inside the room, instead of making every single object by choice, a flag would be easier, im not sure where to begin tho please help I'm learning!

Edit: I'm going for turn-based not timer or action, currently i can attack the enemy object but it does not reply or engage when i enter the room I'm aiming for these things


I think you'd do it by setting, and pardon my psuedocode:

after I enter this room
if (EnemyObject.parent=TheRoomInQuestion)
{Run Enemy Attacking Code}

As for it responding after you attack, just end all your 'player attacks' code with 'and then the enemy attacks'. To simplify, I'd make a new function called EnemyAttacks, put your enemy attacking code in THERE, and have it like


Thank you again for valuable help and information! This makes sense to me :)

I keep getting the error EnemyObject is unknown object or variable even tho i added an attribute EnemyObject to my snake i'm so lost


Oh no, you misunderstood. EnemyObject was the example name of the object, because I don't know what you're calling the snake in your code. So it'd be more like WhateverYourSnakeIsCalled.parent

Remember, the .parent attribute is which room it's in. If the snake is ONLY EVER in that room and never leaves and always attacks when you enter, you can skip the 'if' stuff and just go for

After entering the room

That worked great woot you rock!

This topic is now closed. Topics are closed after 60 days of inactivity.