Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Basic template:
- require("betterAi");
- function DeleteObject(handle)
- betterAi.DeleteObject(handle);
- end
- function AddObject(handle)
- betterAi.AddObject(handle);
- end
- function Update(dTime)
- betterAi.Update(dTime);
- end
- --End of basic template
- --Creating a custom "ai" 1:
- local myTankAi = betterAi.createCustomAi("tankAi");
- myTankAi.init = function(self,handle)
- self.super.init(self,handle);
- self.myClassLabel = GetClassLabel(handle);
- --This function is called when a object that uses the ai is added to the map
- end
- myTankAi.update = function(self,dTime)
- print(self.myClassLabel);
- --Update for each object that uses this ai
- --Can be used with self.handle to command unit
- --i.e Goto(self.handle,path/vector/etc);
- end
- myTankAi.destroy = function(self)
- print(self.handle,self.label .. " died");
- --Called when the unit using the ai is destroyed
- end
- --Makes "avtank" and "svtank" use the ai.
- betterAi.setCustomAi("avtank","tankAi");
- betterAi.setCustomAi("svtank","tankAi");
- --Create a custom "ai" 1 end
- --Create a custom "ai" 2:
- local myWingmanAi = betterAi.createCustomAi("wingmanAi");
- myWingmanAi.init = function(self,handle)
- self.super.init(self,handle);
- self.currentTarget = nil;
- end
- myWingmanAi.update = function(self,dTime)
- if(self.currentTarget ~= GetNearestEnemy(self.handle)) then
- --Selecting target every update will paralyse the unit.
- self.currentTarget = GetNearestEnemy(self.handle);
- Attack(self.handle,self.currentTarget);
- end
- end
- myWingmanAi.destroy = function(self)
- print("Dead");
- end
- --Makes all units of the type "wingman" use the "wingmanAi"
- --Look in the odf files to find out what the class type is for a given unit
- betterAi.setCustomAiForClass("wingman","wingmanAi")
- --Create a custom "ai" 2 end
Advertisement
Add Comment
Please, Sign In to add comment