Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Help with CopperCube
How to modify AI

Anonymous
Guest
Quote
2019-06-06 14:53:38

In-game AI is stupid. How to modify it?


Robo
Guest
Quote
2019-06-14 14:24:43

yes, default AI is very poor.

I have overridden the die and attack default behaviors as they don't work that well.

I added in my own set of actions and timings to look better.
I made the enemy face the player also before attacking/shooting as before we shooting from behind....silly.

I am currently still using the default random patrol but when mixed with the default alert & running and noises added looks pretty good still I think...not perfect yet though...more work to do.

Have a look and let me know what you think:
http://lasttrump.net/gamedev.html

note that AI melee was posted previously by someone and said to be good - I havent tested it yet though...


j9907
Registered User
Quote
2019-06-15 07:24:16

I am beyond impressed!


Robo
Guest
Quote
2019-06-15 10:31:36

oh, cheers....need work but usable for now.. I think I will use the robots near crashed ships (yes will be heaps) that you can go in and explore etc and sleep safe etc..
Will use alien creatures for those that patrol the area and hunt you down predominately...


Robo
Guest
Quote
2019-06-15 10:38:08

By the way - all AI mods were done using no coding at all - only menu driven selections - it can be done..

I have mainly worked to increase enemy speed on activate and then to shoot of course and its actually still doing its random patrol but you don't really sense that as its sounds mad and running around shooting at you. I have another proximity to cancel and slow down when you leave the area and back and restart when you come back again...


j9907
Registered User
Quote
2019-06-16 06:56:29

Fascinating. I was trying to get some specific AI behavior added, but I couldn't do it. Basically I want my AI characters to follow a pre-set path and when the character gets close enough, then he will break out of "patrol mode" and will chase the player. If you run far enough from him he'll return back to his spot and go back into his path. I highly doubt this could be done without some scripting (JS or C++)


Robo
Guest
Quote
2019-07-15 16:11:06

True enough - you cant have smart AI without scripting.
This is my latest version of melee AI which works quite well but not yet perfectly...having few issues...
It can be attached to random patrol etc and will follow you, then charge at you when close enough and then attack if your still there...I'm not yet sure how to fix how you can just sidestep it though...
You will need to add change of speed + attack animations etc for each - hope this helps:

/*
<action jsname="action_moveAI_attack" description="Move AI to position n attack">

<property name="ThisNode" type="scenenode" />
<property name="TargetNode" type="scenenode" />
<property name="ChargeRange" type="float" default="70" />
<property name="ChargeAction" type="action" />
<property name="AttackRange" type="float" default="23" />
<property name="AttackAction" type="action" />
<property name="CancelRange" type="float" default="200" />

</action>

*/


action_moveAI_attack = function()
{

//this.Attacking = false;

this.mode = 0;
};

// called when the action is executed

action_moveAI_attack.prototype.execute = function(currentNode)
{
var me = this;

this.registeredFunction = function() {
me.walk();
};

ccbRegisterOnFrameEvent(this.registeredFunction);

this.ThisNode = currentNode;
}

action_moveAI_attack.prototype.walk = function(){
var moveto = ccbGetSceneNodeProperty(this.TargetNode, "Position")
;
var mepos = ccbGetSceneNodeProperty(this.ThisNode, "Position");
var tmp = mepos.substract(moveto);
var length = tmp.getLength();
var climb = moveto.y - mepos.y;
print("height: "+climb);

var mode_ignore=0;
var mode_follow=1;
var mode_charge=2;
var mode_attack=3;
var mode_wait= 4;
var mode_die=5;
var tries = ccbGetCopperCubeVariable("count");

if (ccbGetCopperCubeVariable("sceneChange")==1) {
ccbUnregisterOnFrameEvent(this.registeredFunction);
this.mode = mode_ignore;
}

var my_health = "" + ccbGetSceneNodeProperty(this.ThisNode,"Name") + ".health";
if (ccbGetCopperCubeVariable(my_health)<=0) {
ccbInvokeAction(this.ActionOnDie);
ccbSetSceneNodeProperty(this.ThisNode, 'Animation', 'die');
ccbSetSceneNodeProperty(this.ThisNode, 'Looping', false);
ccbUnregisterOnFrameEvent(this.registeredFunction);
this.mode = mode_die;
print("5. Im dead");
}

else if(length <=this.AttackRange){
ccbInvokeAction(this.AttackAction, this.ThisNode);
ccbUnregisterOnFrameEvent(this.registeredFunction);
ccbSetCopperCubeVariable("alien1.movementspeed",25);
ccbSetCopperCubeVariable("count",0);
this.mode = mode_wait;
print("4. attack");
}

else if(length <=this.ChargeRange){
if (this.mode == mode_follow){
if (climb <= 22){
this.mode = mode_charge;
ccbInvokeAction(this.ChargeAction, this.ThisNode);
print("2. charge");
}
if (climb > 22){
tries++;
ccbSetCopperCubeVariable("count",tries);
print("attempts: "+tries);
if (tries < 6){
ccbUnregisterOnFrameEvent(this.registeredFunction);
}
if (tries >= 6){
move = mepos.z + 10;
ccbUnregisterOnFrameEvent(this.registeredFunction);
ccbAICommand(this.ThisNode, "moveto", mepos.x, mepos.y, move);
this.mode = mode_ignore;
}
}
}}

else if (length >=this.CancelRange){
ccbUnregisterOnFrameEvent(this.registeredFunction);
ccbSetCopperCubeVariable("alien1.movementspeed",15);
ccbSetSceneNodeProperty(this.ThisNode,"Animation","walk")
;
ccbSetSceneNodeProperty(this.ThisNode, 'Looping', true);
this.mode = mode_ignore;
print("ignore");
}

else {
ccbSetCopperCubeVariable("alien1.movementspeed",25);
var mvec = moveto.substract(mepos);
ccbAICommand(this.ThisNode, &


Robo
Guest
Quote
2019-07-15 16:16:57

You can see my latest game here with the Melee AI - its pretty good but not 100%:

http://lasttrump.net/gamedev.html


guest
Guest
Quote
2021-05-19 17:58:45

how to set health to 100 with script like i want to give life to a dead enemy


Desmond
Guest
Quote
2023-01-02 18:47:54

good


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Internationa?" (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