proto3 initial commit

This commit is contained in:
Segey Lapin
2020-04-13 12:45:25 +03:00
parent 69410badf6
commit 1084b6d5c3
1588 changed files with 368852 additions and 23 deletions
+1
View File
@@ -0,0 +1 @@
.import
+5
View File
@@ -0,0 +1,5 @@
extends BTBase
class_name BTAction
func tick(_tick: Tick) -> int:
return OK
+30
View File
@@ -0,0 +1,30 @@
extends Node
class_name BehaviorTree
func tick(actor, blackboard, debug = false) -> int:
var tick := Tick.new()
tick.tree = self
tick.actor = actor
tick.blackboard = blackboard
tick.debug = debug
var result := FAILED
for child in get_children():
var _result = child._execute(tick)
assert(typeof(_result) == TYPE_INT)
result = _result
# Close nodes from last tick, if needed
var last_open_nodes: Array = tick.blackboard.get('openNodes', self)
var current_open_nodes := tick.open_nodes
# If node isn't currently open, but was open during last tick, close it
for node in last_open_nodes:
if (not current_open_nodes.has(node)
and tick.blackboard.get('isOpen', tick.tree, node)):
node._close(tick)
# Populate the blackboard
blackboard.set('openNodes', current_open_nodes, self)
return result
+59
View File
@@ -0,0 +1,59 @@
extends Node
class_name Blackboard
var _base_memory: Dictionary #stores global info
var _tree_memory: Dictionary #store tree and node info
func _enter_tree() -> void:
_base_memory = {}
_tree_memory = {}
func set(key, value, behavior_tree = null, node_scope = null) -> void:
var memory := _get_memory(behavior_tree, node_scope)
memory[key] = value
func get(key, behavior_tree = null, node_scope = null):
var memory := _get_memory(behavior_tree, node_scope)
if memory.has(key):
return memory[key]
return null
func _get_memory(behavior_tree, node_scope) -> Dictionary:
var memory := _base_memory
if behavior_tree:
memory = _get_tree_memory(behavior_tree)
if node_scope:
memory = _get_node_memory(memory, node_scope)
return memory
func _get_tree_memory(behavior_tree) -> Dictionary:
if not _tree_memory.has(behavior_tree):
_tree_memory[behavior_tree] = {
'nodeMemory':{},
'openNodes':[]
}
return _tree_memory[behavior_tree]
func _get_node_memory(tree_memory: Dictionary, node_scope) -> Dictionary:
var memory: Dictionary = tree_memory['nodeMemory']
if not memory.has(node_scope):
memory[node_scope] = {}
return memory[node_scope]
+66
View File
@@ -0,0 +1,66 @@
extends Node
class_name BTBase
func _execute(tick: Tick) -> int:
_enter(tick)
if not tick.blackboard.get('isOpen', tick.tree, self):
_open(tick)
var status := _tick(tick)
if status != ERR_BUSY:
_close(tick)
_exit(tick)
return status
func _enter(tick: Tick) -> void:
tick.enter_node(self) #debug call to be filled out in Tick object
enter(tick)
func _open(tick: Tick) -> void:
tick.open_node(self)
tick.blackboard.set('isOpen', true, tick.tree, self)
open(tick)
func _tick(tick: Tick) -> int:
tick.tick_node(self)
return tick(tick)
func _close(tick: Tick) -> void:
tick.close_node(self)
tick.blackboard.set('isOpen', false, tick.tree, self)
close(tick)
func _exit(tick: Tick) -> void:
tick.exit_node(self)
exit(tick)
# The following functions are to be overridden in extending nodes
func enter(_tick: Tick) -> void:
pass
func open(_tick: Tick) -> void:
pass
func tick(_tick: Tick) -> int:
return OK
func close(_tick: Tick) -> void:
pass
func exit(_tick: Tick) -> void:
pass
+65
View File
@@ -0,0 +1,65 @@
extends BTAction
class_name BTBuildPath
func is_dynamic_target(npc):
var target_group = npc.has_meta("target_group")
if target_group in ["_player", "_away", "_enemy", "female", "male"]:
return true
return false
func tick(tick: Tick) -> int:
var npc = tick.actor
var bb = tick.blackboard
var npc_pos = npc.global_transform.origin
assert(npc.has_meta("target_loc"))
assert(npc.has_meta("target_group"))
var loc = npc.get_meta("target_loc")
var target_group = npc.get_meta("target_group")
if npc.has_meta("path_valid") && !is_dynamic_target(npc):
var valid = npc.get_meta("path_valid")
if valid > 0.0:
valid -= tick.blackboard.get("delta")
npc.set_meta("path_valid", valid)
return OK
# print("path no longer valid")
if loc:
var path = []
var target_result: Dictionary = bb.get("target_result").duplicate()
assert(typeof(target_result) == TYPE_DICTIONARY)
assert(target_result != null)
print(target_result)
var target_collider: PhysicsBody
var target_position: Vector3
if !target_result.has("collider"):
path = [npc_pos, loc]
if target_result.has("collider"):
target_collider = target_result.collider
target_position = target_result.position
if target_group == "_away":
if target_collider:
loc = target_position
path = [npc_pos, loc]
else:
var metaai = tick.blackboard.get("metaai")
var astar: AStar = metaai.astar
var start = astar.get_closest_point(npc_pos)
var end = astar.get_closest_point(loc)
path = astar.get_point_path(start, end)
if start == end && npc_pos.distance_to(loc) > 2.0:
path = []
if path.size() == 0:
path = [npc_pos, loc]
# assert(path.size() > 0)
# print("BTBuildPath: ", npc.name, " ", path.size(), ": ", path)
if path.size() == 0:
path = [npc_pos, loc]
npc.set_meta("path", path)
if !npc.get_meta("target_group") in ["_player", "_away", "female", "male"]:
npc.set_meta("path_valid", 1.0)
else:
npc.set_meta("path_valid", 0.3)
# if npc.get_meta("target_group") == "hide_spot":
# print("hide_spot: path: ", path)
return OK
# print("path failed")
return FAILED
+26
View File
@@ -0,0 +1,26 @@
extends BTCondition
class_name BTCanGrab
func tick(tick: Tick) -> int:
var npc = tick.actor
var bb = tick.blackboard
if !npc.is_in_group("guard"):
return FAILED
if npc.get_meta("action") == "forcing":
return FAILED
var enemy = bb.get("closest_enemy")
if !enemy:
return FAILED
var enemy_pos = enemy.global_transform.origin
var npc_pos = npc.global_transform.origin
var space_state = npc.get_world().direct_space_state
var result
var up = npc.orientation.basis[1] * 0.9
var dir = (enemy_pos - npc_pos).normalized() * 1.2
result = space_state.intersect_ray(npc_pos + up, npc_pos + dir + up,
[npc], 0xffff)
if result.has("collider"):
if result.collider == enemy:
return OK
return FAILED
+5
View File
@@ -0,0 +1,5 @@
extends BTCondition
class_name BTCanHide
func tick(tick: Tick) -> int:
return FAILED
+28
View File
@@ -0,0 +1,28 @@
extends BTCondition
class_name BTCanThrow
func tick(tick: Tick) -> int:
var npc = tick.actor
var bb = tick.blackboard
var weapon = npc.get_meta("weapon")
if npc.is_in_group("guard"):
return FAILED
if !weapon && !npc.is_in_group("guard"):
return FAILED
var enemy = bb.get("closest_enemy")
if !enemy:
return FAILED
var enemy_pos = enemy.global_transform.origin
var npc_pos = npc.global_transform.origin
var space_state = npc.get_world().direct_space_state
var result
var up = npc.orientation.basis[1] * 0.9
var dir = (enemy_pos - npc_pos).normalized() * 10.0
result = space_state.intersect_ray(npc_pos + up, npc_pos + dir + up,
[npc], 0xffff)
if result.has("collider"):
if result.collider == enemy:
return OK
return FAILED
+4
View File
@@ -0,0 +1,4 @@
extends BTBase
class_name BTCondition
func tick(_tick: Tick) -> int:
return OK
+25
View File
@@ -0,0 +1,25 @@
extends BTAction
class_name BTFetchPathPoint
func tick(tick: Tick) -> int:
var npc = tick.actor
var path = Array(npc.get_meta("path"))
var valid = npc.get_meta("path_valid")
if valid <= 0.0:
# print("no valid path1")
npc.do_stop()
return FAILED
if path.size() == 0:
# print("no valid path2")
npc.do_stop()
return FAILED
var point = path[0]
var npc_pos = npc.global_transform.origin
if npc_pos.distance_to(point) < 0.5:
if path.size() > 0:
point = path.pop_front()
point.y = npc_pos.y
npc.set_meta("path_point", point)
npc.set_meta("path", path)
# print("fetched path point: ", point)
return OK
+13
View File
@@ -0,0 +1,13 @@
extends BTAction
class_name BTGiveUp
func tick(tick: Tick) -> int:
var npc = tick.actor
# var bb = tick.blackboard
var p = []
p = [
["travel", "parameters/main/playback", "Motion"],
["travel", "parameters/main/Motion/playback", "kneel"]
]
npc.smart_obj(p)
return OK
+16
View File
@@ -0,0 +1,16 @@
extends BTAction
class_name BTGrab
func tick(tick: Tick) -> int:
var npc = tick.actor
var bb = tick.blackboard
if npc.get_meta("agression") < 100.0:
return FAILED
var pattack = npc.get_meta("agression") / 1000.0
if pattack < randf():
return FAILED
if !npc.get_meta("grabbing"):
var best = bb.get("closest_enemy")
if !best:
return FAILED
grabbing.grab_character(npc, best)
return OK
+19
View File
@@ -0,0 +1,19 @@
extends BTCondition
class_name BTHasArrived
func tick(tick: Tick) -> int:
var npc = tick.actor
var tgt = npc.get_meta("target_loc")
var point = npc.get_meta("path_point")
var npc_pos = npc.global_transform.origin
# print("target: ", tgt, " point: ", point, " pos: ", npc_pos)
if point.distance_to(tgt) < 0.2:
# print("arrived1")
npc.set_meta("path_valid", 0.0)
return OK
if npc_pos.distance_to(tgt) < 0.4:
# print("arrived2")
npc.set_meta("path_valid", 0.0)
return OK
# print(npc.name, " distance: ", npc_pos.distance_to(tgt))
return FAILED
+9
View File
@@ -0,0 +1,9 @@
extends BTCondition
class_name BTHasWeapon
func tick(tick: Tick) -> int:
assert(tick.actor.has_meta("weapon"))
var objmeta = tick.actor.get_meta("weapon")
if objmeta:
return OK
return FAILED
+16
View File
@@ -0,0 +1,16 @@
extends BTCondition
class_name BTIsAction
export var action = "attack"
func tick(tick: Tick) -> int:
var npc = tick.actor
var ameta = npc.get_meta("action")
assert(ameta.length() > 0)
if action == ameta:
# print("is action:", action)
# if action == "hide":
# print("action = hide")
# print(npc.name, " action ok, ", ameta)
return OK
# print("not action: ", action, " action = ", ameta)
return FAILED
+9
View File
@@ -0,0 +1,9 @@
extends BTCondition
class_name BTIsFree
func tick(tick: Tick) -> int:
var npc = tick.actor
if npc.get_meta("smart_object"):
return FAILED
if npc.get_meta("grabbed"):
return FAILED
return OK
+11
View File
@@ -0,0 +1,11 @@
extends BTCondition
class_name BTIsPlayerNearby
export var min_distance = 6.0
func tick(tick: Tick) -> int:
var metaai = tick.blackboard.get("metaai")
var player = metaai.player
var npc = tick.actor
if combat.player_nearby(npc, min_distance):
return OK
return FAILED
+105
View File
@@ -0,0 +1,105 @@
extends BTAction
class_name BTLookAtPath
func tick(tick: Tick) -> int:
var npc = tick.actor
var bb = tick.blackboard
var point = npc.get_meta("path_point")
# print("look path point: ", point)
# var space_state = npc.get_world().direct_space_state
var result
var correction = 0
var xf = Transform()
# var right = npc.orientation.basis[0] * 0.2
# var front = - npc.orientation.basis[2]* 1.2
# var up = npc.orientation.basis[1] * 0.9
var front_result = bb.get("front_result")
if front_result.has("collider"):
correction |= (1 << 0)
result = bb.get("front_right_result")
if result.has("collider"):
correction |= (1 << 1)
result = bb.get("front_left_result")
if result.has("collider"):
correction |= (1 << 2)
# if correction != 0:
# npc.do_stop()
# 1 = FRONT
# 2 = RIGHT
# 4 = LEFT
if !npc.has_meta("unp_c"):
npc.set_meta("unp_c", (PI/1.5 + PI / 4.0 * randf()) * sign(0.5 - randf()))
var c_angle = npc.get_meta("unp_c")
match(correction):
1, 6, 7:
xf = npc.orientation.rotated(Vector3(0, 1, 0), c_angle)
# npc.orientation.basis = xf.basis
if randf() > 0.6:
npc.smart_obj([["set", "parameters/unstuck1/active", "true"]])
elif randf() > 0.4:
npc.smart_obj([["set", "parameters/unstuck2/active", "true"]])
elif randf() > 0.2:
npc.smart_obj([["set", "parameters/turn_right/active", "true"]])
elif randf() > 0.1:
npc.smart_obj([["set", "parameters/turn_left/active", "true"]])
print("correction: ", correction)
# npc.do_stop()
npc.set_meta("walk_cooldown", 2.0)
# return FAILED
2, 3:
npc.smart_obj([["set", "parameters/turn_left/active", "true"]])
npc.set_meta("walk_cooldown", 0.5)
# return FAILED
4, 5:
npc.smart_obj([["set", "parameters/turn_right/active", "true"]])
npc.set_meta("walk_cooldown", 0.5)
# return FAILED
# 1, 2, 3, 4, 5, 6, 7:
# npc.orientation.basis = npc.orientation.interpolate_with(xf, tick.blackboard.get("delta")).basis
# if !npc.has_meta("path_point"):
# npc.do_stop()
if correction in [0, 1, 2, 3, 4, 5]:
var path = npc.get_meta("path")
var npc_pos = npc.global_transform.origin
point.y = npc_pos.y
var dir = Vector3()
if path.size() > 2:
var p1 = path[0]
var p2 = path[1]
p1.y = npc_pos.y
p2.y = npc_pos.y
var dir1 = (point - npc_pos).normalized()
var dir2 = (p1 - npc_pos).normalized()
var dir3 = (p2 - npc_pos).normalized()
dir = (dir1 * 0.9 + dir2 * 0.5 + dir3 * 0.5).normalized()
else:
dir = (point - npc_pos).normalized()
var npc_xform = npc.global_transform
# print("dir: ", dir)
if front_result.has("collider"):
var steer = front_result.normal * 1.5
steer.y = 0.0
dir = (dir + steer).normalized()
if dir.length() > 0:
xf = npc_xform.looking_at(npc_pos + dir, Vector3(0, 1, 0))
npc.orientation.basis = npc.orientation.basis.slerp(xf.basis, tick.blackboard.get("delta"))
# for k in get_tree().get_nodes_in_group("debug_cube"):
# k.queue_free()
# var cube = CubeMesh.new()
# cube.size = Vector3(0.5, 0.5, 0.5)
# var mi = MeshInstance.new()
# mi.mesh = cube
# var r = get_node("/root")
# r.add_child(mi)
# mi.global_transform.origin = point
# mi.add_to_group("debug_cube")
# if !correction in [0, 2, 4]:
# npc.remove_meta("path")
# npc.remove_meta("path_valid")
# npc.remove_meta("target_loc")
# npc.remove_meta("target_group")
# npc.set_meta("path_cooldown", 1.0)
# print("correction: ", correction)
return OK
+12
View File
@@ -0,0 +1,12 @@
extends BTBase
class_name BTParallel
func tick(tick: Tick) -> int:
var _result := OK #if we have no children, assume success
for child in get_children():
var x_result = child._execute(tick)
assert(typeof(x_result) == TYPE_INT)
_result = x_result
return OK
+16
View File
@@ -0,0 +1,16 @@
extends BTBase
class_name BTSelector
func tick(tick: Tick) -> int:
var result := OK #if we have no children, assume success
for child in get_children():
var _result = child._execute(tick)
assert(typeof(_result) == TYPE_INT)
result = _result
if not result == FAILED:
break
return result
+16
View File
@@ -0,0 +1,16 @@
extends BTBase
class_name BTSequence
func tick(tick: Tick) -> int:
var result := OK #if we have no children, assume success
for child in get_children():
var _result = child._execute(tick)
assert(typeof(_result) == TYPE_INT)
result = _result
if not result == OK:
break
return result
+175
View File
@@ -0,0 +1,175 @@
extends BTAction
class_name BTSetAction
export var min_distance = 9.0
#func utility_player_nearby(tick):
# var player = global.player
# var npc = tick.actor
# if combat.player_nearby(npc, min_distance):
# var player_pos = player.global_transform.origin
# var npc_pos = npc.global_transform.origin
# var dst = player_pos.distance_to(npc_pos)
# if dst < min_distance:
# return 1.0 - dst / min_distance
# return 0.0
func utility_enemy_nearby(tick: Tick):
var bb = tick.blackboard
var npc = tick.actor
var enemy = bb.get("closest_enemy")
# var enemy_dist = bb.get("closest_enemy_distance")
if !enemy:
return 0.0
var enemy_pos = enemy.global_transform.origin
var npc_pos = npc.global_transform.origin
var dst = enemy_pos.distance_to(npc_pos)
if dst < min_distance:
# print("nearby: ", 1.0 - dst / min_distance)
return clamp(1.0 - dst / min_distance, 0.0, 1.0)
return clamp(1.0 / (1.0 + 10.0 * dst * dst), 0.0, 1.0)
func utility_attack(tick):
var npc = tick.actor
var ret = utility_enemy_nearby(tick) * npc.get_meta("agression") / 100.0
if npc.get_meta("weapon") == false:
ret = 0.0
if utility_enemy_nearby(tick) > 0.5:
ret *= 0.2
if utility_enemy_nearby(tick) > 0.5 && npc.is_in_group("guard"):
ret = 1.0
if npc.is_in_group("maid"):
ret = 0.0
return clamp(ret, 0.0, 1.0)
func utility_can_hide(tick):
var npc = tick.actor
var ret = 0.0
if rpg.get_stamina(npc) * rpg.get_health(npc) > 0.1:
ret = 1.0
if utility_enemy_nearby(tick) > 0.85:
ret = 0.1
return ret
func utility_hide(tick):
var npc = tick.actor
if npc.is_in_group("guard"):
return 0.0
if utility_enemy_nearby(tick) > 0.9:
return 0.0
return clamp(utility_can_hide(tick) * (0.1 + utility_enemy_nearby(tick)), 0.0, 1.0)
func utility_run_away(tick):
var npc = tick.actor
var ret = utility_enemy_nearby(tick) * (1.0 + npc.get_meta("panic"))
print(ret)
# if npc.is_in_group("maid"):
# ret = utility_player_nearby(tick) * 0.1 * npc.get_meta("panic")
if npc.get_meta("weapon") == false:
ret *= 2.5
if npc.is_in_group("guard"):
return 0.0
if npc.is_in_group("maid"):
return clamp(ret, 0.0, 0.1)
return clamp(ret, 0.0, 1.0)
func utility_find_weapon(tick):
var npc = tick.actor
if npc.get_meta("weapon") == true:
return 0.0
if get_tree().get_nodes_in_group("weapons").size() == 0:
return 0.0
if npc.is_in_group("guard"):
return 0.0
if npc.is_in_group("maid"):
return 0.0
return 1.0 / (1.0 + utility_enemy_nearby(tick))
func utility_wash_floor(tick):
var npc = tick.actor
if npc.is_in_group("maid"):
return 1.0
return 0.0
func utility_patrol(tick):
var npc = tick.actor
if npc.is_in_group("guard"):
return 1.0
return 0.0
func utility_unstuck(tick):
var npc = tick.actor
if npc.has_meta("stuck"):
var stuck = npc.get_meta("stuck")
if stuck > 0.0:
return 1.0
else:
npc.set_meta("stuck", null)
return 0.0
func utility_give_up(tick):
var npc = tick.actor
if npc.is_in_group("guard"):
return 0.0
elif npc.is_in_group("maid"):
return clamp(rpg.get_panic(npc) / 100.0, 0.0, 1.0)
else:
return clamp(rpg.get_panic(npc) / 1000.0, 0.0, 1.0)
func utility_deliver_captive(tick):
var npc = tick.actor
if npc.get_meta("grabbing"):
var item = grabbing.get_grabbed(npc)
if item.is_in_group("captive"):
return 1.0
else:
return 0.0
func utility_forcing(tick):
var npc = tick.actor
var bb = tick.blackboard
if npc.is_in_group("female"):
return 0.0
if npc.get_meta("grabbing"):
return 0.0
if npc.get_meta("grabbed"):
return 0.0
if !npc.is_in_group("guard"):
if utility_enemy_nearby(tick) * 100.0 > 1.0:
return 0.0
var closest_f = bb.get("closest_visible_female")
var xd = bb.get("closest_visible_female_distance")
if !closest_f:
closest_f = bb.get("closest_female")
xd = bb.get("closest_female_distance")
if !closest_f:
return 0.0
var d = (1.0 + 0.1 * rpg.get_lust(npc)) / (1.0 + xd)
return clamp(d, 0.0, 1.0)
var actions = {
"unstuck": 200.0,
"attack": 40.0,
"hide": 40.0,
"run_away": 6500.0,
"find_weapon": 30.0,
"wash_floor": 30.0,
"patrol": 20.0,
"deliver_captive": 20.0,
"forcing": 4000.0,
"give_up": 210.0
}
func tick(tick: Tick) -> int:
var npc = tick.actor
if !npc.has_meta("action"):
npc.set_meta("action", "")
var current_action = npc.get_meta("action")
var current_score = 0.0
# var old_action = current_action
# if actions.has(current_action):
# current_score = actions[current_action] * 1.5
if current_action == "":
print("score: ", current_score)
for k in actions.keys():
var score = call("utility_" + k, tick) * actions[k]
if k == current_action:
score *= 1.5
if current_score < score:
current_score = score
current_action = k
if current_action == "":
print("utility_" + k, " ", actions[k], " ", score)
npc.set_meta("action", current_action)
print(npc.name)
assert(npc.get_meta("action").length() > 0)
print(npc.name, " ", current_action)
assert(current_action.length() > 0)
return OK
+85
View File
@@ -0,0 +1,85 @@
extends BTAction
class_name BTSetDestinationGroup
export var dst_group: String = ""
#func add_loc_marker(tgt):
# for k in get_tree().get_nodes_in_group("debug_loc_marker"):
# k.queue_free()
# var cube = CubeMesh.new()
# cube.size = Vector3(0.2, 3.0, 0.2)
# var mi = MeshInstance.new()
# mi.mesh = cube
# get_node("/root").add_child(mi)
# mi.global_transform.origin = tgt
# mi.add_to_group("debug_loc_marker")
func tick(tick: Tick) -> int:
var dst = INF
var tgt = Vector3()
var npc = tick.actor
var bb = tick.blackboard
var npc_pos = npc.global_transform.origin
var player_pos = global.player.global_transform.origin
var enemy
enemy = bb.get("closest_enemy")
if !enemy:
enemy = bb.get("last_enemy")
var enemy_pos = Vector3()
if enemy:
enemy_pos = enemy.global_transform.origin
if dst_group == "_away":
assert(enemy)
var dir = (npc_pos - enemy_pos).normalized() * 80.0
tgt = npc_pos + dir
npc.set_meta("target_group", dst_group)
npc.set_meta("target_loc", tgt)
# print("run away ", npc.get_meta("action"))
# add_loc_marker(tgt)
return OK
elif dst_group == "_player":
# print("dst group player ", npc.name)
tgt = player_pos
npc.set_meta("target_group", dst_group)
npc.set_meta("target_loc", tgt)
# add_loc_marker(tgt)
# print("chase player ", npc.get_meta("action"))
return OK
elif dst_group == "_enemy":
# print("dst group enemy ", npc.name)
tgt = enemy_pos
npc.set_meta("target_group", dst_group)
npc.set_meta("target_loc", tgt)
# add_loc_marker(tgt)
# print("chase player ", npc.get_meta("action"))
return OK
elif dst_group == "_patrol":
var points = get_tree().get_nodes_in_group("patrol")
if points.size() > 0:
var c = points[randi() % points.size()]
var tpos = c.global_transform.origin
var ndst = tpos.distance_squared_to(npc_pos)
dst = ndst
tgt = tpos
# print("set target: ", tgt)
npc.set_meta("target_group", dst_group)
npc.set_meta("target_loc", tgt)
# add_loc_marker(tgt)
return OK
# print("dst ", npc.get_meta("action"), " ", dst_group)
for c in get_tree().get_nodes_in_group(dst_group):
if c is Spatial:
# print(c.name)
var tpos = c.global_transform.origin
var ndst = tpos.distance_squared_to(npc_pos)
if dst > ndst:
dst = ndst
tgt = tpos
# print("dst: ", dst)
if dst < 100000.0:
# print("set target: ", tgt)
npc.set_meta("target_group", dst_group)
npc.set_meta("target_loc", tgt)
# add_loc_marker(tgt)
# print("set to: ", dst_group)
# if dst_group == "hide_spot":
# print("hiding to ", tgt)
return OK
return FAILED
+19
View File
@@ -0,0 +1,19 @@
extends BTAction
class_name BTSpawnSmartObj
export(String, MULTILINE) var animation_script = ""
func tick(tick: Tick) -> int:
var npc = tick.actor
var bb = tick.blackboard
var s = bb.get("closest_female")
var root = get_node("/root")
var so = SmartObject.new()
root.add_child(so)
var npc_pos = npc.global_transform.origin
so.global_transform = npc.global_transform
var other_pos = s.global_transform.origin
if npc_pos.distance_to(other_pos) > 0.5:
return FAILED
so.activate2(npc, s, animation_script)
return OK
+7
View File
@@ -0,0 +1,7 @@
extends BTAction
class_name BTStop
func tick(tick: Tick) -> int:
var npc = tick.actor
npc.do_stop()
# print(npc.name, " stand")
return OK
+21
View File
@@ -0,0 +1,21 @@
extends BTAction
class_name BTThrowWeapon
func tick(tick: Tick) -> int:
var npc = tick.actor
if npc.get_meta("agression") < 100.0:
return FAILED
var pattack = npc.get_meta("agression") / 1000.0
if pattack < randf():
return FAILED
npc.set_meta("weapon", false)
var dir = (global.player.global_transform.origin - npc.global_transform.origin).normalized()
var look = npc.global_transform.looking_at(global.player.global_transform.origin, Vector3(0, 1, 0))
npc.orientation.basis = npc.orientation.basis.slerp(look.basis, 3.0 * get_process_delta_time())
var v1 = Vector2(npc.orientation.basis[2].x, npc.orientation.basis[2].z).normalized()
var v2 = -Vector2(dir.x, dir.z).normalized()
if abs(v1.angle_to(v2)) < PI / 9.00:
npc.do_attack()
return OK
else:
return ERR_BUSY
+46
View File
@@ -0,0 +1,46 @@
#Created by the tree and passed to nodes, this lets nodes know which tree they belong to, and gives them a reference to the blackboard being used for this tick.
#It also holds the list of currently open nodes
#Can be extended to do nodeCount and send debug info
extends Node
class_name Tick
var tree
var open_nodes := []
#var node_count
var debug: bool
var actor
var blackboard: Blackboard
func open_node(node) -> void:
if debug:
print("Opening node '%s'" % node.name)
func enter_node(node) -> void:
open_nodes.push_back(node)
if debug:
print("Entering node '%s'" % node.name)
func tick_node(node) -> void:
if debug:
print("Ticking node '%s'" % node.name)
func close_node(node) -> void:
if open_nodes.has(node):
open_nodes.remove(open_nodes.find(node))
if debug:
print("Closing node '%s'" % node.name)
func exit_node(node) -> void:
if debug:
print("Exiting node '%s'" % node.name)
+62
View File
@@ -0,0 +1,62 @@
extends BTAction
class_name BTUnstuck
func npc_stuck(npc, cond):
if cond:
if npc.has_meta("stuck"):
var stuck = npc.get_meta("stuck")
stuck += 2.0 * get_process_delta_time()
npc.set_meta("stuck", stuck)
else:
npc.set_meta("stuck", 2.0 * get_process_delta_time())
print(npc.name, " stuck ", npc.get_meta("stuck"))
else:
if npc.has_meta("stuck"):
var stuck = npc.get_meta("stuck")
stuck -= 3.0 * get_process_delta_time()
print(npc.name, " unstucking: ", stuck)
if stuck > 0.01:
npc.set_meta("stuck", stuck)
else:
npc.set_meta("stuck", null)
func tick(tick: Tick) -> int:
var npc = tick.actor
var bb = tick.blackboard
var p = []
return FAILED
if randf() > 0.5:
p = [
["set", "parameters/main/Motion/walk/walking/blend_position", 1.0],
["set", "parameters/unstuck1/active", true]
]
else:
p = [
["set", "parameters/main/Motion/walk/walking/blend_position", 1.0],
["set", "parameters/unstuck2/active", true]
]
npc.smart_obj(p)
var front_result = bb.get("front_result")
var front_left_result = bb.get("front_left_result")
var front_right_result = bb.get("front_right_result")
var front_col = false
var left_col = false
var right_col = false
if front_result.has("collider"):
var col = front_result.collider
if !col.is_in_group("entry"):
front_col = true
if front_left_result.has("collider"):
var col = front_left_result.collider
if !col.is_in_group("entry"):
left_col = true
if front_right_result.has("collider"):
var col = front_right_result.collider
if !col.is_in_group("entry"):
right_col = true
if right_col && left_col || front_col:
npc_stuck(npc, true)
else:
npc_stuck(npc, false)
return OK
+20
View File
@@ -0,0 +1,20 @@
extends BTCondition
class_name BTIsPathValid
func tick(tick: Tick) -> int:
var npc = tick.actor
if npc.has_meta("path"):
var path = npc.get_meta("path")
if path:
var valid = npc.get_meta("path_valid")
var delta = tick.blackboard.get("delta")
valid -= delta
if valid <= 0.0:
npc.remove_meta("path")
npc.remove_meta("path_valid")
return FAILED
npc.set_meta("path_valid", valid)
# print("path valid: ", valid, " path:", path)
return OK
npc.do_stop()
# print("invalid path: ", npc.name, ", action = ", npc.get_meta("action"))
return FAILED
+174
View File
@@ -0,0 +1,174 @@
extends BTAction
class_name BTWalk
#func npc_stuck(npc, cond):
# if cond:
# if npc.has_meta("stuck"):
# var stuck = npc.get_meta("stuck")
# stuck += 2.0 * get_process_delta_time()
# npc.set_meta("stuck", stuck)
# else:
# npc.set_meta("stuck", 0.4 * get_process_delta_time())
# print(npc.name, " stuck ", npc.get_meta("stuck"))
# else:
# if npc.has_meta("stuck"):
# var stuck = npc.get_meta("stuck")
# stuck -= 0.1 * get_process_delta_time()
# print(npc.name, " unstucking: ", stuck)
# if stuck > 0.0:
# npc.set_meta("stuck", stuck)
# else:
# npc.set_meta("stuck", null)
#func is_npc_stuck(npc):
# if npc.has_meta("stuck"):
# var stuck = npc.get_meta("stuck")
# if stuck > 0.0:
# return true
# return false
func tick(tick: Tick) -> int:
var npc = tick.actor
var bb = tick.blackboard
# npc.disable_gravity = false
if npc.has_meta("walk_cooldown"):
var cd = npc.get_meta("walk_cooldown")
if cd >= 0.0:
cd -= get_process_delta_time()
npc.set_meta("walk_cooldown", cd)
return FAILED
else:
npc.remove_meta("walk_cooldown")
if npc.has_meta("action"):
if npc.get_meta("action") == "run_away":
var p = [["set", "parameters/main/Motion/walk/walking/blend_position", 1.0]]
npc.smart_obj(p)
elif npc.get_meta("action") == "unstuck":
return OK
else:
var p = [["set", "parameters/main/Motion/walk/walking/blend_position", 0.0]]
npc.smart_obj(p)
# var front = - npc.orientation.basis[2]* 0.6
# var up = npc.orientation.basis[1]
# var npc_pos = npc.global_transform.origin
# var space_state = npc.get_world().direct_space_state
# var front_result = space_state.intersect_ray(npc_pos + up, npc_pos + up + front,
# [npc], 0xffff)
var front_result = bb.get("front_result")
# var front_left_result = bb.get("front_left_result")
# var front_right_result = bb.get("front_right_result")
var low_obstacle_result: = {}
for k in ["low_obstacle_result"]:
low_obstacle_result = bb.get("low_obstacle_result")
if low_obstacle_result.has("collider"):
break
var front_col = false
# var left_col = false
# var right_col = false
var low_obstacle = false
if front_result.has("collider"):
var col = front_result.collider
if !col.is_in_group("entry"):
front_col = true
front_col = true
# if front_left_result.has("collider"):
# var col = front_left_result.collider
# if !col.is_in_group("entry"):
# left_col = true
# left_col = true
# if front_right_result.has("collider"):
# var col = front_right_result.collider
# if !col.is_in_group("entry"):
# right_col = true
# right_col = true
if !front_col:
if low_obstacle_result.has("collider"):
var col = low_obstacle_result.collider
if !col.is_in_group("entry"):
low_obstacle = true
if low_obstacle:
# npc.disable_gravity = true
var c = [["set", "parameters/climb_low_obstacle/active", true]]
npc.smart_obj(c)
else:
npc.do_walk()
# if !low_obstacle && !front_col:
## npc_stuck(npc, false)
# npc.do_walk()
## if npc.has_meta("stuck"):
## npc.set_meta("stuck", null)
# return OK
# elif !low_obstacle && front_col:
# var normal = front_result.normal
# var xnormal = npc.global_transform.xform_inv(normal)
# print("xnormal ", xnormal)
# var rot: Basis = npc.orientation.basis
# var ok = false
# if xnormal.z < 0:
# rot = rot.rotated(Vector3(0, 1, 0), deg2rad(-20 + 3.0 * (0.5 - randf())))
# ok = true
# elif xnormal.z > 0:
# rot = rot.rotated(Vector3(0, 1, 0), deg2rad(20 + 3.0 * (0.5 - randf())))
# ok = true
## else:
## rot = rot.rotated(Vector3(0, 1, 0), deg2rad(10 + 10.0 * (0.5 - randf())))
# var cur: Basis = npc.orientation.basis
# cur = cur.slerp(rot, get_process_delta_time())
# npc.orientation.basis = cur
# if ok:
# npc.do_walk()
# return OK
# elif !low_obstacle && left_col && !right_col:
# var rot: Basis = npc.orientation.basis.rotated(Vector3(0, 1, 0), deg2rad(-30))
# var cur: Basis = npc.orientation.basis
# cur = cur.slerp(rot, get_process_delta_time())
# npc.orientation.basis = cur
# npc_stuck(npc, false)
# if !is_npc_stuck(npc):
# npc.do_walk()
# return OK
# elif !low_obstacle && !left_col && right_col:
# var rot: Basis = npc.orientation.basis.rotated(Vector3(0, 1, 0), deg2rad(30))
# var cur: Basis = npc.orientation.basis
# cur = cur.slerp(rot, get_process_delta_time())
# npc.orientation.basis = cur
# npc_stuck(npc, false)
# if !is_npc_stuck(npc):
# npc.do_walk()
# return OK
# elif !low_obstacle && left_col && right_col:
# var rot: Basis = npc.orientation.basis.rotated(Vector3(0, 1, 0), deg2rad(100))
# var cur: Basis = npc.orientation.basis
# cur = cur.slerp(rot, get_process_delta_time())
# npc.orientation.basis = cur
# npc_stuck(npc, false)
# print("correction")
# npc.do_stop()
# if !is_npc_stuck(npc):
# npc.do_walk()
# return OK
# elif !low_obstacle && left_col && right_col:
# var rot: Basis = npc.orientation.basis.rotated(Vector3(0, 1, 0), deg2rad(90))
# var cur: Basis = npc.orientation.basis
# cur = cur.slerp(rot, get_process_delta_time())
# npc.orientation.basis = cur
# npc.do_walk()
# npc_stuck(npc, true)
# return FAILED
# elif !low_obstacle:
# var rot: Basis = npc.orientation.basis.rotated(Vector3(0, 1, 0), deg2rad(-45))
# var cur: Basis = npc.orientation.basis
# cur = cur.slerp(rot, get_process_delta_time())
# npc.orientation.basis = cur
# npc.do_walk()
# if npc.has_meta("stuck"):
# var stuck = npc.get_meta("stuck")
# stuck += 2.0 * get_process_delta_time()
# npc.set_meta("stuck", stuck)
# else:
# npc.set_meta("stuck", 0.0)
# npc_stuck(npc, true)
# return FAILED
return OK
# print(npc.name, " walk")
+13
View File
@@ -0,0 +1,13 @@
extends BTAction
class_name BTWashFloor
func tick(tick: Tick) -> int:
var npc = tick.actor
# var bb = tick.blackboard
var p = []
p = [
["travel", "parameters/main/playback", "Motion"],
["travel", "parameters/main/Motion/playback", "wash_floor"]
]
npc.smart_obj(p)
return OK
+83
View File
@@ -0,0 +1,83 @@
extends Node
var projectile: = preload("res://scenes/weapons/projectile.tscn")
func _ready():
pass # Replace with function body.
var handles = {}
func body_enter(obj, pj):
# if !obj is StaticBody:
# print("body enter: ", obj.name)
if obj.is_in_group("characters"):
rpg.projectile_attack(pj, obj)
rpg.add_agression(obj, 1.3)
# else:
# if obj is StaticBody:
# pj.queue_free()
func register(obj):
assert(obj.is_in_group("characters"))
var obj_path = get_path_to(obj)
var skel = obj.get_skeleton()
var att: = BoneAttachment.new()
att.bone_name = "grabber_R"
skel.add_child(att)
var att_path = get_path_to(att)
handles[obj_path] = att_path
var anim:AnimationPlayer = obj.get_anim_player()
var throw_anim: Animation = anim.get_animation("throw").duplicate()
var track = throw_anim.add_track(Animation.TYPE_METHOD)
throw_anim.track_set_path(track, "/root/combat")
# throw_anim.track_insert_key(track, 0.05, {"method": "shoot", "args": [obj]})
throw_anim.track_insert_key(track, throw_anim.length - 0.02, {"method": "shoot", "args": [obj]})
anim.remove_animation("throw")
var ret = anim.add_animation("throw", throw_anim)
assert(ret == OK)
func shoot(from):
assert(from.is_in_group("characters"))
# print(from.name, " shoots projectile")
var obj_path = get_path_to(from)
var handle_path = handles[obj_path]
var handle = get_node(handle_path)
var from_pos = handle.global_transform.origin
var from_dir = -from.global_transform.basis[2]
# top impulse 6000
# ok = 100
# so-so = 50
var stamina = from.get_meta("stamina")
if stamina > 5:
var impulse = from_dir * (10.0 + clamp(from.get_meta("strength") / 4.0, 0, 10) + randi() % int(clamp((1 + from.get_meta("strength") / 4.0), 0, 5)))
var pj = projectile.instance()
pj.connect("body_entered", self, "body_enter", [pj])
get_node("/root").add_child(pj)
pj.set_meta("owner", from)
pj.global_transform.origin = from_pos
pj.add_collision_exception_with(from)
pj.apply_impulse(Vector3(), impulse)
stamina -= 5 + impulse.length() / (1 + from.get_meta("strength") * 0.1)
if stamina < 0:
stamina = 0
from.set_meta("stamina", stamina)
# print("set stamina to: ", from.name)
func player_nearby(obj, dst):
assert(obj.is_in_group("characters"))
var ppos = global.player.global_transform.origin
var opos = obj.global_transform.origin
if opos.distance_to(ppos) < dst:
return true
return false
func enemy_nearby(obj, dst):
if !obj.is_in_group("npc"):
return false
var bb = obj.get_node("blackboard")
var enemy = bb.get("last_enemy")
if enemy:
var ppos = enemy.global_transform.origin
var opos = obj.global_transform.origin
if opos.distance_to(ppos) < dst:
return true
return false
+54
View File
@@ -0,0 +1,54 @@
extends Node
var raycasts_count = 100
var raycast_queue = []
func _ready():
set_save_slot(0)
func visibility_check(ch1, ch2):
var direction: Vector3 = -ch1.global_transform.basis[2].normalized()
var to_ch2: Vector3 = (ch2.global_transform.origin - ch1.global_transform.origin).normalized()
var angle = direction.angle_to(to_ch2)
if abs(angle) < PI / 2.0:
var space_state = ch1.get_world().direct_space_state
var ch1_pos = ch1.global_transform.origin
var ch2_pos = ch2.global_transform.origin
var up = Vector3(0, 0.6, 0)
var front_result = space_state.intersect_ray(ch1_pos + up, ch2_pos + up,
[ch1, ch2], 0xffff)
if !front_result.has("collider"):
return true
return false
var player = null
var smart_object = []
const save_slot_base = "user://save"
var save_slot = ""
func set_save_slot(id: int):
save_slot = save_slot_base + str(id)
var save_data: Dictionary = {}
func save_characters():
for k in get_tree().get_nodes_in_group("characters"):
var spawner = k.get_meta("spawner")
var stats = {}
for s in rpg.save_stats:
stats[s] = k.get_meta(s)
spawner.set_meta("stats", stats)
func save_game():
assert(save_slot.length() > 0)
var fd = File.new()
fd.open(save_slot, File.WRITE)
var data = JSON.print(save_data, "\t", true)
fd.store_string(data)
fd.close()
func load_game():
assert(save_slot.length() > 0)
var fd = File.new()
if fd.open(save_slot, File.READ) == OK:
var data = fd.get_as_text()
var parse: = JSON.parse(data)
save_data = parse.result
fd.close()
+123
View File
@@ -0,0 +1,123 @@
extends Node
var grab_queue = []
var ungrab_queue = []
func _ready():
pass # Replace with function body.
func grab_character(gch, ch):
if !ch.get_meta("grabbed"):
ch.set_meta("grabbed", true)
ch.set_meta("grabbed_time", 20.0)
if !ch in grab_queue:
grab_queue.push_back([gch, ch])
gch.set_meta("grabbing", true)
gch.do_grab()
func ungrab_character(gch, finisher = null):
if !grab_data.has(gch):
return
var ch = grab_data[gch].item
ch.set_meta("grabbed", false)
ch.set_meta("grabbed_time", 0.0)
if !ch in ungrab_queue:
if finisher:
ungrab_queue.push_back([gch, ch, finisher])
else:
ungrab_queue.push_back([gch, ch])
gch.set_meta("grabbing", false)
gch.do_ungrab()
var grab_data = {}
func get_grabbed(gch):
if grab_data.has(gch):
return grab_data[gch].item
else:
return null
func get_bone_xform(ch, b):
var skel = ch.get_skeleton()
var bone_id = skel.find_bone(b)
assert(bone_id >= 0)
var xform = skel.get_bone_global_pose(bone_id)
return ch.global_transform * xform
func left_arm_ik_enable(m: Spatial, _s: Spatial, target: Spatial):
# var item_skel = s.get_skeleton()
var main_skel = m.get_skeleton()
var ik: = SkeletonIK.new()
# var xf = get_bone_xform(m, "wrist_L")
var conv = target
ik.root_bone = "upperarm01_L"
ik.tip_bone = "wrist_L"
main_skel.add_child(ik)
var tpath = ik.get_path_to(conv)
ik.target_node = tpath
ik.min_distance = 0.01
ik.magnet = Vector3(-8, -10, 0)
ik.use_magnet = true
ik.start()
m.set_meta("left_arm_ik", m.get_path_to(ik))
func left_arm_ik_disable(m):
if m.has_meta("left_arm_ik"):
var ik = m.get_node(m.get_meta("left_arm_ik"))
# print("ik stopped")
ik.interpolation = 0.0
ik.use_magnet = false
ik.stop()
ik.queue_free()
func left_arm_front_neck_ik_enable(m, s):
var target = s.get_front_neck_target()
left_arm_ik_enable(m, s, target)
func left_arm_front_neck_ik_disable(m):
left_arm_ik_disable(m)
func _physics_process(_delta):
while grab_queue.size() > 0:
var characters = grab_queue.pop_front()
var item: KinematicBody = characters[1]
var gch = characters[0]
if grab_data.has(gch):
continue
grab_data[gch] = {}
item.do_stop()
item.do_grabbed()
gch.add_collision_exception_with(item)
item.add_collision_exception_with(gch)
# item.do_disable_collision()
item.global_transform = gch.global_transform
# var grab_xform = Transform()
# grab_xform.origin = gch.calc_offset(item, "neck02")
grab_data[gch].item = item
# grab_data[gch].grab_attachment = gch.add_attachment(gch.grab_bone, grab_xform)
grab_data[gch].grabbed_mask = item.collision_mask
grab_data[gch].grabbed_parent = item.get_parent()
item.collision_mask = 0
item.get_parent().remove_child(item)
# grab_data[gch].grab_attachment.add_child(item)
gch.add_child(item)
item.transform = Transform()
item.orientation.basis = Basis()
var ik_enable = true
if ik_enable:
left_arm_front_neck_ik_enable(gch, item)
while ungrab_queue.size() > 0:
var characters = ungrab_queue.pop_front()
var item: KinematicBody = characters[1]
var gch = characters[0]
var finisher = null
if characters.size() >= 3:
finisher = characters[2]
var tf = item.global_transform
# print("ik disable")
left_arm_front_neck_ik_disable(gch)
# grab_data[gch].grab_attachment.remove_child(item)
gch.remove_child(item)
grab_data[gch].grabbed_parent.add_child(item)
gch.remove_collision_exception_with(item)
item.remove_collision_exception_with(gch)
item.collision_mask = grab_data[gch].grabbed_mask
item.global_transform = tf
if !finisher:
item.do_stop()
item.do_ungrabbed()
else:
# print("finisher: ", finisher)
item.smart_obj(finisher)
item.set_meta("grabbed", false)
grab_data.erase(gch)
for k in grab_data.keys():
grab_data[k].item.transform = Transform()
+39
View File
@@ -0,0 +1,39 @@
extends Node
enum {STATE_INIT, STATE_SIM, STATE_PAUSE}
var state = STATE_INIT
func _ready():
pass # Replace with function body.
var bone_ids = []
#func _physics_process(delta):
# match(state):
# STATE_INIT:
# for k in get_tree().get_nodes_in_group("female"):
# if !k.is_in_group("characters"):
# continue
# var sk: Skeleton = k.get_skeleton()
# if bone_ids.size() == 0:
# for c in range(sk.get_bone_count()):
# var bn = sk.get_bone_name(c)
# if bn.begins_with("skirt"):
# var pose = sk.get_bone_global_pose(c)
# sk.set_bone_global_pose_override(c, pose, 1.0)
# bone_ids.push_back(c)
# if bone_ids.size() > 0:
# state = STATE_SIM
# STATE_SIM:
# for k in get_tree().get_nodes_in_group("female"):
# if !k.is_in_group("characters"):
# continue
# var sk: Skeleton = k.get_skeleton()
# for c in bone_ids:
# var pose = sk.get_bone_global_pose(c)
# pose.origin.y -= 200.0 * delta
# sk.set_bone_global_pose_override(c, pose,1.0)
# state = STATE_PAUSE
# STATE_PAUSE:
# yield(get_tree().create_timer(0.1), "timeout")
# state = STATE_SIM
+286
View File
@@ -0,0 +1,286 @@
extends Node
func _ready():
pass # Replace with function body.
var stats = {
"health": {"rise": 0.0005, "base": 100, "random": 1000, "bonus": 10000},
"stamina": {"rise": 0.0012, "base": 100, "random": 1000, "bonus": 10000},
"strength": {"rise": 0.0, "base": 100, "random": 1000, "bonus": 10000},
"agility": {"rise": 0.0, "base": 100, "random": 1000, "bonus": 10000},
"intelligence": {"rise": 0.0, "base": 100, "random": 1000, "bonus": 10000},
}
var needs = {
"hunger": {
"stat": "max_health",
"mul": 0.001
},
"thirst": {
"stat": "max_health",
"mul": 0.001
},
"lust": {
"stat": "strength",
"mul": 0.002
}
}
func create_stats(obj):
assert(obj.is_in_group("characters"))
for k in stats.keys():
var kmax = "max_" + k
var val = stats[k].base + randi() % stats[k].random
obj.set_meta(k, val)
obj.set_meta(kmax, val)
obj.set_meta("submission", 0)
obj.set_meta("agression", 0)
obj.set_meta("panic", 0)
obj.set_meta("xp", 0)
obj.set_meta("next_xp", 100)
obj.set_meta("level", 1)
for k in needs.keys():
obj.set_meta(k, 0.0)
if obj.is_in_group("guard"):
var st = obj.get_meta("max_strength")
if st < 1000.0:
obj.set_meta("strength", st)
obj.set_meta("max_strength", st)
var sm = obj.get_meta("max_stamina")
if sm < 2000.0:
obj.set_meta("stamina", sm)
obj.set_meta("max_stamina", sm)
if obj.is_in_group("maid"):
var subm = obj.get_meta("submission")
if subm < 1000.0:
obj.set_meta("submission", subm)
var save_stats = [
"health",
"stamina",
"strength",
"agility",
"intelligence",
"submission",
"xp",
"next_xp",
"level"]
func update_needs(obj):
for k in needs.keys():
var s = needs[k].stat
var m = needs[k].mul
var nval = obj.get_meta(k)
nval += obj.get_meta(s) * m * get_process_delta_time()
obj.set_meta(k, nval)
func update_stats(obj):
assert(obj.is_in_group("characters"))
if obj.get_meta("grabbing"):
return
if obj.get_meta("smart_object"):
return
for k in stats.keys():
var val = obj.get_meta(k)
var max_val = obj.get_meta("max_" + k)
var incr = stats[k].rise * max_val * get_process_delta_time()
# print("incr: ", obj.name, " ", incr)
if val < 0.1 * max_val:
val += 0.3 * incr
else:
val += incr
# print("stat: ", k, " incr: ", incr, " val: ", val)
obj.set_meta(k, clamp(val, 0, max_val))
var sub = get_submission(obj)
var aggr = get_agression(obj)
var pnc = get_panic(obj)
var pnc_inc = 0.0
var aggr_inc = 0.0
if combat.enemy_nearby(obj, 4.0):
pnc_inc += 1.0 / (1.0 + sub * 2.0)
aggr_inc += get_strength(obj) / (1.0 + pnc + sub)
if obj.is_in_group("maid"):
pnc_inc *= 0.1
elif obj.is_in_group("guard"):
pnc_inc = 0.0
else:
pnc_inc -= 0.5 * (get_strength(obj) + (1.0 + sub))
if obj.is_in_group("maid"):
pnc_inc *= 100.0
if obj.is_in_group("guard"):
pnc_inc *= 200.0
if obj.is_in_group("maid"):
pnc_inc *= 0.1
aggr += aggr_inc * get_process_delta_time()
pnc += pnc_inc * get_process_delta_time()
aggr = clamp(aggr, 0.0, 100000.0)
pnc = clamp(pnc, 0.0, 100000.0)
obj.set_meta("panic", pnc)
obj.set_meta("agression", aggr)
func level_up(obj):
assert(obj.is_in_group("characters"))
var level = obj.get_meta("level")
var next_xp = obj.get_meta("next_xp")
for k in stats.keys():
var kmax = "max_" + k
if level < 100:
var val = obj.get_meta(kmax) + stats[k].bonus / (100 - level)
obj.set_meta(kmax, val)
obj.set_meta(k, val)
else:
var val = obj.get_meta(kmax) + stats[k].bonus
obj.set_meta(kmax, val)
obj.set_meta(k, val)
if level < 100:
next_xp += int(clamp(level * next_xp / 5, 50, next_xp * 2))
else:
next_xp += int(next_xp * 1.5)
level += 1
dump_stats(obj)
func update_xp(obj, xp):
assert(obj.is_in_group("characters"))
var cur_xp = obj.get_meta("xp")
var next_xp = obj.get_meta("next_xp")
cur_xp += xp
if cur_xp >= next_xp:
level_up(obj)
cur_xp -= next_xp
obj.set_meta("xp", cur_xp)
func can_attack(obj):
assert(obj.is_in_group("characters"))
if obj.get_meta("grabbed"):
return false
if obj.get_meta("smart_object"):
return false
if obj.get_meta("health") <= 0:
return false
if obj.get_meta("stamina") <= 0:
return false
return true
func melee_attack(attacker, enemy):
assert(attacker.is_in_group("characters"))
assert(enemy.is_in_group("characters"))
if !can_attack(attacker):
return
var attack_base = int(attacker.get_meta("strength"))
var attack_bonus = int(attacker.get_meta("agility"))
var attack_val = attack_base + randi() % (1 + attack_bonus)
var defence = enemy.get_meta("agility") + randi() % (1 + int(enemy.get_meta("strength")))
var damage = int(clamp(attack_val - defence, 0, attack_val))
var enemy_health = int(enemy.get_meta("health"))
enemy_health = int(clamp(enemy_health - damage, 0, enemy_health))
enemy.set_meta("health", enemy_health)
var stamina = attacker.get_meta("stamina")
stamina -= damage / (2 + attacker.get_meta("agility"))
attacker.set_meta("stamina", stamina)
if enemy_health == 0:
update_xp(attacker, int(enemy.get_meta("max_health") * 0.1))
else:
update_xp(attacker, int(damage * 0.1))
# dump_stats(enemy)
func projectile_attack(pj, enemy):
var damage = pj.get_mass() * pj.get_linear_velocity().length() * 3.0
# print("DAMAGE: ", damage)
if pj.has_meta("owner"):
var attacker = pj.get_meta("owner")
update_xp(attacker, int(10 + damage))
var enemy_health = int(enemy.get_meta("health"))
enemy_health = int(clamp(enemy_health - damage, 0, enemy_health))
enemy.set_meta("health", enemy_health)
# dump_stats(enemy)
func submission_check(attacker, enemy):
assert(attacker.is_in_group("characters"))
assert(enemy.is_in_group("characters"))
var astrength = attacker.get_meta("strength")
var estrength = enemy.get_meta("strength")
var esub = enemy.get_meta("submission")
if astrength > estrength + esub:
return true
return false
func strength_check(attacker, enemy):
assert(attacker.is_in_group("characters"))
assert(enemy.is_in_group("characters"))
var astrength = attacker.get_meta("strength")
var estrength = attacker.get_meta("strength")
if astrength * 0.5 > estrength:
return true
return false
func dump_stats(obj):
assert(obj.is_in_group("characters"))
# print(stats.keys())
for k in stats.keys():
assert(obj.get_meta(k))
print(k + ": ", obj.get_meta(k))
print("submission: ", obj.get_meta("submission"))
print("xp: ", obj.get_meta("xp"))
print("next_xp: ", obj.get_meta("next_xp"))
print("level: ", obj.get_meta("level"))
func damage_stamina(obj, val):
assert(obj.is_in_group("characters"))
var stamina = obj.get_meta("stamina")
var max_stamina = obj.get_meta("max_stamina")
stamina -= val
obj.set_meta("stamina", clamp(stamina, 0.0, max_stamina))
func get_health(obj):
assert(obj.is_in_group("characters"))
var health = obj.get_meta("health")
return health
func get_stamina(obj):
assert(obj.is_in_group("characters"))
var stamina = obj.get_meta("stamina")
return stamina
func get_strength(obj):
assert(obj.is_in_group("characters"))
var strength = obj.get_meta("strength")
return strength
func get_agression(obj):
assert(obj.is_in_group("characters"))
var agression = obj.get_meta("agression")
return agression
func get_submission(obj):
assert(obj.is_in_group("characters"))
var submission = obj.get_meta("submission")
return submission
func get_panic(obj):
assert(obj.is_in_group("characters"))
var panic = obj.get_meta("panic")
return panic
func get_lust(obj):
assert(obj.is_in_group("characters"))
var lust = obj.get_meta("lust")
return lust
func add_panic(obj, val):
assert(obj.is_in_group("characters"))
var panic = get_panic(obj)
panic += val
obj.set_meta("panic", panic)
func add_agression(obj, val):
assert(obj.is_in_group("characters"))
var agression = get_agression(obj)
agression += val
obj.set_meta("panic", agression)
func is_enemy(ch1, ch2):
var versus = [
["player", "player", false],
["player", "guard", false],
["player", "maid", false],
["player", "captive", true],
["guard", "guard", false],
["guard", "player", false],
["guard", "maid", false],
["guard", "captive", true],
["maid", "maid", false],
["maid", "player", false],
["maid", "guard", true],
["maid", "captive", true],
["captive", "player", true],
["captive", "guard", true],
["captive", "maid", true],
["captive", "captive", false]
]
for e in versus:
if ch1.is_in_group(e[0]) && ch2.is_in_group(e[1]):
return e[2]
return false
+49
View File
@@ -0,0 +1,49 @@
[gd_resource type="ShaderMaterial" load_steps=3 format=2]
[ext_resource path="res://decals/scar-texture.png" type="Texture" id=1]
[sub_resource type="Shader" id=1]
code = "shader_type spatial;
render_mode unshaded, depth_draw_never, cull_front, depth_test_disable;
uniform sampler2D decal : hint_black;
uniform vec2 offset;
uniform vec2 scale;
uniform bool emulate_lighting;
uniform float brightness;
varying flat mat4 model_view_matrix;
void vertex(){
model_view_matrix = MODELVIEW_MATRIX;
}
void fragment(){
//float zdepth = textureLod(DEPTH_TEXTURE, SCREEN_UV, 0.0).r * 2.0 - 1.0;
vec4 pos = inverse(model_view_matrix) * INV_PROJECTION_MATRIX * vec4(SCREEN_UV * 2.0 - 1.0, textureLod(DEPTH_TEXTURE, SCREEN_UV, 0.0).r * 2.0 - 1.0, 1.0);
pos.xyz /= pos.w;
bool inside = all(greaterThanEqual(pos.xyz, vec3(-1.0))) && all(lessThanEqual(pos.xyz, vec3(1.0)));
if(inside){
vec4 color = texture(decal, (pos.xy * -0.5 - 0.5) * scale + offset);
if(emulate_lighting){
float lum = dot(textureLod(SCREEN_TEXTURE, SCREEN_UV, 0).rgb, vec3(0.2125, 0.7154, 0.0721));
lum += brightness;
lum = clamp(lum, 0.0, 1.0);
ALBEDO = color.rgb * lum;
}else{
ALBEDO = color.rgb;
}
ALPHA = color.a;
}else{
discard;
}
}"
[resource]
shader = SubResource( 1 )
shader_param/offset = Vector2( 0.5, 0.5 )
shader_param/scale = Vector2( 20, 20 )
shader_param/emulate_lighting = false
shader_param/brightness = null
shader_param/decal = ExtResource( 1 )
+48
View File
@@ -0,0 +1,48 @@
[gd_scene load_steps=5 format=2]
[ext_resource path="res://decals/decal_test1.tres" type="Material" id=1]
[sub_resource type="CubeMesh" id=1]
[sub_resource type="SpatialMaterial" id=2]
albedo_color = Color( 0.57, 0.35202, 0.2565, 1 )
[sub_resource type="CubeMesh" id=3]
size = Vector3( 0.1, 0.1, 0.01 )
[node name="decal_test" type="Spatial"]
[node name="DirectionalLight" type="DirectionalLight" parent="."]
transform = Transform( 1, 0, 0, 0, 0.707107, 0.707107, 0, -0.707107, 0.707107, 0, 20, 0 )
[node name="cube" type="MeshInstance" parent="."]
mesh = SubResource( 1 )
material/0 = SubResource( 2 )
[node name="decal" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 0.0229489, -0.999737, 0, 0.999737, 0.0229489, -0.208516, 1.00603, -0.087188 )
mesh = SubResource( 3 )
material/0 = ExtResource( 1 )
[node name="decal2" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 0.0229489, -0.999737, 0, 0.999737, 0.0229489, -0.185019, 1.00603, -0.244753 )
mesh = SubResource( 3 )
material/0 = ExtResource( 1 )
[node name="decal3" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 0.0229489, -0.999737, 0, 0.999737, 0.0229489, -0.185019, 1.00603, -0.121742 )
mesh = SubResource( 3 )
material/0 = ExtResource( 1 )
[node name="decal4" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 0.0229489, -0.999737, 0, 0.999737, 0.0229489, -0.185019, 1.00603, -0.18462 )
mesh = SubResource( 3 )
material/0 = ExtResource( 1 )
[node name="decal5" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 0.0229489, -0.999737, 0, 0.999737, 0.0229489, -0.152542, 1.00603, -0.087188 )
mesh = SubResource( 3 )
material/0 = ExtResource( 1 )
[node name="Camera" type="Camera" parent="."]
transform = Transform( 1, 0, 0, 0, 0.726059, 0.687633, 0, -0.687633, 0.726059, 0, 1.57898, 0.848999 )
Binary file not shown.

After

Width:  |  Height:  |  Size: 691 KiB

@@ -0,0 +1,36 @@
[remap]
importer="texture"
type="StreamTexture"
path.s3tc="res://.import/scar-texture.png-94278f85a0f195df31c52d9c1340d370.s3tc.stex"
path.etc2="res://.import/scar-texture.png-94278f85a0f195df31c52d9c1340d370.etc2.stex"
metadata={
"imported_formats": [ "s3tc", "etc2" ],
"vram_texture": true
}
[deps]
source_file="res://decals/scar-texture.png"
dest_files=[ "res://.import/scar-texture.png-94278f85a0f195df31c52d9c1340d370.s3tc.stex", "res://.import/scar-texture.png-94278f85a0f195df31c52d9c1340d370.etc2.stex" ]
[params]
compress/mode=2
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=true
flags/filter=true
flags/mipmaps=true
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0
Binary file not shown.
Binary file not shown.
Binary file not shown.
+13
View File
@@ -0,0 +1,13 @@
Copyright (C) 2008 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
+92
View File
@@ -0,0 +1,92 @@
This Font Software is licensed under the SIL Open Font License,
Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font
creation efforts of academic and linguistic communities, and to
provide a free and open framework in which fonts may be shared and
improved in partnership with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply to
any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software
components as distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to,
deleting, or substituting -- in part or in whole -- any of the
components of the Original Version, by changing formats or by porting
the Font Software to a new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed,
modify, redistribute, and sell modified and unmodified copies of the
Font Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components, in
Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the
corresponding Copyright Holder. This restriction only applies to the
primary font name as presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created using
the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
+45
View File
@@ -0,0 +1,45 @@
The work in the Hack project is Copyright 2018 Source Foundry Authors and licensed under the MIT License
The work in the DejaVu project was committed to the public domain.
Bitstream Vera Sans Mono Copyright 2003 Bitstream Inc. and licensed under the Bitstream Vera License with Reserved Font Names "Bitstream" and "Vera"
### MIT License
Copyright (c) 2018 Source Foundry Authors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
### BITSTREAM VERA LICENSE
Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera is a trademark of Bitstream, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of the fonts accompanying this license ("Fonts") and associated documentation files (the "Font Software"), to reproduce and distribute the Font Software, including without limitation the rights to use, copy, merge, publish, distribute, and/or sell copies of the Font Software, and to permit persons to whom the Font Software is furnished to do so, subject to the following conditions:
The above copyright and trademark notices and this permission notice shall be included in all copies of one or more of the Font Software typefaces.
The Font Software may be modified, altered, or added to, and in particular the designs of glyphs or characters in the Fonts may be modified and additional glyphs or characters may be added to the Fonts, only if the fonts are renamed to names not containing either the words "Bitstream" or the word "Vera".
This License becomes null and void to the extent applicable to Fonts or Font Software that has been modified and is distributed under the "Bitstream Vera" names.
The Font Software may be sold as part of a larger software package but no copy of one or more of the Font Software typefaces may be sold by itself.
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL BITSTREAM OR THE GNOME FOUNDATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.
Except as contained in this notice, the names of Gnome, the Gnome Foundation, and Bitstream Inc., shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Font Software without prior written authorization from the Gnome Foundation or Bitstream Inc., respectively. For further information, contact: fonts at gnome dot org.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+42
View File
@@ -0,0 +1,42 @@
tool
extends EditorScenePostImport
export var save_path = "res://scenes/characters/animation"
var data = {}
func process_anim(ap):
for e in ap.get_animation_list():
var anim_split = e.replace("-loop", "").split("_")
if anim_split.size() < 2:
continue
var anim_name = anim_split[0]
var anim_index = anim_split[1]
var an = ap.get_animation(e)
ResourceSaver.save(save_path + "/" + e + ".anim", an)
if !data.has(anim_name):
data[anim_name] = {}
data[anim_name][anim_index] = e
func create_states():
for k in data.keys():
for l in data[k].keys():
var st: = AnimationNodeBlendTree.new()
st.resource_name = k + "_" + l
var an = AnimationNodeAnimation.new()
an.animation = data[k][l]
var ts = AnimationNodeTimeScale.new()
st.set_node_position("output", Vector2(600, 60))
st.add_node(k + "_" + l + "_animation", an, Vector2(0, 60))
st.add_node(k + "_" + l + "_timescale", ts, Vector2(300, 60))
st.connect_node(k + "_" + l + "_timescale", 0, k + "_" + l + "_animation")
st.connect_node("output", 0, k + "_" + l + "_timescale")
ResourceSaver.save(save_path + "/blendtree_" + k + "_" + l + ".tres", st)
func post_import(scene):
if scene.get_node("first"):
var ap: AnimationPlayer = scene.get_node("first/AnimationPlayer")
process_anim(ap)
if scene.get_node("second"):
var ap: AnimationPlayer = scene.get_node("second/AnimationPlayer")
process_anim(ap)
create_states()
return scene
+268
View File
@@ -0,0 +1,268 @@
; Engine configuration file.
; It's best edited using the editor UI and not directly,
; since the parameters that go here are not all obvious.
;
; Format:
; [section] ; section goes between []
; param=value ; assign values to parameters
config_version=4
_global_script_classes=[ {
"base": "BTBase",
"class": "BTAction",
"language": "GDScript",
"path": "res://ai/action.gd"
}, {
"base": "Node",
"class": "BTBase",
"language": "GDScript",
"path": "res://ai/bt_base.gd"
}, {
"base": "BTAction",
"class": "BTBuildPath",
"language": "GDScript",
"path": "res://ai/build_path.gd"
}, {
"base": "BTCondition",
"class": "BTCanGrab",
"language": "GDScript",
"path": "res://ai/can_grab.gd"
}, {
"base": "BTCondition",
"class": "BTCanHide",
"language": "GDScript",
"path": "res://ai/can_hide.gd"
}, {
"base": "BTCondition",
"class": "BTCanThrow",
"language": "GDScript",
"path": "res://ai/can_throw.gd"
}, {
"base": "BTBase",
"class": "BTCondition",
"language": "GDScript",
"path": "res://ai/condition.gd"
}, {
"base": "BTAction",
"class": "BTFetchPathPoint",
"language": "GDScript",
"path": "res://ai/fetch_path_point.gd"
}, {
"base": "BTAction",
"class": "BTGiveUp",
"language": "GDScript",
"path": "res://ai/give_up.gd"
}, {
"base": "BTAction",
"class": "BTGrab",
"language": "GDScript",
"path": "res://ai/grab.gd"
}, {
"base": "BTCondition",
"class": "BTHasArrived",
"language": "GDScript",
"path": "res://ai/has_arrived.gd"
}, {
"base": "BTCondition",
"class": "BTHasWeapon",
"language": "GDScript",
"path": "res://ai/has_weapon.gd"
}, {
"base": "BTCondition",
"class": "BTIsAction",
"language": "GDScript",
"path": "res://ai/is_action.gd"
}, {
"base": "BTCondition",
"class": "BTIsFree",
"language": "GDScript",
"path": "res://ai/is_free.gd"
}, {
"base": "BTCondition",
"class": "BTIsPathValid",
"language": "GDScript",
"path": "res://ai/valid_path.gd"
}, {
"base": "BTCondition",
"class": "BTIsPlayerNearby",
"language": "GDScript",
"path": "res://ai/is_player_nearby.gd"
}, {
"base": "BTAction",
"class": "BTLookAtPath",
"language": "GDScript",
"path": "res://ai/look_at_path.gd"
}, {
"base": "BTBase",
"class": "BTParallel",
"language": "GDScript",
"path": "res://ai/parallel.gd"
}, {
"base": "BTBase",
"class": "BTSelector",
"language": "GDScript",
"path": "res://ai/selector.gd"
}, {
"base": "BTBase",
"class": "BTSequence",
"language": "GDScript",
"path": "res://ai/sequence.gd"
}, {
"base": "BTAction",
"class": "BTSetAction",
"language": "GDScript",
"path": "res://ai/set_action.gd"
}, {
"base": "BTAction",
"class": "BTSetDestinationGroup",
"language": "GDScript",
"path": "res://ai/set_dst_from_group.gd"
}, {
"base": "BTAction",
"class": "BTSpawnSmartObj",
"language": "GDScript",
"path": "res://ai/spawn_smart_obj.gd"
}, {
"base": "BTAction",
"class": "BTStop",
"language": "GDScript",
"path": "res://ai/stop.gd"
}, {
"base": "BTAction",
"class": "BTThrowWeapon",
"language": "GDScript",
"path": "res://ai/throw_weapon.gd"
}, {
"base": "BTAction",
"class": "BTUnstuck",
"language": "GDScript",
"path": "res://ai/unstuck.gd"
}, {
"base": "BTAction",
"class": "BTWalk",
"language": "GDScript",
"path": "res://ai/walk.gd"
}, {
"base": "BTAction",
"class": "BTWashFloor",
"language": "GDScript",
"path": "res://ai/wash_floor.gd"
}, {
"base": "Node",
"class": "BehaviorTree",
"language": "GDScript",
"path": "res://ai/behavior_tree.gd"
}, {
"base": "Node",
"class": "Blackboard",
"language": "GDScript",
"path": "res://ai/blackboard.gd"
}, {
"base": "Spatial",
"class": "SmartObject",
"language": "GDScript",
"path": "res://scenes/characters/smart_object.gd"
}, {
"base": "Node",
"class": "Tick",
"language": "GDScript",
"path": "res://ai/tick.gd"
} ]
_global_script_class_icons={
"BTAction": "",
"BTBase": "",
"BTBuildPath": "",
"BTCanGrab": "",
"BTCanHide": "",
"BTCanThrow": "",
"BTCondition": "",
"BTFetchPathPoint": "",
"BTGiveUp": "",
"BTGrab": "",
"BTHasArrived": "",
"BTHasWeapon": "",
"BTIsAction": "",
"BTIsFree": "",
"BTIsPathValid": "",
"BTIsPlayerNearby": "",
"BTLookAtPath": "",
"BTParallel": "",
"BTSelector": "",
"BTSequence": "",
"BTSetAction": "",
"BTSetDestinationGroup": "",
"BTSpawnSmartObj": "",
"BTStop": "",
"BTThrowWeapon": "",
"BTUnstuck": "",
"BTWalk": "",
"BTWashFloor": "",
"BehaviorTree": "",
"Blackboard": "",
"SmartObject": "",
"Tick": ""
}
[application]
config/name="Aquisition"
run/main_scene="res://ui/menu_root.tscn"
config/use_custom_user_dir=true
config/custom_user_dir_name=".aquisition"
[autoload]
grabbing="*res://autoloads/grabbing.gd"
global="*res://autoloads/global.gd"
rpg="*res://autoloads/rpg.gd"
combat="*res://autoloads/combat.gd"
phy_bones="*res://autoloads/phy_bones.gd"
[input]
walk_forward={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":87,"unicode":0,"echo":false,"script":null)
]
}
walk_back={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":83,"unicode":0,"echo":false,"script":null)
]
}
walk_left={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":65,"unicode":0,"echo":false,"script":null)
]
}
walk_right={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":68,"unicode":0,"echo":false,"script":null)
]
}
grab={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":69,"unicode":0,"echo":false,"script":null)
]
}
attack={
"deadzone": 0.5,
"events": [ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":1,"pressed":false,"doubleclick":false,"script":null)
]
}
save_game={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777245,"unicode":0,"echo":false,"script":null)
]
}
load_game={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777246,"unicode":0,"echo":false,"script":null)
]
}
ai_debug={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":80,"unicode":0,"echo":false,"script":null)
]
}
+237
View File
@@ -0,0 +1,237 @@
extends Spatial
var playback = {
"init": {
"slave": [
["travel", "parameters/main/playback", "SmartObject"],
["travel", "parameters/main/SmartObject/playback", "bed"],
["travel", "parameters/main/SmartObject/bed/playback", "bed_facing_up"],
["set", "parameters/free_grabbed/current", 0]
]
},
"engage": {
"master": [
["travel", "parameters/main/playback", "SmartObject"],
["travel", "parameters/main/SmartObject/playback", "bed"],
["travel", "parameters/main/SmartObject/bed/playback", "bed_start_m"],
["set", "parameters/free_grabbed/current", 0]
],
"slave": [
["travel", "parameters/main/playback", "SmartObject"],
["travel", "parameters/main/SmartObject/playback", "bed"],
["travel", "parameters/main/SmartObject/bed/playback", "bed_start"],
["set", "parameters/free_grabbed/current", 0]
]
},
"torture": {
"master": [
["travel", "parameters/main/playback", "SmartObject"],
["travel", "parameters/main/SmartObject/playback", "bed"],
["travel", "parameters/main/SmartObject/bed/playback", "beating_m"],
["set", "parameters/free_grabbed/current", 0]
],
"slave": [
["travel", "parameters/main/playback", "SmartObject"],
["travel", "parameters/main/SmartObject/playback", "bed"],
["travel", "parameters/main/SmartObject/bed/playback", "beating"],
["set", "parameters/free_grabbed/current", 0]
]
},
"force": {
"master": [
["travel", "parameters/main/playback", "SmartObject"],
["travel", "parameters/main/SmartObject/playback", "bed"],
["travel", "parameters/main/SmartObject/bed/playback", "forcing_m"],
["set", "parameters/free_grabbed/current", 0]
],
"slave": [
["travel", "parameters/main/playback", "SmartObject"],
["travel", "parameters/main/SmartObject/playback", "bed"],
["travel", "parameters/main/SmartObject/bed/playback", "forcing"],
["set", "parameters/free_grabbed/current", 0]
]
},
"force_s1": {
"master": [
["travel", "parameters/main/playback", "SmartObject"],
["travel", "parameters/main/SmartObject/playback", "bed"],
["travel", "parameters/main/SmartObject/bed/playback", "forcing_s1_m"],
["set", "parameters/free_grabbed/current", 0]
],
"slave": [
["travel", "parameters/main/playback", "SmartObject"],
["travel", "parameters/main/SmartObject/playback", "bed"],
["travel", "parameters/main/SmartObject/bed/playback", "forcing_s1"],
["set", "parameters/free_grabbed/current", 0]
]
}
}
var state = "init"
var active_state = ""
var bodies = []
func entered(body):
if body.is_in_group("characters"):
if body.get_meta("grabbing"):
bodies.push_back(body)
global.smart_object.push_back(body)
print("entered:", body.name)
elif !body.get_meta("grabbed"):
bodies.push_back(body)
func exited(body):
if body in bodies:
print("exited:", body.name)
bodies.erase(body)
global.smart_object.erase(body)
var move_queue = []
var captured = []
func capture_slave(ch, orig_owner):
ch.add_collision_exception_with(orig_owner)
ch.set_meta("smart_object", true)
ch.set_meta("orig_owner", get_path_to(orig_owner))
for place in get_children():
if place.name.begins_with("place"):
if !place.has_meta("busy"):
move_queue.push_back([ch, place])
place.set_meta("busy", ch)
print("place: ", place.name)
break
captured.push_back(get_path_to(ch))
func free_slave(ch):
var orig_owner = ch.get_meta("orig_owner")
ch.remove_collision_exception_with(get_node(orig_owner))
ch.set_meta("smart_object", false)
ch.remove_meta("orig_owner")
var activate_delay = 0.0
func activate():
if activate_delay > 0.0:
return
if state in ["init", "engage", "torture"]:
activate_state()
activate_delay += 0.5
func activate_state():
# if active_state == state:
# return
print("ACTIVATE ", state)
match(state):
"init":
for k in bodies:
var ch = grabbing.get_grabbed(k)
if !ch:
continue
var s = playback[state]["slave"]
print("ungrab")
print("SMART: ", s)
grabbing.ungrab_character(k, s)
capture_slave(ch, k)
state = "engage"
"engage":
for k in bodies:
if k.get_meta("smart_object"):
continue
for place in get_children():
if place.name.begins_with("place"):
if place.has_meta("busy"):
print("has npc")
if !place.has_meta("master"):
print("has no master")
place.set_meta("master", k)
k.set_meta("smart_object", true)
print(k.name)
place.get_meta("busy").smart_obj(playback[state]["slave"])
place.get_meta("master").smart_obj(playback[state]["master"])
state = "torture"
"torture":
for place in get_children():
if place.name.begins_with("place"):
if place.has_meta("busy"):
if place.has_meta("master"):
place.get_meta("busy").smart_obj(playback[state]["slave"])
place.get_meta("master").smart_obj(playback[state]["master"])
"force":
for place in get_children():
if place.name.begins_with("place"):
if place.has_meta("busy"):
if place.has_meta("master"):
place.get_meta("busy").smart_obj(playback[state]["slave"])
place.get_meta("master").smart_obj(playback[state]["master"])
"force_s1":
for place in get_children():
if place.name.begins_with("place"):
if place.has_meta("busy"):
if place.has_meta("master"):
place.get_meta("busy").smart_obj(playback[state]["slave"])
place.get_meta("master").smart_obj(playback[state]["master"])
"leave":
for place in get_children():
if place.has_meta("busy") && place.has_meta("master"):
var m = place.get_meta("master")
m.set_meta("smart_object", false)
place.remove_meta("master")
m.do_stop()
var s = place.get_meta("busy")
free_slave(s)
place.remove_meta("busy")
s.do_stop()
var sub = rpg.get_submission(s)
sub += 100.0
s.set_meta("submission", sub)
rpg.update_xp(m, 300.0)
active_state = state
func _ready():
var e = $Area.connect("body_entered", self, "entered")
assert(e == OK)
e = $Area.connect("body_exited", self, "exited")
assert(e == OK)
var act = false
func _process(_delta):
if Input.is_action_just_pressed("grab"):
act = true
func _physics_process(delta):
if act:
activate()
act = false
while move_queue.size() > 0:
var item = move_queue.pop_front()
item[0].global_transform = item[1].global_transform
for place in get_children():
if place.has_meta("busy"):
place.get_meta("busy").global_transform = place.global_transform
place.get_meta("busy").orientation.basis = place.global_transform.basis
if place.has_meta("master"):
place.get_meta("master").global_transform = place.global_transform
place.get_meta("master").orientation.basis = place.global_transform.basis
activate_delay -= delta
if active_state == "torture":
for place in get_children():
if place.has_meta("busy") && place.has_meta("master"):
var strength = rpg.get_strength(place.get_meta("master"))
rpg.damage_stamina(place.get_meta("busy"), strength * 0.1 * delta)
print(rpg.get_stamina(place.get_meta("busy")))
if rpg.get_stamina(place.get_meta("busy")) <= 10.0:
state = "force"
activate_state()
rpg.damage_stamina(place.get_meta("master"), 5.0 * delta)
if active_state == "force":
for place in get_children():
if place.has_meta("busy") && place.has_meta("master"):
var strength = rpg.get_strength(place.get_meta("master"))
rpg.damage_stamina(place.get_meta("busy"), strength * 0.01 * delta)
print(rpg.get_stamina(place.get_meta("busy")))
if rpg.get_stamina(place.get_meta("busy")) <= 10.0:
state = "force_s1"
activate_state()
rpg.damage_stamina(place.get_meta("master"), 1.0 * delta)
if active_state == "force_s1":
for place in get_children():
if place.has_meta("busy") && place.has_meta("master"):
var strength = rpg.get_strength(place.get_meta("master"))
rpg.damage_stamina(place.get_meta("busy"), strength * 0.01 * delta)
print(rpg.get_stamina(place.get_meta("busy")))
rpg.damage_stamina(place.get_meta("master"), 1.0 * delta)
if rpg.get_stamina(place.get_meta("busy")) <= 0.0:
state = "leave"
activate_state()
if active_state == "leave":
state = "init"
active_state = ""
+6
View File
@@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://scenes/bed_control.gd" type="Script" id=1]
[node name="bed_control" type="Spatial"]
script = ExtResource( 1 )
Binary file not shown.
@@ -0,0 +1,430 @@
[gd_resource type="AnimationNodeBlendTree" load_steps=98 format=2]
[sub_resource type="AnimationNodeAnimation" id=98]
animation = "hang-grab_a-loop"
[sub_resource type="AnimationNodeOneShot" id=99]
[sub_resource type="AnimationNodeAnimation" id=100]
animation = "climb-low-obstacle"
[sub_resource type="AnimationNodeTimeScale" id=101]
[sub_resource type="AnimationNodeTransition" id=102]
input_count = 2
input_0/name = "free"
input_0/auto_advance = false
input_1/name = "grabbed"
input_1/auto_advance = false
[sub_resource type="AnimationNodeBlend2" id=103]
filter_enabled = true
filters = [ ".:clavicle_L", ".:finger1-1_L", ".:finger1-2_L", ".:finger1-3_L", ".:finger2-1_L", ".:finger2-2_L", ".:finger2-3_L", ".:finger3-1_L", ".:finger3-2_L", ".:finger3-3_L", ".:finger4-1_L", ".:finger4-2_L", ".:finger4-3_L", ".:finger5-1_L", ".:finger5-2_L", ".:finger5-3_L", ".:grabber_L", ".:lowerarm01_L", ".:metacarpal1_L", ".:metacarpal2_L", ".:metacarpal3_L", ".:metacarpal4_L", ".:shoulder01_L", ".:spine01", ".:spine02", ".:spine03", ".:spine04", ".:spine05", ".:upperarm01_L", ".:upperarm02_L", ".:wrist_L" ]
[sub_resource type="AnimationNodeOneShot" id=104]
[sub_resource type="AnimationNodeAnimation" id=105]
animation = "hang-grab_attack_a"
[sub_resource type="AnimationNodeTimeScale" id=106]
[sub_resource type="AnimationNodeTimeScale" id=107]
[sub_resource type="AnimationNodeTimeSeek" id=108]
[sub_resource type="AnimationNodeAnimation" id=109]
animation = "hang-grab_b-loop"
[sub_resource type="AnimationNodeAnimation" id=110]
animation = "hang-grab_attack_b"
[sub_resource type="AnimationNodeTimeScale" id=111]
[sub_resource type="AnimationNodeOneShot" id=112]
[sub_resource type="AnimationNodeTimeScale" id=113]
[sub_resource type="AnimationNodeTimeSeek" id=114]
[sub_resource type="AnimationNodeAnimation" id=93]
animation = "kneeling-loop"
[sub_resource type="AnimationNodeTimeScale" id=94]
[sub_resource type="AnimationNodeBlendTree" id=95]
nodes/kneel_animation/node = SubResource( 93 )
nodes/kneel_animation/position = Vector2( 180, 120 )
nodes/kneel_speed/node = SubResource( 94 )
nodes/kneel_speed/position = Vector2( 500, 120 )
nodes/output/position = Vector2( 740, 120 )
node_connections = [ "output", 0, "kneel_speed", "kneel_speed", 0, "kneel_animation" ]
[sub_resource type="AnimationNodeAnimation" id=18]
animation = "stand-to-walk"
[sub_resource type="AnimationNodeAnimation" id=19]
animation = "stand"
[sub_resource type="AnimationNodeTimeScale" id=20]
[sub_resource type="AnimationNodeTimeScale" id=21]
[sub_resource type="AnimationNodeBlendTree" id=22]
nodes/Animation/node = SubResource( 19 )
nodes/Animation/position = Vector2( 240, 100 )
nodes/output/position = Vector2( 1000, 100 )
nodes/speed/node = SubResource( 20 )
nodes/speed/position = Vector2( 800, 100 )
nodes/stand_speed/node = SubResource( 21 )
nodes/stand_speed/position = Vector2( 520, 100 )
node_connections = [ "speed", 0, "stand_speed", "output", 0, "speed", "stand_speed", 0, "Animation" ]
[sub_resource type="AnimationNodeTimeScale" id=23]
[sub_resource type="AnimationNodeTimeScale" id=24]
[sub_resource type="AnimationNodeAnimation" id=25]
animation = "walk-loop"
[sub_resource type="AnimationNodeAnimation" id=26]
animation = "walk2-loop"
[sub_resource type="AnimationNodeBlendSpace1D" id=27]
blend_point_0/node = SubResource( 25 )
blend_point_0/pos = 0.0
blend_point_1/node = SubResource( 26 )
blend_point_1/pos = 1.0
[sub_resource type="AnimationNodeBlendTree" id=28]
graph_offset = Vector2( 0, 133.5 )
nodes/output/position = Vector2( 1000, 140 )
nodes/speed/node = SubResource( 23 )
nodes/speed/position = Vector2( 760, 140 )
nodes/walk_speed/node = SubResource( 24 )
nodes/walk_speed/position = Vector2( 480, 140 )
nodes/walking/node = SubResource( 27 )
nodes/walking/position = Vector2( 120, 260 )
node_connections = [ "speed", 0, "walk_speed", "output", 0, "speed", "walk_speed", 0, "walking" ]
[sub_resource type="AnimationNodeTimeScale" id=29]
[sub_resource type="AnimationNodeAnimation" id=30]
animation = "wash-floor-loop"
[sub_resource type="AnimationNodeBlendTree" id=31]
graph_offset = Vector2( 0, -251 )
nodes/TimeScale/node = SubResource( 29 )
nodes/TimeScale/position = Vector2( 460, 160 )
nodes/output/position = Vector2( 700, 160 )
nodes/wash_floor_animation/node = SubResource( 30 )
nodes/wash_floor_animation/position = Vector2( 140, 160 )
node_connections = [ "output", 0, "TimeScale", "TimeScale", 0, "wash_floor_animation" ]
[sub_resource type="AnimationNodeStateMachineTransition" id=32]
[sub_resource type="AnimationNodeStateMachineTransition" id=33]
[sub_resource type="AnimationNodeStateMachineTransition" id=34]
[sub_resource type="AnimationNodeStateMachineTransition" id=35]
[sub_resource type="AnimationNodeStateMachineTransition" id=36]
[sub_resource type="AnimationNodeStateMachineTransition" id=96]
[sub_resource type="AnimationNodeStateMachineTransition" id=97]
[sub_resource type="AnimationNodeStateMachine" id=37]
states/kneel/node = SubResource( 95 )
states/kneel/position = Vector2( 459, 358 )
states/stand/node = SubResource( 22 )
states/stand/position = Vector2( 222, 87 )
states/stand-to-walk/node = SubResource( 18 )
states/stand-to-walk/position = Vector2( 605, 71 )
states/walk/node = SubResource( 28 )
states/walk/position = Vector2( 647, 210 )
states/wash_floor/node = SubResource( 31 )
states/wash_floor/position = Vector2( 140, 268 )
transitions = [ "stand", "stand-to-walk", SubResource( 32 ), "stand-to-walk", "walk", SubResource( 33 ), "walk", "stand", SubResource( 34 ), "stand", "wash_floor", SubResource( 35 ), "wash_floor", "stand", SubResource( 36 ), "stand", "kneel", SubResource( 96 ), "kneel", "stand", SubResource( 97 ) ]
start_node = "stand"
[sub_resource type="AnimationNodeAnimation" id=115]
animation = "bed_torture_beating_b-loop"
[sub_resource type="AnimationNodeTimeScale" id=116]
[sub_resource type="AnimationNodeBlendTree" id=117]
nodes/Animation/node = SubResource( 115 )
nodes/Animation/position = Vector2( 97, 97 )
nodes/beating_speed/node = SubResource( 116 )
nodes/beating_speed/position = Vector2( 420, 100 )
nodes/output/position = Vector2( 700, 120 )
node_connections = [ "output", 0, "beating_speed", "beating_speed", 0, "Animation" ]
[sub_resource type="AnimationNodeAnimation" id=118]
animation = "bed_torture_beating_a-loop"
[sub_resource type="AnimationNodeTimeScale" id=119]
[sub_resource type="AnimationNodeBlendTree" id=120]
graph_offset = Vector2( 0, -251 )
nodes/Animation/node = SubResource( 118 )
nodes/Animation/position = Vector2( 80, 100 )
nodes/beating_m_speed/node = SubResource( 119 )
nodes/beating_m_speed/position = Vector2( 560, 100 )
nodes/output/position = Vector2( 960, 140 )
node_connections = [ "output", 0, "beating_m_speed", "beating_m_speed", 0, "Animation" ]
[sub_resource type="AnimationNodeAnimation" id=121]
animation = "lying-on-back-arms-tied-loop"
[sub_resource type="AnimationNodeTimeScale" id=122]
[sub_resource type="AnimationNodeBlendTree" id=123]
nodes/Animation/node = SubResource( 121 )
nodes/Animation/position = Vector2( 60, 80 )
nodes/TimeScale/node = SubResource( 122 )
nodes/TimeScale/position = Vector2( 480, 80 )
nodes/output/position = Vector2( 720, 80 )
node_connections = [ "output", 0, "TimeScale", "TimeScale", 0, "Animation" ]
[sub_resource type="AnimationNodeAnimation" id=124]
animation = "bed_torture_start_b"
[sub_resource type="AnimationNodeTimeScale" id=125]
[sub_resource type="AnimationNodeBlendTree" id=126]
nodes/Animation/node = SubResource( 124 )
nodes/Animation/position = Vector2( 80, 80 )
nodes/bed_start_speed/node = SubResource( 125 )
nodes/bed_start_speed/position = Vector2( 380, 80 )
nodes/output/position = Vector2( 620, 80 )
node_connections = [ "output", 0, "bed_start_speed", "bed_start_speed", 0, "Animation" ]
[sub_resource type="AnimationNodeAnimation" id=127]
animation = "bed_torture_start_a"
[sub_resource type="AnimationNodeTimeScale" id=128]
[sub_resource type="AnimationNodeBlendTree" id=129]
graph_offset = Vector2( 0, 15.75 )
nodes/Animation/node = SubResource( 127 )
nodes/Animation/position = Vector2( 69, 94 )
nodes/bed_start_m_speed/node = SubResource( 128 )
nodes/bed_start_m_speed/position = Vector2( 360, 80 )
nodes/output/position = Vector2( 660, 80 )
node_connections = [ "output", 0, "bed_start_m_speed", "bed_start_m_speed", 0, "Animation" ]
[sub_resource type="AnimationNodeAnimation" id=130]
animation = "bed_torture_forcing_b"
[sub_resource type="AnimationNodeTimeScale" id=131]
[sub_resource type="AnimationNodeBlendTree" id=132]
graph_offset = Vector2( 0, -55 )
nodes/forcing_animation/node = SubResource( 130 )
nodes/forcing_animation/position = Vector2( 159, 121 )
nodes/forcing_speed/node = SubResource( 131 )
nodes/forcing_speed/position = Vector2( 460, 100 )
nodes/output/position = Vector2( 740, 100 )
node_connections = [ "output", 0, "forcing_speed", "forcing_speed", 0, "forcing_animation" ]
[sub_resource type="AnimationNodeAnimation" id=133]
animation = "bed_torture_forcing_a"
[sub_resource type="AnimationNodeTimeScale" id=134]
[sub_resource type="AnimationNodeBlendTree" id=135]
nodes/forcing_m_animation/node = SubResource( 133 )
nodes/forcing_m_animation/position = Vector2( 102, 110 )
nodes/forcing_m_speed/node = SubResource( 134 )
nodes/forcing_m_speed/position = Vector2( 442, 120 )
nodes/output/position = Vector2( 740, 120 )
node_connections = [ "output", 0, "forcing_m_speed", "forcing_m_speed", 0, "forcing_m_animation" ]
[sub_resource type="AnimationNodeAnimation" id=136]
animation = "bed_torture_forcing_s1_b-loop"
[sub_resource type="AnimationNodeTimeScale" id=137]
[sub_resource type="AnimationNodeBlendTree" id=138]
nodes/forcing_s1_animation/node = SubResource( 136 )
nodes/forcing_s1_animation/position = Vector2( 160, 140 )
nodes/forcing_s1_speed/node = SubResource( 137 )
nodes/forcing_s1_speed/position = Vector2( 640, 160 )
nodes/output/position = Vector2( 920, 160 )
node_connections = [ "output", 0, "forcing_s1_speed", "forcing_s1_speed", 0, "forcing_s1_animation" ]
[sub_resource type="AnimationNodeAnimation" id=139]
animation = "bed_torture_forcing_s1_a-loop"
[sub_resource type="AnimationNodeTimeScale" id=140]
[sub_resource type="AnimationNodeBlendTree" id=141]
nodes/forcing_s1_animation/node = SubResource( 139 )
nodes/forcing_s1_animation/position = Vector2( 300, 260 )
nodes/forcing_s1_speed/node = SubResource( 140 )
nodes/forcing_s1_speed/position = Vector2( 680, 260 )
nodes/output/position = Vector2( 980, 280 )
node_connections = [ "output", 0, "forcing_s1_speed", "forcing_s1_speed", 0, "forcing_s1_animation" ]
[sub_resource type="AnimationNodeStateMachineTransition" id=142]
[sub_resource type="AnimationNodeStateMachineTransition" id=143]
[sub_resource type="AnimationNodeStateMachineTransition" id=144]
[sub_resource type="AnimationNodeStateMachineTransition" id=145]
[sub_resource type="AnimationNodeStateMachineTransition" id=146]
[sub_resource type="AnimationNodeStateMachineTransition" id=147]
[sub_resource type="AnimationNodeStateMachineTransition" id=148]
[sub_resource type="AnimationNodeStateMachineTransition" id=149]
[sub_resource type="AnimationNodeStateMachine" id=150]
states/beating/node = SubResource( 117 )
states/beating/position = Vector2( 421, 244 )
states/beating_m/node = SubResource( 120 )
states/beating_m/position = Vector2( 225, 283 )
states/bed_facing_up/node = SubResource( 123 )
states/bed_facing_up/position = Vector2( 189, 53 )
states/bed_start/node = SubResource( 126 )
states/bed_start/position = Vector2( 299, 138 )
states/bed_start_m/node = SubResource( 129 )
states/bed_start_m/position = Vector2( 201, 203 )
states/forcing/node = SubResource( 132 )
states/forcing/position = Vector2( 429, 330 )
states/forcing_m/node = SubResource( 135 )
states/forcing_m/position = Vector2( 247, 390 )
states/forcing_s1/node = SubResource( 138 )
states/forcing_s1/position = Vector2( 533, 428 )
states/forcing_s1_m/node = SubResource( 141 )
states/forcing_s1_m/position = Vector2( 247, 544 )
transitions = [ "bed_facing_up", "bed_start", SubResource( 142 ), "bed_facing_up", "bed_start_m", SubResource( 143 ), "bed_start_m", "beating_m", SubResource( 144 ), "bed_start", "beating", SubResource( 145 ), "beating_m", "forcing_m", SubResource( 146 ), "beating", "forcing", SubResource( 147 ), "forcing_m", "forcing_s1_m", SubResource( 148 ), "forcing", "forcing_s1", SubResource( 149 ) ]
start_node = "bed_facing_up"
[sub_resource type="AnimationNodeStateMachine" id=151]
states/bed/node = SubResource( 150 )
states/bed/position = Vector2( 251, 82 )
start_node = "bed"
[sub_resource type="AnimationNodeStateMachineTransition" id=152]
[sub_resource type="AnimationNodeStateMachineTransition" id=153]
[sub_resource type="AnimationNodeStateMachine" id=154]
states/Motion/node = SubResource( 37 )
states/Motion/position = Vector2( 188, 65 )
states/SmartObject/node = SubResource( 151 )
states/SmartObject/position = Vector2( 250, 140 )
transitions = [ "Motion", "SmartObject", SubResource( 152 ), "SmartObject", "Motion", SubResource( 153 ) ]
start_node = "Motion"
[sub_resource type="AnimationNodeOneShot" id=155]
[sub_resource type="AnimationNodeAnimation" id=156]
animation = "throw"
[sub_resource type="AnimationNodeTimeScale" id=157]
[sub_resource type="AnimationNodeOneShot" id=158]
[sub_resource type="AnimationNodeAnimation" id=159]
animation = "small_turn_left"
[sub_resource type="AnimationNodeTimeScale" id=160]
[sub_resource type="AnimationNodeOneShot" id=161]
[sub_resource type="AnimationNodeAnimation" id=162]
animation = "small_turn_right"
[sub_resource type="AnimationNodeTimeScale" id=163]
[sub_resource type="AnimationNodeOneShot" id=164]
[sub_resource type="AnimationNodeAnimation" id=165]
animation = "unstuck1"
[sub_resource type="AnimationNodeTimeScale" id=166]
[sub_resource type="AnimationNodeOneShot" id=167]
[sub_resource type="AnimationNodeAnimation" id=168]
animation = "unstuck2"
[sub_resource type="AnimationNodeTimeScale" id=169]
[resource]
graph_offset = Vector2( -227.051, -544.846 )
nodes/Animation/node = SubResource( 98 )
nodes/Animation/position = Vector2( 120, -200 )
nodes/climb_low_obstacle/node = SubResource( 99 )
nodes/climb_low_obstacle/position = Vector2( 2340, -380 )
nodes/climb_low_obstacle_animation/node = SubResource( 100 )
nodes/climb_low_obstacle_animation/position = Vector2( 1800, 20 )
nodes/climb_low_obstacle_speed/node = SubResource( 101 )
nodes/climb_low_obstacle_speed/position = Vector2( 2120, -160 )
nodes/free_grabbed/node = SubResource( 102 )
nodes/free_grabbed/position = Vector2( 3500, -260 )
nodes/grab/node = SubResource( 103 )
nodes/grab/position = Vector2( 2640, -380 )
nodes/grab_attack/node = SubResource( 104 )
nodes/grab_attack/position = Vector2( 600, -420 )
nodes/grab_attack_animation/node = SubResource( 105 )
nodes/grab_attack_animation/position = Vector2( 400, -40 )
nodes/grab_attack_speed/node = SubResource( 106 )
nodes/grab_attack_speed/position = Vector2( 680, -40 )
nodes/grab_scale/node = SubResource( 107 )
nodes/grab_scale/position = Vector2( 600, -200 )
nodes/grab_seek/node = SubResource( 108 )
nodes/grab_seek/position = Vector2( 400, -200 )
nodes/grabbed_animation/node = SubResource( 109 )
nodes/grabbed_animation/position = Vector2( 2260, 160 )
nodes/grabbed_attack_animation/node = SubResource( 110 )
nodes/grabbed_attack_animation/position = Vector2( 2340, 340 )
nodes/grabbed_attack_speed/node = SubResource( 111 )
nodes/grabbed_attack_speed/position = Vector2( 2680, 340 )
nodes/grabbed_attacked/node = SubResource( 112 )
nodes/grabbed_attacked/position = Vector2( 3080, 0 )
nodes/grabbed_scale/node = SubResource( 113 )
nodes/grabbed_scale/position = Vector2( 2800, 40 )
nodes/grabbed_seek/node = SubResource( 114 )
nodes/grabbed_seek/position = Vector2( 2540, 40 )
nodes/main/node = SubResource( 154 )
nodes/main/position = Vector2( 280, -360 )
nodes/output/position = Vector2( 3740, -260 )
nodes/throw/node = SubResource( 155 )
nodes/throw/position = Vector2( 3000, -280 )
nodes/throw_animation/node = SubResource( 156 )
nodes/throw_animation/position = Vector2( 2560, -160 )
nodes/throw_speed/node = SubResource( 157 )
nodes/throw_speed/position = Vector2( 2800, -160 )
nodes/turn_left/node = SubResource( 158 )
nodes/turn_left/position = Vector2( 1200, -400 )
nodes/turn_left_animation/node = SubResource( 159 )
nodes/turn_left_animation/position = Vector2( 440, 100 )
nodes/turn_left_speed/node = SubResource( 160 )
nodes/turn_left_speed/position = Vector2( 680, 100 )
nodes/turn_right/node = SubResource( 161 )
nodes/turn_right/position = Vector2( 900, -400 )
nodes/turn_right_animation/node = SubResource( 162 )
nodes/turn_right_animation/position = Vector2( 440, 220 )
nodes/turn_right_speed/node = SubResource( 163 )
nodes/turn_right_speed/position = Vector2( 680, 220 )
nodes/unstuck1/node = SubResource( 164 )
nodes/unstuck1/position = Vector2( 1520, -380 )
nodes/unstuck1_animation/node = SubResource( 165 )
nodes/unstuck1_animation/position = Vector2( 1180, 0 )
nodes/unstuck1_speed/node = SubResource( 166 )
nodes/unstuck1_speed/position = Vector2( 1380, -160 )
nodes/unstuck2/node = SubResource( 167 )
nodes/unstuck2/position = Vector2( 1920, -380 )
nodes/unstuck2_animation/node = SubResource( 168 )
nodes/unstuck2_animation/position = Vector2( 1460, -20 )
nodes/unstuck2_speed/node = SubResource( 169 )
nodes/unstuck2_speed/position = Vector2( 1700, -160 )
node_connections = [ "output", 0, "free_grabbed", "grab_seek", 0, "Animation", "climb_low_obstacle", 0, "unstuck2", "climb_low_obstacle", 1, "climb_low_obstacle_speed", "grab_scale", 0, "grab_seek", "grabbed_seek", 0, "grabbed_animation", "unstuck1", 0, "turn_left", "unstuck1", 1, "unstuck1_speed", "turn_left_speed", 0, "turn_left_animation", "throw_speed", 0, "throw_animation", "unstuck1_speed", 0, "unstuck1_animation", "grab_attack_speed", 0, "grab_attack_animation", "unstuck2", 0, "unstuck1", "unstuck2", 1, "unstuck2_speed", "turn_right", 0, "grab_attack", "turn_right", 1, "turn_right_speed", "grab", 0, "climb_low_obstacle", "grab", 1, "grab_scale", "grabbed_scale", 0, "grabbed_seek", "turn_left", 0, "turn_right", "turn_left", 1, "turn_left_speed", "grabbed_attack_speed", 0, "grabbed_attack_animation", "climb_low_obstacle_speed", 0, "climb_low_obstacle_animation", "free_grabbed", 0, "throw", "free_grabbed", 1, "grabbed_attacked", "grabbed_attacked", 0, "grabbed_scale", "grabbed_attacked", 1, "grabbed_attack_speed", "unstuck2_speed", 0, "unstuck2_animation", "throw", 0, "grab", "throw", 1, "throw_speed", "turn_right_speed", 0, "turn_right_animation", "grab_attack", 0, "main", "grab_attack", 1, "grab_attack_speed" ]
Binary file not shown.

After

Width:  |  Height:  |  Size: 596 KiB

@@ -0,0 +1,36 @@
[remap]
importer="texture"
type="StreamTexture"
path.s3tc="res://.import/brown_eye.png-60d098a1f88d54238400fc846fa1ccdd.s3tc.stex"
path.etc2="res://.import/brown_eye.png-60d098a1f88d54238400fc846fa1ccdd.etc2.stex"
metadata={
"imported_formats": [ "s3tc", "etc2" ],
"vram_texture": true
}
[deps]
source_file="res://scenes/characters/brown_eye.png"
dest_files=[ "res://.import/brown_eye.png-60d098a1f88d54238400fc846fa1ccdd.s3tc.stex", "res://.import/brown_eye.png-60d098a1f88d54238400fc846fa1ccdd.etc2.stex" ]
[params]
compress/mode=2
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=true
flags/filter=true
flags/mipmaps=true
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0
@@ -0,0 +1,20 @@
extends Spatial
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
$male2.add_collision_exception_with($male)
$male2.set_meta("smart_object", true)
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
func _physics_process(delta):
$male2.global_transform = $male.global_transform
@@ -0,0 +1,26 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://scenes/characters/male.tscn" type="PackedScene" id=1]
[ext_resource path="res://scenes/characters/dual_test.gd" type="Script" id=2]
[sub_resource type="BoxShape" id=1]
extents = Vector3( 100, 0.5, 100 )
[node name="dual_test" type="Spatial"]
script = ExtResource( 2 )
[node name="male" parent="." instance=ExtResource( 1 )]
[node name="male2" parent="." instance=ExtResource( 1 )]
[node name="StaticBody" type="StaticBody" parent="."]
[node name="CollisionShape" type="CollisionShape" parent="StaticBody"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.25, 0 )
shape = SubResource( 1 )
[node name="DirectionalLight" type="DirectionalLight" parent="."]
transform = Transform( 1, 0, 0, 0, 0.608332, 0.793683, 0, -0.793683, 0.608332, 0, 3.00065, 0 )
[node name="Camera" type="Camera" parent="."]
transform = Transform( 0.707107, 0, -0.707107, 0, 1, 0, 0.707107, 0, 0.707107, -1, 0.6, 1 )
Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

@@ -0,0 +1,36 @@
[remap]
importer="texture"
type="StreamTexture"
path.s3tc="res://.import/eyelashes04.png-d20f38ad08e742a4c5e005cc75324a62.s3tc.stex"
path.etc2="res://.import/eyelashes04.png-d20f38ad08e742a4c5e005cc75324a62.etc2.stex"
metadata={
"imported_formats": [ "s3tc", "etc2" ],
"vram_texture": true
}
[deps]
source_file="res://scenes/characters/eyelashes04.png"
dest_files=[ "res://.import/eyelashes04.png-d20f38ad08e742a4c5e005cc75324a62.s3tc.stex", "res://.import/eyelashes04.png-d20f38ad08e742a4c5e005cc75324a62.etc2.stex" ]
[params]
compress/mode=2
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=true
flags/filter=true
flags/mipmaps=true
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0
+198
View File
@@ -0,0 +1,198 @@
extends KinematicBody
const MOTION_INTERPOLATE_SPEED = 10
var orientation = Transform()
var fixup = Transform()
var root_motion = Transform()
var motion = Vector2()
var motion_target = Vector2()
var velocity = Vector3()
var disable_gravity = false
const p1 = "parameters/main/playback"
const p2 = "parameters/main/Motion/playback"
func _ready():
# var ap = $AnimationTree.get_node($AnimationTree.get_animation_player())
orientation = global_transform
orientation.origin = Vector3()
add_to_group("characters")
do_ungrab()
func _physics_process(delta):
# motion = motion.linear_interpolate(motion_target, MOTION_INTERPOLATE_SPEED * delta)
assert(has_meta("grabbed"))
var in_smart_obj = get_meta("smart_object")
if get_meta("grabbed"):
orientation.basis = get_parent().global_transform.basis
root_motion = $AnimationTree.get_root_motion_transform()
orientation *= root_motion
var h_velocity = orientation.origin / delta
velocity.x = h_velocity.x
velocity.z = h_velocity.z
velocity.y = h_velocity.y
if !get_meta("grabbed") && !in_smart_obj && !disable_gravity:
velocity.y += -9.8 * delta
velocity = move_and_slide(velocity,Vector3(0,1,0))
orientation.origin = Vector3()
fixup.origin = Vector3()
orientation *= Transform().interpolate_with(fixup, delta)
orientation = orientation.orthonormalized()
global_transform.basis = orientation.basis
if get_meta("grabbed"):
global_transform.origin = get_parent().global_transform.origin
# global_transform = get_parent().global_transform
if attacking >= 0.0:
attacking -= delta
rpg.update_stats(self)
rpg.update_needs(self)
var skel
func get_skeleton():
if skel:
return get_node(skel)
var queue = [self]
while queue.size() > 0:
var item = queue.pop_front()
if item is Skeleton:
skel = get_path_to(item)
return get_node(skel)
for k in item.get_children():
queue.push_back(k)
func get_anim_player():
return $female_2018/female_2018/AnimationPlayer
var attachment_start
var attachment_end
var mod_p = false
func get_front_neck_target():
if !mod_p:
$female_2018/female_2018/neck02BoneAttachment/front_neck_target.transform.basis = Basis()
mod_p = true
return $female_2018/female_2018/neck02BoneAttachment/front_neck_target
func add_attachment(bname, xform):
var ba: BoneAttachment = BoneAttachment.new()
ba.bone_name = bname
var sk = get_skeleton()
sk.add_child(ba)
var on1 = Spatial.new()
ba.add_child(on1)
var on2 = Spatial.new()
ba.add_child(on2)
on1.transform = Transform()
# on1.global_transform.basis = Basis()
on2.transform = xform
# on2.rotate_y(PI)
attachment_start = ba
attachment_end = on2
return on2
static func calc_offset(c2, bone2):
var skel2 = c2.get_skeleton()
var id2 = skel2.find_bone(bone2)
assert(skel2 != null)
assert(id2 >= 0)
var offt2 = skel2.get_bone_global_pose(id2).origin
var offset = Vector3(-offt2.x, -offt2.y, -offt2.z)
# print("offset: ", offset)
return offset
var act = {
"stop":[
["travel", p1, "Motion"],
["travel", p2, "stand"],
],
"walk":[
["travel", p1, "Motion"],
["travel", p2, "walk"],
],
"grabbed":[
["set", "parameters/free_grabbed/current", 1],
["set", "parameters/grabbed_seek/seek_position", 0.0]
],
"ungrabbed":[
["set", "parameters/free_grabbed/current", 0]
],
"grab":[
["set", "parameters/grab/blend_amount", 1.0],
["set", "parameters/grab_seek/seek_position", 0.0]
],
"grab_attack1_on":[
["set", "parameters/grab_attack/active", true],
],
"grabbed_attacked1_on":[
["set", "parameters/grabbed_attacked/active", true],
],
"ungrab":[
["set", "parameters/grab/blend_amount", 0.0]
],
"throw_projectile":[
["set", "parameters/throw/active", true]
]
}
#func skirt_simulation(enable):
# if enable:
# var skel: Skeleton = get_skeleton()
# for k in range(skel.get_bone_count()):
# var bone = skel.get_bone_name(k)
# if bone.begins_with("skirt"):
# var pb: = PhysicalBone.new()
# pb.bone_name = bone
# pb.joint_type = pb.JOINT_TYPE_HINGE
# pb.body_offset = skel.get_bone_global_pose(k)
# pb.joint_offset = skel.get_bone_global_pose(k)
# skel.add_child(pb)
# var cs = CollisionShape.new()
# var sshape: = BoxShape.new()
# sshape.extents = Vector3(0.05, 0.05, 0.05)
# cs.shape = sshape
# pb.add_child(cs)
# skel.physical_bones_add_collision_exception(self.get_rid())
# skel.physical_bones_start_simulation()
# else:
# var skel: Skeleton = get_skeleton()
# skel.physical_bones_stop_simulation()
# skel.physical_bones_remove_collision_exception(self.get_rid())
# for k in skel.get_children():
# if k is PhysicalBone:
# k.queue_free()
func smart_obj(sm):
for k in sm:
if k[0] == "travel":
$AnimationTree[k[1]].travel(k[2])
if k[0] == "set":
$AnimationTree[k[1]] = k[2]
func do_stop():
# if name != "player":
# print(name, " stop")
smart_obj(act.stop)
func do_walk():
# if name != "player":
# print(name, "walk")
smart_obj(act.walk)
func set_walk_speed(x):
var s = [["set", "parameters/main/Motion/walk/walk_speed/scale", x]]
smart_obj(s)
var grab_bone = "grabber_L"
func do_grab():
smart_obj(act.grab)
var attacking = 0.0
func do_attack():
if attacking > 0.0:
return
if get_meta("grabbing"):
smart_obj(act.grab_attack1_on)
var s = grabbing.get_grabbed(self)
s.do_attacked()
rpg.melee_attack(self, s)
attacking += 1.0
else:
smart_obj(act.throw_projectile)
func do_attacked():
if get_meta("grabbed"):
smart_obj(act.grabbed_attacked1_on)
func do_ungrab():
smart_obj(act.ungrab)
func do_grabbed():
smart_obj(act.grabbed)
func do_ungrabbed():
smart_obj(act.ungrabbed)
@@ -0,0 +1,70 @@
[gd_scene load_steps=9 format=2]
[ext_resource path="res://scenes/characters/female_2018.escn" type="PackedScene" id=1]
[ext_resource path="res://scenes/characters/female.gd" type="Script" id=2]
[ext_resource path="res://scenes/characters/animation_tree_root.tres" type="AnimationNodeBlendTree" id=3]
[sub_resource type="CapsuleShape" id=1]
radius = 0.234161
height = 1.26341
[sub_resource type="AnimationNodeStateMachinePlayback" id=2]
[sub_resource type="AnimationNodeStateMachinePlayback" id=3]
[sub_resource type="AnimationNodeStateMachinePlayback" id=4]
[sub_resource type="AnimationNodeStateMachinePlayback" id=5]
[node name="female" type="KinematicBody"]
collision_layer = 4
collision_mask = 31
script = ExtResource( 2 )
[node name="CollisionShape" type="CollisionShape" parent="."]
transform = Transform( 1, 0, 0, 0, -1.62921e-07, 1, 0, -1, -1.62921e-07, 0, 0.869824, 0 )
shape = SubResource( 1 )
[node name="col-lying" type="CollisionShape" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.25, 0.8 )
shape = SubResource( 1 )
disabled = true
[node name="col-lying2" type="CollisionShape" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.25, -0.8 )
shape = SubResource( 1 )
disabled = true
[node name="AnimationTree" type="AnimationTree" parent="."]
tree_root = ExtResource( 3 )
anim_player = NodePath("../female_2018/female_2018/AnimationPlayer")
active = true
process_mode = 0
root_motion_track = NodePath(".:root")
parameters/free_grabbed/current = 0
parameters/grab/blend_amount = 0.0
parameters/grab_attack/active = false
parameters/grab_attack_speed/scale = 1.0
parameters/grab_scale/scale = 0.5
parameters/grab_seek/seek_position = -1.0
parameters/grabbed_attack_speed/scale = 1.0
parameters/grabbed_attacked/active = false
parameters/grabbed_scale/scale = 0.5
parameters/grabbed_seek/seek_position = -1.0
parameters/main/playback = SubResource( 2 )
parameters/main/Motion/playback = SubResource( 3 )
parameters/main/Motion/stand/speed/scale = 1.0
parameters/main/Motion/stand/stand_speed/scale = 1.0
parameters/main/Motion/walk/speed/scale = 1.0
parameters/main/Motion/walk/walk_speed/scale = 1.0
parameters/main/SmartObject/playback = SubResource( 4 )
parameters/main/SmartObject/bed/playback = SubResource( 5 )
parameters/main/SmartObject/bed/beating/beating_speed/scale = 1.0
parameters/main/SmartObject/bed/beating_m/beating_m_speed/scale = 1.0
parameters/main/SmartObject/bed/bed_facing_up/TimeScale/scale = 1.0
parameters/main/SmartObject/bed/bed_start/bed_start_speed/scale = 1.0
parameters/main/SmartObject/bed/bed_start_m/bed_start_m_speed/scale = 1.0
parameters/throw/active = false
parameters/throw_speed/scale = 1.0
[node name="female_2018" parent="." instance=ExtResource( 1 )]
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
+171
View File
@@ -0,0 +1,171 @@
extends KinematicBody
const MOTION_INTERPOLATE_SPEED = 10
var orientation = Transform()
var root_motion = Transform()
var fixup = Transform()
var motion = Vector2()
var motion_target = Vector2()
var velocity = Vector3()
var disable_gravity = false
const p1 = "parameters/main/playback"
const p2 = "parameters/main/Motion/playback"
func _ready():
# var _ap = $AnimationTree.get_node($AnimationTree.get_animation_player())
orientation = global_transform
orientation.origin = Vector3()
add_to_group("characters")
do_ungrab()
func _physics_process(delta):
# motion = motion.linear_interpolate(motion_target, MOTION_INTERPOLATE_SPEED * delta)
assert(has_meta("grabbed"))
var in_smart_obj = get_meta("smart_object")
if get_meta("grabbed"):
orientation.basis = get_parent().global_transform.basis
root_motion = $AnimationTree.get_root_motion_transform()
orientation *= root_motion
var h_velocity = orientation.origin / delta
velocity.x = h_velocity.x
velocity.z = h_velocity.z
velocity.y = h_velocity.y
if !get_meta("grabbed") && !in_smart_obj && !disable_gravity:
velocity.y += -9.8 * delta
velocity = move_and_slide(velocity,Vector3(0,1,0))
orientation.origin = Vector3()
fixup.origin = Vector3()
orientation *= Transform().interpolate_with(fixup, delta)
orientation = orientation.orthonormalized()
global_transform.basis = orientation.basis
if get_meta("grabbed"):
global_transform.origin = get_parent().global_transform.origin
# global_transform = get_parent().global_transform
if attacking >= 0.0:
attacking -= delta
rpg.update_stats(self)
var skel
func get_skeleton():
if skel:
return get_node(skel)
var queue = [self]
while queue.size() > 0:
var item = queue.pop_front()
if item is Skeleton:
skel = get_path_to(item)
return get_node(skel)
for k in item.get_children():
queue.push_back(k)
func get_anim_player():
return $male_2018/male_g_2018/AnimationPlayer
var attachment_start
var attachment_end
var mod_p = false
func get_front_neck_target():
if !mod_p:
$male_2018/male_g_2018/neck02BoneAttachment/grab_neck_front.transform.basis = Basis()
mod_p = true
return $male_2018/male_g_2018/neck02BoneAttachment/grab_neck_front
func add_attachment(bname, xform):
var ba: BoneAttachment = BoneAttachment.new()
ba.bone_name = bname
var sk = get_skeleton()
sk.add_child(ba)
var on1 = Spatial.new()
ba.add_child(on1)
var on2 = Spatial.new()
ba.add_child(on2)
on1.transform = Transform()
# on1.global_transform.basis = Basis()
on2.transform = xform
# on2.rotate_y(PI)
attachment_start = ba
attachment_end = on2
return on2
static func calc_offset(c2, bone2):
var skel2 = c2.get_skeleton()
var id2 = skel2.find_bone(bone2)
assert(skel2 != null)
assert(id2 >= 0)
var offt2 = skel2.get_bone_global_pose(id2).origin
var offset = Vector3(-offt2.x, -offt2.y, -offt2.z)
# print("offset: ", offset)
return offset
var act = {
"stop":[
["travel", p1, "Motion"],
["travel", p2, "stand"],
],
"walk":[
["travel", p1, "Motion"],
["travel", p2, "walk"],
],
"grabbed":[
["set", "parameters/free_grabbed/current", 1],
["set", "parameters/grabbed_seek/seek_position", 0.0]
],
"ungrabbed":[
["set", "parameters/free_grabbed/current", 0]
],
"grab":[
["set", "parameters/grab/blend_amount", 1.0],
["set", "parameters/grab_seek/seek_position", 0.0]
],
"grab_attack1_on":[
["set", "parameters/grab_attack/active", true],
],
"grabbed_attacked1_on":[
["set", "parameters/grabbed_attacked/active", true],
],
"ungrab":[
["set", "parameters/grab/blend_amount", 0.0]
],
"throw_projectile":[
["set", "parameters/throw/active", true]
]
}
func smart_obj(sm):
for k in sm:
if k[0] == "travel":
$AnimationTree[k[1]].travel(k[2])
if k[0] == "set":
$AnimationTree[k[1]] = k[2]
func do_stop():
# if name != "player":
# print(name, " stop")
smart_obj(act.stop)
func do_walk():
# if name != "player":
# print(name, "walk")
smart_obj(act.walk)
func set_walk_speed(x):
var s = [["set", "parameters/main/Motion/walk/walk_speed/scale", x]]
smart_obj(s)
var grab_bone = "grabber_L"
func do_grab():
smart_obj(act.grab)
var attacking = 0.0
func do_attack():
if attacking > 0.0:
return
if get_meta("grabbing"):
smart_obj(act.grab_attack1_on)
var s = grabbing.get_grabbed(self)
s.do_attacked()
rpg.melee_attack(self, s)
attacking += 1.0
else:
smart_obj(act.throw_projectile)
func do_attacked():
if get_meta("grabbed"):
smart_obj(act.grabbed_attacked1_on)
func do_ungrab():
smart_obj(act.ungrab)
func do_grabbed():
smart_obj(act.grabbed)
func do_ungrabbed():
smart_obj(act.ungrabbed)
+87
View File
@@ -0,0 +1,87 @@
[gd_scene load_steps=9 format=2]
[ext_resource path="res://scenes/characters/male_2018.escn" type="PackedScene" id=1]
[ext_resource path="res://scenes/characters/male.gd" type="Script" id=2]
[ext_resource path="res://scenes/characters/animation_tree_root.tres" type="AnimationNodeBlendTree" id=3]
[sub_resource type="CapsuleShape" id=1]
radius = 0.234161
height = 1.26341
[sub_resource type="AnimationNodeStateMachinePlayback" id=2]
[sub_resource type="AnimationNodeStateMachinePlayback" id=3]
[sub_resource type="AnimationNodeStateMachinePlayback" id=4]
[sub_resource type="AnimationNodeStateMachinePlayback" id=5]
[node name="male" type="KinematicBody"]
collision_layer = 4
collision_mask = 31
script = ExtResource( 2 )
[node name="CollisionShape" type="CollisionShape" parent="."]
transform = Transform( 1, 0, 0, 0, -1.62921e-07, 1, 0, -1, -1.62921e-07, 0, 0.869824, 0 )
shape = SubResource( 1 )
[node name="col-lying" type="CollisionShape" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.25, 0.8 )
shape = SubResource( 1 )
disabled = true
[node name="col-lying2" type="CollisionShape" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.25, -0.8 )
shape = SubResource( 1 )
disabled = true
[node name="AnimationTree" type="AnimationTree" parent="."]
tree_root = ExtResource( 3 )
anim_player = NodePath("../male_2018/male_g_2018/AnimationPlayer")
active = true
process_mode = 0
root_motion_track = NodePath(".:root")
parameters/climb_low_obstacle/active = false
parameters/climb_low_obstacle_speed/scale = 1.0
parameters/free_grabbed/current = 0
parameters/grab/blend_amount = 0.0
parameters/grab_attack/active = false
parameters/grab_attack_speed/scale = 1.0
parameters/grab_scale/scale = 0.5
parameters/grab_seek/seek_position = -1.0
parameters/grabbed_attack_speed/scale = 1.0
parameters/grabbed_attacked/active = false
parameters/grabbed_scale/scale = 0.5
parameters/grabbed_seek/seek_position = -1.0
parameters/main/playback = SubResource( 2 )
parameters/main/Motion/playback = SubResource( 3 )
parameters/main/Motion/kneel/kneel_speed/scale = 1.0
parameters/main/Motion/stand/speed/scale = 1.0
parameters/main/Motion/stand/stand_speed/scale = 1.0
parameters/main/Motion/walk/speed/scale = 1.0
parameters/main/Motion/walk/walk_speed/scale = 1.0
parameters/main/Motion/walk/walking/blend_position = 0.0
parameters/main/Motion/wash_floor/TimeScale/scale = 1.0
parameters/main/SmartObject/playback = SubResource( 4 )
parameters/main/SmartObject/bed/playback = SubResource( 5 )
parameters/main/SmartObject/bed/beating/beating_speed/scale = 1.0
parameters/main/SmartObject/bed/beating_m/beating_m_speed/scale = 1.0
parameters/main/SmartObject/bed/bed_facing_up/TimeScale/scale = 1.0
parameters/main/SmartObject/bed/bed_start/bed_start_speed/scale = 1.0
parameters/main/SmartObject/bed/bed_start_m/bed_start_m_speed/scale = 1.0
parameters/main/SmartObject/bed/forcing/forcing_speed/scale = 1.0
parameters/main/SmartObject/bed/forcing_m/forcing_m_speed/scale = 1.0
parameters/main/SmartObject/bed/forcing_s1/forcing_s1_speed/scale = 1.0
parameters/main/SmartObject/bed/forcing_s1_m/forcing_s1_speed/scale = 1.0
parameters/throw/active = false
parameters/throw_speed/scale = 1.0
parameters/turn_left/active = false
parameters/turn_left_speed/scale = 1.0
parameters/turn_right/active = false
parameters/turn_right_speed/scale = 1.0
parameters/unstuck1/active = false
parameters/unstuck1_speed/scale = 1.0
parameters/unstuck2/active = false
parameters/unstuck2_speed/scale = 1.0
[node name="male_2018" parent="." instance=ExtResource( 1 )]
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,199 @@
extends Spatial
class_name SmartObject
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
var first
var second
var script1
var script2
var state = -1
var _state
class SmartObjectState:
var first
var second
var script1
var script2
var active = false
var next_cond
var exit_cond
var stage_name
func init(n, p1, s1, p2, s2):
stage_name = n
first = p1
second = p2
script1 = s1
script2 = s2
first.set_meta("smart_object", true)
second.set_meta("smart_object", true)
func activate():
second.add_collision_exception_with(first)
second.global_transform = first.global_transform
first.smart_obj(script1)
second.smart_obj(script2)
active = true
func leave():
active = false
func process():
if active:
second.global_transform = first.global_transform
func finalize():
second.remove_collision_exception_with(first)
first.do_stop()
second.do_stop()
first.set_meta("smart_object", false)
second.set_meta("smart_object", false)
func parse(sc: String):
var stages = {}
var init_stage
var cur_stage
var cur_character
for k in sc.split("\n"):
var sc_line: String = k
sc_line = sc_line.strip_edges()
if sc_line.substr(0, 1) == "#":
continue
var words: = Array(sc_line.split(" "))
if words[0] == "stage":
cur_stage = words[1]
if !init_stage:
init_stage = cur_stage
elif words[0] == "init:":
init_stage = cur_stage
elif words[0] == "first:":
cur_character = "first"
elif words[0] == "second:":
cur_character = "second"
elif words[0] == "next_cond":
assert(cur_stage)
if !stages.has(cur_stage):
stages[cur_stage] = {}
stages[cur_stage].next_cond = words.slice(1, words.size() - 1)
elif words[0] == "exit_cond":
assert(cur_stage)
if !stages.has(cur_stage):
stages[cur_stage] = {}
stages[cur_stage].exit_cond = words.slice(1, words.size() - 1)
elif words[0] == "next_stage":
assert(cur_stage)
if !stages.has(cur_stage):
stages[cur_stage] = {}
stages[cur_stage].next_stage = words[1]
elif words[0] == "mod_stat":
assert(cur_stage)
assert(cur_character)
if !stages.has(cur_stage):
stages[cur_stage] = {}
if !stages[cur_stage].has(cur_character):
stages[cur_stage][cur_character] = []
if !stages[cur_stage].has("mod_stats"):
stages[cur_stage].mod_stats = {}
if !stages[cur_stage].mod_stats.has(cur_character):
stages[cur_stage].mod_stats[cur_character] = {}
stages[cur_stage].mod_stats[cur_character][words[1]] = float(words[2])
else:
assert(cur_stage)
assert(cur_character)
if !stages.has(cur_stage):
stages[cur_stage] = {}
if !stages[cur_stage].has(cur_character):
stages[cur_stage][cur_character] = []
stages[cur_stage][cur_character].push_back(words)
for k in stages:
for e in stages[k]:
if e == "mod_stats":
continue
if !stages[k].has("mod_stats"):
stages[k].mod_stats = {}
if !stages[k].mod_stats.has(e):
stages[k].mod_stats[e] = {}
stages.init_stage = init_stage
print(stages)
return stages
func activate(npc, m_script, s, s_script):
main.init(npc, m_script, s, s_script)
_state = main
main.activate()
var _stages
var _exit_cond
var npcs = {}
func activate2(npc, s, script):
npcs.first = npc
npcs.second = s
_stages = parse(script)
for k in _stages.keys():
if k == "init_stage":
continue
var st = SmartObjectState.new()
_stages[k].obj = st
_stages[k].obj.init(k, npc, _stages[k].first, s, _stages[k].second)
if _stages[k].has("next_cond"):
_stages[k].obj.next_cond = _stages[k].next_cond
if _stages[k].has("exit_cond"):
_stages[k].obj.exit_cond = _stages[k].exit_cond
if k == _stages.init_stage:
_state = st
_state.activate()
func cond_stat_morethan(which, stat, val):
if npcs[which].get_meta(stat) > float(val):
return true
return false
func cond_stat_lessthan(which, stat, val):
if npcs[which].get_meta(stat) < float(val):
return true
return false
func _physics_process(delta):
if _state:
_state.process()
var nextc = false
var leave = false
for k in _stages[_state.stage_name]:
if k in ["mod_stats", "next_stage", "next_cond", "obj"]:
continue
var mod_stats = _stages[_state.stage_name].mod_stats[k]
for l in mod_stats.keys():
if npcs.has(k):
var sval = npcs[k].get_meta(l)
sval += mod_stats[l] * delta
npcs[k].set_meta(l, sval)
if _state.next_cond:
var c = _state.next_cond
if c.size() > 1:
nextc = callv(c[0], c.slice(1, c.size() - 1))
else:
nextc = callv(c[0], [])
if _state.exit_cond:
var c = _state.exit_cond
if c.size() > 1:
leave = callv(c[0], c.slice(1, c.size() - 1))
else:
leave = callv(c[0], [])
if nextc:
_state.leave()
if _stages[_state.stage_name].has("next_stage"):
var next = _stages[_state.stage_name].next_stage
_state = _stages[next].obj
_state.activate()
else:
_state.finalize()
_state = null
queue_free()
if leave:
_state.finalize()
_state = null
queue_free()
var main
func _ready():
main = SmartObjectState.new()
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

@@ -0,0 +1,36 @@
[remap]
importer="texture"
type="StreamTexture"
path.s3tc="res://.import/teeth.png-d6f1c3b87461533d507186ee347e1628.s3tc.stex"
path.etc2="res://.import/teeth.png-d6f1c3b87461533d507186ee347e1628.etc2.stex"
metadata={
"imported_formats": [ "s3tc", "etc2" ],
"vram_texture": true
}
[deps]
source_file="res://scenes/characters/teeth.png"
dest_files=[ "res://.import/teeth.png-d6f1c3b87461533d507186ee347e1628.s3tc.stex", "res://.import/teeth.png-d6f1c3b87461533d507186ee347e1628.etc2.stex" ]
[params]
compress/mode=2
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=true
flags/filter=true
flags/mipmaps=true
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0
Binary file not shown.

After

Width:  |  Height:  |  Size: 611 KiB

@@ -0,0 +1,36 @@
[remap]
importer="texture"
type="StreamTexture"
path.s3tc="res://.import/tongue01_diffuse.png-1e5b4e69a407696ad7e313af1e409e13.s3tc.stex"
path.etc2="res://.import/tongue01_diffuse.png-1e5b4e69a407696ad7e313af1e409e13.etc2.stex"
metadata={
"imported_formats": [ "s3tc", "etc2" ],
"vram_texture": true
}
[deps]
source_file="res://scenes/characters/tongue01_diffuse.png"
dest_files=[ "res://.import/tongue01_diffuse.png-1e5b4e69a407696ad7e313af1e409e13.s3tc.stex", "res://.import/tongue01_diffuse.png-1e5b4e69a407696ad7e313af1e409e13.etc2.stex" ]
[params]
compress/mode=2
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=true
flags/filter=true
flags/mipmaps=true
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0
+36
View File
@@ -0,0 +1,36 @@
extends KinematicBody
var orientation = Transform()
var velocity = Vector3()
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
var front_result = {}
var front_left_result = {}
var front_right_result = {}
var low_obstacle_result = {}
var unp_fixup_angle = 0.0
# Called when the node enters the scene tree for the first time.
func _ready():
add_to_group("agent")
unp_fixup_angle = (PI / 2.0 + PI / 2.0 * randf()) * sign(0.5 - randf())
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
func _physics_process(delta):
orientation *= Transform().translated(Vector3(0, 0, -1) * 0.1)
var h_velocity = orientation.origin / delta
velocity.x = h_velocity.x
velocity.z = h_velocity.z
velocity.y = h_velocity.y
# if !get_meta("grabbed") && !in_smart_obj && !disable_gravity:
velocity.y += -9.8
velocity = move_and_slide(velocity,Vector3(0,1,0))
orientation.origin = Vector3()
orientation = orientation.orthonormalized()
global_transform.basis = orientation.basis
+60
View File
@@ -0,0 +1,60 @@
extends Control
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
for k in $VBoxContainer/list.get_children():
k.queue_free()
var dst = INF
var player_pos = global.player.global_transform.origin
for k in get_tree().get_nodes_in_group("npc"):
var hb = HBoxContainer.new()
var label1 = Label.new()
label1.text = k.name
var label2 = Label.new()
if k.has_meta("action"):
label2.text = k.get_meta("action")
else:
label2.text = "unknown action"
hb.add_child(label1)
hb.add_child(label2)
$VBoxContainer/list.add_child(hb)
var npc_pos = k.global_transform.origin
var ndst = player_pos.distance_squared_to(npc_pos)
if ndst < dst:
var bb = k.get_node("blackboard")
$VBoxContainer/closest/name.text = k.name
dst = ndst
if k.has_meta("action"):
$VBoxContainer/closest/action.text = "action: " + k.get_meta("action")
var enemy = bb.get("closest_enemy")
if enemy:
$VBoxContainer/closest/closest_enemy.text = "enemy: " + enemy.name
else:
$VBoxContainer/closest/closest_enemy.text = "no enemy"
if k.has_meta("target_group"):
$VBoxContainer/closest/target_group.text = "target: " + k.get_meta("target_group")
else:
$VBoxContainer/closest/target_group.text = ""
if k.has_meta("target_loc"):
$VBoxContainer/closest/target_loc.text = "target loc: " + str(k.get_meta("target_loc"))
else:
$VBoxContainer/closest/target_loc.text = ""
if k.has_meta("path"):
$VBoxContainer/closest/path.text = "path: " + str(k.get_meta("path"))
else:
$VBoxContainer/closest/path.text = ""
if k.has_meta("path_point"):
$VBoxContainer/closest/path_point.text = "path point: " + str(k.get_meta("path_point"))
else:
$VBoxContainer/closest/path_point.text = ""
+74
View File
@@ -0,0 +1,74 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://scenes/debug/ai_debug.gd" type="Script" id=1]
[node name="ai_debug" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="VBoxContainer" type="VBoxContainer" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
size_flags_horizontal = 3
size_flags_vertical = 3
__meta__ = {
"_edit_use_anchors_": false
}
[node name="list" type="VBoxContainer" parent="VBoxContainer"]
margin_right = 1024.0
margin_bottom = 298.0
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="closest" type="VBoxContainer" parent="VBoxContainer"]
margin_top = 302.0
margin_right = 1024.0
margin_bottom = 600.0
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="name" type="Label" parent="VBoxContainer/closest"]
margin_right = 1024.0
margin_bottom = 14.0
text = "name"
[node name="action" type="Label" parent="VBoxContainer/closest"]
margin_top = 18.0
margin_right = 1024.0
margin_bottom = 32.0
text = "action"
[node name="closest_enemy" type="Label" parent="VBoxContainer/closest"]
margin_top = 36.0
margin_right = 1024.0
margin_bottom = 50.0
text = "action"
[node name="target_group" type="Label" parent="VBoxContainer/closest"]
margin_top = 54.0
margin_right = 1024.0
margin_bottom = 68.0
text = "action"
[node name="target_loc" type="Label" parent="VBoxContainer/closest"]
margin_top = 72.0
margin_right = 1024.0
margin_bottom = 86.0
text = "action"
[node name="path" type="Label" parent="VBoxContainer/closest"]
margin_top = 90.0
margin_right = 1024.0
margin_bottom = 104.0
text = "action"
[node name="path_point" type="Label" parent="VBoxContainer/closest"]
margin_top = 108.0
margin_right = 1024.0
margin_bottom = 122.0
text = "action"
@@ -0,0 +1,99 @@
extends Spatial
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
func _physics_process(delta):
for g in get_tree().get_nodes_in_group("agent"):
var bb = g
var space_state = g.get_world().direct_space_state
var up = Vector3(0, 1, 0)
var npc_pos = g.global_transform.origin
var front = -g.global_transform.basis[2]
var right = g.global_transform.basis[0]
var front_result = space_state.intersect_ray(npc_pos + up, npc_pos + up + front * 0.6,
[g], 0xffff)
bb.set("front_result", front_result)
var front_right_result = space_state.intersect_ray(npc_pos + up + right * 0.1, npc_pos + up + front * 0.8 + right * 0.3,
[g], 0xffff)
bb.set("front_right_result", front_right_result)
var front_left_result = space_state.intersect_ray(npc_pos + up - right * 0.1, npc_pos + up + front * 0.8 - right * 0.3,
[g], 0xffff)
bb.set("front_left_result", front_left_result)
var low_obstacle_result = space_state.intersect_ray(npc_pos + up * 0.3, npc_pos + up * 0.3 + front * 0.6,
[g], 0xffff)
bb.set("low_obstacle_result", low_obstacle_result)
for g in get_tree().get_nodes_in_group("agent"):
var bb = g
var front_result = bb.get("front_result")
var front_left_result = bb.get("front_left_result")
var front_right_result = bb.get("front_right_result")
var low_obstacle_result = bb.get("low_obstacle_result")
var front_col = false
var left_col = false
var right_col = false
var low_obstacle = false
if front_result.has("collider"):
var col = front_result.collider
if !col.is_in_group("entry"):
front_col = true
front_col = true
if front_left_result.has("collider"):
var col = front_left_result.collider
if !col.is_in_group("entry"):
left_col = true
left_col = true
if front_right_result.has("collider"):
var col = front_right_result.collider
if !col.is_in_group("entry"):
right_col = true
right_col = true
if !front_col:
if low_obstacle_result.has("collider"):
var col = low_obstacle_result.collider
if !col.is_in_group("entry"):
low_obstacle = true
# if left_col && right_col:
# if low_obstacle:
# npc.disable_gravity = true
# var c = [["set", "parameters/climb_low_obstacle/active", true]]
# npc.smart_obj(c)
var npc = g
var rot: Basis = npc.orientation.basis
if front_col:
var normal = front_result.normal
var xnormal = npc.global_transform.xform_inv(normal)
print("normal ", normal)
print("xnormal ", xnormal)
# var ok = false
# if xnormal.x < 0:
# rot = rot.rotated(Vector3(0, 1, 0), deg2rad(30 + 0.2 * (0.5 - randf())))
# ok = true
# elif xnormal.x > 0:
# rot = rot.rotated(Vector3(0, 1, 0), deg2rad(-30 + 0.2 * (0.5 - randf())))
# ok = true
if left_col && !right_col:
rot = rot.rotated(Vector3(0, 1, 0), deg2rad(-100 - 15.2 * (0.5 - randf())))
print("l")
elif right_col && !left_col:
rot = rot.rotated(Vector3(0, 1, 0), deg2rad(100 + 15.2 * (0.5 - randf())))
print("r")
elif right_col && left_col:
rot = rot.rotated(Vector3(0, 1, 0), npc.unp_fixup_angle)
# else:
# rot = rot.rotated(Vector3(0, 1, 0), deg2rad(10 + 10.0 * (0.5 - randf())))
var cur: Basis = npc.orientation.basis
cur = cur.slerp(rot, get_process_delta_time())
npc.orientation.basis = cur
@@ -0,0 +1,223 @@
[gd_scene load_steps=11 format=2]
[ext_resource path="res://scenes/debug/agent.gd" type="Script" id=1]
[ext_resource path="res://scenes/debug/steering_test.gd" type="Script" id=2]
[sub_resource type="CapsuleShape" id=1]
radius = 0.5
[sub_resource type="CapsuleMesh" id=3]
radius = 0.5
[sub_resource type="SpatialMaterial" id=8]
albedo_color = Color( 0.509804, 0.188235, 0.188235, 1 )
[sub_resource type="SphereMesh" id=7]
material = SubResource( 8 )
radius = 0.1
height = 0.2
[sub_resource type="BoxShape" id=2]
extents = Vector3( 20, 0.5, 10 )
[sub_resource type="PlaneMesh" id=4]
size = Vector2( 40, 20 )
[sub_resource type="CubeMesh" id=5]
[sub_resource type="ConcavePolygonShape" id=6]
data = PoolVector3Array( -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, -1 )
[node name="steering_test" type="Spatial"]
script = ExtResource( 2 )
[node name="agent" type="KinematicBody" parent="."]
script = ExtResource( 1 )
[node name="CollisionShape" type="CollisionShape" parent="agent"]
transform = Transform( 1, 0, 0, 0, -1.62921e-07, -1, 0, 1, -1.62921e-07, 0, 1, 0 )
shape = SubResource( 1 )
[node name="MeshInstance" type="MeshInstance" parent="agent"]
transform = Transform( 1, 0, 0, 0, -1.62921e-07, 1, 0, -1, -1.62921e-07, 0, 1, 0 )
mesh = SubResource( 3 )
material/0 = null
[node name="MeshInstance2" type="MeshInstance" parent="agent"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.554261 )
mesh = SubResource( 7 )
material/0 = null
[node name="agent2" type="KinematicBody" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1.85301 )
script = ExtResource( 1 )
[node name="CollisionShape" type="CollisionShape" parent="agent2"]
transform = Transform( 1, 0, 0, 0, -1.62921e-07, -1, 0, 1, -1.62921e-07, 0, 1, 0 )
shape = SubResource( 1 )
[node name="MeshInstance" type="MeshInstance" parent="agent2"]
transform = Transform( 1, 0, 0, 0, -1.62921e-07, 1, 0, -1, -1.62921e-07, 0, 1, 0 )
mesh = SubResource( 3 )
material/0 = null
[node name="MeshInstance2" type="MeshInstance" parent="agent2"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.554261 )
mesh = SubResource( 7 )
material/0 = null
[node name="agent3" type="KinematicBody" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 3.76611 )
script = ExtResource( 1 )
[node name="CollisionShape" type="CollisionShape" parent="agent3"]
transform = Transform( 1, 0, 0, 0, -1.62921e-07, -1, 0, 1, -1.62921e-07, 0, 1, 0 )
shape = SubResource( 1 )
[node name="MeshInstance" type="MeshInstance" parent="agent3"]
transform = Transform( 1, 0, 0, 0, -1.62921e-07, 1, 0, -1, -1.62921e-07, 0, 1, 0 )
mesh = SubResource( 3 )
material/0 = null
[node name="MeshInstance2" type="MeshInstance" parent="agent3"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.554261 )
mesh = SubResource( 7 )
material/0 = null
[node name="StaticBody" type="StaticBody" parent="."]
[node name="CollisionShape" type="CollisionShape" parent="StaticBody"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.5, 0 )
shape = SubResource( 2 )
[node name="MeshInstance" type="MeshInstance" parent="StaticBody"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, 0 )
mesh = SubResource( 4 )
material/0 = null
[node name="Camera" type="Camera" parent="."]
transform = Transform( 1, 0, 0, 0, 0.891481, 0.453057, 0, -0.453057, 0.891481, 0, 5, 3.608 )
[node name="DirectionalLight" type="DirectionalLight" parent="."]
transform = Transform( 1, 0, 0, 0, 0.707107, 0.707107, 0, -0.707107, 0.707107, 0, 25, 0 )
shadow_enabled = true
[node name="wall1" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, -8.79885 )
mesh = SubResource( 5 )
material/0 = null
[node name="StaticBody" type="StaticBody" parent="wall1"]
[node name="CollisionShape" type="CollisionShape" parent="wall1/StaticBody"]
shape = SubResource( 6 )
[node name="wall2" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 2.04237, 1, -8.80032 )
mesh = SubResource( 5 )
material/0 = null
[node name="StaticBody" type="StaticBody" parent="wall2"]
[node name="CollisionShape" type="CollisionShape" parent="wall2/StaticBody"]
shape = SubResource( 6 )
[node name="wall9" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 4.08062, 1, -8.80032 )
mesh = SubResource( 5 )
material/0 = null
[node name="StaticBody" type="StaticBody" parent="wall9"]
[node name="CollisionShape" type="CollisionShape" parent="wall9/StaticBody"]
shape = SubResource( 6 )
[node name="wall10" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 6.101, 1, -8.80032 )
mesh = SubResource( 5 )
material/0 = null
[node name="StaticBody" type="StaticBody" parent="wall10"]
[node name="CollisionShape" type="CollisionShape" parent="wall10/StaticBody"]
shape = SubResource( 6 )
[node name="wall11" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 8.15713, 1, -6.77994 )
mesh = SubResource( 5 )
material/0 = null
[node name="StaticBody" type="StaticBody" parent="wall11"]
[node name="CollisionShape" type="CollisionShape" parent="wall11/StaticBody"]
shape = SubResource( 6 )
[node name="wall12" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 8.15713, 1, -4.74169 )
mesh = SubResource( 5 )
material/0 = null
[node name="StaticBody" type="StaticBody" parent="wall12"]
[node name="CollisionShape" type="CollisionShape" parent="wall12/StaticBody"]
shape = SubResource( 6 )
[node name="wall3" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -2.02011, 1, -7.45936 )
mesh = SubResource( 5 )
material/0 = null
[node name="StaticBody" type="StaticBody" parent="wall3"]
[node name="CollisionShape" type="CollisionShape" parent="wall3/StaticBody"]
shape = SubResource( 6 )
[node name="wall4" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -3.34319, 1, -5.41119 )
mesh = SubResource( 5 )
material/0 = null
[node name="StaticBody" type="StaticBody" parent="wall4"]
[node name="CollisionShape" type="CollisionShape" parent="wall4/StaticBody"]
shape = SubResource( 6 )
[node name="wall5" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 3.28132, 1, -3.52095 )
mesh = SubResource( 5 )
material/0 = null
[node name="StaticBody" type="StaticBody" parent="wall5"]
[node name="CollisionShape" type="CollisionShape" parent="wall5/StaticBody"]
shape = SubResource( 6 )
[node name="wall6" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -3.32278, 1, -3.39579 )
mesh = SubResource( 5 )
material/0 = null
[node name="StaticBody" type="StaticBody" parent="wall6"]
[node name="CollisionShape" type="CollisionShape" parent="wall6/StaticBody"]
shape = SubResource( 6 )
[node name="wall7" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -3.3049, 1, -1.39596 )
mesh = SubResource( 5 )
material/0 = null
[node name="StaticBody" type="StaticBody" parent="wall7"]
[node name="CollisionShape" type="CollisionShape" parent="wall7/StaticBody"]
shape = SubResource( 6 )
[node name="wall8" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 3.28648, 1, -1.539 )
mesh = SubResource( 5 )
material/0 = null
[node name="StaticBody" type="StaticBody" parent="wall8"]
[node name="CollisionShape" type="CollisionShape" parent="wall8/StaticBody"]
shape = SubResource( 6 )
+22
View File
@@ -0,0 +1,22 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://scenes/maps/door_control.gd" type="Script" id=1]
[sub_resource type="BoxShape" id=1]
extents = Vector3( 0.120102, 1, 0.493961 )
[node name="door_control" type="Spatial"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -7.02733, 0, -8.06109 )
script = ExtResource( 1 )
[node name="e1" type="Area" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.393938, 0, 0.0576496 )
[node name="CollisionShape" type="CollisionShape" parent="e1"]
shape = SubResource( 1 )
[node name="e2" type="Area" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.326679, 0, 0.0672574 )
[node name="CollisionShape2" type="CollisionShape" parent="e2"]
shape = SubResource( 1 )
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
+237
View File
@@ -0,0 +1,237 @@
extends Spatial
var playback = {
"init": {
"slave": [
["travel", "parameters/main/playback", "SmartObject"],
["travel", "parameters/main/SmartObject/playback", "bed"],
["travel", "parameters/main/SmartObject/bed/playback", "bed_facing_up"],
["set", "parameters/free_grabbed/current", 0]
]
},
"engage": {
"master": [
["travel", "parameters/main/playback", "SmartObject"],
["travel", "parameters/main/SmartObject/playback", "bed"],
["travel", "parameters/main/SmartObject/bed/playback", "bed_start_m"],
["set", "parameters/free_grabbed/current", 0]
],
"slave": [
["travel", "parameters/main/playback", "SmartObject"],
["travel", "parameters/main/SmartObject/playback", "bed"],
["travel", "parameters/main/SmartObject/bed/playback", "bed_start"],
["set", "parameters/free_grabbed/current", 0]
]
},
"torture": {
"master": [
["travel", "parameters/main/playback", "SmartObject"],
["travel", "parameters/main/SmartObject/playback", "bed"],
["travel", "parameters/main/SmartObject/bed/playback", "beating_m"],
["set", "parameters/free_grabbed/current", 0]
],
"slave": [
["travel", "parameters/main/playback", "SmartObject"],
["travel", "parameters/main/SmartObject/playback", "bed"],
["travel", "parameters/main/SmartObject/bed/playback", "beating"],
["set", "parameters/free_grabbed/current", 0]
]
},
"force": {
"master": [
["travel", "parameters/main/playback", "SmartObject"],
["travel", "parameters/main/SmartObject/playback", "bed"],
["travel", "parameters/main/SmartObject/bed/playback", "forcing_m"],
["set", "parameters/free_grabbed/current", 0]
],
"slave": [
["travel", "parameters/main/playback", "SmartObject"],
["travel", "parameters/main/SmartObject/playback", "bed"],
["travel", "parameters/main/SmartObject/bed/playback", "forcing"],
["set", "parameters/free_grabbed/current", 0]
]
},
"force_s1": {
"master": [
["travel", "parameters/main/playback", "SmartObject"],
["travel", "parameters/main/SmartObject/playback", "bed"],
["travel", "parameters/main/SmartObject/bed/playback", "forcing_s1_m"],
["set", "parameters/free_grabbed/current", 0]
],
"slave": [
["travel", "parameters/main/playback", "SmartObject"],
["travel", "parameters/main/SmartObject/playback", "bed"],
["travel", "parameters/main/SmartObject/bed/playback", "forcing_s1"],
["set", "parameters/free_grabbed/current", 0]
]
}
}
var state = "init"
var active_state = ""
var bodies = []
func entered(body):
if body.is_in_group("characters"):
if body.get_meta("grabbing"):
bodies.push_back(body)
global.smart_object.push_back(body)
print("entered:", body.name)
elif !body.get_meta("grabbed"):
bodies.push_back(body)
func exited(body):
if body in bodies:
print("exited:", body.name)
bodies.erase(body)
global.smart_object.erase(body)
var move_queue = []
var captured = []
func capture_slave(ch, orig_owner):
ch.add_collision_exception_with(orig_owner)
ch.set_meta("smart_object", true)
ch.set_meta("orig_owner", get_path_to(orig_owner))
for place in get_children():
if place.name.begins_with("place"):
if !place.has_meta("busy"):
move_queue.push_back([ch, place])
place.set_meta("busy", ch)
print("place: ", place.name)
break
captured.push_back(get_path_to(ch))
func free_slave(ch):
var orig_owner = ch.get_meta("orig_owner")
ch.remove_collision_exception_with(get_node(orig_owner))
ch.set_meta("smart_object", false)
ch.remove_meta("orig_owner")
var activate_delay = 0.0
func activate():
if activate_delay > 0.0:
return
if state in ["init", "engage", "torture"]:
activate_state()
activate_delay += 0.5
func activate_state():
# if active_state == state:
# return
print("ACTIVATE ", state)
match(state):
"init":
for k in bodies:
var ch = grabbing.get_grabbed(k)
if !ch:
continue
var s = playback[state]["slave"]
print("ungrab")
print("SMART: ", s)
grabbing.ungrab_character(k, s)
capture_slave(ch, k)
state = "engage"
"engage":
for k in bodies:
if k.get_meta("smart_object"):
continue
for place in get_children():
if place.name.begins_with("place"):
if place.has_meta("busy"):
print("has npc")
if !place.has_meta("master"):
print("has no master")
place.set_meta("master", k)
k.set_meta("smart_object", true)
print(k.name)
place.get_meta("busy").smart_obj(playback[state]["slave"])
place.get_meta("master").smart_obj(playback[state]["master"])
state = "torture"
"torture":
for place in get_children():
if place.name.begins_with("place"):
if place.has_meta("busy"):
if place.has_meta("master"):
place.get_meta("busy").smart_obj(playback[state]["slave"])
place.get_meta("master").smart_obj(playback[state]["master"])
"force":
for place in get_children():
if place.name.begins_with("place"):
if place.has_meta("busy"):
if place.has_meta("master"):
place.get_meta("busy").smart_obj(playback[state]["slave"])
place.get_meta("master").smart_obj(playback[state]["master"])
"force_s1":
for place in get_children():
if place.name.begins_with("place"):
if place.has_meta("busy"):
if place.has_meta("master"):
place.get_meta("busy").smart_obj(playback[state]["slave"])
place.get_meta("master").smart_obj(playback[state]["master"])
"leave":
for place in get_children():
if place.has_meta("busy") && place.has_meta("master"):
var m = place.get_meta("master")
m.set_meta("smart_object", false)
place.remove_meta("master")
m.do_stop()
var s = place.get_meta("busy")
free_slave(s)
place.remove_meta("busy")
s.do_stop()
var sub = rpg.get_submission(s)
sub += 100.0
s.set_meta("submission", sub)
rpg.update_xp(m, 300.0)
active_state = state
func _ready():
var e = $Area.connect("body_entered", self, "entered")
assert(e == OK)
e = $Area.connect("body_exited", self, "exited")
assert(e == OK)
var act = false
func _process(_delta):
if Input.is_action_just_pressed("grab"):
act = true
func _physics_process(delta):
if act:
activate()
act = false
while move_queue.size() > 0:
var item = move_queue.pop_front()
item[0].global_transform = item[1].global_transform
for place in get_children():
if place.has_meta("busy"):
place.get_meta("busy").global_transform = place.global_transform
place.get_meta("busy").orientation.basis = place.global_transform.basis
if place.has_meta("master"):
place.get_meta("master").global_transform = place.global_transform
place.get_meta("master").orientation.basis = place.global_transform.basis
activate_delay -= delta
if active_state == "torture":
for place in get_children():
if place.has_meta("busy") && place.has_meta("master"):
var strength = rpg.get_strength(place.get_meta("master"))
rpg.damage_stamina(place.get_meta("busy"), strength * 0.1 * delta)
print(rpg.get_stamina(place.get_meta("busy")))
if rpg.get_stamina(place.get_meta("busy")) <= 10.0:
state = "force"
activate_state()
rpg.damage_stamina(place.get_meta("master"), 5.0 * delta)
if active_state == "force":
for place in get_children():
if place.has_meta("busy") && place.has_meta("master"):
var strength = rpg.get_strength(place.get_meta("master"))
rpg.damage_stamina(place.get_meta("busy"), strength * 0.01 * delta)
print(rpg.get_stamina(place.get_meta("busy")))
if rpg.get_stamina(place.get_meta("busy")) <= 10.0:
state = "force_s1"
activate_state()
rpg.damage_stamina(place.get_meta("master"), 1.0 * delta)
if active_state == "force_s1":
for place in get_children():
if place.has_meta("busy") && place.has_meta("master"):
var strength = rpg.get_strength(place.get_meta("master"))
rpg.damage_stamina(place.get_meta("busy"), strength * 0.01 * delta)
print(rpg.get_stamina(place.get_meta("busy")))
rpg.damage_stamina(place.get_meta("master"), 1.0 * delta)
if rpg.get_stamina(place.get_meta("busy")) <= 0.0:
state = "leave"
activate_state()
if active_state == "leave":
state = "init"
active_state = ""
+19
View File
@@ -0,0 +1,19 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://scenes/furniture/bed.escn" type="PackedScene" id=1]
[ext_resource path="res://scenes/furniture/bed.gd" type="Script" id=2]
[sub_resource type="BoxShape" id=1]
extents = Vector3( 0.741339, 0.577236, 1.07588 )
[node name="bed" instance=ExtResource( 1 )]
script = ExtResource( 2 )
[node name="Area" type="Area" parent="." index="1"]
[node name="CollisionShape" type="CollisionShape" parent="Area" index="0"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.595083, 0 )
shape = SubResource( 1 )
[node name="place1" type="Spatial" parent="." index="2"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.133919, 0.464468, 0.90286 )
+540
View File
@@ -0,0 +1,540 @@
[gd_scene load_steps=1 format=2]
[sub_resource id=1 type="Shader"]
resource_name = "Shader Nodetree"
code = "shader_type spatial;
render_mode blend_mix, depth_draw_always, cull_back, diffuse_burley, specular_schlick_ggx;
void node_bsdf_principled(vec4 color, float subsurface, vec4 subsurface_color,
float metallic, float specular, float roughness, float clearcoat,
float clearcoat_roughness, float anisotropy, float transmission,
float IOR, out vec3 albedo, out float sss_strength_out,
out float metallic_out, out float specular_out,
out float roughness_out, out float clearcoat_out,
out float clearcoat_gloss_out, out float anisotropy_out,
out float transmission_out, out float ior) {
metallic = clamp(metallic, 0.0, 1.0);
transmission = clamp(transmission, 0.0, 1.0);
subsurface = subsurface * (1.0 - metallic);
albedo = mix(color.rgb, subsurface_color.rgb, subsurface);
sss_strength_out = subsurface;
metallic_out = metallic;
specular_out = pow((IOR - 1.0)/(IOR + 1.0), 2)/0.08;
roughness_out = roughness;
clearcoat_out = clearcoat * (1.0 - transmission);
clearcoat_gloss_out = 1.0 - clearcoat_roughness;
anisotropy_out = clamp(anisotropy, 0.0, 1.0);
transmission_out = (1.0 - transmission) * (1.0 - metallic);
ior = IOR;
}
void vertex () {
}
void fragment () {
// node: 'Principled BSDF'
// type: 'ShaderNodeBsdfPrincipled'
// input sockets handling
vec4 node0_in0_basecolor = vec4(0.6399999856948853, 0.6399999856948853,
0.6399999856948853, 1.0);
float node0_in1_subsurface = float(0.0);
vec3 node0_in2_subsurfaceradius = vec3(1.0, 0.20000000298023224,
0.10000000149011612);
vec4 node0_in3_subsurfacecolor = vec4(0.800000011920929, 0.800000011920929,
0.800000011920929, 1.0);
float node0_in4_metallic = float(0.0);
float node0_in5_specular = float(0.019999999552965164);
float node0_in6_speculartint = float(0.0);
float node0_in7_roughness = float(1.0);
float node0_in8_anisotropic = float(0.0);
float node0_in9_anisotropicrotation = float(0.0);
float node0_in10_sheen = float(0.0);
float node0_in11_sheentint = float(0.5);
float node0_in12_clearcoat = float(0.0);
float node0_in13_clearcoatroughness = float(0.029999999329447746);
float node0_in14_ior = float(1.0);
float node0_in15_transmission = float(0.0);
float node0_in16_transmissionroughness = float(0.0);
vec4 node0_in17_emission = vec4(0.0, 0.0, 0.0, 1.0);
float node0_in18_alpha = float(1.0);
vec3 node0_in19_normal = NORMAL;
vec3 node0_in20_clearcoatnormal = vec3(0.0, 0.0, 0.0);
vec3 node0_in21_tangent = TANGENT;
// output sockets definitions
vec3 node0_bsdf_out0_albedo;
float node0_bsdf_out1_sss_strength;
float node0_bsdf_out3_specular;
float node0_bsdf_out2_metallic;
float node0_bsdf_out4_roughness;
float node0_bsdf_out5_clearcoat;
float node0_bsdf_out6_clearcoat_gloss;
float node0_bsdf_out7_anisotropy;
float node0_bsdf_out8_transmission;
float node0_bsdf_out9_ior;
node_bsdf_principled(node0_in0_basecolor, node0_in1_subsurface,
node0_in3_subsurfacecolor, node0_in4_metallic, node0_in5_specular,
node0_in7_roughness, node0_in12_clearcoat, node0_in13_clearcoatroughness,
node0_in8_anisotropic, node0_in15_transmission, node0_in14_ior,
node0_bsdf_out0_albedo, node0_bsdf_out1_sss_strength, node0_bsdf_out2_metallic,
node0_bsdf_out3_specular, node0_bsdf_out4_roughness, node0_bsdf_out5_clearcoat,
node0_bsdf_out6_clearcoat_gloss, node0_bsdf_out7_anisotropy,
node0_bsdf_out8_transmission, node0_bsdf_out9_ior);
ALBEDO = node0_bsdf_out0_albedo;
SSS_STRENGTH = node0_bsdf_out1_sss_strength;
SPECULAR = node0_bsdf_out3_specular;
METALLIC = node0_bsdf_out2_metallic;
ROUGHNESS = node0_bsdf_out4_roughness;
CLEARCOAT = node0_bsdf_out5_clearcoat;
CLEARCOAT_GLOSS = node0_bsdf_out6_clearcoat_gloss;
NORMAL = node0_in19_normal;
// uncomment it when you need it
// TRANSMISSION = vec3(1.0, 1.0, 1.0) * node0_bsdf_out8_transmission;
// uncomment it when you are modifing TANGENT
// TANGENT = normalize(cross(cross(node0_in21_tangent, NORMAL), NORMAL));
// BINORMAL = cross(TANGENT, NORMAL);
// uncomment it when you have tangent(UV) set
// ANISOTROPY = node0_bsdf_out7_anisotropy;
}
"
[sub_resource id=2 type="ShaderMaterial"]
resource_name = ""
shader = SubResource(1)
[sub_resource id=3 type="ArrayMesh"]
resource_name = "closet"
surfaces/0 = {
"material":SubResource(2),
"primitive":4,
"arrays":[
Vector3Array(0.518332, 1.89936, 0.670455, 0.518332, 0.0134721, 0.00236547, 0.518332, 1.89936, 0.00236556, 0.518332, 1.89936, 0.00236556, -0.481668, 0.0134721, 0.00236547, -0.481668, 1.89936, 0.00236556, -0.481668, 1.89936, 0.670455, 0.518332, 1.89936, 0.00236556, -0.481668, 1.89936, 0.00236556, 0.446375, 1.8274, 0.670455, 0.518332, 0.0134721, 0.670455, 0.518332, 1.89936, 0.670455, 0.518332, 0.0134721, 0.670455, -0.481668, 0.0134721, 0.00236547, 0.518332, 0.0134721, 0.00236547, -0.481668, 1.89936, 0.00236556, -0.481668, 0.0134721, 0.670455, -0.481668, 1.89936, 0.670455, -0.40971, 0.076086, 0.670455, -0.40971, 1.8274, 0.670455, -0.481668, 0.0134721, 0.670455, -0.00357551, 1.8274, 0.589424, 0.052192, 1.8274, 0.589424, 0.446375, 1.8274, 0.670455, 0.446375, 1.8274, 0.670455, 0.446375, 0.076086, 0.074323, 0.446375, 0.076086, 0.670455, -0.40971, 0.880073, 0.573859, -0.40971, 1.34076, 0.573859, -0.40971, 1.8274, 0.670455, -0.40971, 1.38007, 0.0743235, -0.00357551, 1.8274, 0.0743236, -0.40971, 1.8274, 0.0743236, -0.00357551, 0.840766, 0.573858, -0.00357551, 0.380074, 0.573858, -0.00357551, 0.076086, 0.589423, -0.00357551, 0.076086, 0.589423, 0.052192, 1.8274, 0.589424, -0.00357551, 1.8274, 0.589424, 0.052192, 0.076086, 0.589423, 0.052192, 1.8274, 0.0743231, 0.052192, 1.8274, 0.589424, 0.446375, 0.076086, 0.074323, 0.052192, 1.8274, 0.0743231, 0.052192, 0.076086, 0.074323, -0.40971, 0.076086, 0.670455, 0.446375, 0.076086, 0.670455, -0.00357551, 0.076086, 0.589423, -0.40971, 0.076086, 0.0743235, -0.00357551, 0.340766, 0.0743235, -0.40971, 0.340766, 0.0743235, -0.40971, 0.380074, 0.0743235, -0.00357551, 0.840766, 0.0743235, -0.40971, 0.840766, 0.0743235, -0.40971, 0.840766, 0.573858, -0.00357551, 0.840766, 0.0743235, -0.00357551, 0.840766, 0.573858, -0.40971, 0.880073, 0.573859, -0.00357551, 0.840766, 0.573858, -0.00357551, 0.880073, 0.573859, -0.00357551, 0.880073, 0.573859, -0.40971, 0.880073, 0.0743235, -0.40971, 0.880073, 0.573859, -0.40971, 0.880073, 0.0743235, -0.00357551, 1.34076, 0.0743235, -0.40971, 1.34076, 0.0743235, -0.40971, 1.34076, 0.573859, -0.00357551, 1.34076, 0.0743235, -0.00357551, 1.34076, 0.573859, -0.40971, 1.38007, 0.573859, -0.00357551, 1.34076, 0.573859, -0.00357551, 1.38007, 0.573859, -0.00357551, 1.38007, 0.573859, -0.40971, 1.38007, 0.0743235, -0.40971, 1.38007, 0.573859, -0.40971, 0.380074, 0.573858, -0.00357551, 0.340766, 0.573858, -0.00357551, 0.380074, 0.573858, -0.00357551, 0.380074, 0.573858, -0.40971, 0.380074, 0.0743235, -0.40971, 0.380074, 0.573858, -0.40971, 0.340766, 0.573858, -0.00357551, 0.340766, 0.0743235, -0.00357551, 0.340766, 0.573858, 0.518332, 0.0134721, 0.670455, 0.518332, 0.0134721, 0.00236547, 0.518332, 1.89936, 0.670455, -0.481668, 1.89936, 0.670455, 0.446375, 0.076086, 0.670455, -0.481668, 0.0134721, 0.670455, -0.481668, 0.0134721, 0.00236547, -0.40971, 1.8274, 0.670455, -0.40971, 1.8274, 0.0743236, -0.00357551, 1.8274, 0.0743236, 0.052192, 1.8274, 0.0743231, 0.446375, 1.8274, 0.0743231, 0.446375, 1.8274, 0.0743231, -0.40971, 0.076086, 0.670455, -0.40971, 0.076086, 0.0743235, -0.40971, 0.340766, 0.573858, -0.40971, 0.340766, 0.0743235, -0.40971, 1.38007, 0.0743235, -0.40971, 1.8274, 0.0743236, -0.40971, 1.38007, 0.573859, -0.40971, 0.380074, 0.573858, -0.40971, 0.380074, 0.0743235, -0.40971, 0.840766, 0.0743235, -0.40971, 0.840766, 0.573858, -0.40971, 0.880073, 0.0743235, -0.40971, 1.34076, 0.0743235, -0.00357551, 1.38007, 0.0743235, -0.00357551, 1.8274, 0.589424, -0.00357551, 1.8274, 0.0743236, -0.00357551, 1.38007, 0.573859, -0.00357551, 1.38007, 0.0743235, -0.00357551, 0.340766, 0.0743235, -0.00357551, 0.076086, 0.0743235, -0.00357551, 0.340766, 0.573858, -0.00357551, 0.880073, 0.573859, -0.00357551, 1.34076, 0.573859, -0.00357551, 1.34076, 0.0743235, -0.00357551, 0.880073, 0.0743235, -0.00357551, 0.840766, 0.0743235, -0.00357551, 0.380074, 0.0743235, 0.052192, 0.076086, 0.589423, 0.052192, 0.076086, 0.074323, 0.446375, 1.8274, 0.0743231, 0.446375, 0.076086, 0.074323, 0.052192, 0.076086, 0.589423, 0.052192, 0.076086, 0.074323, -0.00357551, 0.076086, 0.0743235, -0.40971, 0.076086, 0.0743235, -0.00357551, 0.076086, 0.0743235, -0.00357551, 0.380074, 0.0743235, -0.40971, 0.840766, 0.0743235, -0.40971, 0.840766, 0.573858, -0.00357551, 0.880073, 0.0743235, -0.00357551, 0.880073, 0.0743235, -0.40971, 1.34076, 0.0743235, -0.40971, 1.34076, 0.573859, -0.00357551, 1.38007, 0.0743235, -0.40971, 0.340766, 0.573858, -0.00357551, 0.380074, 0.0743235, -0.40971, 0.340766, 0.0743235),
Vector3Array(1.0, 0.0, 5.1487e-09, 1.0, 0.0, 1.8606e-08, 1.0, 0.0, 0.0, 0.0, 4.74084e-08, -1.0, 0.0, 4.74084e-08, -1.0, 0.0, 4.74084e-08, -1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 2.93786e-07, -1.05504e-06, 1.0, 2.35911e-07, 8.35406e-07, 1.0, 2.90353e-07, -7.90992e-07, 1.0, 0.0, -1.0, -4.32143e-08, 0.0, -1.0, -4.32143e-08, 0.0, -1.0, -4.32143e-08, -1.0, 0.0, 4.78451e-09, -1.0, 0.0, 1.72899e-08, -1.0, 0.0, 0.0, 2.60951e-07, -9.20937e-07, 1.0, 2.24448e-07, 1.51451e-06, 1.0, 2.31943e-07, -8.70686e-07, 1.0, 2.29882e-07, -1.0, 0.0, -9.04573e-08, -1.0, 0.0, -3.31371e-07, -1.0, 0.0, -1.0, 0.0, 1.85264e-08, -1.0, 0.0, 7.01728e-08, -1.0, 0.0, 8.86991e-08, 1.0, 0.0, 5.29904e-08, 1.0, 1.95241e-14, 1.5066e-09, 1.0, 1.49341e-07, -6.89472e-07, 0.0, -6.15151e-08, 1.0, 0.0, -6.15151e-08, 1.0, 0.0, -6.15151e-08, 1.0, -1.0, 0.0, -5.03943e-07, -1.0, 0.0, 2.12941e-08, -1.0, 0.0, 1.01615e-09, 0.0, -7.47399e-08, 1.0, 0.0, -1.5459e-09, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, -1.35101e-08, 1.0, 0.0, -3.0081e-09, 1.0, 0.0, 0.0, 0.0, -5.32026e-08, 1.0, 0.0, -4.93274e-08, 1.0, 0.0, -5.39632e-08, 1.0, 1.68222e-08, 1.0, 5.52527e-08, -2.76142e-08, 1.0, 5.5408e-08, 4.48989e-09, 1.0, 7.52739e-08, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, -2.29335e-07, 1.0, 0.0, -3.50434e-06, 1.0, 0.0, -3.73367e-06, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, -7.0483e-08, 1.0, 0.0, -6.88895e-08, 1.0, 0.0, -5.97311e-08, 1.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, 1.0, 0.0, 2.37547e-08, 0.0, 4.74084e-08, -1.0, 0.0, 1.0, 0.0, 2.22615e-07, 1.60175e-06, 1.0, 2.72321e-07, 1.14468e-06, 1.0, 0.0, -1.0, -4.32143e-08, -1.0, 0.0, 2.20744e-08, 8.61295e-07, -1.0, 0.0, 4.18568e-07, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, -1.58217e-07, -1.0, 0.0, -1.0, 0.0, 0.0, 1.0, -2.26892e-07, -7.26161e-07, 1.0, -9.05513e-08, -9.92635e-07, 1.0, -8.88019e-08, -1.55459e-06, 1.0, 0.0, -1.01432e-06, 1.0, 1.27191e-13, -9.33583e-07, 1.0, 8.03072e-08, -9.15209e-07, 1.0, 3.86019e-08, 4.53385e-06, 1.0, 0.0, -4.50756e-07, 1.0, 0.0, -1.03601e-06, 1.0, 0.0, -9.74591e-07, 1.0, 0.0, 9.74448e-06, 1.0, 6.49297e-14, -9.67925e-07, 1.0, 1.23502e-13, -9.06508e-07, 0.0, -6.15151e-08, 1.0, -1.0, 0.0, 2.3574e-10, -1.0, 0.0, 0.0, -1.0, 0.0, -3.13612e-08, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, 2.64865e-10, -1.0, 0.0, 2.06983e-10, -1.0, 0.0, -3.01341e-09, -1.0, 0.0, 2.11035e-08, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, -7.62858e-08, 1.0, 1.0, 0.0, -1.65182e-08, 0.0, -4.85669e-08, 1.0, -1.31847e-08, 1.0, 4.61374e-08, -7.53811e-09, 1.0, 7.52428e-08, 0.0, 1.0, 4.3393e-08, 0.0, 1.0, 4.3393e-08, 8.17515e-09, 1.0, 4.61983e-08, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, -1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, -7.96414e-08, 1.0, 0.0, -1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, -1.0, 0.0),
null, ; No Tangents,
null, ; no Vertex Colors,
null, ; No UV1,
null, ; No UV2,
null, ; No Bones,
null, ; No Weights,
IntArray(0, 2, 1, 3, 5, 4, 6, 8, 7, 9, 11, 10, 12, 14, 13, 15, 17, 16, 18, 20, 19, 21, 23, 22, 24, 26, 25, 27, 29, 28, 30, 32, 31, 33, 35, 34, 36, 38, 37, 39, 41, 40, 42, 44, 43, 45, 47, 46, 48, 50, 49, 51, 53, 52, 54, 56, 55, 57, 59, 58, 60, 62, 61, 63, 65, 64, 66, 68, 67, 69, 71, 70, 72, 74, 73, 75, 77, 76, 78, 80, 79, 81, 83, 82, 0, 1, 84, 3, 4, 85, 6, 7, 86, 87, 11, 19, 19, 11, 9, 9, 10, 88, 12, 13, 89, 15, 16, 90, 19, 20, 87, 20, 18, 10, 10, 18, 88, 91, 21, 92, 92, 21, 93, 94, 22, 95, 95, 22, 23, 91, 23, 21, 24, 25, 96, 97, 99, 98, 98, 99, 100, 101, 103, 102, 102, 103, 29, 29, 27, 97, 97, 104, 99, 104, 106, 105, 97, 107, 104, 27, 107, 97, 28, 29, 103, 108, 28, 109, 27, 28, 108, 104, 107, 106, 30, 31, 110, 111, 113, 112, 112, 113, 114, 115, 117, 116, 116, 117, 35, 35, 118, 111, 111, 119, 113, 119, 118, 120, 120, 118, 121, 111, 118, 119, 34, 35, 117, 122, 34, 123, 33, 34, 122, 118, 35, 33, 36, 37, 124, 39, 40, 125, 42, 43, 126, 46, 128, 127, 127, 128, 129, 130, 47, 131, 131, 47, 45, 46, 47, 128, 48, 49, 132, 51, 52, 133, 54, 55, 134, 57, 58, 135, 60, 61, 136, 63, 64, 137, 66, 67, 138, 69, 70, 139, 72, 73, 140, 75, 76, 141, 78, 79, 142, 81, 82, 143)
],
"morph_arrays":[]
}
[sub_resource id=4 type="Shader"]
resource_name = "Shader Nodetree"
code = "shader_type spatial;
render_mode blend_mix, depth_draw_always, cull_back, diffuse_burley, specular_schlick_ggx;
void node_bsdf_principled(vec4 color, float subsurface, vec4 subsurface_color,
float metallic, float specular, float roughness, float clearcoat,
float clearcoat_roughness, float anisotropy, float transmission,
float IOR, out vec3 albedo, out float sss_strength_out,
out float metallic_out, out float specular_out,
out float roughness_out, out float clearcoat_out,
out float clearcoat_gloss_out, out float anisotropy_out,
out float transmission_out, out float ior) {
metallic = clamp(metallic, 0.0, 1.0);
transmission = clamp(transmission, 0.0, 1.0);
subsurface = subsurface * (1.0 - metallic);
albedo = mix(color.rgb, subsurface_color.rgb, subsurface);
sss_strength_out = subsurface;
metallic_out = metallic;
specular_out = pow((IOR - 1.0)/(IOR + 1.0), 2)/0.08;
roughness_out = roughness;
clearcoat_out = clearcoat * (1.0 - transmission);
clearcoat_gloss_out = 1.0 - clearcoat_roughness;
anisotropy_out = clamp(anisotropy, 0.0, 1.0);
transmission_out = (1.0 - transmission) * (1.0 - metallic);
ior = IOR;
}
void vertex () {
}
void fragment () {
// node: 'Principled BSDF'
// type: 'ShaderNodeBsdfPrincipled'
// input sockets handling
vec4 node0_in0_basecolor = vec4(0.6399999856948853, 0.6399999856948853,
0.6399999856948853, 1.0);
float node0_in1_subsurface = float(0.0);
vec3 node0_in2_subsurfaceradius = vec3(1.0, 0.20000000298023224,
0.10000000149011612);
vec4 node0_in3_subsurfacecolor = vec4(0.800000011920929, 0.800000011920929,
0.800000011920929, 1.0);
float node0_in4_metallic = float(0.0);
float node0_in5_specular = float(0.019999999552965164);
float node0_in6_speculartint = float(0.0);
float node0_in7_roughness = float(1.0);
float node0_in8_anisotropic = float(0.0);
float node0_in9_anisotropicrotation = float(0.0);
float node0_in10_sheen = float(0.0);
float node0_in11_sheentint = float(0.5);
float node0_in12_clearcoat = float(0.0);
float node0_in13_clearcoatroughness = float(0.029999999329447746);
float node0_in14_ior = float(1.0);
float node0_in15_transmission = float(0.0);
float node0_in16_transmissionroughness = float(0.0);
vec4 node0_in17_emission = vec4(0.0, 0.0, 0.0, 1.0);
float node0_in18_alpha = float(1.0);
vec3 node0_in19_normal = NORMAL;
vec3 node0_in20_clearcoatnormal = vec3(0.0, 0.0, 0.0);
vec3 node0_in21_tangent = TANGENT;
// output sockets definitions
vec3 node0_bsdf_out0_albedo;
float node0_bsdf_out1_sss_strength;
float node0_bsdf_out3_specular;
float node0_bsdf_out2_metallic;
float node0_bsdf_out4_roughness;
float node0_bsdf_out5_clearcoat;
float node0_bsdf_out6_clearcoat_gloss;
float node0_bsdf_out7_anisotropy;
float node0_bsdf_out8_transmission;
float node0_bsdf_out9_ior;
node_bsdf_principled(node0_in0_basecolor, node0_in1_subsurface,
node0_in3_subsurfacecolor, node0_in4_metallic, node0_in5_specular,
node0_in7_roughness, node0_in12_clearcoat, node0_in13_clearcoatroughness,
node0_in8_anisotropic, node0_in15_transmission, node0_in14_ior,
node0_bsdf_out0_albedo, node0_bsdf_out1_sss_strength, node0_bsdf_out2_metallic,
node0_bsdf_out3_specular, node0_bsdf_out4_roughness, node0_bsdf_out5_clearcoat,
node0_bsdf_out6_clearcoat_gloss, node0_bsdf_out7_anisotropy,
node0_bsdf_out8_transmission, node0_bsdf_out9_ior);
ALBEDO = node0_bsdf_out0_albedo;
SSS_STRENGTH = node0_bsdf_out1_sss_strength;
SPECULAR = node0_bsdf_out3_specular;
METALLIC = node0_bsdf_out2_metallic;
ROUGHNESS = node0_bsdf_out4_roughness;
CLEARCOAT = node0_bsdf_out5_clearcoat;
CLEARCOAT_GLOSS = node0_bsdf_out6_clearcoat_gloss;
NORMAL = node0_in19_normal;
// uncomment it when you need it
// TRANSMISSION = vec3(1.0, 1.0, 1.0) * node0_bsdf_out8_transmission;
// uncomment it when you are modifing TANGENT
// TANGENT = normalize(cross(cross(node0_in21_tangent, NORMAL), NORMAL));
// BINORMAL = cross(TANGENT, NORMAL);
// uncomment it when you have tangent(UV) set
// ANISOTROPY = node0_bsdf_out7_anisotropy;
}
"
[sub_resource id=5 type="ShaderMaterial"]
resource_name = ""
shader = SubResource(4)
[sub_resource id=6 type="ArrayMesh"]
resource_name = "closet_door_left"
surfaces/0 = {
"material":SubResource(5),
"primitive":4,
"arrays":[
Vector3Array(0.00635256, 1.82395, -0.00049841, 0.366967, 0.817119, -0.00049847, 0.366967, 1.09745, -0.00049847, 0.399134, 0.817119, -0.00049847, 0.42621, 0.0835765, -0.00049847, 0.00635256, 1.82395, -0.00049841, 0.42621, 1.82395, -0.0324249, 0.00635256, 1.82395, -0.0324249, 0.000172034, 1.82395, -0.00049841, 0.00635256, 0.0835765, -0.00049847, 0.00635256, 0.0835765, -0.032425, 0.42621, 0.0835765, -0.00049847, 0.00635256, 0.0835765, -0.00049847, 0.42621, 1.82395, -0.00049841, 0.42621, 0.0835765, -0.032425, 0.42621, 1.82395, -0.0324249, 0.00635256, 1.82395, -0.0324249, 0.42621, 0.0835765, -0.032425, 0.00635256, 0.0835765, -0.032425, 0.000172034, 1.82395, -0.00049841, 0.000172034, 1.82395, -0.0324249, 0.000172034, 1.82395, -0.0324249, 0.000172034, 0.0835765, -0.00049847, 0.000172034, 1.82395, -0.00049841, 0.000172034, 0.0835765, -0.032425, 0.000172034, 0.0835765, -0.032425, 0.000172034, 1.82395, -0.0324249, 0.366967, 0.817119, 0.017358, 0.366967, 1.09745, -0.00049847, 0.366967, 0.817119, -0.00049847, 0.399134, 0.817119, 0.017358, 0.366967, 0.817119, -0.00049847, 0.399134, 0.817119, -0.00049847, 0.366967, 1.09745, 0.017358, 0.399134, 0.817119, 0.017358, 0.399134, 1.09745, 0.017358, 0.366967, 1.09745, 0.017358, 0.399134, 1.09745, -0.00049847, 0.366967, 1.09745, -0.00049847, 0.399134, 1.09745, 0.017358, 0.399134, 0.817119, -0.00049847, 0.399134, 1.09745, -0.00049847, 0.399134, 1.09745, -0.00049847, 0.42621, 1.82395, -0.00049841, 0.42621, 1.82395, -0.00049841, 0.000172034, 0.0835765, -0.00049847, 0.42621, 0.0835765, -0.032425, 0.42621, 0.0835765, -0.00049847, 0.42621, 1.82395, -0.0324249, 0.000172034, 0.0835765, -0.032425, 0.000172034, 0.0835765, -0.00049847, 0.366967, 1.09745, 0.017358, 0.366967, 0.817119, 0.017358, 0.366967, 0.817119, 0.017358, 0.399134, 1.09745, 0.017358, 0.399134, 0.817119, 0.017358),
Vector3Array(1.37725e-08, -4.98629e-08, 1.0, 4.66681e-08, -1.70523e-08, 1.0, 9.40305e-08, -3.53204e-08, 1.0, -6.18584e-07, -2.24412e-08, 1.0, -2.17942e-08, -8.43063e-10, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, -3.42443e-08, 1.0, 1.01322e-08, -2.21122e-08, 1.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 3.41533e-08, -1.0, 0.0, 3.31384e-08, -1.0, 0.0, 3.28035e-08, -1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 3.24748e-08, -1.0, 0.0, 3.51744e-08, -1.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, -1.45022e-06, -2.79417e-08, 1.0, -3.04242e-08, -8.06921e-08, 1.0, 0.0, 1.0, 0.0, 0.0, -3.42443e-08, 1.0, 0.0, -1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 3.31383e-08, -1.0, -1.0, 0.0, 0.0, 0.0, -1.0, 0.0, -1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0),
null, ; No Tangents,
null, ; no Vertex Colors,
null, ; No UV1,
null, ; No UV2,
null, ; No Bones,
null, ; No Weights,
IntArray(0, 2, 1, 3, 4, 1, 5, 7, 6, 8, 0, 9, 10, 12, 11, 13, 15, 14, 16, 18, 17, 19, 20, 7, 21, 23, 22, 12, 10, 24, 16, 26, 25, 27, 29, 28, 30, 32, 31, 33, 35, 34, 36, 38, 37, 39, 41, 40, 0, 1, 9, 9, 1, 4, 42, 2, 43, 43, 2, 0, 4, 3, 43, 43, 3, 42, 5, 6, 44, 8, 9, 45, 10, 11, 46, 13, 14, 47, 16, 17, 48, 19, 7, 5, 21, 22, 49, 12, 24, 50, 16, 25, 18, 27, 28, 51, 30, 31, 52, 33, 34, 53, 36, 37, 54, 39, 40, 55)
],
"morph_arrays":[]
}
[sub_resource id=7 type="Animation"]
resource_name = "closed"
step = 0.1
length = 0.0416667
loop = false
tracks/0/type = "transform"
tracks/0/path = NodePath(".:")
tracks/0/interp = 1
tracks/0/keys = [0.0, 1.0, -0.408956, 0.0, 0.672461, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0416667, 1.0, -0.408956, 0.0, 0.672461, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0]
[sub_resource id=8 type="Animation"]
resource_name = "default"
step = 0.1
length = 0.0416667
loop = false
tracks/0/type = "transform"
tracks/0/path = NodePath(".:")
tracks/0/interp = 1
tracks/0/keys = [0.0, 1.0, -0.408956, 0.0, 0.672461, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0416667, 1.0, -0.408956, 0.0, 0.672461, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0]
[sub_resource id=9 type="Animation"]
resource_name = "closed"
step = 0.1
length = 0.0416667
loop = false
tracks/0/type = "transform"
tracks/0/path = NodePath(".:")
tracks/0/interp = 1
tracks/0/keys = [0.0, 1.0, -0.408956, 0.0, 0.672461, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0416667, 1.0, -0.408956, 0.0, 0.672461, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0]
[sub_resource id=10 type="Animation"]
resource_name = "open"
step = 0.1
length = 0.0416667
loop = false
tracks/0/type = "transform"
tracks/0/path = NodePath(".:")
tracks/0/interp = 1
tracks/0/keys = [0.0, 1.0, -0.408956, 0.0, 0.672461, 0.0, -0.974314, 0.0, 0.225194, 1.0, 1.0, 1.0, 0.0416667, 1.0, -0.408956, 0.0, 0.672461, 0.0, -0.974314, 0.0, 0.225194, 1.0, 1.0, 1.0]
[sub_resource id=11 type="Animation"]
resource_name = "openning"
step = 0.1
length = 1.20833
loop = false
tracks/0/type = "transform"
tracks/0/path = NodePath(".:")
tracks/0/interp = 1
tracks/0/keys = [0.0, 1.0, -0.408956, 0.0, 0.672461, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0416667, 1.0, -0.408956, 0.0, 0.672461, 0.0, -6.39612e-05, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0833333, 1.0, -0.408956, 0.0, 0.672461, 0.0, -0.00051169, 0.0, 1.0, 1.0, 1.0, 1.0, 0.125, 1.0, -0.408956, 0.0, 0.672461, 0.0, -0.00172695, 0.0, 0.999999, 1.0, 1.0, 1.0, 0.166667, 1.0, -0.408956, 0.0, 0.672461, 0.0, -0.00409351, 0.0, 0.999992, 1.0, 1.0, 1.0, 0.208333, 1.0, -0.408956, 0.0, 0.672461, 0.0, -0.00799507, 0.0, 0.999968, 1.0, 1.0, 1.0, 0.25, 1.0, -0.408956, 0.0, 0.672461, 0.0, -0.0138152, 0.0, 0.999905, 1.0, 1.0, 1.0, 0.291667, 1.0, -0.408956, 0.0, 0.672461, 0.0, -0.0219369, 0.0, 0.999759, 1.0, 1.0, 1.0, 0.333333, 1.0, -0.408956, 0.0, 0.672461, 0.0, -0.0327423, 0.0, 0.999464, 1.0, 1.0, 1.0, 0.375, 1.0, -0.408956, 0.0, 0.672461, 0.0, -0.0466108, 0.0, 0.998913, 1.0, 1.0, 1.0, 0.416667, 1.0, -0.408956, 0.0, 0.672461, 0.0, -0.0639176, 0.0, 0.997955, 1.0, 1.0, 1.0, 0.458333, 1.0, -0.408956, 0.0, 0.672461, 0.0, -0.0850296, 0.0, 0.996378, 1.0, 1.0, 1.0, 0.5, 1.0, -0.408956, 0.0, 0.672461, 0.0, -0.1103, 0.0, 0.993898, 1.0, 1.0, 1.0, 0.541667, 1.0, -0.408956, 0.0, 0.672461, 0.0, -0.140061, 0.0, 0.990143, 1.0, 1.0, 1.0, 0.583333, 1.0, -0.408956, 0.0, 0.672461, 0.0, -0.17461, 0.0, 0.984638, 1.0, 1.0, 1.0, 0.625, 1.0, -0.408956, 0.0, 0.672461, 0.0, -0.214196, 0.0, 0.976791, 1.0, 1.0, 1.0, 0.666667, 1.0, -0.408956, 0.0, 0.672461, 0.0, -0.258999, 0.0, 0.965878, 1.0, 1.0, 1.0, 0.708333, 1.0, -0.408956, 0.0, 0.672461, 0.0, -0.309095, 0.0, 0.951031, 1.0, 1.0, 1.0, 0.75, 1.0, -0.408956, 0.0, 0.672461, 0.0, -0.364431, 0.0, 0.93123, 1.0, 1.0, 1.0, 0.791667, 1.0, -0.408956, 0.0, 0.672461, 0.0, -0.424772, 0.0, 0.9053, 1.0, 1.0, 1.0, 0.833333, 1.0, -0.408956, 0.0, 0.672461, 0.0, -0.489651, 0.0, 0.871918, 1.0, 1.0, 1.0, 0.875, 1.0, -0.408956, 0.0, 0.672461, 0.0, -0.558308, 0.0, 0.829634, 1.0, 1.0, 1.0, 0.916667, 1.0, -0.408956, 0.0, 0.672461, 0.0, -0.629616, 0.0, 0.776906, 1.0, 1.0, 1.0, 0.958333, 1.0, -0.408956, 0.0, 0.672461, 0.0, -0.70201, 0.0, 0.712167, 1.0, 1.0, 1.0, 1.0, 1.0, -0.408956, 0.0, 0.672461, 0.0, -0.779959, 0.0, 0.625831, 1.0, 1.0, 1.0, 1.04167, 1.0, -0.408956, 0.0, 0.672461, 0.0, -0.856819, 0.0, 0.515617, 1.0, 1.0, 1.0, 1.08333, 1.0, -0.408956, 0.0, 0.672461, 0.0, -0.918442, 0.0, 0.395557, 1.0, 1.0, 1.0, 1.125, 1.0, -0.408956, 0.0, 0.672461, 0.0, -0.958661, 0.0, 0.284551, 1.0, 1.0, 1.0, 1.16667, 1.0, -0.408956, 0.0, 0.672461, 0.0, -0.979097, 0.0, 0.203393, 1.0, 1.0, 1.0, 1.20833, 1.0, -0.408956, 0.0, 0.672461, 0.0, -0.985068, 0.0, 0.172165, 1.0, 1.0, 1.0]
[sub_resource id=12 type="Shader"]
resource_name = "Shader Nodetree"
code = "shader_type spatial;
render_mode blend_mix, depth_draw_always, cull_back, diffuse_burley, specular_schlick_ggx;
void node_bsdf_principled(vec4 color, float subsurface, vec4 subsurface_color,
float metallic, float specular, float roughness, float clearcoat,
float clearcoat_roughness, float anisotropy, float transmission,
float IOR, out vec3 albedo, out float sss_strength_out,
out float metallic_out, out float specular_out,
out float roughness_out, out float clearcoat_out,
out float clearcoat_gloss_out, out float anisotropy_out,
out float transmission_out, out float ior) {
metallic = clamp(metallic, 0.0, 1.0);
transmission = clamp(transmission, 0.0, 1.0);
subsurface = subsurface * (1.0 - metallic);
albedo = mix(color.rgb, subsurface_color.rgb, subsurface);
sss_strength_out = subsurface;
metallic_out = metallic;
specular_out = pow((IOR - 1.0)/(IOR + 1.0), 2)/0.08;
roughness_out = roughness;
clearcoat_out = clearcoat * (1.0 - transmission);
clearcoat_gloss_out = 1.0 - clearcoat_roughness;
anisotropy_out = clamp(anisotropy, 0.0, 1.0);
transmission_out = (1.0 - transmission) * (1.0 - metallic);
ior = IOR;
}
void vertex () {
}
void fragment () {
// node: 'Principled BSDF'
// type: 'ShaderNodeBsdfPrincipled'
// input sockets handling
vec4 node0_in0_basecolor = vec4(0.6399999856948853, 0.6399999856948853,
0.6399999856948853, 1.0);
float node0_in1_subsurface = float(0.0);
vec3 node0_in2_subsurfaceradius = vec3(1.0, 0.20000000298023224,
0.10000000149011612);
vec4 node0_in3_subsurfacecolor = vec4(0.800000011920929, 0.800000011920929,
0.800000011920929, 1.0);
float node0_in4_metallic = float(0.0);
float node0_in5_specular = float(0.019999999552965164);
float node0_in6_speculartint = float(0.0);
float node0_in7_roughness = float(1.0);
float node0_in8_anisotropic = float(0.0);
float node0_in9_anisotropicrotation = float(0.0);
float node0_in10_sheen = float(0.0);
float node0_in11_sheentint = float(0.5);
float node0_in12_clearcoat = float(0.0);
float node0_in13_clearcoatroughness = float(0.029999999329447746);
float node0_in14_ior = float(1.0);
float node0_in15_transmission = float(0.0);
float node0_in16_transmissionroughness = float(0.0);
vec4 node0_in17_emission = vec4(0.0, 0.0, 0.0, 1.0);
float node0_in18_alpha = float(1.0);
vec3 node0_in19_normal = NORMAL;
vec3 node0_in20_clearcoatnormal = vec3(0.0, 0.0, 0.0);
vec3 node0_in21_tangent = TANGENT;
// output sockets definitions
vec3 node0_bsdf_out0_albedo;
float node0_bsdf_out1_sss_strength;
float node0_bsdf_out3_specular;
float node0_bsdf_out2_metallic;
float node0_bsdf_out4_roughness;
float node0_bsdf_out5_clearcoat;
float node0_bsdf_out6_clearcoat_gloss;
float node0_bsdf_out7_anisotropy;
float node0_bsdf_out8_transmission;
float node0_bsdf_out9_ior;
node_bsdf_principled(node0_in0_basecolor, node0_in1_subsurface,
node0_in3_subsurfacecolor, node0_in4_metallic, node0_in5_specular,
node0_in7_roughness, node0_in12_clearcoat, node0_in13_clearcoatroughness,
node0_in8_anisotropic, node0_in15_transmission, node0_in14_ior,
node0_bsdf_out0_albedo, node0_bsdf_out1_sss_strength, node0_bsdf_out2_metallic,
node0_bsdf_out3_specular, node0_bsdf_out4_roughness, node0_bsdf_out5_clearcoat,
node0_bsdf_out6_clearcoat_gloss, node0_bsdf_out7_anisotropy,
node0_bsdf_out8_transmission, node0_bsdf_out9_ior);
ALBEDO = node0_bsdf_out0_albedo;
SSS_STRENGTH = node0_bsdf_out1_sss_strength;
SPECULAR = node0_bsdf_out3_specular;
METALLIC = node0_bsdf_out2_metallic;
ROUGHNESS = node0_bsdf_out4_roughness;
CLEARCOAT = node0_bsdf_out5_clearcoat;
CLEARCOAT_GLOSS = node0_bsdf_out6_clearcoat_gloss;
NORMAL = node0_in19_normal;
// uncomment it when you need it
// TRANSMISSION = vec3(1.0, 1.0, 1.0) * node0_bsdf_out8_transmission;
// uncomment it when you are modifing TANGENT
// TANGENT = normalize(cross(cross(node0_in21_tangent, NORMAL), NORMAL));
// BINORMAL = cross(TANGENT, NORMAL);
// uncomment it when you have tangent(UV) set
// ANISOTROPY = node0_bsdf_out7_anisotropy;
}
"
[sub_resource id=13 type="ShaderMaterial"]
resource_name = ""
shader = SubResource(12)
[sub_resource id=14 type="ArrayMesh"]
resource_name = "closet_door_right"
surfaces/0 = {
"material":SubResource(13),
"primitive":4,
"arrays":[
Vector3Array(-0.417257, 1.82395, 0.000198439, -0.39682, 1.09745, 0.00019838, -0.364652, 1.09745, 0.00019838, -0.00103214, 0.0835765, 0.00019838, -0.364652, 0.817119, 0.00019838, -0.417257, 1.82395, 0.000198439, -0.00103214, 1.82395, -0.0317281, -0.417257, 1.82395, -0.0317281, -0.423438, 1.82395, 0.000198439, -0.417257, 0.0835765, 0.00019838, -0.417257, 0.0835765, -0.0317281, -0.00103214, 0.0835765, 0.00019838, -0.417257, 0.0835765, 0.00019838, -0.00103214, 1.82395, 0.000198439, -0.00103214, 0.0835765, -0.0317281, -0.00103214, 1.82395, -0.0317281, -0.417257, 1.82395, -0.0317281, -0.00103214, 0.0835765, -0.0317281, -0.417257, 0.0835765, -0.0317281, -0.423438, 1.82395, 0.000198439, -0.423438, 1.82395, -0.0317281, -0.423438, 1.82395, -0.0317281, -0.423438, 0.0835765, 0.00019838, -0.423438, 1.82395, 0.000198439, -0.423438, 0.0835765, -0.0317281, -0.423438, 0.0835765, -0.0317281, -0.423438, 1.82395, -0.0317281, -0.39682, 0.817119, 0.0180549, -0.39682, 1.09745, 0.00019838, -0.39682, 0.817119, 0.00019838, -0.364652, 0.817119, 0.0180549, -0.39682, 0.817119, 0.00019838, -0.364652, 0.817119, 0.00019838, -0.39682, 1.09745, 0.0180549, -0.364652, 0.817119, 0.0180549, -0.364652, 1.09745, 0.0180549, -0.39682, 1.09745, 0.0180549, -0.364652, 1.09745, 0.00019838, -0.39682, 1.09745, 0.00019838, -0.364652, 1.09745, 0.0180549, -0.364652, 0.817119, 0.00019838, -0.364652, 1.09745, 0.00019838, -0.39682, 0.817119, 0.00019838, -0.00103214, 1.82395, 0.000198439, -0.00103214, 1.82395, 0.000198439, -0.423438, 0.0835765, 0.00019838, -0.00103214, 0.0835765, -0.0317281, -0.00103214, 0.0835765, 0.00019838, -0.00103214, 1.82395, -0.0317281, -0.423438, 0.0835765, -0.0317281, -0.423438, 0.0835765, 0.00019838, -0.39682, 1.09745, 0.0180549, -0.39682, 0.817119, 0.0180549, -0.39682, 0.817119, 0.0180549, -0.364652, 1.09745, 0.0180549, -0.364652, 0.817119, 0.0180549),
Vector3Array(1.52159e-08, -5.76213e-08, 1.0, 1.9269e-06, -2.78361e-08, 1.0, -4.72805e-08, -5.23765e-08, 1.0, -2.09344e-08, -7.50606e-09, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, -3.42418e-08, 1.0, 1.08996e-08, -1.7435e-08, 1.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 3.44918e-08, -1.0, 0.0, 3.56146e-08, -1.0, 0.0, 3.55853e-08, -1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 3.51717e-08, -1.0, 0.0, 3.51717e-08, -1.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 8.19491e-07, -2.24756e-08, 1.0, -2.82116e-08, -6.79092e-08, 1.0, 0.0, 1.0, 0.0, 0.0, -3.42629e-08, 1.0, 0.0, -1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 3.34275e-08, -1.0, -1.0, 0.0, 0.0, 0.0, -1.0, 0.0, -1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0),
null, ; No Tangents,
null, ; no Vertex Colors,
null, ; No UV1,
null, ; No UV2,
null, ; No Bones,
null, ; No Weights,
IntArray(0, 2, 1, 3, 4, 2, 5, 7, 6, 8, 0, 9, 10, 12, 11, 13, 15, 14, 16, 18, 17, 19, 20, 7, 21, 23, 22, 12, 10, 24, 16, 26, 25, 27, 29, 28, 30, 32, 31, 33, 35, 34, 36, 38, 37, 39, 41, 40, 0, 42, 9, 0, 1, 42, 3, 2, 43, 43, 2, 0, 42, 4, 9, 9, 4, 3, 5, 6, 44, 8, 9, 45, 10, 11, 46, 13, 14, 47, 16, 17, 48, 19, 7, 5, 21, 22, 49, 12, 24, 50, 16, 25, 18, 27, 28, 51, 30, 31, 52, 33, 34, 53, 36, 37, 54, 39, 40, 55)
],
"morph_arrays":[]
}
[sub_resource id=15 type="Animation"]
resource_name = "closed"
step = 0.1
length = 0.0416667
loop = false
tracks/0/type = "transform"
tracks/0/path = NodePath(".:")
tracks/0/interp = 1
tracks/0/keys = [0.0, 1.0, 0.445465, 0.0, 0.672461, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0416667, 1.0, 0.445465, 0.0, 0.672461, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0]
[sub_resource id=16 type="Animation"]
resource_name = "default"
step = 0.1
length = 0.0416667
loop = false
tracks/0/type = "transform"
tracks/0/path = NodePath(".:")
tracks/0/interp = 1
tracks/0/keys = [0.0, 1.0, 0.445465, 0.0, 0.672461, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0416667, 1.0, 0.445465, 0.0, 0.672461, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0]
[sub_resource id=17 type="Animation"]
resource_name = "closed"
step = 0.1
length = 0.0416667
loop = false
tracks/0/type = "transform"
tracks/0/path = NodePath(".:")
tracks/0/interp = 1
tracks/0/keys = [0.0, 1.0, 0.445465, 0.0, 0.672461, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0416667, 1.0, 0.445465, 0.0, 0.672461, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0]
[sub_resource id=18 type="Animation"]
resource_name = "open_r"
step = 0.1
length = 0.0416667
loop = false
tracks/0/type = "transform"
tracks/0/path = NodePath(".:")
tracks/0/interp = 1
tracks/0/keys = [0.0, 1.0, 0.445465, 0.0, 0.672461, 0.0, 0.986832, 0.0, 0.161751, 1.0, 1.0, 1.0, 0.0416667, 1.0, 0.445465, 0.0, 0.672461, 0.0, 0.986832, 0.0, 0.161751, 1.0, 1.0, 1.0]
[sub_resource id=19 type="Animation"]
resource_name = "openning_r"
step = 0.1
length = 1.20833
loop = false
tracks/0/type = "transform"
tracks/0/path = NodePath(".:")
tracks/0/interp = 1
tracks/0/keys = [0.0, 1.0, 0.445465, 0.0, 0.672461, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0416667, 1.0, 0.445465, 0.0, 0.672461, 0.0, 5.71012e-05, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0833333, 1.0, 0.445465, 0.0, 0.672461, 0.0, 0.000456809, 0.0, 1.0, 1.0, 1.0, 1.0, 0.125, 1.0, 0.445465, 0.0, 0.672461, 0.0, 0.00154173, 0.0, 0.999999, 1.0, 1.0, 1.0, 0.166667, 1.0, 0.445465, 0.0, 0.672461, 0.0, 0.00365447, 0.0, 0.999993, 1.0, 1.0, 1.0, 0.208333, 1.0, 0.445465, 0.0, 0.672461, 0.0, 0.00713759, 0.0, 0.999975, 1.0, 1.0, 1.0, 0.25, 1.0, 0.445465, 0.0, 0.672461, 0.0, 0.0123335, 0.0, 0.999924, 1.0, 1.0, 1.0, 0.291667, 1.0, 0.445465, 0.0, 0.672461, 0.0, 0.0195844, 0.0, 0.999808, 1.0, 1.0, 1.0, 0.333333, 1.0, 0.445465, 0.0, 0.672461, 0.0, 0.0292316, 0.0, 0.999573, 1.0, 1.0, 1.0, 0.375, 1.0, 0.445465, 0.0, 0.672461, 0.0, 0.0416147, 0.0, 0.999134, 1.0, 1.0, 1.0, 0.416667, 1.0, 0.445465, 0.0, 0.672461, 0.0, 0.0570701, 0.0, 0.99837, 1.0, 1.0, 1.0, 0.458333, 1.0, 0.445465, 0.0, 0.672461, 0.0, 0.0759285, 0.0, 0.997113, 1.0, 1.0, 1.0, 0.5, 1.0, 0.445465, 0.0, 0.672461, 0.0, 0.0985108, 0.0, 0.995136, 1.0, 1.0, 1.0, 0.541667, 1.0, 0.445465, 0.0, 0.672461, 0.0, 0.125122, 0.0, 0.992141, 1.0, 1.0, 1.0, 0.583333, 1.0, 0.445465, 0.0, 0.672461, 0.0, 0.156045, 0.0, 0.98775, 1.0, 1.0, 1.0, 0.625, 1.0, 0.445465, 0.0, 0.672461, 0.0, 0.191526, 0.0, 0.981488, 1.0, 1.0, 1.0, 0.666667, 1.0, 0.445465, 0.0, 0.672461, 0.0, 0.23176, 0.0, 0.972773, 1.0, 1.0, 1.0, 0.708333, 1.0, 0.445465, 0.0, 0.672461, 0.0, 0.276873, 0.0, 0.960907, 1.0, 1.0, 1.0, 0.75, 1.0, 0.445465, 0.0, 0.672461, 0.0, 0.326893, 0.0, 0.945061, 1.0, 1.0, 1.0, 0.791667, 1.0, 0.445465, 0.0, 0.672461, 0.0, 0.38172, 0.0, 0.924278, 1.0, 1.0, 1.0, 0.833333, 1.0, 0.445465, 0.0, 0.672461, 0.0, 0.441087, 0.0, 0.897465, 1.0, 1.0, 1.0, 0.875, 1.0, 0.445465, 0.0, 0.672461, 0.0, 0.50451, 0.0, 0.863406, 1.0, 1.0, 1.0, 0.916667, 1.0, 0.445465, 0.0, 0.672461, 0.0, 0.571238, 0.0, 0.820785, 1.0, 1.0, 1.0, 0.958333, 1.0, 0.445465, 0.0, 0.672461, 0.0, 0.640193, 0.0, 0.768214, 1.0, 1.0, 1.0, 1.0, 1.0, 0.445465, 0.0, 0.672461, 0.0, 0.709907, 0.0, 0.704295, 1.0, 1.0, 1.0, 1.04167, 1.0, 0.445465, 0.0, 0.672461, 0.0, 0.793713, 0.0, 0.608293, 1.0, 1.0, 1.0, 1.08333, 1.0, 0.445465, 0.0, 0.672461, 0.0, 0.881148, 0.0, 0.47284, 1.0, 1.0, 1.0, 1.125, 1.0, 0.445465, 0.0, 0.672461, 0.0, 0.945073, 0.0, 0.326859, 1.0, 1.0, 1.0, 1.16667, 1.0, 0.445465, 0.0, 0.672461, 0.0, 0.977812, 0.0, 0.209486, 1.0, 1.0, 1.0, 1.20833, 1.0, 0.445465, 0.0, 0.672461, 0.0, 0.986832, 0.0, 0.161751, 1.0, 1.0, 1.0]
[node type="Spatial" name="Scene"]
[node name="closet-col" type="MeshInstance" parent="."]
mesh = SubResource(3)
visible = true
transform = Transform(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0)
[node name="closet_door_left-col" type="MeshInstance" parent="closet-col"]
mesh = SubResource(6)
visible = true
transform = Transform(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, -0.408956, 0.0, 0.672461)
[node name="AnimationPlayer" type="AnimationPlayer" parent="closet-col/closet_door_left-col"]
root_node = NodePath("..:")
anims/closed = SubResource(9)
anims/default = SubResource(8)
anims/open = SubResource(10)
anims/openning = SubResource(11)
[node name="closet_door_right-col" type="MeshInstance" parent="closet-col"]
mesh = SubResource(14)
visible = true
transform = Transform(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.445465, 0.0, 0.672461)
[node name="AnimationPlayer" type="AnimationPlayer" parent="closet-col/closet_door_right-col"]
root_node = NodePath("..:")
anims/closed = SubResource(17)
anims/default = SubResource(16)
anims/open_r = SubResource(18)
anims/openning_r = SubResource(19)
File diff suppressed because it is too large Load Diff
+131
View File
@@ -0,0 +1,131 @@
extends Spatial
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
enum {DOOR_OPEN, DOOR_CLOSED}
var door_l_state = DOOR_CLOSED
var door_r_state = DOOR_CLOSED
var act_l_delay = 0.0
var act_r_delay = 0.0
var l_act = false
var r_act = false
var hide_delay = 4.0
var hidden = false
func activate_l_door(def):
if def && door_l_state == DOOR_CLOSED:
$closet/closet_door_left/AnimationPlayer.play("openning")
door_l_state = DOOR_OPEN
if !def && door_l_state == DOOR_OPEN:
$closet/closet_door_left/AnimationPlayer.play_backwards("openning")
door_l_state = DOOR_CLOSED
func activate_r_door(def):
if def && door_r_state == DOOR_CLOSED:
$closet/closet_door_right/AnimationPlayer.play("openning_r")
door_r_state = DOOR_OPEN
if !def && door_r_state == DOOR_OPEN:
$closet/closet_door_right/AnimationPlayer.play_backwards("openning_r")
door_r_state = DOOR_CLOSED
func _ready():
add_to_group("closet")
add_to_group("hide_spot")
var ret = $left.connect("body_entered", self, "body_enter")
assert(ret == OK)
ret = $left.connect("body_exited", self, "body_exit")
assert(ret == OK)
ret = $right.connect("body_entered", self, "body_enter")
assert(ret == OK)
ret = $right.connect("body_exited", self, "body_exit")
assert(ret == OK)
ret = $Timer.connect("timeout", self, "free_character")
assert(ret == OK)
func _process(delta):
if l_act:
act_l_delay += delta
if act_l_delay >= 1.5:
if door_l_state == DOOR_CLOSED:
door_l_state = DOOR_OPEN
l_act = false
if r_act:
act_l_delay += delta
if act_l_delay >= 1.5:
if door_l_state == DOOR_CLOSED:
door_l_state = DOOR_OPEN
r_act = false
func free_character():
var c = get_meta("hidden_character")
c.remove_collision_exception_with($closet/closet_door_left/static_collision)
c.remove_collision_exception_with($closet/closet_door_right/static_collision)
c.remove_collision_exception_with($closet/static_collision)
c.global_transform = $exit_spot.global_transform
yield(get_tree().create_timer(0.1), "timeout")
c.global_transform = $exit_spot.global_transform
c.set_meta("smart_object", false)
c.do_walk()
hidden = false
set_meta("hidden_character", null)
func body_enter(body):
if !body.is_in_group("characters"):
return
if body.get_meta("grabbing"):
return
# TODO
if body.get_meta("grabbed"):
return
if !hidden:
if body == global.player:
print("CLOSET")
activate_l_door(true)
activate_r_door(true)
elif body.has_meta("action"):
var action = body.get_meta("action")
if action == "hide":
activate_l_door(true)
activate_r_door(true)
body.set_meta("smart_object", true)
body.do_stop()
set_meta("hidden_character", body)
hidden = true
yield(get_tree().create_timer(hide_delay), "timeout")
body.add_collision_exception_with($closet/closet_door_left/static_collision)
body.add_collision_exception_with($closet/closet_door_right/static_collision)
body.add_collision_exception_with($closet/static_collision)
body.global_transform = $hide_spot.global_transform
yield(get_tree().create_timer(0.1), "timeout")
body.global_transform = $hide_spot.global_transform
yield(get_tree().create_timer(hide_delay), "timeout")
activate_l_door(false)
activate_r_door(false)
else:
return
else:
activate_l_door(true)
activate_r_door(true)
else:
if body == get_meta("hidden_character"):
return
if body == global.player:
activate_l_door(true)
activate_r_door(true)
$Timer.start(4.0)
elif body.has_meta("action"):
var action = body.get_meta("action")
if action == "hide":
return
if action == "patrol":
# var c = get_meta("hidden_character")
activate_l_door(true)
activate_r_door(true)
$Timer.start(4.0)
func body_exit(_body):
pass
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
+40
View File
@@ -0,0 +1,40 @@
[gd_scene load_steps=5 format=2]
[ext_resource path="res://scenes/furniture/closet.escn" type="PackedScene" id=1]
[ext_resource path="res://scenes/furniture/closet.gd" type="Script" id=2]
[sub_resource type="BoxShape" id=1]
extents = Vector3( 0.307138, 1, 0.229338 )
[sub_resource type="BoxShape" id=2]
extents = Vector3( 0.30995, 1, 0.227319 )
[node name="closet" instance=ExtResource( 1 )]
script = ExtResource( 2 )
[node name="AnimationPlayer" parent="closet/closet_door_left" index="0"]
playback_process_mode = 0
[node name="AnimationPlayer" parent="closet/closet_door_right" index="0"]
playback_process_mode = 0
[node name="left" type="Area" parent="." index="1"]
[node name="CollisionShape" type="CollisionShape" parent="left" index="0"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.332212, 0, 0.920621 )
shape = SubResource( 1 )
[node name="right" type="Area" parent="." index="2"]
[node name="CollisionShape" type="CollisionShape" parent="right" index="0"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.314295, 0, 0.923483 )
shape = SubResource( 2 )
[node name="hide_spot" type="Spatial" parent="." index="3"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.257012, 0.0920849, 0.345239 )
[node name="exit_spot" type="Spatial" parent="." index="4"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.257012, 0.0920849, 0.653263 )
[node name="Timer" type="Timer" parent="." index="5"]
one_shot = true

Some files were not shown because too many files have changed in this diff Show More