View Single Post
  #15  
Old 08-30-2011, 07:37 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
Trying to word this is going to be tricky, but i'll give it a go.
The issue i'm having is that I'm trying to make collision for my custom baddie.
Basically, if the baddie reconizes the player.ani is an "ATTACK" gani, it will trigger the event. The ISSUE is that i have more than one ani for attack. (for different weapons)

For example, I have servername_sword_atkblade, servername_sword_atkstaff, etc

How do i make the baddie reconize all GANIs starting with "servername_sword_"?

PHP Code:
if (player.ani "servername_sword_???")
{
 
//blablabla 
Other Note: i DO NOT want to use function onWas.Hit because i am not using default movement system so it doesn't even work.
If this is a matter of making your baddies receive attacks from the player, it would be inefficient to have every single baddy checking for the players gani, especially should you go on to add multiple different types of attacks later on.
It would be much better to script an area NPCs trigger within the weapon script.

Basic example:

PHP Code:
//#CLIENTSIDE
function swordAttack(){
  
temp.player.0.5 + (vecx(player.dir) * 2);
  
temp.player.+ (vecy(player.dir) * 2);
  
temp.tnpcs findareanpcs(temp.xtemp.y22);
  for(
temp.temp.tnpcs){
    
temp.n.trigger("Slash"player.swordpower);
  }

I personally have a system for handling multiple types of area NPC triggers different attack weapons are communicating with rather than writing this type of code out within each weapon.

What you're attempting to do with checking ganis however is pretty much how the default hit detection works, it's a good way to check for attacks from other players.
What I do for this on Classic is create a static var containing all the different types of attacks as secondary variable names:

PHP Code:
//#CLIENTSIDE
function onCreated(){
  
//function, frames
  
this.attacks = new TStaticVar();
  
this.attacks.nameofswordgani = {"functionToGetAttackData"ArrayOfFrameNums};

Rather than looping through an array of different possible attacks, it is then essentially a matter of doing:

PHP Code:
temp.attack this.attacks.(@ temp.playerobj.ani.name);
if(
temp.attack != NULL){
  
//check the frame number is valid for attacking, NULL means any
  
if(temp.attack[1].index(temp.playerobj.anistep) > -|| temp.attack[1] == NULL){
    
temp.attackdata this.(@ this.attacks[0])(temp.playerobj);
    
//do stuff to check hitboxes based on that data
  
}

Reply With Quote