# [3.3.5][Bug]Problem about swim and under-water-walking #12534

Open
opened this Issue Jul 17, 2014 · 23 comments

Projects
None yet
6 participants

### kldxzzhc2 commented Jul 17, 2014

 db : up-to-date core : 345bed2 In the core, if we want a creature can swim, we usually set InhabitType = 3 ( or 2). It's OK, the creature can go into water and walk on ground under water. But if we attack it, it will walk to you, not swim to you, and we will see the creature could fall down when it walk to player. So, we want the creature can swim in the water, usually we set the unit_flags is 32768, then, the creature can swim and never fall down. But the creature only swim on ground under water (not walk on it), for some creature (for example, 3106), this is not correct, they just walk under water (but never fall down when attack player) I think this is a bug, can someone confirm and fix it? Thanks :) Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
Contributor

### Rushor commented Jul 17, 2014

 what would happen if we set the inhabit to 6/7?

### kldxzzhc2 commented Jul 17, 2014

 no , the creature will fly to sky

Contributor

### MrSmite commented Jul 18, 2014

 Do you have a specific creature example? The Murlocs in Elwynn Forest don't have this behavior. When I aggro them in the water they will swim to me and fight properly.

### kldxzzhc2 commented Jul 18, 2014

 Yeah, try this creature 3106. When: out of combat, it should walk under water (not swim) in combat, swim to player and attack (don't fall down) Murlocs in Elwynn Forest has unit_flags 32768, so no problem with it (can swim always). Finally, we need inhabittype is 3, unif_flags is not 32768, not fall down

### kldxzzhc2 commented Jul 18, 2014

 Another problem, the speed of walk under water is faster than walk on the ground

### kldxzzhc2 commented Jul 18, 2014

 I have try change Unit.cpp ```bool Unit::SetSwim(bool enable) { // if (enable == HasUnitMovementFlag(MOVEMENTFLAG_SWIMMING)) // return false; if (enable) { AddUnitMovementFlag(MOVEMENTFLAG_SWIMMING); AddUnitMovementFlag(MOVEMENTFLAG_DISABLE_GRAVITY); } else { RemoveUnitMovementFlag(MOVEMENTFLAG_SWIMMING); RemoveUnitMovementFlag(MOVEMENTFLAG_DISABLE_GRAVITY); } return true; }``` It just like the creature has unit_flags 32768, so it doesn't work

### kldxzzhc2 commented Jul 18, 2014

 any news?
Contributor

### MrSmite commented Jul 19, 2014

 Well this seems to effect Hunter pets too. I just noticed as I swam down a river in Elwynn that my pet was walking on the bottom of the river.

### kldxzzhc2 commented Jul 19, 2014

 Yeah, the pet has same problem, when pet attack a creature swimming, sometimes fall down

Closed

### kldxzzhc2 commented Aug 20, 2014

 creature.cpp line 2476 add this code ``` CreatureTemplate const* cInfo = GetCreatureTemplate(); if ((cInfo->unit_flags & 32768) == 0) { if (enable) if (GetMotionMaster()->GetCurrentMovementGeneratorType() < MAX_DB_MOTION_TYPE) { RemoveFlag(UNIT_FIELD_FLAGS, 32768); } else { SetFlag(UNIT_FIELD_FLAGS, 32768); } else RemoveFlag(UNIT_FIELD_FLAGS, 32768); } ```
Contributor

### Pitcrawler commented Aug 20, 2014

 So if I get you right unit_flags = 32768 makes the creature to be able to swim when it is under water? Then wiki needs an update: ``````32768 0x0000 8000 UNIT_FLAG_UNK_15 `````` Btw almost any mob has this unit_flag set. If this specific doesn't have it, it is most probably missing and should be added. Maybe @Aokromes can confirm this from sniff.
Owner

### Aokromes commented Aug 20, 2014

 Nope. ```-- Template updates for creature 3106 (Pygmy Surf Crawler) UPDATE `creature_template` SET `faction`=7,`speed_walk`=1,`speed_run`=0.85714 WHERE `entry`=3106; -- Pygmy Surf Crawler```
Contributor

### Pitcrawler commented Aug 20, 2014

 Can you check the behavior of this creature on retail? Does it swim up to you when you attack it while swimming in the water or does it always stay on the ground at the bottom of the water?

### kldxzzhc2 commented Aug 20, 2014

 Yes I test and checked, when in combat, it will swim to you, when out of combat, it will always walk at the bottom of the water

### kldxzzhc2 commented Aug 20, 2014

 @Aokromes Just modify speed and faction will not fix this issues. I think you don't understand this issue
Owner

### Aokromes commented Aug 20, 2014

 You don't understand what that sql means, only that's different from retails data for mob 3106's creature_template.

### kldxzzhc2 commented Aug 20, 2014

 I understand your sql, but does it fix something? The mob 3106 will not fall when it swim to player? will it keep walking at the bottom when out of combat? Will it play swim action when it in combat?

### kldxzzhc2 commented Aug 20, 2014

 We can not simply change unit_flags to 32768 to mob 3106, it will make it always swim underwater. But in offical server, It walks at the bottom of water, just swim when in combat
Owner

### Aokromes commented Aug 20, 2014

 No, it only shows that the only bad data on that npc is the speed.

 :)
Contributor

### Pitcrawler commented Aug 20, 2014

 @kldxzzhc2 I think we need some generic way like a check if an npc is in combat which adds this unit_flag. If the npc leaves combat and arrives back at its homeposition the flag needs to be removed. All this should be performed only if the npc doesn't have the flag assigned by DB.

### kldxzzhc2 commented Aug 20, 2014

 the movement condition will check this:)
Contributor

### Saben65 commented May 1, 2016

 an example of a NPC this would affect is Clam Master K. If you impliment his WPs with his current InhabitType=3 he will swim the path instead of walking it. ```-- Pathing for Clam Master K Entry: 25800 'TDB FORMAT' SET @NPC := 114803; SET @PATH := @NPC * 10; UPDATE `creature` SET `spawndist`=0,`MovementType`=2,`position_x`=2342.325,`position_y`=5050.552,`position_z`=-21.01424 WHERE `guid`=@NPC; DELETE FROM `creature_addon` WHERE `guid`=@NPC; INSERT INTO `creature_addon` (`guid`,`path_id`,`mount`,`bytes1`,`bytes2`,`emote`,`auras`) VALUES (@NPC,@PATH,0,0,1,0, ''); DELETE FROM `waypoint_data` WHERE `id`=@PATH; INSERT INTO `waypoint_data` (`id`,`point`,`position_x`,`position_y`,`position_z`,`orientation`,`delay`,`move_type`,`action`,`action_chance`,`wpguid`) VALUES (@PATH,1,2342.325,5050.552,-21.01424,0,0,0,0,100,0), -- 06:32:15 (@PATH,2,2338.003,5044.308,-22.64446,0,0,0,0,100,0), -- 06:32:22 (@PATH,3,2336.804,5029.821,-26.94789,0,0,0,0,100,0), -- 06:32:27 (@PATH,4,2341.884,5018.865,-30.1459,0,0,0,0,100,0), -- 06:32:33 (@PATH,5,2348.352,5002.221,-30.94783,0,0,0,0,100,0), -- 06:32:40 (@PATH,6,2349.925,4993.154,-32.16956,0,0,0,0,100,0), -- 06:32:45 (@PATH,7,2354.025,4983.295,-33.4639,0,0,0,0,100,0), -- 06:32:50 (@PATH,8,2357.896,4977.057,-33.84595,0,0,0,0,100,0), -- 06:32:53 (@PATH,9,2353.561,4983.914,-33.77616,0,0,0,0,100,0), -- 06:33:00 (@PATH,10,2349.806,4994.94,-31.05927,0,0,0,0,100,0), -- 06:33:04 (@PATH,11,2346.473,5009.516,-31.52969,0,0,0,0,100,0), -- 06:33:08 (@PATH,12,2338.316,5025.714,-28.18582,0,0,0,0,100,0), -- 06:33:13 (@PATH,13,2334.683,5038.239,-23.58451,0,0,0,0,100,0); -- 06:33:20 -- 0x2001244760193200000015000025F374 .go 2342.325 5050.552 -21.01424```

Closed