Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-25-2011, 02:43 PM
blackbeltben blackbeltben is offline
Registered User
Join Date: Aug 2011
Posts: 83
blackbeltben is on a distinguished road
NPC collision

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.
Reply With Quote
  #2  
Old 08-25-2011, 02:54 PM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Currently no. You'll need to write your own collision detection. I don't think it would be very feasible getting an event added for NPC touching NPC
Reply With Quote
  #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
  #4  
Old 08-25-2011, 11:30 PM
Tricxta Tricxta is offline
The Muffin Man
Tricxta's Avatar
Join Date: Oct 2010
Location: Australia
Posts: 563
Tricxta is a jewel in the roughTricxta is a jewel in the rough
Could always place a constant firing triggeraction in front of the npc:
PHP Code:
triggeractionplayerx.+1.5+(vecx(player.dir)), player.y+2+(vecy(player.dir)), "npctouchedme"NULL); 
Then in the receiving npc just find out when the triggeraction is called and your rolling. Im only suggesting this because Thors method is a bit daunting for some people. So unless you understand what his done theres always a second more easier to understand approach. Its just a bit less stable lol.

It might not be the most elegant solution but it sure is straight forward
Reply With Quote
  #5  
Old 08-25-2011, 11:43 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Quote:
Originally Posted by Tricxta View Post
Could always place a constant firing triggeraction in front of the npc:
PHP Code:
triggeractionplayerx.+1.5+(vecx(player.dir)), player.y+2+(vecy(player.dir)), "npctouchedme"NULL); 
Then in the receiving npc just find out when the triggeraction is called and your rolling. Im only suggesting this because Thors method is a bit daunting for some people. So unless you understand what his done theres always a second more easier to understand approach. Its just a bit less stable lol.

It might not be the most elegant solution but it sure is straight forward
Not only is it not elegant but running triggeraction loops is horribly inefficient and taxing on the server.

NPCs, if given a shape(via setshape() or showcharacter()) are considered walls via onwall(). Instead, he could check for walls and only when they collide with a wall, check for an NPC in front of them... if you want to do something simple. However, this requires NPCs to block which may not be desired, and will end up emulating almost exactly what Thor is doing anyways... he could fall back on triggeraction when it hits a wall but I don't like to recommend triggeraction.
Reply With Quote
  #6  
Old 08-26-2011, 05:00 AM
Tricxta Tricxta is offline
The Muffin Man
Tricxta's Avatar
Join Date: Oct 2010
Location: Australia
Posts: 563
Tricxta is a jewel in the roughTricxta is a jewel in the rough
Quote:
Originally Posted by DustyPorViva View Post
Not only is it not elegant but running triggeraction loops is horribly inefficient and taxing on the server.

NPCs, if given a shape(via setshape() or showcharacter()) are considered walls via onwall(). Instead, he could check for walls and only when they collide with a wall, check for an NPC in front of them... if you want to do something simple. However, this requires NPCs to block which may not be desired, and will end up emulating almost exactly what Thor is doing anyways... he could fall back on triggeraction when it hits a wall but I don't like to recommend triggeraction.
Good point... I had in mind it only being used a cheats way to make things work with the average npc character though, but yes... I was wrong to suggest such a horrid solution
Reply With Quote
Reply


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 02:12 AM.


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