Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
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 a jewel in the roughMysticalDragon is a jewel in the rough
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
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 07:45 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.