Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by Gamma

Hello everyone,

How would I be able to make an enemy take certain amounts of damage by certain weapons that the player uses. My player currently has 2 weapons, and both weapons deal different amounts of damage to ANY enemy entity, how do I make some enemies immune to some weapons or at least take less damage?

I'm guessing that would have to be incorporated into the enemies update function, am I correct?

1 decade ago by Xatruch

You could use the check() function on your enemy entity, like:

check: function(other) {
  if(other.weaponType == 'typeA') {
   this.damage(5);
  }
  else if(other.weaponType == 'typeB') {
   this.damage(10);
  }
}

1 decade ago by Gamma

Thank you for your help Xatruch. I'm sorry to say it didn't have any affect on the enemy entity, I did mess around with your code a bit, I replaced "weaponType" with "activeWeapon" since that is what is put on my player entity, and instead of "typeA" I put "EntityPistol". I then removed "damage" and replaced it with "recieveDamage" and nothing worked. Is there anything that I did wrong. I see why you put it in the check function since thats were the receiving damage code is placed for how much the damage the player will be taking.

1 decade ago by Gamma

Ok, so I experimented with the code, and yes your are correct, but it resulted in the wrong way. It seems that he takes different amonts of damage when collided with a specific weapon in hand....
Page 1 of 1
« first « previous next › last »