## 수매 퀘스트 셋업 PurchaseQuestDefaultSetup: type: yaml data configpath: ../JemrQuest/purchase.yml # sellerpath: ../JemrQuest/sellerlist.yml logpath: ./plugins/JemrQuest/trade.log ## 수매 시작 warehouse_Purchase_start: type: task script: - yaml load: id:purchase - wait 1s - define npc ### 수매중이라면 실행 중지 - if == true { - narrate "지금은 수매중입니다." - queue clear } - if == null { - narrate "최소한 하나 이상의 아이템이 등록되어 있어야 합니다." - log "하나 이상의 아이템 등록 필요" type:warning file: - queue clear } - define npc - define item - define item_name .name]> - define price .current.price]> - define quantity .current.quantity]> - flag item: - flag item_name: - flag price: - flag quantity: - flag timeout:: duration: - log "Purchaing statred!" type:fine file: ## 안내시작 - title "title: " "subtitle:<&c>창고에서 수매를 시작합니다" targets: stay:5s - narrate target: "지금부터 수매를 시작합니다! " - bossbar create purchasing players: "title:창고에서 수매중... " color:red progress:0 ## 수매 종/료 warehouse_Purchase_end: type: task speed: 1t script: - yaml load: id:purchase - wait 1s - define npc ### 수매중이지 않다면 실행 중지 - if == false { - narrate "수매중이 아닙니다." - queue clear } ### 플래그에서 그간 저장된 변수 가져오기 시작 - define item - define price - define quantity .current.quantity].sub[]> - define expenditure .current.price].mul[]> ### 하나도 안팔린 경우 이벤트 그냥 종료하기 - if >= .current.quantity]> { - narrate "아무도 구매하지 않았습니다." } else { ## 수매정보를 업데이트 - yaml id:purchase set purchase_list..history.total.procurement:+:1 - yaml id:purchase set purchase_list..history.total.purchased_expenditure:+: - yaml id:purchase set purchase_list..history.total.purchased_quantity:+: #평균 수매량과, 평균가 계산 - define total_expenditure .history.total.purchased_expenditure]> - define total_quantity .history.total.purchased_quantity]> - define procurement .history.total.procurement]> - yaml id:purchase set purchase_list..history.average.quantity:]> - yaml id:purchase set purchase_list..history.average.price:]> ## 수매 목표량 계산 - define target_quantity .current.quantity]||1> - define achievement ]> - narrate "%입니다. " ##수매 결과에 따라 가격 갱신 # 계산식, y=2mx+(1-m) ### q갱신 q_delta, achievement - define q_delta - define p_delta ## 최소 최대값 불러오기 - define p_min - define p_max - define q_min - define q_max # 랜덤 변화를 위한... # gauss 70%가 -2에서 +2사이에 존재함. - define ran - yaml id:purchase set purchase_list..current.quantity:*:].add[1].sub[].add[]> - yaml id:purchase set purchase_list..current.quantity:.current.quantity].round.max[].min[]> - define ran - yaml id:purchase set purchase_list..current.price:*:].add[1].add[].add[]> - yaml id:purchase set purchase_list..current.price:.current.price].round_to[2].max[].min[]> ### 수매 결과를 로그에 기록하기 ## 수매결과 - narrate "수매를 종료합니다." - log "Result:, TQ:.current.quantity]> purchased:, %, expenditure:, percost:" type:info file: ## 개인별 참여여부 기록 - foreach { - if { - log " ]>" type:none file: - flag :! } } } - yaml savefile: id:purchase ## 이벤트 마감 공지 - title "title: " "subtitle:<&c>수매를 종료합니다" targets: stay:5s - narrate target: "수매가 종료되었습니다!" - bossbar remove purchasing ### npc 플래그 삭제하기 - flag item:! - flag item_name:! - flag price:! - flag timeout:! - flag purchasing:! - flag quantity:! ### 수매시간 마감 시 종료하기 "purchase_timer": type: world events: on system time hourly: # 세명 이상이라면 매시간 수매 이벤트 시작하기 - if >= 3 run warehouse_Purchase_start instantly # 보스바 업데이트로 공지하기 on system time minutely: # 진행중이지 않다면, 공지x - ~define npc # q가 0이거나 플래그가 없다면 => 수매가 끝났다면 - if <= 0 { - run warehouse_Purchase_end instantly - queue clear } #수매가 진행중이라면 보스바로 공지 - define item_name #progress calc - define item - define target_q .current.quantity]> - define remain_q - define current_q ]> - define progress ]> - narrate target: "" - bossbar update purchasing players: progress: