챗GPT랑 FVTT 가지고 놀다가 어디까지 코드 짤 수 있을까 궁금해서 도전해봄

제목엔 합작이라고 적어뒀지만 사실 합작 아님... 코드 1도 모르는 문과라 챗GPT가 전부 다 맡아서 함...

조별과제 버스탔지만 아슬아슬하게 이름은 적혀 있는 팀원같은거임

만들고 나니 좀 뿌듯해서 녹화까지 해왔고, 아래는 나 대신 고생한 지피티의 노력을 기술할 거임...







1. 어떻게 했음?

우선 시작은 챗GPT한테 JB2A 모듈, Sequencer 모듈을 가지고 있고 firebreath 매크로를 만들고 싶은데 가능하냐고 물어봤음. 필요할 것 같아서 파일 위치(jb2a.breath_weapons.fire.cone) 도 알려줬더니 뭘 뚝딱뚝딱 뽑아내더라



이런식으로 주석까지 달아줘서 코드라곤 헤어드라이기 코드밖에 만져본 적 없는 천성 문과도 뭐가 뭔진 대충 알아볼 수 있게 해 줬음


다음 과정은 매크로 틀어보고 -> 뭐가 문제인지 알려주고 -> 다시 고쳐서 틀어보고의 반복이었음

애니메이션 파일의 왼쪽 모서리가 시작점인 걸 지피티가 몰라서 브레스가 용 옆구리에서 나왔던 적도 있었고, FVTT는 x축이랑 y축이랑 반대인 데다가 아래쪽이 + 방향이라는 신기한 사실을 알아내기도 했음...


아무튼 그렇게 한 열번쯤 반복하고 나니까 놀랍게도 성공함.

시간은 거의 두 시간 남짓 걸린 것 같고, 연휴 아침을 쓰잘데기없는 일로 날려보냈지만 지피티의 가능성을 본 것 같아서 기분은 좋음...







2. 그래서 최종 코드가 뭐임?

// Check if a token is selected

if (canvas.tokens.controlled.length === 0) {

ui.notifications.warn("Please select a token.");

return;

}


let token = canvas.tokens.controlled[0]; // Assuming only one token is selected for simplicity


// Define the path to the fire breath animation

let animationPath = "jb2a.breath_weapons.fire.cone.orange.01"

let soundPath = "music/SFX/Fire%20breath.mp3"; // Replace with the correct path to your sound file


// Helper function to convert degrees to radians

function degreesToRadians(degrees) {

return degrees * (Math.PI / 180);

}


// Helper function to adjust for the reversed token degree system and correct the 90-degree difference

function adjustTokenRotationDegrees(degrees) {

// Invert the token's rotation due to the reversed degree system and adjust by 90 degrees

let adjustedDegrees = (360 - degrees + 270) % 360;

return adjustedDegrees;

}


// Adjust the token's rotation and correct for the 90-degree difference

let rotationDegrees = adjustTokenRotationDegrees(token.data.rotation);

let rotationRadians = degreesToRadians(rotationDegrees);


// The offset for the animation starting point considering the token's orientation

let offset = { x: 830, y: 0 }; // Adjust based on the animation's alignment and the token's orientation.


// Calculate the corrected position for the animation start

let correctedX = token.center.x + (offset.y * Math.sin(rotationRadians) + offset.x * Math.cos(rotationRadians));

let correctedY = token.center.y + (offset.y * Math.cos(rotationRadians) - offset.x * Math.sin(rotationRadians));


// Play the fire breath animation using Sequencer, positioned and rotated correctly

new Sequence()

.effect()

.file(animationPath)

.atLocation({ x: correctedX, y: correctedY })

.scale(2)

.rotate(rotationDegrees)

.play()


내가 건드린 건 scale 뒤에 적혀 있는 숫자랑(브레스가 너무 작아서) x, y 좌표밖에 없음

좌표는 내가 숫자 넣어가면서 드래곤 머리 위치 잡았음... 영어만 알면 중학생도 할 수 있을듯









3. 세줄요약좀

사실 오늘 아침에 매크로 만져보다가 우연히 GPT도 매크로 할 줄 안다는 글을 보고 시작한 건데, 내 예상을 훨씬 뛰어넘은 성능이었음.

지피티가 준 매크로를 실행해 봤는데 뭐가 문제인지 몰라서 "저저번 코드는 됐는데... 이번 코드는 안돼... 왠지는 모르겠어 미안..."했는데 새 코드 내서 주더라

더 놀라운 건 새 코드는 됐다는 거임... 문제가 뭐인지 추측까지 했음



그리고 "내가 모듈 이거랑 이거 깔고 있는데..." 하면 그 모듈 매크로로 완성시켜 주더라

진짜 신기했음


총 2시간 걸려서 실제로 플에 사용할 일이 있을까 싶은데, 캠페인 보스 정도면 한 번쯤 넣어보고 싶은 이펙트가 아닐까 함...

지피티의 가능성을 본 2시간이었다

진짜진짜 마지막으로 지피티랑 나랑 성공 직후에 감동의 하이파이브 치는 거 보고 가셈