Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Announcements and Showcase
BAsic Agressive AI for characters

Jaime Zegpi
Guest
Quote
2020-03-30 01:56:04

Hi this is a basic AI. Very very basic.
Follow character when is visible and shot or make som action when in range.

Here a boring video to show..

https://www.youtube.com/watch?v=...

If this help i send you the behavior script.. is super basic.


please NIKO , i love coppercube please clean visualization bugs .


Jaime Zegpi
Guest
Quote
2020-03-30 02:29:23

https://drive.google.com/open?id...

Behavior


yalazkan
Registered User
Quote
2020-03-30 21:53:41

Very useful, thanks
i ve added some more functions…
checking node health
switch between walk and attack animations.

// This is a coppercube behavior AI
// The following embedded xml is for the editor and describes how the behavior can be edited:
// Supported types are: int, float, string, bool, color, vect3d, scenenode, texture, action
/*
<behavior jsname="behavior_AI" description="Basic AI - AGRESSIVE">
<property name="attack_node" type="scenenode" />
<property name="attack_radius" type="int" default="100" />
<property name="attack_action" type="action" />
<property name="attack_interval" type="int" default="500" />
<property name="step_before_fire" type="int" default="5" />
</behavior>
*/

behavior_AI = function()
{
// settings:
this.attack_node = this.attack_node;
this.attack_radius = this.attack_radius;
this.LastTime = null;
this.LastPosition = new vector3d(0,0,0);
this.stepcounter =0;
this.firecounter=0;
this.step_before_fire=this.step_before_fire;
};

behavior_AI.prototype.onAnimate = function(n, timeMs)
{
var targetPos = ccbGetSceneNodeProperty(this.attack_node, 'Position');
var currentPos = ccbGetSceneNodeProperty(n, 'Position');
var name=ccbGetSceneNodeProperty(n, 'Name');
var health=ccbGetCopperCubeVariable("(hashtag)+name+".health");

if (health == 0 ) return false;// AI must be died, return..
if ( ( timeMs - this.LastTime) > this.attack_interval ){
var distance = Math.sqrt(
Math.pow( parseInt(targetPos.x-currentPos.x) ,2)
+ Math.pow( parseInt(targetPos.y-currentPos.y) ,2)
+ Math.pow( parseInt(targetPos.z-currentPos.z) ,2)
);

if ( distance < this.attack_radius ){// moving towards attack node..
if (this.firecounter ==0) {
ccbAICommand(n, "cancel");
ccbAICommand(n, "moveto", targetPos);
this.stepcounter++;
}
else this.firecounter --; // wait until attack anım ends...
}
else {
// may be random patrol...
}


if ( this.stepcounter>this.step_before_fire){ // start attack and wait attack anımation
ccbAICommand(n, "cancel");
ccbAICommand(n, "attack", this.attack_node);
ccbInvokeAction(this.attack_action);
this.stepcounter=0;
this.firecounter =1;
}
this.LastTime = timeMs;
}

return false;
}


Jaime Zegpi
Guest
Quote
2020-03-30 23:21:53

"...checking node health
switch between walk and attack animations...""


Wow nice improvements, i like!!!


;)


just_in_case
Moderator
Quote
2020-03-31 14:34:25

Impressive!!


Zoo
Guest
Quote
2020-04-05 21:32:46

Jaime Zegpi...Thought you had left the community. There are a couple of people looking for you as you built a multiplayer script and abandoned the development before producing the key elements of the system...

When will you be able to finish it?

Your website went down over a year ago...

Please can you finish it and release it to the community


Jaime Zegpi
Guest
Quote
2020-04-05 22:04:55

Hi Zoo
here you can test.
https://jaime.zegpi.cl/lab/coppercube/multinverso/scene/
( open two windows , one normal and other private )

You can download from here.
https://github.com/jaimezegpi/multinverso

Please this is only test i made in my boring time.. change as you like.

A multiplayer Script need be made by Niko, here have more experience and knowledge about his engine.


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Intern?tional" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact