Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 06-12-2012, 02:57 AM
greggiles greggiles is offline
Registered User
greggiles's Avatar
Join Date: Sep 2007
Posts: 149
greggiles has a spectacular aura about
NPCs triggering other NPCs

I'm trying to make a damage block instead of the player triggering the damage. But unfortunately I'm running into some issues.

How would I make this work to trigger other NPC's besides itself.

Graal Script Code:
function onActionServerside(temp.commandtemp.xtemp.y)
{
  switch(
temp.command){ 
    case 
"attack"
      
temp.tnpcs findareanpcs(temp.5temp.3106);   
      for(
temp.temp.tnpcs){   
        
temp.n.chat "Hit!";
  }
 }

Perhaps this question is badly worded and for that, I'm sorry forums.
Reply With Quote
  #2  
Old 06-12-2012, 08:15 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
I'm not quite sure what you're asking, but I think you mean that you're trying to trigger NPCs when they've been attacked.

Let's create a simple function for it..

Graal Script Code:
// put this in a class like func_damage so you can reuse it
function attackNPCs(temp.attackertemp.attackXtemp.attackYtemp.attackRadius) {
  for (
temp.npc findAreaNPCs(temp.attackX temp.attackRadiustemp.attackY temp.attackRadiustemp.attackRadius 2temp.attackRadius 2)) {
    
// you could do proper radius checking rather than a square with
    // length of 2*radius, but this is easier and generally sufficient for your needs
    
temp.npc.trigger("attack"temp.attacker); // tell the NPC it's been attacked
  
}

Now in any NPCs, you can do

Graal Script Code:
function onAttack(temp.attacker) {
  
this.chat "I was attacked by " temp.attacker.nick "!";

Then in your weapon, you can just do this:

Graal Script Code:
function onCreated() {
  
this.join("func_damage");
}

function 
onActionServerside(temp.commandtemp.xtemp.y

  switch(
temp.command){  
    case 
"attack":
      
this.attackNPCs(playertemp.xtemp.y1);
    break;
 } 

__________________
Reply With Quote
  #3  
Old 06-12-2012, 02:39 PM
greggiles greggiles is offline
Registered User
greggiles's Avatar
Join Date: Sep 2007
Posts: 149
greggiles has a spectacular aura about
So the first script is the Dmg block. Second is the baddie. third is the weapon. Got it~ THANK YOU
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 10:40 AM.


Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (C) 1998-2008 Linux cyberjoueurs All Rights Reserved.