Teleporting monster
Teleporting monster
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.
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.
-
Watermelon
- Zandrone
- Posts: 1244
- Joined: Thu Jun 28, 2012 9:07 pm
- Location: Rwanda
RE: Teleporting monster
Sorry I have to make this quick but:
0 tic frames are dangerous and should only be used if you know what you're doing.does A_Wander for a large number of times all lasting 0 tics
RE: Teleporting monster
Like when using them for a set number of times, which is exactly what he's doing?Watermelon wrote: 0 tic frames are dangerous and should only be used if you know what you're 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 TeleportLoopIt'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.
- Lord_of_D:
- Posts a lot
- Posts: 691
- Joined: Sun Aug 26, 2012 5:31 am
- Location: Mexico
- Contact:
RE: Teleporting monster
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
Could you explain that code a little bit?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
I don't particularly understand the third line and 'TeleportLoop'
RE: Teleporting monster
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.
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

Apparently "velx" and "vely" are "unknown identifiers".
Would you know what's going on?
RE: Teleporting monster
Those parameters are undefined on Zandronum. Go with momx and momy instead.
=== RAGNAROK DM ON ... uh... dead forever? ===
=== ALWAYS BET ON ... uh... dead forever? ===
=== Who wanta sum wang? ===
=== Death and Decay - A new Monster/Weapon replacer ===
=== ALWAYS BET ON ... uh... dead forever? ===
=== Who wanta sum wang? ===
=== Death and Decay - A new Monster/Weapon replacer ===
RE: Teleporting monster
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.
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.
Last edited by bleson on Tue Jan 08, 2013 2:59 am, edited 1 time in total.
[/spoiler]

