View Single Post
  #3  
Old 03-11-2018, 10:43 PM
MysticalDragon MysticalDragon is offline
Global Administration
MysticalDragon's Avatar
Join Date: Oct 2002
Location: Lynn Ma
Posts: 883
MysticalDragon is just really niceMysticalDragon is just really nice
Send a message via AIM to MysticalDragon Send a message via MSN to MysticalDragon
Quote:
Originally Posted by kittygirl765 View Post
Oh, this is actually a good starting place for a state machine (especially for gscript2, where making ai isn't easily done natively or ends up becoming spaghetti code)

Now I need to make an ai_execute_firing_my_lasers() function

PHP Code:
function ai_enter_float() { 
  
this.ani "idle"
  
this.aiPeriod 1


function 
ai_execute_float() { 
  
temp.pl this.acquireTarget(); //you can do findnearestplayers to see if there is a target
  
if (temp.pl != nil) {
    
this.ani "alert";
    
changeState("attack");
    return;
  }
  
//logic here move? 
  
this.ani "move"
}

function 
ai_enter_attack() {
  
this.aiPeriod 0.4 this.attack_speed;
}

function 
ai_execute_attack() {  
   
temp.target this.acquireTarget();
  if (
temp.target == nil) {
    
changeState("float");
    return;
  }
  
attack(temp.target);
}

function 
attack(temp.target) {
  
temp.pos_x this.0.5 vecxthis.dir ) * 1.5;
  
temp.pos_y this.vecythis.dir ) * 1.5;
  
temp.angle getangletemp.target.temp.pos_xtemp.target.temp.pos_y );
  
temp.speed 1;
  
setshootparamsthistemp.dmgparams);
  
shoot(
     
temp.pos_xtemp.pos_y0,
     
temp.angle0.1temp.speed,
     
this.ani_arrownull
   
);
}

function 
acquireTarget() {
  
// Add aggro to players near entity
  
temp.targets findnearestplayers(this.xthis.y);
  return 
temp.targets[0];

__________________
~Delteria Support
~Playerworld Support
~PWA Chief
http://support.toonslab.com
[email protected]




Last edited by MysticalDragon; 03-11-2018 at 11:01 PM..
Reply With Quote