Page 1 of 1
Teleporting monster
Posted: Fri Jan 04, 2013 2:46 pm
by bleson
I'm relatively very new to DECORATE.
I want to create a monster function that allows it to 'teleport' to another random location in the map.
In my first attempt I gave the monster a 'Teleport' state in which it does A_Wander for a large number of times all lasting 0 tics. As a result the monster would have 'wandered' somewhere in the space of no time at all, thus a sort of teleportation.
However this encounters problems in particular areas. For instance if the monster is inside a medium-sized room with only a single exit, there is an extremely low chance that the monster can 'teleport' out of the room. Same problem applies when enclosed by a door.
So I suppose a more practical method would be to start the function with noclip. At the end of its 'teleportation' wandering, it would check whether it is able to move. If it's false, the 'teleportation' would be repeated until its random destination allows it to move.
I can't be confident this is the best way to do it, so would you have any suggestions?
My main question is to ask what DECORATE functions would be involved in checking the ability to move and how to implement the 'true' or 'false' outcomes.
Thanks.
RE: Teleporting monster
Posted: Fri Jan 04, 2013 4:14 pm
by Watermelon
Sorry I have to make this quick but:
does A_Wander for a large number of times all lasting 0 tics
0 tic frames are dangerous and should only be used if you know what you're doing.
RE: Teleporting monster
Posted: Sat Jan 05, 2013 8:10 pm
by XutaWoo
Watermelon wrote:
0 tic frames are dangerous and should only be used if you know what you're doing.
Like when using them for a set number of times, which is exactly what he's doing?
Anyway, if the abs function has been added to Zandronum, then you could do something like this:
Code: Select all
TNT1 A 0 A_ChangeFlag ("NOCLIP", 0)
TNT1 A 1 A_Recoil (2)
TNT1 A 0 A_JumpIf ( ( abs(velx) + abs(vely) ) != 0, "TeleportFinish")
TNT1 A 0 A_ChangeFlag ("NOCLIP", 1)
goto TeleportLoop
which will make it not quite an instant teleportation, especially if it does get stuck in a wall or decoration, but depending on the situation it'll probably not be too noticable.
It's not quite as elegant as a true function for checking if movement is possible, but alas there isn't even such a function in ZDoom.
An alternative could be to spawn an object with the same dimensions as the monster and targets it, and if it spawn then give the monster an inventory item that it checks for to end the teleportation. Unfortunately, I'm not sure if Zandronum has the capabilities to set an actor's target fields, so that's still not quite good.
RE: Teleporting monster
Posted: Sat Jan 05, 2013 8:21 pm
by Lord_of_D:
another way of doing this is using something like in Ghoul Forest 3, when sjas gets hurt he used to teleport back to a random spot in the map, but this is trough scripts, not decorate D:
RE: Teleporting monster
Posted: Sun Jan 06, 2013 5:25 am
by bleson
XutaWoo wrote:
Anyway, if the abs function has been added to Zandronum, then you could do something like this:
Code: Select all
TNT1 A 0 A_ChangeFlag ("NOCLIP", 0)
TNT1 A 1 A_Recoil (2)
TNT1 A 0 A_JumpIf ( ( abs(velx) + abs(vely) ) != 0, "TeleportFinish")
TNT1 A 0 A_ChangeFlag ("NOCLIP", 1)
goto TeleportLoop
Could you explain that code a little bit?
I don't particularly understand the third line and 'TeleportLoop'
RE: Teleporting monster
Posted: Mon Jan 07, 2013 3:16 am
by XutaWoo
Oh, sorry.
That would be the end of the so called TeleportLoop state, which would also include whatever you're using for the monster to move around. The code makes the monster move a bit then checks if it has any leftover velocity (which isn't given by A_Chase or A_Wander) and if so, since it means it's not stuck in something and can move, goes to the TeleportFinish state where you put anything you want for when the monsters stops teleporting, such as teleport fogs and the such.
RE: Teleporting monster
Posted: Mon Jan 07, 2013 12:03 pm
by bleson
Apparently "velx" and "vely" are "unknown identifiers".
Would you know what's going on?
RE: Teleporting monster
Posted: Mon Jan 07, 2013 12:07 pm
by Ivan
Those parameters are undefined on Zandronum. Go with momx and momy instead.
RE: Teleporting monster
Posted: Tue Jan 08, 2013 1:40 am
by bleson
Thanks Ivan.
That worked.
ONCE.
And then when I try to run it again, this happens.
Line 50 is the one that involves the 'abs' function, and that's known to cause this error.
But it worked before.
I didn't even change a thing.
Any ideas?
EDIT: Getting rid of 'abs' got rid of the error. Now to test if the expression still works regardless.
EDIT: It seems to work just fine. I discovered that the whole DECORATE teleportation concept just doesn't work well though. In a bland test map, the monster's teleportation trick works. But in the house map I made specifically to test it out, he just gets lost into cyberspace every time. Something like teleportation would require some ACS scripting which I lack knowledge nor dedication to at the moment. Thanks for helping, fellows.