Teleporting monster

Discuss all aspects related to modding Zandronum here.
Post Reply
bleson
 
Posts: 65
Joined: Thu Dec 20, 2012 7:15 am
Location: Australia
Contact:

Teleporting monster

#1

Post by bleson » Fri Jan 04, 2013 2:46 pm

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.

Watermelon
Zandrone
Posts: 1244
Joined: Thu Jun 28, 2012 9:07 pm
Location: Rwanda

RE: Teleporting monster

#2

Post by Watermelon » Fri Jan 04, 2013 4:14 pm

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.

XutaWoo
Forum Regular
Posts: 113
Joined: Mon Jun 04, 2012 7:04 am

RE: Teleporting monster

#3

Post by XutaWoo » Sat Jan 05, 2013 8:10 pm

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.
[spoiler]Image[/spoiler]
Image

User avatar
Lord_of_D:
Posts a lot
Posts: 691
Joined: Sun Aug 26, 2012 5:31 am
Location: Mexico
Contact:

RE: Teleporting monster

#4

Post by Lord_of_D: » Sat Jan 05, 2013 8:21 pm

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:
Image

bleson
 
Posts: 65
Joined: Thu Dec 20, 2012 7:15 am
Location: Australia
Contact:

RE: Teleporting monster

#5

Post by bleson » Sun Jan 06, 2013 5:25 am

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'

XutaWoo
Forum Regular
Posts: 113
Joined: Mon Jun 04, 2012 7:04 am

RE: Teleporting monster

#6

Post by XutaWoo » Mon Jan 07, 2013 3:16 am

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.
[spoiler]Image[/spoiler]
Image

bleson
 
Posts: 65
Joined: Thu Dec 20, 2012 7:15 am
Location: Australia
Contact:

RE: Teleporting monster

#7

Post by bleson » Mon Jan 07, 2013 12:03 pm

Image

Apparently "velx" and "vely" are "unknown identifiers".
Would you know what's going on?

User avatar
Ivan
Addicted to Zandronum
Posts: 2229
Joined: Mon Jun 04, 2012 5:38 pm
Location: Omnipresent

RE: Teleporting monster

#8

Post by Ivan » Mon Jan 07, 2013 12:07 pm

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 ===

bleson
 
Posts: 65
Joined: Thu Dec 20, 2012 7:15 am
Location: Australia
Contact:

RE: Teleporting monster

#9

Post by bleson » Tue Jan 08, 2013 1:40 am

Thanks Ivan.
That worked.

ONCE.

And then when I try to run it again, this happens.
Image

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.

Post Reply