Code Monkey home page Code Monkey logo

Comments (6)

tapir avatar tapir commented on June 12, 2024

With the latest update it's now completely broken. I'm getting false positives. Variables that are supposedly not used are actually used.

from godot-vscode-plugin.

Geequlim avatar Geequlim commented on June 12, 2024

Could you please give me an example to reproduct that?

from godot-vscode-plugin.

tapir avatar tapir commented on June 12, 2024

Here is how below file looks on my screen

extends Node

# Vars
var select_player_index = -1
var mouse_pressed = false
var mouse_pos = Vector2(0, 0)
var damage = {}

# Nodes
onready var player = get_node("/root/Main/Map/Viewport/Player")
onready var ui_animation = get_node("/root/Main/AnimationPlayer")
onready var combat_extras = get_node("/root/Main/CombatExtras")
onready var combat_anim = get_node("/root/Main/CombatExtras/Background")
onready var combat_buttons = get_node("/root/Main/BottomUI/CombatButtons")
onready var combat_team = get_node("/root/Main/TopUI/CombatTeam")
onready var player_team = get_node("/root/Main/BottomUI/PlayerTeam")

func start():
	g.ticker_slide_in("COMBAT!!")
	ui_animation.play("TopUI_Up")
	combat_anim.play("appear")
	combat_extras.show()
	combat_buttons.show()

	# Randomize enemy team and reset enemy bar
	g.random_enemy_team()
	combat_team.reset_enemy_bar()

func update(delta):
	# While dragging the attack line
	if g.attacking:
		combat_extras.drag_arrow(mouse_pos)

	# Only run once after the enemy selection is done
	if g.enemy_selection != -1 && !g.attacking:
		#var select_enemy = combat_team.get_child(g.enemy_selection)
		var sp = g.player_team[select_player_index]
		var se = g.enemy_team[g.enemy_selection]
		damage = _hit(sp, se)
		#print(g.player_team)
		print(damage)
		#select_enemy.start_shooting(damage.hits, 5) #TODO: Weapon specific speeds
		g.enemy_selection = -1

func input(event):
	if event.type == InputEvent.MOUSE_BUTTON:
		mouse_pressed = event.pressed
		if !mouse_pressed:
			combat_extras.hide_arrow()
			g.attacking = false

	if event.type == InputEvent.MOUSE_MOTION && mouse_pressed:
		mouse_pos = event.pos
		if !g.attacking && g.player_selection != -1:
			var select_player = player_team.get_child(g.player_selection)
			if select_player.mouse_on:
				combat_extras.reset_arrow(select_player.get_pos()+Vector2(12, 247))
				select_player_index = g.player_selection
				g.attacking = true

func end():
	combat_anim.play("disappear")
	ui_animation.play("TopUI_Down")
	combat_buttons.hide()

func _hit(from, to):
	var total_damage = 0
	var total_crit = 0
	var bullet_hits = []
	var jam_round = -1
	var double_damage = false

	# Damage per bullet
	var from_attack = from.attack + from.weapon.attack_bonus
	var damage_per_bullet = from.weapon.damage * from_attack * 0.1
	var skill_diff = from_attack - to.defense
	var critical_cutoff = to.defense * 3 - 2
	var total_damage_multiplier = from.weapon.coeff * from.coeff

	# Calc total damage coeff
	var attack_roll = randi() % 21
	if attack_roll <= 2:
		return {
			"total_crit": 0,
			"total_damage": 0,
			"double_damage": double_damage,
			"hits": bullet_hits
		}
	elif attack_roll > 2 && attack_roll <= 8:
		total_damage_multiplier *= 0.5
	elif attack_roll > 8 && attack_roll <= 18:
		total_damage_multiplier *= 1
	else:
		total_damage_multiplier *= 2
		double_damage = true

	# Call skill total domage coefs
	total_damage_multiplier *= c.SKILL_LEVELS[from.skills[from.weapon.type]]

	# Check for jam
	if randi() % 101 <= from.weapon.jam_rate:
		jam_round = randi() % from.weapon.bullets_left

	# Per bullet calculation
	for i in range(from.weapon.bullets_left):
		# If jammed
		if i == jam_round:
			bullet_hits.append({"is_jammed": true, "damage": 0})
			break

		var result
		var basic_roll = round(randf() * to.defense * 3)
		if skill_diff < 0:
			if basic_roll == to.defense * 3:
				result = to.defense * 3
			else:
				result = basic_roll + skill_diff
		else:
			result = basic_roll + abs(skill_diff)

		# Check for hit/miss/critical
		if result >= skill_diff + to.defense:
			# Check for critical
			if result > critical_cutoff:
				bullet_hits.append({"is_jammed": false , "damage": damage_per_bullet*total_damage_multiplier*-2})
			else:
				bullet_hits.append({"is_jammed": false , "damage": damage_per_bullet*total_damage_multiplier})
		else:
			bullet_hits.append({"is_jammed": false, "damage": 0})

	# Calc total damage
	for bullet in bullet_hits:
		if bullet.damage < 0:
			total_crit += bullet.damage
		else:
			total_damage += bullet.damage

	return {"total_crit": total_crit, "total_damage": total_damage, "double_damage": double_damage, "hits": bullet_hits}

screenshot from 2017-03-12 18-32-44

from godot-vscode-plugin.

Geequlim avatar Geequlim commented on June 12, 2024

This bug should be fixed in next release.

from godot-vscode-plugin.

tapir avatar tapir commented on June 12, 2024

Thanks

from godot-vscode-plugin.

tapir avatar tapir commented on June 12, 2024

Is there a chance that we get a new release? this bug is kind of annoying

from godot-vscode-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.