A.I.
To some people the word is evil...to others its creation and manipulation is impossible...for me...EASY!
I always look at source code such as the ones included in DarkBASIC and wonder why do they have to be so complex for only a few objects...the A.I. in those games would be very hard to manipulate when you want to create a huge game such as Zelda...in Zelda you must constanlty creat monsters and destroy them and so on...which is why I tested my theory of Game Design A.I.
Functions
My theory which has proven positive gave me great power that would otherwise be not only complex but nearly impossible... Let me take you through the steps that I used...We only need a MINIMUM of two functions...on to creat a monster and another for A.I.
Create_Object_Goblin(n,x,y,z)
This function shall create a goblin n and will be positions at x,y,z (put 0,0,0 if you don't want to position it now). In it you shall append all animation data...set default values if any (in arrays for example you can store HP or something) and set its default properties (wireframe, animation speed, ect.). My example:
Function Make_Goblin(n,x,y,z)
Load Object "Idle.x",n
Append Object "Crouch.x",n,100
Append Object "Walk.x",n,200
Append Object "Attack.x",n,300
Append Object "Die.x",n,400
Scale Object n,200,200,200
Yrotate Object n,180
Fix Object Pivot n
Position Object n,x,y,z
Set Object Speed n,25
Set Object Interpolation n,25
Endfunction
you can add more paremeters in order to store non-default data if you wish.
AI(n,x)
This simple function is the "meat" of the game...the most important piece you'll ever use. n would be the object number you wish to "AI" at the moment and y is the AI you want (goblin, bug flying around a flower, lil stupid dog that runs away from you, please not AI will not configure your animation data). For example:
Function AI(n,x)
If x=1
mX#=Object Position X(n)
mY#=Object Position Y(n)
mZ#=Object Position Z(n)
bX#=Object Position X(101)
bY#=Object Position Y(101)
bZ#=Object Position Z(101)
If Sqrt((mX# - bX#)^2 + (mY#+25 - bY#)^2 + (mZ# - bZ#)^2) 100
oX#= Object Angle X(n)
oY#= Object Angle Y(n)
oZ#= Object Angle Z(n)
Point Object n,bX#,bY#,bZ#
Rotate Object n,oX#,Object Angle Y(n),oZ#
Move Object n,5
pX#= Object Position X(n)
pZ#= Object Position Z(n)
Position Object n,Object Position X(n),Get Ground Height(1,pX#,pZ#),Object Position z(n)
If Object Frame(n)200
If Object Frame(n)300
If Object Frame(n)
If life gives you a lemon, shove it up a water gun and squirt it into someone's eyes!