If you meet a monster or similar you might be able to kill it.
In my game if you go deeper into the forest you eventually find a Basilisk - It can and will kill you but you might be able to fight it.
The code for this is a little complex but you need to decide what the options are as usual in the first place.
So my options are to run away - or to Lash out. - as ever you can look at your inventory. If you do not have an inventory of things you can pick up then this option will not be there of course.
When we have the choice we then need to handle what to do, Back is simple - just run away back through the forest.
Lash on the other hand means we chose to fight - so we could - Win or Lose or Answer a question to try to escape.
My whole code for this is below.
I hope you can see how it works.
I used a random number between 1 and 100 - if the random number was less than 50 then the player dies. - Basilisks are tough.
If the random number is between 50 and 75 then you may still be killed - I have asked a question in this case.
Finally if the random number is over 75 you win and kill the Basilisk.
My simple routine to clear the inventory is below.