Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

FPSC Classic Scripts / Make enemies follow -each other-?

Author
Message
kms
15
Years of Service
User Offline
Joined: 9th Jan 2009
Location:
Posted: 1st Mar 2009 07:45 Edited at: 1st Mar 2009 07:45
I was wondering if it was possible to program one enemy specifically to follow another enemy. On the waypoints, they sometimes choose to go different directions and are seen without one another. This is what I am trying to avoid. Basically, I want it so that you can't ever see one without the other. Is it possible to do this? So far, I've only seen scripts which have an enemy follow the player.

Any help would be appreciated. Thanks!
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 2nd Mar 2009 05:37
How about having the follower target the leader and just use the "movetotarget" command?


The one and only,


kms
15
Years of Service
User Offline
Joined: 9th Jan 2009
Location:
Posted: 6th Mar 2009 19:12 Edited at: 6th Mar 2009 19:13
((Sorry I vanished there right after posting. Computer's dying, I think...))

I apologize, but I am unsure how to achieve this. I looked through the forums, there seemed to be a little confusion as to how targeting works.


For example, in this (http://forum.thegamecreators.com/?m=forum_view&t=115537&b=23) thread, they discuss the possibility of using:

to set a target as an entity, but they acknowledge in full levels with many entities, this could be a problem, as it would be in mine.

Is there any way you'd mind clarifying how this works? Thanks.
X10 User
15
Years of Service
User Offline
Joined: 21st Jan 2009
Location:
Posted: 6th Mar 2009 22:33
try this,

set an entity up to follow a way point and call it 'target1'

set another entity up behind it and give it this in the aimain script

:state=0:settargetname=target1,state=2
:state=2:rotatetotarget,state=3
:state=3:movefore=10,state=2

that instructs it to target the entity you have following the waypoints, and keep rotating and moving towards him, effectively following him

its the easiest way i can think of to accomplish it

- Why is everyone on here so rude? -
kms
15
Years of Service
User Offline
Joined: 9th Jan 2009
Location:
Posted: 9th Mar 2009 16:28
Thanks for the response. 'My Threads' seems to be malfunctioning. It's not registering that you wrote, so I'm glad I found it. I tried this out, but unfortunately, it seems to just leave my character shaking around in one place, as if it can't decide where to go. I tried messing around with it myself, but there was nothing... I like your idea, but I just can't get the entity to move.
Hockeykid
DBPro Tool Maker
17
Years of Service
User Offline
Joined: 26th Sep 2007
Location:
Posted: 10th Mar 2009 22:28
Quote: ":state=0:settargetname=target1,state=2
:state=2:rotatetotarget,state=3
:state=3:movefore=10,state=2"


instead of movefore=10 use movetotarget.


kms
15
Years of Service
User Offline
Joined: 9th Jan 2009
Location:
Posted: 25th Mar 2009 07:20
@hockeykid: Thanks for being so helpful with all of these problems I'm having. I looked again, and I can't see at all why the script isn't working. Intuitively, it should, but for some reason, my entity is just standing there in place. There's no more twitching, so it seems like it's not even attempting to move this time.
kms
15
Years of Service
User Offline
Joined: 9th Jan 2009
Location:
Posted: 24th Apr 2009 03:41
Apologies for bumping this thread again, but since I'm designing this game for someone else, I really do need to try and figure out a solution for this problem.

Any other insights would be extremely appreciated.
Hockeykid
DBPro Tool Maker
17
Years of Service
User Offline
Joined: 26th Sep 2007
Location:
Posted: 24th Apr 2009 04:11


Ok apply this to the enemy and name the other enemy target1

kms
15
Years of Service
User Offline
Joined: 9th Jan 2009
Location:
Posted: 25th Apr 2009 01:07
Hey hockeykid. I tried that, but now the character just stands there. Again, there isn't anymore twitching. I also tried some variations on that, like breaking it into separate states and having it cycle back to state=2, but it still did nothing...
Hockeykid
DBPro Tool Maker
17
Years of Service
User Offline
Joined: 26th Sep 2007
Location:
Posted: 25th Apr 2009 01:34
are you sure you set the other enemy to target1? exactly like that

kms
15
Years of Service
User Offline
Joined: 9th Jan 2009
Location:
Posted: 25th Apr 2009 09:54
Yeah, I did. I checked capitalization and everything.
Hockeykid
DBPro Tool Maker
17
Years of Service
User Offline
Joined: 26th Sep 2007
Location:
Posted: 27th Apr 2009 02:08
Actually i think i know why!




use that code and instead name the guy target instead of target1

kms
15
Years of Service
User Offline
Joined: 9th Jan 2009
Location:
Posted: 27th Apr 2009 13:00
Well, it seems like the entity is trying to move again, instead of just standing still. There's a weird problem now, though, where it's not following the 'target'. It walks, but it almost seems like it's walking toward the waypoint start, instead of the target, which makes no sense. There's no mention of waypoints in the script.

I attached a picture, and I added several entities with the script to show the effect. The one in the center, seemingly on the waypoint, doesn't even seem to move and stays frozen in 'walk' position unless bumped by the 'target'. The entities don't otherwise bump each other, just sort of walking in place around the one spot.

I have no idea how this could be when you didn't even mention waypoints. Do you think the word 'follow' is confusing it? I don't think scripts work like that, though, do they?

Attachments

Login to view attachments
Hockeykid
DBPro Tool Maker
17
Years of Service
User Offline
Joined: 26th Sep 2007
Location:
Posted: 27th Apr 2009 23:36


Well were getting closer, try this

kms
15
Years of Service
User Offline
Joined: 9th Jan 2009
Location:
Posted: 28th Apr 2009 04:45
Sorry, but there doesn't seem to be a difference between this one and the last one.

They both seem to say:


Am I missing something?

Thanks for all this help, by the way. You'll definitely be in the credits.
Hockeykid
DBPro Tool Maker
17
Years of Service
User Offline
Joined: 26th Sep 2007
Location:
Posted: 28th Apr 2009 05:35
did you try the last one i posted? sometimes if you don't have
desc = something. It glitches the script.

kms
15
Years of Service
User Offline
Joined: 9th Jan 2009
Location:
Posted: 28th Apr 2009 06:18
Oh, I see. I'd actually added a "desc =" on my own the last time, but I tried it with your title, anyway, and unfortunately, it didn't do anything. Instead the entity ended up off in the corner floor (it started toward the center) and not moving. I don't know why it should have behaved differently this time. The nature of the "desc=" shouldn't change anything.
Leon Kennedy
16
Years of Service
User Offline
Joined: 7th Sep 2008
Location: Neither here nor there
Posted: 28th Apr 2009 16:17
This is going to be a long shot, but....

Sometimes when entities get placed and you use the "Enter" key to align them to the floor, they actually get placed INSIDE the floor. That is, a small portion of them (their feet, ankles, heels, whatever) end up getting placed inside the floor. This will cause them to not be able to move at all, even though they can still rotate towards the specified target.

Try deleting the entity and then re-adding it without hitting the enter key. Or, you could right-click on the entity and manually adjust where it is using the arrow keys and page up/page down to make sure that it isn't in the floor.

Let us know if that worked?

Priest of the Church of Joe Wood
kms
15
Years of Service
User Offline
Joined: 9th Jan 2009
Location:
Posted: 28th Apr 2009 21:38
I'd actually wondered that myself, so I already tested the entities on just following waypoints and things, and it will follow those just fine.

I tried it again, though, with this script specifically, and again, it just froze at the waypoint. Again, I put some duplicate entities farther away from the spot, and like before, they all ended up mysteriously transported to walk around that one spot.

I also changed the 'target' entity to 'chase' and removed the waypoints, but this time, they all just stayed walking toward where I think the 'target' spawned. Even as it ran off to fire at me, all of those entities just kept walking around that lone spot. I started to wonder if maybe they were only rotating and moving to the 'target' origin (that they didn't know to /keep/ rotating and moving), so I tried this to see if I could get some kind of cycle going:



But it didn't change anything.
Leon Kennedy
16
Years of Service
User Offline
Joined: 7th Sep 2008
Location: Neither here nor there
Posted: 28th Apr 2009 22:14
This is going to be another long shot, but...

I know that setting variables is weird. You have to state what variable you are using, and then set it. Maybe targets are the same? Try this and see if it works:


I don't know if that will work or not, but I'm basing this on the same principle as with variables (globalvar=1,setvar=1).

Priest of the Church of Joe Wood
kms
15
Years of Service
User Offline
Joined: 9th Jan 2009
Location:
Posted: 29th Apr 2009 00:32
Whoa! This is the closest it's gotten so far! It's actually /moving/!

The only problem is that the entity is walking so constantly at the 'target' that it is often pushes it off-track like on waypoints or traps it when, for example, the 'target' stops to reload or turn corners. It will either circle around the point where the target is standing or just keep pushing it, even backward while walking or crouching, even off of the map (I have that one in an image). Also, when the target dies, the entity just sort of freezes mid-walk.

Regardless, I'm just so happy that it's even moving now! Thanks so much! This is really on to something. To be honest, though, I was looking through the various conditions, and I can't find any that even involve the 'target', so I don't know if there's even any way to control for if the target stops, etc...

Attachments

Login to view attachments
Leon Kennedy
16
Years of Service
User Offline
Joined: 7th Sep 2008
Location: Neither here nor there
Posted: 29th Apr 2009 14:58
There is a condition that allows you to check if the entity has reached its target. It is called...REACHTARGET. I'm not sure how you'd have to code this, but you can use this condition to check if the entity has reached the target or not.

Priest of the Church of Joe Wood
Leon Kennedy
16
Years of Service
User Offline
Joined: 7th Sep 2008
Location: Neither here nor there
Posted: 29th Apr 2009 18:58
I was reading another thread, and had an idea on how to code this:



I don't know if this will work or not, but I thought I'd at least give you the thought I had on this. Try this and let us know if that works or not. If not, I'll work on this at home tonight and see if I can't come up with something else.

Priest of the Church of Joe Wood
Hockeykid
DBPro Tool Maker
17
Years of Service
User Offline
Joined: 26th Sep 2007
Location:
Posted: 29th Apr 2009 22:40
Reachtarget is not =x it is simply reachtarget, and reachtarget only works if the person is on top of the target. You could have something like a dynamic bottle follow the enemy and have its alpha fade at 0 so it would be inviable and then have the other guy follow the bottle since he would be able to stand on a bottle.

kms
15
Years of Service
User Offline
Joined: 9th Jan 2009
Location:
Posted: 30th Apr 2009 00:29
Hey Leon- Unfortunately, now, the entity doesn't move at all. I'm trying to understand/replicate what hockeykid mentioned now about the bottle? Do you mean to add the script to the bottle and just set the entity on top of it? I only wonder, though, wouldn't it look like the entity is just levitating around? Am I misunderstanding?
Hockeykid
DBPro Tool Maker
17
Years of Service
User Offline
Joined: 26th Sep 2007
Location:
Posted: 30th Apr 2009 01:07
ok here apply this to the bottle





and apply this to the person you want to follow the enemy


make sure you name the bottle bottle.

uman
Retired Moderator
20
Years of Service
User Offline
Joined: 22nd Oct 2004
Location: UK
Posted: 30th Apr 2009 03:05
You can do what you want using waypoints. However there are numerous issues with Characters following waypoints - they can be erratic to say the least and at best. The more complex your level the more erratic will become the Characters behaviours while followng waypoints or anything else for that matter.

Obstacle avoidance is also relatively poor in FPSC and that also may well cause additional issues.

For example two Characters moving along a waypoint will do so at a distance relative to each other consitently as long as nothing interrupts the flow of movement of either. Of course if you want a reverse movement then the first to turn back along the waypoint route will in avoidance of the other firstly bump into then move around the other and this may affect the speed of one or the other slightly and the distance between both may become greater (or lesser) eventually they may become way apart or very close and bump like two carriages of a train. Unless of course they die first.

In a very simple level attached to a simple path things may go very well. In a complex level, with a complex path or any other obstacles or interferances to Character movement or behaviour and there may be many, It may be asking much to much of FPSC.

Same goes for free moving scripted movement - absolute stable behaviours are few and far between in FPSC if you have anything more than the simplest of scenarios.

It can be done using waypoints so only trying will show how well in your level. I am not sure specifically why you should be having any problems getting a number of Charaters to follow waypoints but it can happen I know. If movement becomes stopped try deleting the characters - and the waypoints all and try again.

Try setting up in a test level first though unfortunately what works in test does not always work in a real level because of the added stress on the AI and engine.



kms
15
Years of Service
User Offline
Joined: 9th Jan 2009
Location:
Posted: 30th Apr 2009 04:12
Hockeykid: Unfortunately, when I tried it, the character just started jerking in person, as if unsure what to do. I also tried changing some of the scripts around, like repeating the "settargetname=" like Leon had done and looping back to "state=0", but nothing I tried worked. It stopped jerking, but then the character just stood there. I also made the bottle visible to see if it was moving, and it didn't seem to be, either, but I don't know if that's just because I also had to turn the collision back on to be able to see it. When I did that, the character just walked in place behind the bottle, which makes sense, although I guess I was hoping for some kind of magic change.


uman: I actually considered that at the very first, but because of the exact same inconsistencies you mentioned, I decided against it. After all, with waypoints more complex than just one line, one entity might turn back along the same path (for example, in a square-shaped waypoint set) while the other continues on and they essentially end up completely separate, or they might (as you mentioned) get stuck together. They were pushing each other up onto walls and getting stuck, etc. since sadly, it is not a very simple level.

Also, when the 'target' runs to attack, it was important that the other entity followed along, which is not possible with waypoints. Basically, it is required that when you see the 'target' the other entity is with it. This is a pivotal requirement of the request I've been given, which I know sounds odd, but that is unfortunately the way it is. I think that it's certainly getting closer (thanks to hockeykid and Leon), but yes, I, too, am worried that I am asking for more than FPSC is capable.
Leon Kennedy
16
Years of Service
User Offline
Joined: 7th Sep 2008
Location: Neither here nor there
Posted: 30th Apr 2009 15:12
@hockeykid: The community guide actually shows this as REACHTARGET=X, which is where I got it from. If this is not the correct syntax, then I think the guide needs to be updated.

@kms: I'm at a loss on this now. It seems that the only way to get your entity to walk is to continue to use the SETTARGETNAME command, but then there is no way to use REACHTARGET because SETTARGETNAME isn't a condition, it's an action. I honestly am out of ideas here.

Priest of the Church of Joe Wood
Hockeykid
DBPro Tool Maker
17
Years of Service
User Offline
Joined: 26th Sep 2007
Location:
Posted: 30th Apr 2009 23:11
well is the only time the enemy starts to walk is when the player i around? Because then you could use plrdistwithin to freeze the little kid

kms
15
Years of Service
User Offline
Joined: 9th Jan 2009
Location:
Posted: 5th May 2009 20:30
Sorry it took so long to get back. I'm in the process of moving apartments, and I lost internet capabilities there for a bit.

@Leon Kennedy: That's completely fine. That was the same problem that I was talking about: that there's no other conditions for that, so I'm as at much of a loss as you are. I wouldn't have gotten this far at all without your guy's help, so I appreciate it.

@hockeykid: Well, the kid also has a tendency to 'push' the enemy off of the floor segments (the attachment on post 28th Apr 2009 17:32) or trap him against walls, but I suppose all of the entities have that problem now and again when waypoints are involved (unfortunately). I helped to correct for that by decreasing the kid's speed so that he can't 'push' the target enemy as often.

It is most noticeable when the player is around,though, so I tried what you said with all of these:







But none seemed to do any good. Am I misunderstanding how this "plrdist" condition is meant to work?

Login to post a reply

Server time is: 2024-11-25 00:25:03
Your offset time is: 2024-11-25 00:25:03