View Full Version : Enemies (AI)
Mayhew
09-27-2008, 09:11 AM
I've been wandering around the forums for a while now, looking for answers to my own issue related to AI. I've tried to find methods given to other distressed gamers, but nothing, so my issue is this:
http://i239.photobucket.com/albums/ff273/Galathies_Knight/FLASH-Project_TLOZ.png
Those tiny flying leaf balls are called Mini-Shrubs. They're hostile so I want them to zero in on Link (my main character) and attack him. But what script can manage that?
Oh! And ONE more thing. I'd also like to know how to give these creatures HP. Many thanks.
http://i239.photobucket.com/albums/ff273/Galathies_Knight/mini-shrub.png
Here's one of the mini-shrubs up close. The movieclip for this AI is labeled "mini-shrub", and Link's movieclip is labeled "link". Just in case I needed to mention.
I'll credit anyone who can help me move my little shrubz ;O;
mrownage
09-28-2008, 12:11 PM
Hey ya the script for that isnt to hard but it depends on how advance you want it. This is a simple script that will work for your needs just fine I think, this AI will make your "mini-shrub" follow Link.
onClipEvent (enterFrame) {
if (this._x<(_root.Link._x-1)) {
this._x += 2;
}
if (this._x>(_root.Link._x+1)) {
this._x -= 2;
}
if (this._y<(_root.Link._y-1)) {
this._y += 2;
}
if (this._y>(_root.Link._y+1)) {
this._y -= 2;
}
}
This should work, so now if Link is anywhere on the frame ur "mini-shrub" will follow him by 2 in any direction even on angles. Once this is working I might help you make your "mini-shrub" turn around to face Link when they are moving so that they dont fly backwards :P I hope this helps if you have any issues please tell me and ill fix it asap.
Mayhew
09-28-2008, 11:42 PM
Very good, Mrownage. They are following Linkzz! >w<
This is the link to the flash.
Click Herez (http://aviark.deviantart.com/art/The-Legend-Of-Zelda-In-Making-99418477) (Link Fixed!)
You may see it if you'd like. I just hope the link works. Many thanks for taking the time to guide me. Perhaps maybe I'll be needing your help much later, if you are willing.
mrownage
10-02-2008, 02:20 AM
hey no problem i would love to help (If i can :P) and ur game is off to a flying start, lol i remember my first game *shuder* BTW did u make the link sprites urself? casue if u did I worship ur skills they rock!
anyway ya glad I could help and I look forward to helping more in the future.
There's also some similar code in the thread titled "moving towards mouse." You'd just need to adjust it to move towards the character instead of the mouse.
xdeath
10-03-2008, 04:09 AM
There's also some similar code in the thread titled "moving towards mouse." You'd just need to adjust it to move towards the character instead of the mouse.
yes i actually just more code to it. which would make it a little easier to understand. you would just need to change a few things but it wouldn't be that hard.
also i just realized that no one has given you the solution to your health problem yet.
um well on main timeline write this:
// create a new hp variable for all your enemies.
var hp:Number = 100 // this says we are creating a new
// variable which will only be a number value and we are
// setting it to be 100.
now on your enemy place a code like this:
/* i don't know how your link attack code works or is set
up so i will assume it is a seperate movieclip which controls
the attack images and all that stuff. */
if (this.hitTest(linkAttack)){// if a collision has happened
// with links attack and and this enemy
hp-=5 // take 5 health away.
}
// you will have to make a variable or something which
// controls if link has hit it and health has been taken
// away once already so it doesn't keep minusing it.
// plus make sure this goes on the enterFrame event.
um yeah i think that is it?
Mayhew
10-10-2008, 11:11 PM
Well hello there, and thank you, xdeath. That script worked flawlessly. owo!
For those who helped me, could you not give me your names? It doesn't have to be your real names, but I'd like to include the names of my helpers in the game when it's finished. What yeh say? :I
- Mrownage?
- Xdeath?
mrownage
10-11-2008, 02:29 AM
sure I have no prob giving out my real name :P
Its Cameron Gullotta
xdeath
10-11-2008, 03:12 AM
sure just credit me as "x-death". and i'm glad to here that it worked for you :)
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.