Graal Forums  

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

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #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..

PHP 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

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

Then in your weapon, you can just do this:

PHP 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
 


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 05:16 AM.


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