≡
Products
▼
Support
▼
Company
▼
Forum
Ambiera Forum
Discussions, Help and Support.
Create a new account
,
Search
, or Login:
Create reply in
How to modify AI
Posted by:
(you are not logged in)
Enter the missing letter in: "In?ernational"
(you are not logged in)
Text:
[quote][b]Robo[/b] wrote: 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, &[/quote]
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