View Single Post
  #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