Pārlūkot izejas kodu

Alchemist Marine Sphere Code Cleanup (#9071)

- Cleaned up some code based on suggestions of Lemongrass and my own ideas
- Follow-up to 8edbda1
Playtester 3 mēneši atpakaļ
vecāks
revīzija
9d71271ba1
3 mainītis faili ar 9 papildinājumiem un 7 dzēšanām
  1. 3 3
      src/map/skill.cpp
  2. 1 1
      src/map/status.cpp
  3. 5 3
      src/map/unit.cpp

+ 3 - 3
src/map/skill.cpp

@@ -10136,11 +10136,11 @@ int32 skill_castend_nodamage_id (struct block_list *src, struct block_list *bl,
 		break;
 
 	case NPC_RANDOMMOVE:
-		if (md) {
+		if (md != nullptr) {
 			// This skill creates fake casting state where a monster moves while showing a cast bar
 			int32 tricktime = MOB_SKILL_INTERVAL * 3;
 			md->trickcasting = tick + tricktime;
-			clif_skillcasting(src, src->id, src->id, 0, 0, skill_id, skill_lv, ELE_FIRE, tricktime + 500);
+			clif_skillcasting(src, src->id, src->id, 0, 0, skill_id, skill_lv, ELE_FIRE, tricktime + MOB_SKILL_INTERVAL / 2);
 			// Monster cannot be stopped while moving
 			md->state.can_escape = 1;
 			// Move up to 8 cells
@@ -10149,7 +10149,7 @@ int32 skill_castend_nodamage_id (struct block_list *src, struct block_list *bl,
 		break;
 
 	case NPC_SPEEDUP:
-		if (md) {
+		if (md != nullptr) {
 			// Officially, trickcasting continues as long as there are more than 700ms left
 			int32 trickstop = (MOB_SKILL_INTERVAL * 7) / 10;
 			if (DIFF_TICK(md->trickcasting, tick) >= trickstop) {

+ 1 - 1
src/map/status.cpp

@@ -2784,7 +2784,7 @@ int32 status_calc_mob_(struct mob_data* md, uint8 opt)
 	if (flag&8 && mbl) {
 		struct status_data *mstatus = status_get_base_status(mbl);
 
-		if (mstatus && md->special_state.ai != AI_SPHERE &&
+		if (mstatus != nullptr && md->special_state.ai != AI_SPHERE &&
 			battle_config.slaves_inherit_speed&(status_has_mode(mstatus,MD_CANMOVE)?1:2))
 			status->speed = mstatus->speed;
 		if (status->speed < MIN_WALK_SPEED)

+ 5 - 3
src/map/unit.cpp

@@ -1104,8 +1104,9 @@ t_tick unit_escape(struct block_list *bl, struct block_list *target, int16 dist,
 	uint8 dir = map_calc_dir(target, bl->x, bl->y);
 
 	if (flag&1) {
+		// Straight line escape
 		// Keep moving until we hit an unreachable cell
-		for (int i = 1; i <= dist; i++) {
+		for (int16 i = 1; i <= dist; i++) {
 			if (map_getcell(bl->m, bl->x + i*dirx[dir], bl->y + i*diry[dir], CELL_CHKNOREACH))
 				dist = i - 1;
 		}
@@ -1752,9 +1753,10 @@ int32 unit_set_walkdelay(struct block_list *bl, t_tick tick, t_tick delay, int32
 			return 0;
 	} else {
 		if (bl->type == BL_MOB) {
-			mob_data* md = BL_CAST(BL_MOB, bl);
+			mob_data& md = *reinterpret_cast<mob_data*>(bl);
+
 			// Mob needs to escape, don't stop it
-			if (md && md->state.can_escape == 1)
+			if (md.state.can_escape == 1)
 				return 0;
 		}
 		// Don't set walk delays when already trapped.