[SOLVED] Look for nearby monsters?

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Locked
User avatar
Vincent(PDP)
Posts: 60
Joined: Fri May 16, 2014 3:49 pm
Location: Sweden
Contact:

[SOLVED] Look for nearby monsters?

Post by Vincent(PDP) »

Hi!
This is a rather odd question, but I want a script that is able to look for any kind monsters that are in a certain range from the player.
I need to be able to get the monsters' x, y and z coordinates, and perhaps also it's angle.

My solution so far is trying to create a script that launches some invisible projectiles which will make the monsters go in a certain pain state when hit that activates a script. (The projectile only hurts 1HP).

Pretty much any solution is acceptable, except for creating a custom game engine.
Also note that I want this to be working in Zandronum (ZDoom 2.5.0), and in multiplayer for different players.

Thank you in advance. :)
Last edited by Vincent(PDP) on Fri May 22, 2015 4:07 am, edited 1 time in total.
User avatar
kodi
 
 
Posts: 1361
Joined: Mon May 06, 2013 8:02 am

Re: Look for nearby monsters?

Post by kodi »

you can put A_JumpIfInTargetLos in the first frame of every monster state and have it jump to an intermediate state ("CloseToPlayer" or something) where a script is called that adds the monster to an ACS list for example, and from that state you go to a duplicate of See(not necessarily but most likely at least) called CloseSee. CloseSee is identical to See, but loops through A_JumpIfInTargetLos pointing to itself - and if it returns false, it goes to a second intermediate state("nolongerclose") where it removes itself from the list. From NoLongerClose it returns to the normal See state.
User avatar
Vincent(PDP)
Posts: 60
Joined: Fri May 16, 2014 3:49 pm
Location: Sweden
Contact:

Re: Look for nearby monsters?

Post by Vincent(PDP) »

kodi wrote:you can put A_JumpIfInTargetLos in the first frame of every monster state and have it jump to an intermediate state ("CloseToPlayer" or something) where a script is called that adds the monster to an ACS list for example, and from that state you go to a duplicate of See(not necessarily but most likely at least) called CloseSee. CloseSee is identical to See, but loops through A_JumpIfInTargetLos pointing to itself - and if it returns false, it goes to a second intermediate state("nolongerclose") where it removes itself from the list. From NoLongerClose it returns to the normal See state.
Thanks, but does A_JumpIfInTargetLos exist in ZDoom 2.5.0?
Also sorry for being unclear about it, but I want this to be compatible with the most wads. Your solution sounds good but to make it compatible with for example DOOM2 and also other WADS/PWADS it needs to be as little editing as possible to the monsters.

I just posted my temporary and WIP solution's code here: http://zandronum.com/forum/showthread.p ... 9#pid81449
if you want to take a look of what I've done so far.
RaveYard
Posts: 194
Joined: Fri Apr 12, 2013 10:51 am

Re: Look for nearby monsters?

Post by RaveYard »

Well, you could...
Spoiler: Option 1
Spoiler: Option 1 version B
Spoiler: Option 2
Spoiler: Option 3
If you are going to have more than one player, don't forget to check for each one.

I'd go with option 2, because it doesn't require any changes to the monsters or their TID's. But It doesn't work with friendly monsters.
Also, I didn't bother to go into details on how some parts work, so if you need, I will try to explain them.
User avatar
Vincent(PDP)
Posts: 60
Joined: Fri May 16, 2014 3:49 pm
Location: Sweden
Contact:

Re: Look for nearby monsters?

Post by Vincent(PDP) »

RaveYard wrote:Well, you could...
Spoiler: Option 1
Spoiler: Option 1 version B
Spoiler: Option 2
Spoiler: Option 3
If you are going to have more than one player, don't forget to check for each one.

I'd go with option 2, because it doesn't require any changes to the monsters or their TID's. But It doesn't work with friendly monsters.
Also, I didn't bother to go into details on how some parts work, so if you need, I will try to explain them.
No details required, I understand how I should go about. :D
Option 2 seems like the best one, yes. And don't worry about the friendly monsters. I only need to find the hostile ones.

I will try option 2 when I get time.


Thanks alot!
User avatar
Vincent(PDP)
Posts: 60
Joined: Fri May 16, 2014 3:49 pm
Location: Sweden
Contact:

Re: Look for nearby monsters?

Post by Vincent(PDP) »

Thanks alot RaveYard!
I used option 2 to check for monsters, and it works perfectly! :D
Locked

Return to “Editing (Archive)”