I want to do a fighting challenge in a room around 25 tile (5x5). but the twist is that every 5 second all tile from the room will activate a teleport and move every entity to a random location in the room.
I'm not a programer or a scripter so I have no idea if its doable or how it would need to be done if possible.
thanks for the time
[RESOLVED] - [Script] need help for random location teleport
[RESOLVED] - [Script] need help for random location teleport
Last edited by Golamare on Mon Jan 21, 2013 2:31 am, edited 1 time in total.
Re: [Script] need help for random location teleport
one problem will be that you probably can't hope for "every" tile because the teleporters would be an infinite progression until they turn off, several teleports within a very small time. Maybe you could set up something like a checker pattern every other time, so half the entities get moved to non-teleporter squares. To truly randomize teleporter destinations is a little bit of coding but not too bad I guess, just generate a random x from the range you have on that room, and a random y to go with it, and program the teleorter before activating it, doing that for each one
Finished Dungeons - complete mods to play
Re: [Script] need help for random location teleport
To avoid the problem of teleporters, you could use the recently added function:
Monster:setPosition(x, y, facing, level)
To do so, you would have to programmatically get the id of each monster in your room, create a list of unique random co-ordinates, and then cycle through each monster ID calling the setPosition function.
Monster:setPosition(x, y, facing, level)
To do so, you would have to programmatically get the id of each monster in your room, create a list of unique random co-ordinates, and then cycle through each monster ID calling the setPosition function.
Puzzle Frameworks - http://www.grimrock.net/forum/viewtopic.php?f=14&t=4564
Magic Pack - https://www.nexusmods.com/grimrock/mods/70
Area of Effect Spell System - http://www.grimrock.net/forum/viewtopic ... 150#p44382
Magic Pack - https://www.nexusmods.com/grimrock/mods/70
Area of Effect Spell System - http://www.grimrock.net/forum/viewtopic ... 150#p44382
Re: [Script] need help for random location teleport
Thanks for the feedback I guess I will try to activate only teleporter on entity location.
However I'm not aware of a function that could do that.
However I'm not aware of a function that could do that.
Re: [Script] need help for random location teleport
I think Grimwold's idea will probably be the best approach this time, pretty clean and not too hard to implement
Finished Dungeons - complete mods to play
Re: [Script] need help for random location teleport
for does that may have interest in how I end up dooing it here it is.
I used teleporter in checker formation. This was combined with 4 timers (2 for activating the 2 function of the script and 2 to deactivate the teleporter) all in sequence.
thanks again for the help
I used teleporter in checker formation. This was combined with 4 timers (2 for activating the 2 function of the script and 2 to deactivate the teleporter) all in sequence.
Code: Select all
-- challenge were the player has too fight monster
-- in a room full of teleporter. teleporter destination
-- change every activation
-- was made in a checker patherner since the limitation
-- of the application (would loop teleported entity)
function teleport1()
-- ///////////////////////////////////
-- // all location for the teleport //
-- ///////////////////////////////////
local l1 = {17, 4, math.random(0, 3), 3}
local l2 = {16, 5, math.random(0, 3), 3}
local l3 = {18, 5, math.random(0, 3), 3}
local l4 = {15, 6, math.random(0, 3), 3}
local l5 = {17, 6, math.random(0, 3), 3}
local l6 = {19, 6, math.random(0, 3), 3}
local l7 = {16, 7, math.random(0, 3), 3}
local l8 = {18, 7, math.random(0, 3), 3}
local l9 = {17, 8, math.random(0, 3), 3}
-- /////////////////////////////
-- // table with all location //
-- /////////////////////////////
local table1 = {l1, l2, l3, l4, l5, l6, l7,l8, l9}
-- //////////////////////////////////////////////
-- // this should return a value of the table //
-- // for every teleport(exemple 5 will be l5) //
-- //////////////////////////////////////////////
local random23 = table1[math.random(#table1)]
local random24 = table1[math.random(#table1)]
local random25 = table1[math.random(#table1)]
local random26 = table1[math.random(#table1)]
local random27 = table1[math.random(#table1)]
local random28 = table1[math.random(#table1)]
local random29 = table1[math.random(#table1)]
local random30 = table1[math.random(#table1)]
local random31 = table1[math.random(#table1)]
local random32 = table1[math.random(#table1)]
local random33 = table1[math.random(#table1)]
local random34 = table1[math.random(#table1)]
teleporter_23:setTeleportTarget(random23[1], random23[2], random23[3], random23[4])
teleporter_24:setTeleportTarget(random24[1], random24[2], random24[3], random24[4])
teleporter_25:setTeleportTarget(random25[1], random25[2], random25[3], random25[4])
teleporter_26:setTeleportTarget(random26[1], random26[2], random26[3], random26[4])
teleporter_27:setTeleportTarget(random27[1], random27[2], random27[3], random27[4])
teleporter_28:setTeleportTarget(random28[1], random28[2], random28[3], random28[4])
teleporter_29:setTeleportTarget(random29[1], random29[2], random29[3], random29[4])
teleporter_30:setTeleportTarget(random30[1], random30[2], random30[3], random30[4])
teleporter_31:setTeleportTarget(random31[1], random31[2], random31[3], random31[4])
teleporter_32:setTeleportTarget(random32[1], random32[2], random32[3], random32[4])
teleporter_33:setTeleportTarget(random33[1], random33[2], random33[3], random33[4])
teleporter_34:setTeleportTarget(random34[1], random34[2], random34[3], random34[4])
end
function teleport2()
local l10 = {16, 4, math.random(0, 3), 3}
local l11 = {18, 4, math.random(0, 3), 3}
local l12 = {15, 5, math.random(0, 3), 3}
local l13 = {17, 5, math.random(0, 3), 3}
local l14 = {19, 5, math.random(0, 3), 3}
local l15 = {16, 6, math.random(0, 3), 3}
local l16 = {18, 6, math.random(0, 3), 3}
local l17 = {15, 7, math.random(0, 3), 3}
local l18 = {17, 7, math.random(0, 3), 3}
local l19 = {19, 7, math.random(0, 3), 3}
local l20 = {16, 8, math.random(0, 3), 3}
local l21 = {18, 8, math.random(0, 3), 3}
local table1 = {l10, l11, l12, l13, l14, l15, l16, l17, l18, l19, l20, l21}
local random35 = table1[math.random(#table1)]
local random36 = table1[math.random(#table1)]
local random37 = table1[math.random(#table1)]
local random38 = table1[math.random(#table1)]
local random39 = table1[math.random(#table1)]
local random40 = table1[math.random(#table1)]
local random41 = table1[math.random(#table1)]
local random42 = table1[math.random(#table1)]
local random43 = table1[math.random(#table1)]
teleporter_35:setTeleportTarget(random35[1], random35[2], random35[3], random35[4])
teleporter_36:setTeleportTarget(random36[1], random36[2], random36[3], random36[4])
teleporter_37:setTeleportTarget(random37[1], random37[2], random37[3], random37[4])
teleporter_38:setTeleportTarget(random38[1], random38[2], random38[3], random38[4])
teleporter_39:setTeleportTarget(random39[1], random39[2], random39[3], random39[4])
teleporter_40:setTeleportTarget(random40[1], random40[2], random40[3], random40[4])
teleporter_41:setTeleportTarget(random41[1], random41[2], random41[3], random41[4])
teleporter_42:setTeleportTarget(random42[1], random42[2], random42[3], random42[4])
teleporter_43:setTeleportTarget(random43[1], random43[2], random43[3], random43[4])
end