Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Programming and Scripting
Custom AI scripting

sven
Registered User
Quote
2021-06-26 14:05:09

Because built in AI kinda sucks and i have no real control over it then i have made some my own AI scripts and tests that i want to share (maybe they can help you or give you ideas who knows):

You can download them from here:
https://drive.google.com/file/d/...


cristian_emz
Registered User
Quote
2021-06-26 16:02:30

@sven

Great thank you very much


monika_5
Registered User
Quote
2021-06-26 23:31:39

hey sven!

thanks for the AI examples. I still need to look them over more, which I will probably do tonight, but I noticed in the txt file for the soldier that you said you didn't have any better animated models, so I figured I would send you one.

https://ufile.io/k4xppqwr

this is an animated soldier from FPS Creator. the file format is Milkshape 3D.

may be of some use to you. cheers.


rigsby
Registered User
Quote
2021-06-28 15:37:43

These are a vast improvement, I especially like the pathfinding
with the goblin a.i.

Would it be difficult to add the pathfinding to the 'soldier x' code,
or the action on attack to the goblin?

Great work sven.


sven
Registered User
Quote
2021-06-28 15:58:32

Thanks monika_5 This is nice soldier model and can be useful.

rigsby
Thanks
This is not real pathfinder.. it will just randomly pick a point you have added to the map and if he sees it ( not behind the wall) then he moves to it..then picks next target.

Its easy to extend my AI scripts..
If i have time in this week i can modify scripts as you need.


rigsby
Registered User
Quote
2021-06-29 00:27:33

I was using an earlier version of your goblin ai without the random patrol, so i'm very grateful you have shared it here.


sven
Registered User
Quote
2021-06-29 18:14:19

wrote:
I was using an earlier version of your goblin ai without the random patrol, so i'm very grateful you have shared it here.


I added option to set action on attack for GoblinAI:
https://drive.google.com/file/d/...


sven
Registered User
Quote
2021-06-29 21:08:50

Now you can set AI route manually so its not random.

You have 3 options:
AI will stand still.
AI will roam around map randomly.
AI will follow path you give to it.
(read info.txt and look info.bmp files for more info)

https://drive.google.com/file/d/...






To make checkpoints invisible in game but visible in editor use this edited script for checkpoints:


/*
<behavior jsname="behavior_SOLDIER_CHECKPOINTS" description="SOLDIER_CHECKPOINTS v1">
<property name="obj1" type="scenenode" default="POINT" />
</behavior>
*/

//Just a visual checkpoint or waypoint object with name CP1 CP2 and so on..
//Global variable MAXCP so Soldier can acces it and scan them by name.
CP_counter=0;

behavior_SOLDIER_CHECKPOINTS = function()
{
this.firstrundone=0;
this.CP_id=0;
}

behavior_SOLDIER_CHECKPOINTS.prototype.onAnimate = function()
{
//Run Once-------------
if (this.firstrundone==0 )
{
this.firstrundone=1;
//give ID
CP_counter+=1;
this.CP_id=CP_counter;
print("CP_" + CP_counter + "_added");
//make cp invisible in_game..visible only in editor.
ccbSetSceneNodeProperty(this.obj1, "Visible", "0");
}//---------------------

return true;
}



rigsby
Registered User
Quote
2021-07-02 07:36:28

Hi sven,
these are impressive scripts, without them I
wouldn't have been able to have workable enemies in my
project.

I'm having the odd occasion where an enemy gets stuck in a loop on patrol, and won't come out of it until the ai spots the player, but I suspect it's the animated model I'm using.

Thanks again sven, you've been a great help.

More users on here should check these out, especially
if you want your enemies to function properly.


sven
Registered User
Quote
2021-07-02 08:07:22

Thanks..

wrote:
I'm having the odd occasion where an enemy gets stuck in a loop on patrol, and won't come out of it until the ai spots the player, but I suspect it's the animated model I'm using.



You can try to edit this value in script (at 2 places for PATROL and ROUTE)..
(AItest9.js)

//AI checki is distance less than 10 from checkpoint before getting new target..
(sometimes if its not flat area or you entered checkpoint too close to the ground -it may happen that distance will never be less than 10..
(also if your AI model has different scale than the model i used you may need to change these values)
IF error still occurs then let me know and i try to fix it.


//first edit
if (distanceR <=10) //TRY VALUE 15 INSTEAD OF 10
{
this.CPtarget =0;//vali uus random
}

//second edit
if (AdistanceR <=10) //TRY VALUE 15 INSTEAD OF 10
{
this.Counter +=1;
if (res[this.Counter]=="END")//GO TO FIRST
{


rigsby
Registered User
Quote
2021-07-02 14:54:54

Hi sven,
I made the two changes you suggested and the model didn't move at all when set to 15, or any other number other than 10.

But your goblin creature, and the coppercube stock characters, all walk around the map without a glitch.

I think you are right about the scale. I'll re-export my model
from 3ds and try to match standard scale and see if that fixes it.

Thanks.


Create reply:


Posted by: (you are not logged in)


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