Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> < Resolved! >Artificial Enemy AI (Awareness), I've been spotted!
Xyster
post Jan 28 2010, 10:18 PM
Post #1


Level 10
Group Icon

Group: Revolutionary
Posts: 150
Type: Developer
RM Skill: Undisclosed




I've been searching for this for a while, but to no avail...so I figured that I would ask in the mean time and keep looking. Thanks in advance to anyone that tries to help.

Simply put, I'm looking to make my enemies aware of my hero's position. I am trying to devise a system where the enemies (seen as events on the screen) move in random or pathed directions until my hero comes within a certain distance of them. At that point the enemy would change move route to toward player, basically chasing them down to initiate the battle.

I would prefer if this could be done with events, if not I would be satisfied with a script. I'm not sure of the complexity level of this request or if it is even possible.

The basics:
*Eventing or scripting that makes my enemies on screen react to and chase hero based on distance from enemy (sight range).
*I am not using an ABS, I am using the standard battle screen with a script.
*Eventing would be preferred, but a script is still efficient.
*Please let me know if you need any more description of this.

Thanks again. I'll continue to look in the mean time.

This post has been edited by Xyster: Jan 30 2010, 04:12 PM


__________________________
Go to the top of the page
 
+Quote Post
   
Pandemikk
post Jan 29 2010, 12:13 AM
Post #2


Level 19
Group Icon

Group: Revolutionary
Posts: 394
Type: Writer
RM Skill: Advanced




Ah.. I used this in one of my games. It's a bit tricky and it will require a lot of testing.


The more simple approach is to make an event for every location in which the enemy could "spot" the player. Make this event "On player touch" and set the required variable to something like "Event2FaceRight" or whatever. Then make a conditional branch with the required set "Event [EVENTID] is facing [DIRECTION]". Put whatever you want after this. Something like a message popping up and a game over screen or make the event chase the player with "Move towards character".

The only problems with this is it's VERY redundant and has a margin of error by about half a second meaning. This is usually accounted for by human reflexes but someone could move at the wrong moment and get busted before they should have. It's not noticeable to all but the most acute gamer, although.

I'd be interested if someone has a better system though of. My skills with events are pretty good but I'm not so-called "Masterful". biggrin.gif


__________________________
Click here! Beware, once you click it you have to post no matter what! Mwahaha!



Looking for an intelligent debate? A challenger appears! Looking to exchange grandiloquent gibberish? A challenger disappears!
Go to the top of the page
 
+Quote Post
   
Logan110
post Jan 29 2010, 12:54 AM
Post #3


Level 15
Group Icon

Group: Revolutionary
Posts: 271
Type: Event Designer
RM Skill: Advanced




You could also make variables for positions.

Character X
Character Y

Monster X
Monster Y

Location X
Location Y

Parallel Process

Set Character and Monster Variables to positions on map
Then
Set Location X = Character X - Monster X
Set Location Y = Character Y - Monster Y


If Location X < 5 AND > -5
And
If Location Y < 5 AND > -5
Set Move Route Towards Player

Wait 5

This will work with any number of events and will allow the events to continue their random or set paths if the character moves out of detection range. This does not account for Line of Sight - Looking at the character. If you want that as well I will gladly tell you how to change it to work.

*Edit*
I just tested this with 20 events and interestingly this does allow you to copy and paste this code into every event and work individually with the same variables at the same time. I originally thought you needed 2 new variables for each monster, but it seems it is not the case.

This post has been edited by Logan110: Jan 29 2010, 12:54 AM


__________________________
Fishing Tutorial - Twitch Skill

[Show/Hide] Picture

Waiting for that event sub forum...

Go to the top of the page
 
+Quote Post
   
Xyster
post Jan 29 2010, 10:23 AM
Post #4


Level 10
Group Icon

Group: Revolutionary
Posts: 150
Type: Developer
RM Skill: Undisclosed




That looks percisely like what I was searching for. I think I get the gist of how it will work, and I'll try it out later today.

Thanks so much, I'll let you know if everything is working out for me and if this resolves it for me.

Thanks!


__________________________
Go to the top of the page
 
+Quote Post
   
Pandemikk
post Jan 29 2010, 04:33 PM
Post #5


Level 19
Group Icon

Group: Revolutionary
Posts: 394
Type: Writer
RM Skill: Advanced




Logan forgive me if I'm wrong but that will not work regarding the enemy's facing. Even if he isn't facing the Hero he would still "spot" him.


__________________________
Click here! Beware, once you click it you have to post no matter what! Mwahaha!



Looking for an intelligent debate? A challenger appears! Looking to exchange grandiloquent gibberish? A challenger disappears!
Go to the top of the page
 
+Quote Post
   
Logan110
post Jan 29 2010, 04:42 PM
Post #6


Level 15
Group Icon

Group: Revolutionary
Posts: 271
Type: Event Designer
RM Skill: Advanced




QUOTE (Logan110 @ Jan 29 2010, 12:54 AM) *
This will work with any number of events and will allow the events to continue their random or set paths if the character moves out of detection range. This does not account for Line of Sight - Looking at the character. If you want that as well I will gladly tell you how to change it to work.

Thats why I told him it didnt smile.gif


__________________________
Fishing Tutorial - Twitch Skill

[Show/Hide] Picture

Waiting for that event sub forum...

Go to the top of the page
 
+Quote Post
   
Pandemikk
post Jan 29 2010, 04:56 PM
Post #7


Level 19
Group Icon

Group: Revolutionary
Posts: 394
Type: Writer
RM Skill: Advanced




sweat.gif


__________________________
Click here! Beware, once you click it you have to post no matter what! Mwahaha!



Looking for an intelligent debate? A challenger appears! Looking to exchange grandiloquent gibberish? A challenger disappears!
Go to the top of the page
 
+Quote Post
   
Xyster
post Jan 29 2010, 10:42 PM
Post #8


Level 10
Group Icon

Group: Revolutionary
Posts: 150
Type: Developer
RM Skill: Undisclosed




*her* Thank you.

And actually this is what I was looking for. For now I'm just trying to get them to not chase me from all over the screen when I can't see them. I can always get more advanced with it later.

Thanks again both of you, I'm trying it out right now.

*Edit*
Alright, I think that I got this much of it right. I'm not used to using variables in depth yet, so if I could get a little help with the rest of it...maybe an image of the eventing so that I know that I'm working with...it would be very much appreciated. Also, please let me know if I have it right so far.

[Show/Hide] Variables


This post has been edited by Xyster: Jan 29 2010, 11:37 PM


__________________________
Go to the top of the page
 
+Quote Post
   
Logan110
post Jan 30 2010, 05:30 AM
Post #9


Level 15
Group Icon

Group: Revolutionary
Posts: 271
Type: Event Designer
RM Skill: Advanced




Yea that looks right, this is mine that I made just for reference. I did it slightly different just to test, and you actually only need 4 variables. I thought it would cause problems trying to reference the same variables as the same time but as you can see in the background 20 events can use and edit the same variable at the same time without problems.

http://img341.imageshack.us/img341/1728/variables.png


__________________________
Fishing Tutorial - Twitch Skill

[Show/Hide] Picture

Waiting for that event sub forum...

Go to the top of the page
 
+Quote Post
   
Ty
post Jan 30 2010, 02:12 PM
Post #10


Level 38
Group Icon

Group: +Gold Member
Posts: 1,007
Type: Scripter
RM Skill: Undisclosed




I made something similar about three years ago...It was made with events, you can open it up and take a look and modify it as you see fit and every line is pretty much commented. Open it up and change it as needed.

http://www.rpgrevolution.com/forums/index....ic=6482&hl=


__________________________
My Script Demo link broken? Looking for old scripts? Go here:
http://synthesize.4shared.com
Go to the top of the page
 
+Quote Post
   
Logan110
post Jan 30 2010, 03:33 PM
Post #11


Level 15
Group Icon

Group: Revolutionary
Posts: 271
Type: Event Designer
RM Skill: Advanced




Thats about the same way I would do it, but you really dont need all the variables you used. Depends on the person and project if they want to use them I suppose.

BTW Xyster, You are going to have a lot of work getting LOS lost between objects. As far as I know it has to be completely custom per map


__________________________
Fishing Tutorial - Twitch Skill

[Show/Hide] Picture

Waiting for that event sub forum...

Go to the top of the page
 
+Quote Post
   
Xyster
post Jan 30 2010, 04:12 PM
Post #12


Level 10
Group Icon

Group: Revolutionary
Posts: 150
Type: Developer
RM Skill: Undisclosed




Okay, thanks to all the help from you guys I was able to finally get the eventing completed. It is able to make the enemy event "sense" the presence of your character and chase them down, thus imitating a randomized encounter.

With all the great advise that you guys gave me I should also be able to make the more advanced "spotting" techiques do the same thing, which is now the main encounter system for my game. I've attached a picture of the eventing used in case anyone was interested in how I finally got it to do everything I wanted it to.

[Show/Hide] Battle Encounter AI


This even "respawns" the event after you leave and come back to the map, something I was hoping for.

Thanks everyone!


__________________________
Go to the top of the page
 
+Quote Post
   
Pandemikk
post Jan 30 2010, 04:21 PM
Post #13


Level 19
Group Icon

Group: Revolutionary
Posts: 394
Type: Writer
RM Skill: Advanced




Redacted. See below.


__________________________
Click here! Beware, once you click it you have to post no matter what! Mwahaha!



Looking for an intelligent debate? A challenger appears! Looking to exchange grandiloquent gibberish? A challenger disappears!
Go to the top of the page
 
+Quote Post
   
Logan110
post Jan 30 2010, 04:58 PM
Post #14


Level 15
Group Icon

Group: Revolutionary
Posts: 271
Type: Event Designer
RM Skill: Advanced




Hmm kinda confused. I get terrain tag to use something like high grass. But that wouldnt work for say, hiding behind a tree or building.


__________________________
Fishing Tutorial - Twitch Skill

[Show/Hide] Picture

Waiting for that event sub forum...

Go to the top of the page
 
+Quote Post
   
Pandemikk
post Jan 30 2010, 05:03 PM
Post #15


Level 19
Group Icon

Group: Revolutionary
Posts: 394
Type: Writer
RM Skill: Advanced




You're thinking of Bush Flags.

And excuse me for messing up. Terrains tags are not accessible on the conditional branch. They have to be set with a variable. They're under Character Player's [Drop Down Box]

You'll have to store that in a variable and make the conditional branch respond to the tileset with the terrain tag behind the obstructing object. You can use a blank titleset (or whatever you fancy) on the third layer for this. Just make sure you configure it correctly.


__________________________
Click here! Beware, once you click it you have to post no matter what! Mwahaha!



Looking for an intelligent debate? A challenger appears! Looking to exchange grandiloquent gibberish? A challenger disappears!
Go to the top of the page
 
+Quote Post
   
Logan110
post Jan 30 2010, 05:25 PM
Post #16


Level 15
Group Icon

Group: Revolutionary
Posts: 271
Type: Event Designer
RM Skill: Advanced




Ok so say you take a tree, you would need to set 4 different terrain tags, one for each side of the tree. Then reference them by which direction they are looking. Right? Hmm, I think that would work except in angle situations...


__________________________
Fishing Tutorial - Twitch Skill

[Show/Hide] Picture

Waiting for that event sub forum...

Go to the top of the page
 
+Quote Post
   
Pandemikk
post Jan 30 2010, 06:41 PM
Post #17


Level 19
Group Icon

Group: Revolutionary
Posts: 394
Type: Writer
RM Skill: Advanced




Angle situations don't work in RMXP because the common template is 4-direction movement. And you would only need terrain tags on places you could adequately hide behind. If a guard is facing towards the tree, the same terrain tag would be needed for the spaces behind the tree.

Terrain tags are very simple once you get use to them. Very useful as well. But I think we should stop hijacking her thread. smile.gif


__________________________
Click here! Beware, once you click it you have to post no matter what! Mwahaha!



Looking for an intelligent debate? A challenger appears! Looking to exchange grandiloquent gibberish? A challenger disappears!
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 20th May 2013 - 09:33 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker