News:

SMF - Just Installed!

Main Menu

LUA-question

Started by doublejack, September 03, 2012, 03:22:17 PM

Previous topic - Next topic

Stephen

Hi,

Sorry for taking so long to reply... I somehow missed your post

I'm a little confused, what are you trying to do exactly?

ImpassIve

#46
Hello, Stephen.

We have already changed the concept of the mod, so described questions are not so important anymore...

Anyway, we were planning to make a vampire, who could turn into a special bat (in a similar way, as it was implemented in Rat Riders mod: just replacing old monster with another one) to avoid lethal damage. This bat was supposed to run away from all knights and if it is still alive after XX seconds - it can turn back into a vampire form (fully regenerated, of course).

  1) Since we don't have much control over AI behaviour, we had an idea to fill "ai_fear" field with all possible knight weapons, but... yeah, now I see in the wiki - "ai_fear" is listed in "Walking monsters only" category.

  2) Then we had another idea: FlyingMonsterAI class from the source code has a "run_away_flag" variable, which forces flying creature to run away from the target. It is even possible to set it into "true" state via Lua script, by calling "kts.Damage" with zero amount of damage at each tile (or just frequently enough).

But there were a problem: it cannot be done from inside the "on_move" hook of the monster (see previous post), while other hooks are... not so reliable. Looks like Lua doesn't provide a way to run a function with specific time intervals?

Also, later we realised that a monster with constant "run_away_flag == 1" wouldn't run from the knight - it will run in the direction, pointed by knight's facing, so we had to abandon this concept.

  3) There were a backup plan: in some legends, vampires are turning into fog instead of bats, so we could use (1) case with walking type of monster. But a walking monster can easily be cornered, so this wouldn't add a lot to his survivability.

Anyway, as I mentioned in the beginning of the post, the concept of the mod has been changed and it doesn't require any manipulations over monster's behavious anymore.

EDIT:
Quote from: ImpassIve_rus on November 07, 2016, 09:42:25 AM
Looks like Lua doesn't provide a way to run a function with specific time intervals?

Ah, my bad!
I haven't noticed the "kts.AddTask()" function...


Stephen

OK, that mod does sound interesting.

I did once have an idea to make AI controllable from Lua, so that you could write little Lua scripts to control what a monster does. That would be quite a lot of work though.

There's no good reason why ai_fear should be walking monsters only... it just needs to be implemented in the FlyingMonsterAI as well. (The only reason it wasn't implemented, is because it was only needed for zombies at the time.) I guess I could do that sometime.

If I ever make another indie game, I will put the scripting in from the beginning, instead of tacking it on at the end like I did with Knights... that is the cause of most of these problems I think :)

ImpassIve

An offtop note:
hey, looks like I've got a personal remote-controlled monster!


Stephen