Page 1 of 1

[Mobs Api Question] How to make a Mob inmune to a weapon?

PostPosted: Mon Mar 07, 2016 23:23
by MineYoshi
Yes i am working in a mod, an add-on to Pilz Adam Mobs, so i need help, how i make a mob inmune to a weapon?

I mean i hit test:potato_mob with a wooden sword , when i hit it my sword doesn't harm the potato_mob!

How i do that?

Re: [Mobs Api Question] How to make a Mob inmune to a weapon

PostPosted: Tue Mar 08, 2016 13:51
by maikerumine
armor =0,
this will make it invincible.

Re: [Mobs Api Question] How to make a Mob inmune to a weapon

PostPosted: Tue Mar 08, 2016 15:02
by maikerumine
Sorry! I should explain better:

here is code for monster:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
-- Sand Monster by PilzAdam
mobs:register_mob("esmobs:sand_monster", {
   type = "monster",
   passive = false,
   attack_type = "dogfight",
   reach = 2,
   damage = 3,
   hp_min = 34,
   hp_max = 60,
   armor = 100,
   collisionbox = {-0.4, -1, -0.4, 0.4, 0.8, 0.4},
   visual = "mesh",
   mesh = "mobs_sand_monster.b3d",
   textures = {
      "mobs_3.png"
   },
   makes_footstep_sound = true,
   sounds = {
      random = "mobs_sandmonster",
   },
   walk_velocity = 3.5,
   run_velocity = 4.5,
   view_range = 15,
   jump = true,
   floats = 0,
   drops = {
      {name = "default:desert_sand",
      chance = 1, min = 3, max = 5},
   },
   water_damage = 3,
   lava_damage = 4,
   light_damage = 0,
   fear_height = 3,
   group_attack = true,
   animation = {
      speed_normal = 15,
      speed_run = 15,
      stand_start = 0,
      stand_end = 39,
      walk_start = 41,
      walk_end = 72,
      run_start = 74,
      run_end = 105,
      punch_start = 74,
      punch_end = 105,
   },
})




See the part: armor = 100,
This is confusing, 100 means just a punch can hurt monster and something like armor = 85, you would need a strong sword to hurt, etc.

I hope this helps!

Re: [Mobs Api Question] How to make a Mob inmune to a weapon

PostPosted: Tue Mar 08, 2016 20:57
by MineYoshi
I mean i can harm the mob with a wooden sword, but if i do the same with a golden sword don't works!

Re: [Mobs Api Question] How to make a Mob inmune to a weapon

PostPosted: Tue Mar 08, 2016 21:14
by maikerumine
MineYoshi wrote:I mean i can harm the mob with a wooden sword, but if i do the same with a golden sword don't works!

Short answer: not easily.

Here is basic wood sword:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.register_tool("default:sword_wood", {
   description = "Wooden Sword",
   inventory_image = "default_tool_woodsword.png",
   tool_capabilities = {
      full_punch_interval = 1,
      max_drop_level=0,
      groupcaps={
         snappy={times={[2]=1.6, [3]=0.40}, uses=10, maxlevel=1},
      },
      damage_groups = {fleshy=2},
   }
})


And diamond:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.register_tool("default:sword_diamond", {
   description = "Diamond Sword",
   inventory_image = "default_tool_diamondsword.png",
   tool_capabilities = {
      full_punch_interval = 0.7,
      max_drop_level=1,
      groupcaps={
         snappy={times={[1]=1.90, [2]=0.90, [3]=0.30}, uses=40, maxlevel=3},
      },
      damage_groups = {fleshy=8},
   }
})

See the part about damage_groups = {fleshy=8},

That is the amount of damage each weapon does to all fleshy groups.

If you want only one mob to be invincible to a gold sword, you may need to look into advanced coding.

Re: [Mobs Api Question] How to make a Mob inmune to a weapon

PostPosted: Tue Mar 08, 2016 23:32
by MineYoshi
.....

Oh man, i don't know anything about that!


How i can do that, any website that contains info about that, the situation is that Tails said me he wanted a mob for ethereal
of mobs, and he said me some info about everyone of the mobs, and one of that is:
-This mob is inmune to golden and iron sword.


I don't know what to do...
Anyways THX for your help!

Re: [Mobs Api Question] How to make a Mob inmune to a weapon

PostPosted: Wed Mar 09, 2016 00:23
by qwertymine3
There is no easy mechanism in the game to do this.
I think you can do this by somehow disabling the default damage system (immortal?) and applying it yourself if the tool is not blacklisted, or by doing a reverse calculation of the damage and healing the entity when on_punch is called if the tool isn't supposed to do damage.

Sorry, can't help much - but here is a relevant lua_api.txt link (Entity Damage System)

https://github.com/minetest/minetest/blob/master/doc/lua_api.txt#L1254

Re: [Mobs Api Question] How to make a Mob inmune to a weapon

PostPosted: Wed Mar 09, 2016 00:42
by MineYoshi
I think this is more about the mobs api!

not about default Minetest api!

in my opinion that is a good point,
but i think is better blacklist the weapon when you hit it with a tool!

Re: [Mobs Api Question] How to make a Mob inmune to a weapon

PostPosted: Wed Mar 09, 2016 15:11
by stu
MineYoshi wrote:I think this is more about the mobs api!

not about default Minetest api!

in my opinion that is a good point,
but i think is better blacklist the weapon when you hit it with a tool!

There is nothing in mobs api that can make the default gold sword less powerful towards a specific mob, sorry. I see two ways you can do it, either make the gold sword less powerful toward everything or you catch the mob's on_punch callback and process the damage yourself (as previously suggested) Neither the minetest nor any of the mob api's are capable of handling such obscure use cases. (afaik)

Re: [Mobs Api Question] How to make a Mob inmune to a weapon

PostPosted: Wed Mar 09, 2016 21:38
by MineYoshi
oh man....

i better say to PilzAdam if he can add the feature to the api!...

....
I can use the on_punch_callback i think that can work, but anyways i don't want that....

Re: [Mobs Api Question] How to make a Mob inmune to a weapon

PostPosted: Thu Mar 10, 2016 09:02
by TenPlus1
So wait, you want certain mobs to be immune to specific tool types ? Like golden swords cannot damage dungeon masters for instance ???

Update: Mobs Redo 1.28 has new damage system added where mobs can be immune to certain weapons or healed by them (check out oerkki.lua file to see how)

viewtopic.php?f=11&t=9917

Re: [Mobs Api Question] How to make a Mob inmune to a weapon

PostPosted: Thu Mar 10, 2016 20:20
by MineYoshi
OK i will see now i have to replace some code....

THX a lot!

Re: [Mobs Api Question] How to make a Mob inmune to a weapon

PostPosted: Thu Mar 10, 2016 20:48
by TenPlus1
MineYoshi: if it helps remember that Mobs Redo is backwards compatible with SimpleMobs mobs.

Re: [Mobs Api Question] How to make a Mob inmune to a weapon

PostPosted: Thu Mar 10, 2016 23:13
by MineYoshi
OK, anyways i need to update some things too!