Skip to content

Commit

Permalink
Merge pull request #25 from EamonnMR/cheats
Browse files Browse the repository at this point in the history
Cheats
  • Loading branch information
EamonnMR authored Jun 28, 2023
2 parents 16ce0a0 + 069c89e commit 31e41d8
Show file tree
Hide file tree
Showing 18 changed files with 174 additions and 40 deletions.
66 changes: 65 additions & 1 deletion Cheats.gd
Original file line number Diff line number Diff line change
@@ -1,3 +1,67 @@
extends Node

var explore_all = true
var explore_all = false
var max_craft_level = false

var CHEATS = [
{
"hash": "d10ba5f768ac9db04b8419a2590bce54",
"callback": func explore_all_now(args):
explore_all = true
for i in Procgen.systems:
Client.get_ui().get_node("Map").update_for_explore(i)
return true},
{
"hash": "eba4a7a2f23a106e01e1380deac5190d",
"callback": func free_resources(args):
if not(len(args) == 2):
Client.display_message("Please enter an item type and quantity")
return false
var type = args[0]
var amount = int(args[1])
if not (type in Data.items):
Client.display_message("Unknown item type: " + type)
return
Client.player.get_node("Inventory").add(type, amount)
return true},
{
"hash": "8f1120f13067fb18ca2ee5bf7b57f9b8",
"callback": func(_args): set_var("max_craft_level")
},
{
"hash": "21a8297be0a2e4a39ec56a65015c0451",
"callback": func make_player_invincible(args):
var health = Client.player.get_node("Health")
health.invulnerable = not health.invulnerable
return health.invulnerable}
]

func set_var(variable_name):
set(variable_name, not get(variable_name))
return get(variable_name)

func hash_code(code):
var ctx = HashingContext.new()
ctx.start(HashingContext.HASH_MD5)
ctx.update(code.to_utf8_buffer())
var res = ctx.finish()
var encoded = res.hex_encode()
return encoded

func attempt_cheat(input):
if input.is_empty():
return

var split = input.split(":")
var code = split[0].to_lower()
var args = split[1].trim_prefix(" ").split(" ") if split.size() > 1 else []
var hash = hash_code(code)
var valence: bool
for cheat in CHEATS:
if cheat.hash == hash:
valence = cheat.callback.call(args)
if valence:
Client.display_message("Cheat Enabled")
else:
Client.display_message("Cheat Disabled")
return
6 changes: 3 additions & 3 deletions Cheats.tscn
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[gd_scene load_steps=2 format=2]
[gd_scene load_steps=2 format=3 uid="uid://bdk4iculmnvrj"]

[ext_resource path="res://Cheats.gd" type="Script" id=1]
[ext_resource type="Script" path="res://Cheats.gd" id="1"]

[node name="Node" type="Node"]
script = ExtResource( 1 )
script = ExtResource("1")
4 changes: 4 additions & 0 deletions Client.gd
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ var STARTING_MONEY = 10
var money = STARTING_MONEY
var player_name: String = "Shannon Merrol"

var typing: bool = false

func has_money(price):
return money >= price

Expand Down Expand Up @@ -79,6 +81,8 @@ func valid_jump_destination_selected():
func change_system():
var old_system = current_system
current_system = selected_system
get_ui().get_node("Map").update_for_explore(current_system)
Procgen.systems[current_system].explored = true
sel_sys(null, null)
exited_system.emit()
get_main().change_system(old_system, current_system)
Expand Down
4 changes: 4 additions & 0 deletions component/Health.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class_name Health

var already_destroyed: bool = false
var shield_regen_cooldown: bool = false
var invulnerable: bool = false

signal damaged(source)
signal healed
Expand Down Expand Up @@ -49,6 +50,9 @@ func can_heal():

func take_damage(damage, source):

if invulnerable:
return

reset_shield_regen()

if shields > 0:
Expand Down
16 changes: 12 additions & 4 deletions component/controllers/KeyboardController.gd
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,21 @@ func get_rotation_impulse() -> int:
return dc

func _physics_process(delta):

toggle_pause()
if not Client.typing:
toggle_pause()

if warp_autopilot:
process_warping_out(delta)
return

if Client.typing:
return

thrusting = Input.is_action_pressed("thrust")
braking = Input.is_action_pressed("brake")
shooting = Input.is_action_pressed("shoot")
shooting_secondary = Input.is_action_pressed("shoot_secondary")
rotation_impulse = get_rotation_impulse() * delta * parent.turn

toggle_map()
toggle_inventory()
toggle_codex()
Expand All @@ -35,11 +37,11 @@ func _physics_process(delta):
cycle_targets()
interact()
hyperspace()
handle_cheat_modal()


func _ready():
Client.set_player(parent)
# toggle_map_hack_what_happened_to_visibility()

func toggle_map():
if Input.is_action_just_released("toggle_map"):
Expand Down Expand Up @@ -108,3 +110,9 @@ func toggle_fire_mode():
if Input.is_action_just_pressed("toggle_chain_fire"):
parent.chain_fire_mode = not parent.chain_fire_mode
Client.display_message("Fire Mode: " + ("chain fire" if parent.chain_fire_mode else "syncro"))

func handle_cheat_modal():
if Input.is_action_just_pressed("open_cheat_dialogue"):
var dialogue = Client.get_ui().get_node("CheatInput")
if not dialogue.visible:
Client.get_ui().get_node("CheatInput").show()
16 changes: 16 additions & 0 deletions data/codex/help/keybindings.bbcode
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[b]Keybindings[/b]

[b]W A D[/b] - thrust / turn
[b]L Alt[/b] - brake
[b]Space[/b] - Fire primary weapons
[b]Left CTL[/b] - Fire secondary weapons
[b]F[/b] - Toggle chain fire / syncro fire
[b]Q[/b] - Target nearest hostile
[b]E[/b] - Interact with target
[b]O[/b] - Toggle Codex
[b]Q[/b] - Target nearest hostile
[b]J[/b] - Enter hyperspace (make sure to select an adjacent system first)
[b]M[/b] - Toggle galaxy map
[b]I[/b] - Toggle inventory & Crafting
[b]P/Escape/capslock[/b] - Toggle Pause
[b]Shift + Enter[/b] - Open cheat dialogue (it's a textbox so click into it)
2 changes: 1 addition & 1 deletion data/ships.csv
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ burner,Burner,Minimalism,Perth Starworks,8,0.06,1,20,3,10,5,2,8,4,FALSE,res://en
dragon,Dragon,Light Gunship,iLisk,4,0.02,0.8,15,1,32,20,2,4,7,TRUE,res://entities/ship/ship_types/Dragon.tscn,200,LeftGun: plasma; RightGun: plasma,2,metal: 4,,3,res://assets/eamonn/icons/dragon.png,A contrarian gunship design if there ever was one. --Krish
delivery,Delivery,On Schedule,Autofac Starships Division,3,0.05,1,15,1,12,10,2,6,5,FALSE,res://entities/ship/ship_types/Delivery.tscn,150,LeftGun: plasma,0,metal: 3,,5,res://assets/eamonn/icons/delivery.png,"Designed to make cargo runs, but mostly seen on the prowl –No 7"
cargo,Heighliner,Bulk Cargo,Avon Aviation,3,0.02,0.5,5,0.5,44,20,2,5,2,TRUE,res://entities/ship/ship_types/Cargo.tscn,200,LeftGun: plasma,0,metal: 2,,2,res://assets/eamonn/icons/heighliner.png,"Big cargo capacity and, well, big cargo capacity. --Krish"
melchior,Melchior,Self Driving,Twilight,3,0.4,0.5,10,0.5,64,64,1,4,6,TRUE,res://entities/ship/ship_types/Melchior.tscn,200,LeftFrontGun: plasma; RightFrontGun: plasma,0,metal: 1,,6,res://assets/eamonn/icons/melchior.png,I’m truly impressed by this design. It’s got Urizen’s hands all over it. --Syd
melchior,Melchior,Self Driving,Twilight,3,0.4,0.5,10,0.5,64,64,1,4,6,TRUE,res://entities/ship/ship_types/Melchior.tscn,200,LeftFrontGun: plasma; RightFrontGun: plasma,10,metal: 1,,6,res://assets/eamonn/icons/melchior.png,I’m truly impressed by this design. It’s got Urizen’s hands all over it. --Syd
aerospace,Aerospace,Dropship,MIC,4,0.025,0.8,17,2.2,30,20,2,5,3,TRUE,res://entities/ship/ship_types/Aerospace.tscn,100,LeftGun: plasma; RightGun: plasma,0,metal: 7,,7,res://assets/eamonn/icons/gifts_ungiven.png,"Perfect for troop transport under fire in atmo. Out here in space, well, it’s airtight. --Syd"
Binary file modified export/linux/space_craft_22.pck
Binary file not shown.
Binary file modified export/linux/space_craft_22_linux.zip
Binary file not shown.
Binary file modified export/windows/asteroids_22.pck
Binary file not shown.
Binary file modified export/windows/asteroids_22_windows.zip
Binary file not shown.
5 changes: 5 additions & 0 deletions project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,11 @@ toggle_codex={
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":79,"key_label":0,"unicode":111,"echo":false,"script":null)
]
}
open_cheat_dialogue={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":true,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194309,"key_label":0,"unicode":0,"echo":false,"script":null)
]
}

[layer_names]

Expand Down
14 changes: 14 additions & 0 deletions ui/CheatInput.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
extends LineEdit

func _on_text_submitted(new_text):
text = ""
hide()
Client.typing = false
Cheats.attempt_cheat(new_text)


func _on_focus_entered():
Client.typing = true

func _on_focus_exited():
Client.typing = false
19 changes: 19 additions & 0 deletions ui/CheatInput.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[gd_scene load_steps=2 format=3 uid="uid://bff3c2g6wfevf"]

[ext_resource type="Script" path="res://ui/CheatInput.gd" id="1_vb7mo"]

[node name="CheatInput" type="LineEdit"]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_right = -858.0
offset_bottom = -617.0
grow_horizontal = 2
grow_vertical = 2
caret_blink = true
caret_blink_interval = 0.5
script = ExtResource("1_vb7mo")

[connection signal="focus_entered" from="." to="." method="_on_focus_entered"]
[connection signal="focus_exited" from="." to="." method="_on_focus_exited"]
[connection signal="text_submitted" from="." to="." method="_on_text_submitted"]
2 changes: 1 addition & 1 deletion ui/crafting/Crafting.gd
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func unassign():
func build_blueprint_list():
for blueprint_id in _blueprints():
var blueprint = _blueprints()[blueprint_id]
if blueprint.require_level <= crafting_level:
if (blueprint.require_level <= crafting_level) or Cheats.max_craft_level:
var icon = _get_icon_node(blueprint)
icon.pressed.connect(
func _blueprint_selected():
Expand Down
2 changes: 1 addition & 1 deletion ui/map/Map.gd
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func _generate_map_nodes():
movement.add_child(circle)

for i in Procgen.systems:
if Procgen.systems[i].explored:
if Procgen.systems[i].explored or Cheats.explore_all:
update_for_explore(i)

_set_initial_center()
Expand Down
43 changes: 15 additions & 28 deletions ui/map/Map.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,18 @@ mouse_filter = 2
script = ExtResource("3")

[node name="MarginContainer" type="MarginContainer" parent="."]
anchors_preset = 15
layout_mode = 0
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 2

[node name="NinePatchPanel" parent="MarginContainer" instance=ExtResource("2")]
offset_right = 1152.0
offset_bottom = 648.0
layout_mode = 2

[node name="MarginContainer2" type="MarginContainer" parent="MarginContainer/NinePatchPanel"]
anchors_preset = 15
layout_mode = 0
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = 15.0
Expand All @@ -44,21 +43,20 @@ mouse_filter = 2

[node name="Panel" type="Panel" parent="MarginContainer/NinePatchPanel/MarginContainer2"]
clip_contents = true
offset_right = 1122.0
offset_bottom = 618.0
layout_mode = 2
mouse_filter = 2
theme = SubResource("1")

[node name="Movement" type="Control" parent="MarginContainer/NinePatchPanel/MarginContainer2/Panel"]
layout_mode = 3
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2

[node name="Infobox" parent="MarginContainer/NinePatchPanel/MarginContainer2/Panel" instance=ExtResource("2")]
anchors_preset = 3
layout_mode = 0
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
Expand All @@ -72,7 +70,7 @@ grow_vertical = 0
script = ExtResource("1")

[node name="MarginContainer" type="MarginContainer" parent="MarginContainer/NinePatchPanel/MarginContainer2/Panel/Infobox"]
anchors_preset = 15
layout_mode = 0
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = 13.0
Expand All @@ -83,49 +81,38 @@ grow_horizontal = 2
grow_vertical = 2

[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/NinePatchPanel/MarginContainer2/Panel/Infobox/MarginContainer"]
offset_right = 200.0
offset_bottom = 185.0
layout_mode = 2

[node name="Name" type="Label" parent="MarginContainer/NinePatchPanel/MarginContainer2/Panel/Infobox/MarginContainer/VBoxContainer"]
unique_name_in_owner = true
offset_right = 200.0
offset_bottom = 23.0
layout_mode = 2

[node name="Biome" type="Label" parent="MarginContainer/NinePatchPanel/MarginContainer2/Panel/Infobox/MarginContainer/VBoxContainer"]
unique_name_in_owner = true
offset_top = 27.0
offset_right = 200.0
offset_bottom = 50.0
layout_mode = 2

[node name="Faction" type="Label" parent="MarginContainer/NinePatchPanel/MarginContainer2/Panel/Infobox/MarginContainer/VBoxContainer"]
unique_name_in_owner = true
offset_top = 54.0
offset_right = 200.0
offset_bottom = 77.0
layout_mode = 2

[node name="Spobs" type="Label" parent="MarginContainer/NinePatchPanel/MarginContainer2/Panel/Infobox/MarginContainer/VBoxContainer"]
unique_name_in_owner = true
offset_top = 81.0
offset_right = 200.0
offset_bottom = 104.0
layout_mode = 2

[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/NinePatchPanel/MarginContainer2/Panel"]
anchors_preset = 2
layout_mode = 0
anchor_top = 1.0
anchor_bottom = 1.0
offset_top = -40.0
offset_right = 75.0
grow_vertical = 0

[node name="Recenter" type="Button" parent="MarginContainer/NinePatchPanel/MarginContainer2/Panel/VBoxContainer"]
offset_right = 85.0
offset_bottom = 31.0
layout_mode = 2
text = "Re-Center"

[node name="Mode" type="OptionButton" parent="MarginContainer/NinePatchPanel/MarginContainer2/Panel/VBoxContainer"]
offset_top = 35.0
offset_right = 85.0
offset_bottom = 55.0
layout_mode = 2

[connection signal="pressed" from="MarginContainer/NinePatchPanel/MarginContainer2/Panel/VBoxContainer/Recenter" to="." method="_on_Recenter_pressed"]
[connection signal="item_selected" from="MarginContainer/NinePatchPanel/MarginContainer2/Panel/VBoxContainer/Mode" to="." method="_on_Mode_item_selected"]
15 changes: 14 additions & 1 deletion ui/ui.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=22 format=3 uid="uid://cw2nt0g5sx0tb"]
[gd_scene load_steps=23 format=3 uid="uid://cw2nt0g5sx0tb"]

[ext_resource type="Script" path="res://ui/Ui.gd" id="1_twatu"]
[ext_resource type="PackedScene" uid="uid://dqqjk32pvym87" path="res://ui/Money.tscn" id="2_4wpjj"]
Expand All @@ -20,6 +20,7 @@
[ext_resource type="PackedScene" uid="uid://c1cjcpk0fqkan" path="res://ui/Hud/galaxy_nav_indicator.tscn" id="17_wqcqy"]
[ext_resource type="PackedScene" uid="uid://b5sa7qn1e2xyb" path="res://ui/NinePatchPanel.tscn" id="18_6eupn"]
[ext_resource type="Script" path="res://ui/Codex.gd" id="19_aythd"]
[ext_resource type="PackedScene" uid="uid://bff3c2g6wfevf" path="res://ui/CheatInput.tscn" id="20_l3b1l"]

[sub_resource type="LabelSettings" id="LabelSettings_tkka7"]
font = ExtResource("15_lbbmr")
Expand Down Expand Up @@ -195,6 +196,18 @@ bbcode_enabled = true
layout_mode = 2
text = "close"

[node name="CheatInput" parent="." instance=ExtResource("20_l3b1l")]
visible = false
anchors_preset = 7
anchor_left = 0.5
anchor_top = 1.0
anchor_right = 0.5
offset_left = -104.0
offset_top = -117.0
offset_right = 116.0
offset_bottom = -86.0
grow_vertical = 0

[connection signal="timeout" from="MessageBox/Timer" to="MessageBox" method="_on_timer_timeout"]
[connection signal="button_clicked" from="Codex/VBoxContainer/HBoxContainer/Tree" to="Codex" method="_on_tree_button_clicked"]
[connection signal="cell_selected" from="Codex/VBoxContainer/HBoxContainer/Tree" to="Codex" method="_on_tree_cell_selected"]
Expand Down

0 comments on commit 31e41d8

Please sign in to comment.