Issix-mod/Scenes/ParadedOnALeashScene.gd

123 lines
3.1 KiB
GDScript3
Raw Normal View History

extends "res://Scenes/SceneBase.gd"
var startLocation = ""
var endLocation = ""
var path = []
var whoLeashingID = ""
var randomChat = []
var teleportwhenskipped = true
var pose = "walk"
func _initScene(_args = []):
whoLeashingID = _args[0]
startLocation = _args[1]
endLocation = _args[2]
if(_args.size() > 3):
randomChat = _args[3]
if (_args.size() > 4):
teleportwhenskipped = _args[4]
if (_args.size() > 5):
pose = _args[5]
2024-12-20 18:32:08 +00:00
path = GM.world.calculatePath(startLocation, endLocation)
if(path.size() <= 0):
endScene()
func _init():
sceneID = "ParadedOnALeashScene"
func _run():
if(state == ""):
addCharacter(whoLeashingID)
2024-12-20 18:32:08 +00:00
if(state == "" || state == "leashed"):
2024-12-20 18:32:08 +00:00
if(state == "leashed"):
playAnimation(StageScene.Duo, pose, {npc=whoLeashingID, npcAction="walk", flipNPC=true, bodyState={leashedBy=whoLeashingID}})
if(path.size() > 0):
aimCameraAndSetLocName(path[0])
2024-12-20 18:32:08 +00:00
var _roomInfo = GM.world.getRoomByID(path[0])
2024-12-20 18:32:08 +00:00
if(_roomInfo == null):
saynn("You're being walked on a leash by {leasher.name}")
else:
saynn("You're being walked on a leash by {leasher.name}")
2024-12-20 18:32:08 +00:00
if(GM.pc.isBlindfolded() && !GM.pc.canHandleBlindness()):
saynn(_roomInfo.getBlindDescription())
else:
saynn(_roomInfo.getDescription())
2024-12-20 18:32:08 +00:00
if(randomChat.size() > 0 && RNG.chance(min(30, randomChat.size() * 10))):
saynn("[say=leasher]"+RNG.pick(randomChat)+"[/say]")
2024-12-20 18:32:08 +00:00
if (teleportwhenskipped):
addButton("Skip", "Skip the walk", "skipwalk")
else:
addButton("Skip", "Skip the walk", "endthescene")
addButtonAt(6, "Follow", "Follow the leash", "follow")
addDisabledButtonAt(10, "Leashed", "Can't escape from the leash")
addDisabledButtonAt(11, "Leashed", "Can't escape from the leash")
addDisabledButtonAt(12, "Leashed", "Can't escape from the leash")
if (state == "skipwalk"):
aimCamera(endLocation)
GM.pc.setLocation(endLocation)
2024-12-20 18:32:08 +00:00
endScene()
func _react(_action: String, _args):
if(_action == "endthescene"):
endScene()
return
2024-12-20 18:32:08 +00:00
if(_action == "follow"):
if(path.size() == 0):
endScene()
return
2024-12-20 18:32:08 +00:00
var nextLoc = path[0]
path.remove(0)
2024-12-20 18:32:08 +00:00
if(!GM.world.hasRoomID(nextLoc)):
endScene()
return
2024-12-20 18:32:08 +00:00
GM.pc.setLocation(nextLoc)
if(path.size() == 0):
endScene()
return
setState("leashed")
return
2024-12-20 18:32:08 +00:00
setState(_action)
func saveData():
var data = .saveData()
2024-12-20 18:32:08 +00:00
data["startLocation"] = startLocation
data["endLocation"] = endLocation
data["path"] = path
data["whoLeashingID"] = whoLeashingID
data["randomChat"] = randomChat
data["teleportwhenskipped"] = teleportwhenskipped
2024-12-20 18:32:08 +00:00
data["pose"] = pose
return data
2024-12-20 18:32:08 +00:00
func loadData(data):
.loadData(data)
2024-12-20 18:32:08 +00:00
startLocation = SAVE.loadVar(data, "startLocation", "")
endLocation = SAVE.loadVar(data, "endLocation", "")
path = SAVE.loadVar(data, "path", [])
whoLeashingID = SAVE.loadVar(data, "whoLeashingID", "")
randomChat = SAVE.loadVar(data, "randomChat", [])
teleportwhenskipped = SAVE.loadVar(data, "teleportwhenskipped", true)
2024-12-20 18:32:08 +00:00
pose = SAVE.loadVar(data, "pose", "walk")
func resolveCustomCharacterName(_charID):
if(_charID == "leasher" && whoLeashingID != ""):
return whoLeashingID
2024-12-20 18:32:08 +00:00
return null