Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runtime with wander insanity #1255

Closed
PotatoTomahto opened this issue Aug 19, 2023 · 1 comment
Closed

Runtime with wander insanity #1255

PotatoTomahto opened this issue Aug 19, 2023 · 1 comment
Labels
Fix There was a bug, and we fixed it!

Comments

@PotatoTomahto
Copy link
Collaborator

image

/datum/ai_behavior/insanity_wander_center/proc/MoveInPath(datum/ai_controller/insane/wander/controller)
	var/mob/living/living_pawn = controller.pawn
	// Insanity lines
	if(world.time > controller.last_message + 4 SECONDS)
		controller.last_message = world.time
		controller.current_behaviors += GET_AI_BEHAVIOR(controller.lines_type)
	// Suicide replacement
	if(world.time > controller.suicide_enter)
		if(prob(10))
			living_pawn.visible_message("<span class='danger'>[living_pawn] freezes with an expression of despair on their face!</span>")
			QDEL_NULL(living_pawn.ai_controller)
			living_pawn.ai_controller = /datum/ai_controller/insane/suicide
			living_pawn.InitializeAIController()
			return TRUE
		else
			controller.suicide_enter = world.time + 30 SECONDS
	// Movement
	if(LAZYLEN(controller.current_path) && !IS_DEAD_OR_INCAP(living_pawn)) //Runtime error here
		var/target_turf = controller.current_path[1]
		if(target_turf && get_dist(living_pawn, target_turf) < 3)
			if(!step_towards(living_pawn, target_turf)) //If it fails to move
				controller.pathing_attempts++
				if(controller.pathing_attempts >= MAX_PATHING_ATTEMPTS)
					controller.pathing_attempts = 0
					controller.current_path = list()
					finish_action(controller, TRUE)
					return FALSE
			else // Don't reset the attempts and remove the next if they didn't move there.
				if(get_turf(living_pawn) == target_turf)
					controller.current_path.Remove(target_turf)
					controller.pathing_attempts = 0
				else
					controller.pathing_attempts++
			var/move_delay = max(0.8, 0.2 + living_pawn.cached_multiplicative_slowdown - (get_attribute_level(living_pawn, JUSTICE_ATTRIBUTE) * 0.004))
			addtimer(CALLBACK(src, .proc/MoveInPath, controller), move_delay)
			return TRUE
	controller.pathing_attempts = 0
	controller.current_path = list() // Reset the path and stop
	finish_action(controller, TRUE)
	return FALSE

Reproduction:

Issue occurs when wander insanity is triggered from insanity.

@InsightfulParasite InsightfulParasite added the Fix There was a bug, and we fixed it! label Nov 1, 2023
@InsightfulParasite
Copy link
Collaborator

I couldnt reproduce this issue so i think #1353 may have fixed this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fix There was a bug, and we fixed it!
Projects
None yet
Development

No branches or pull requests

2 participants