Thread: NPC collision
View Single Post
  #3  
Old 08-25-2011, 04:59 PM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
Quote:
Originally Posted by blackbeltben View Post
You can make an NPC that has a function for onPlayerTouchsMe() and so on will happen.

But can you make a NPC have the same thing happen for an onPlayerTouchsMe().

An NPC touching another NPC.
I'm using for a baddie.
After moving the NPC, you can do something such as:

PHP Code:
function doTouchTrigger(){
  
temp.pixel 16;
  
temp.halfpixel 32;
  if(
this.dir == 1){
    
temp.this.0.75 temp.halfpixel + (vecx(this.dir) * (0.75 temp.halfpixel));
    
temp.this.1;
    
temp.temp.pixel;
    
temp.2;
  }
  else{
    
temp.this.0.5;
    
temp.this.1.25 temp.halfpixel + (vecy(this.dir) * (0.75 temp.halfpixel));
    
temp.2;
    
temp.temp.pixel;
  }
  
  
temp.tnpcs findareanpcs(temp.xtemp.ytemp.wtemp.h);
  
//I'm not sure if findareanpcs(); filters out npcs which call the function
  
temp.tnpcs.remove(this);
  for(
temp.temp.tnpcs){
    
temp.n.trigger("NPCTouchsMe"this);
  }
}

//Will result in
function onNPCTouchsMe(temp.n){
  
this.chat "I was touched by the NPC at " temp.n.", " temp.n.y;

These coordinates are based on showcharacter npcs.
Reply With Quote