Quote:
Originally Posted by blackbeltben
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 = 1 / 16;
temp.halfpixel = 1 / 32;
if(this.dir % 2 == 1){
temp.x = this.x + 0.75 - temp.halfpixel + (vecx(this.dir) * (0.75 + temp.halfpixel));
temp.y = this.y + 1;
temp.w = 1 + temp.pixel;
temp.h = 2;
}
else{
temp.x = this.x + 0.5;
temp.y = this.y + 1.25 - temp.halfpixel + (vecy(this.dir) * (0.75 + temp.halfpixel));
temp.w = 2;
temp.h = 1 + temp.pixel;
}
temp.tnpcs = findareanpcs(temp.x, temp.y, temp.w, temp.h);
//I'm not sure if findareanpcs(); filters out npcs which call the function
temp.tnpcs.remove(this);
for(temp.n : 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.x @ ", " @ temp.n.y;
}
These coordinates are based on showcharacter npcs.