Just continuing with the "monster patrols" concept, I've tried to write a set of commands to give to a monster in order to have it "behave" as you like (so to have it interact with the party...).
The result (however incomplete) is here.
To explain, I give a "creature crowern" these commands:
Code: Select all
crowern_commands = {
start = {
{"wait","partyIsAt",{1,15,15,0},true}, -- partyIsAt checks whether the party is at a specific location in the dungeon
{"blockparty",true},
{"go",1,15,14,2},
{"say", {"I hope no one of you has...","...the sword of Nex!"}},
{"delay",2},
{"branch","nexyes","nexno","partyHas",{"nex_sword"},true}, -- partyHas checks if the party has a certain item (as of now, not if it is hidden in a container... i was lazy!)
},
nexyes = {
{"say", {"I'm sorry, but since you have the Sword of Nex...","...you cannot continue!","Please, throw it in the pit!"}},
{"go",1,15,13,2},
{"wait", "locationHas", {1,23,8,"nex_sword"}, true}, -- locationHas checks if a certain item is the given location
{"go",1,15,14,2},
{"jump", "nexno"},
},
nexno = {
{"say", {"Ok, you can come with me, now!"}},
{"close", "pit_1"},
{"go",1,17,10,0},
{"blockparty", false},
{"say",{"*you feel you can move, now*"}},
{"teleport",1,22,8,3},
{"wait","distanceLess",{2.1}, true}, -- distanceLess checks whether the party is at a (euclidean) distance less than the number specified from the creature
{"blockparty",true},
{"say", {"Now that you are here...","... it is time for me to go!","But first... a challenge!"}},
{"open","dsd_2"},
{"delay",4},
{"execute","makePatrol",{"c_scavenger",{1,24,5,2},{{1,24,10,0},{1,24,6,2}}}}, -- makePatrols makes a patrol [the function creates a mini-program for a creature]
{"go",1,22,6,0},
{"open","dsd_1"},
{"delay",4},
{"go",1,22,5,2},
{"close","dsd_1"},
{"delay",5},
{"blockparty",false},
{"kill"},
},
}
- "go",level,x,y,facing -- moves the creature to a place in the dungeon, and you can see it moving
- "teleport", level,x,y,facing -- does the same, but instantly
- "say",{text1,text2,text3...} -- hudPrint-s the lines of text
- "delay", time -- waits for the specified time
- "blockparty",boolean -- blocks the party in place if "true", frees it if "false"
- "open"/"close"/"toggle", object -- self explaining!
- "jump",label -- moves the execution of the 'program' to another block
- "branch",label1,label2,function,parameters,boolean -- moves the execution to label1 if function(parameters) = boolean, to label2 otherwise
- "wait",function,parameters,boolean -- waits for function(parameters) to be = to boolean, then resumes flow
- "execute",function,parameters -- executes function(parameters)
- "kill" -- goodby, cruel world!
All commands and functions are contained in a big table "allCommands" (which can be modified/expanded/etc) whose entries are of the form
Code: Select all
open = function(creature,object) -- the first parameter has to be 'creature'
findEntity(object):open()
creature.index = creature.index + 1 -- execute next command in the list
waitFor(0.5,creature) -- wait for 0.5 seconds (the second parameter, 'creature', is mandatory, as is the 'waitFor' command)
end,
alois