欢迎光临散文网 会员登陆 & 注册

Stone Story RPG【石头纪】简单的自用ui代码

2023-08-08 00:46 作者:巧克力莲子  | 我要投稿

该ui包含以下内容:

相当粗糙且充满bug的伤害统计

尚有bug的时间统计

还可以优化的冷却显示

同样有些bug但不影响使用的敌我血量美化

做到一半的己方buff显示


以下是代码:

?loc.begin

  var sleepOn=false

  var beginTime=0

  var waitTime=0

  var count=1

  var on=true

  var bashcd=item.GetCooldown("bash")/30

  var dashcd=item.GetCooldown("dash")/30

  var armcd=item.GetCooldown("skeleton_arm")/30

  var bladecd=item.GetCooldown("blade")/30

  var hammercd=item.GetCooldown("hammer")/30

  var sHP=foe.hp+foe.armor

  var eHP=foe.hp+foe.armor

  var DMG=0

  var TtDMG=0

  var LoopDMG=0

  var lastCount=foe.count

  var DMGtimes=0

  var Tttime=1

  var hpPC=100

  var armorPC=0 

  var maxarmor1=maxarmor

  var hpPL=100

  var armorPL=0

  var buffon1 //巧手

  var buffon2 //重击

  var buffice

  var buffatk

  switchs()

?loc.loop

  sHP=foe.hp+foe.armor

  eHP=foe.hp+foe.armor

  LoopDMG=0

  DMGtimes=0

  count++

  Tttime++

  switchs()


//千位进K百万进M

func transp(num)

  ?num<1000

    return num

  :?num<1000000

    return num/100*1.0/10+k

  : 

    return num/100000*1.0/10+m 


//自动冲刺

func dash()

  ?foe.distance>=11&foe.distance<=17

  ^&bashcd=0       

    equipR bash

  :?foe.distance>=11&foe.distance<=17

  ^&bashcd>0&dashcd=0

    equipR dash   


//收获物

func harvests()

  ?foe.count=0|pickup.distance<=10

    equipR star

  ?harvest=Boulder&harvest.distance<5

    equip shovel

  :?harvest=Tree

    equipR Hatchet


//按键们

func switchs()

  var switch = ui.AddButton()

  switch.visible=true

  switch.w=6

  switch.h=3

  switch.y=6

  switch.x=-40

  switch.text=UI开关

  switch.SetPressed(switchon)


//己方血条美化

func Ahp_ui(x,y)

  draw.Box(x,y,17,2,#FFFFFF,0)

  ?maxarmor1<maxarmor

    maxarmor1=maxarmor

  hpPC=hp*1.0/maxhp

  armorPC=armor*1.0/maxarmor1

  var hpPCint=math.CeiltoInt(10*hpPC)

  var armorPCint=math.CeiltoInt(10*armorPC)

  ?armorPCint>10

    armorPCint=10

  hpPC=math.CeiltoInt(100*hpPC)

  armorPC=math.CeiltoInt(100*armorPC)

  var namestr=string.format("{0} LV{1}"

  ^,player.name,(maxhp-20))

  >`@x+19@,@y+1@,#rainAA,@namestr@

  ?hpPC>60

    draw.Bg(x,y+1,#green,hpPCint,1)

    >`@x+10@,@y+1@,#green,@hp@ @hpPC@%  

  :?hpPC>30

    draw.Bg(x,y+1,#CCCC22,hpPCint,1)

    >`@x+10@,@y+1@,#CCCC22,@hp@ @hpPC@%  

  :

    draw.Bg(x,y+1,#CC1122,hpPCint,1)

    >`@x+10@,@y+1@,#CC1122,@hp@ @hpPC@%

  ?armorPC>60

    draw.Bg(x,y,#blue,armorPCint,1)

    >`@x+10@,@y@,#blue,@armor+0.1*armor.f@

    ^ @armorPC@%

  :?armorPC>30

    draw.Bg(x,y,#CCCC22,armorPCint,1)

    >`@x+10@,@y@,#CCCC22,@armor+0.1*armor.f@

    ^ @armorPC@% 

  :

    draw.Bg(x,y,#CC1122,armorPCint,1)

    >`@x+10@,@y@,#CC1122,@armor+0.1*armor.f@

    ^ @armorPC@%


//敌方血条美化

func Bhp_ui(x,y)

  ?foe.state!-1&foe.state!0

    >f-2,-3,#C5B358,ascii

##|

#\|/

##`

asciiend

  draw.Box(x,y,20,2,#FFFFFF,0)

  hpPL=foe.hp*1.0/foe.maxhp

  armorPL=foe.armor*1.0/foe.maxarmor

  var hpPLint=math.CeiltoInt(20*hpPL)

  var armorPLint=math.CeiltoInt(20*armorPL)

  ?armorPLint>20

    armorPLint=20

  hpPL=math.CeiltoInt(100*hpPL)

  armorPL=math.CeiltoInt(100*armorPL)

  var hpStr=string.format("{0,0}  {1,0}% {2,0}"

  ^,foe.name,hpPL,foe.hp)

  var armorStr=string.format("{0,0}% {1,0}"

  ^,armorPL,foe.armor)

  ?foe.count>0&foe.state!-1

    ?hpPLint>=0

      draw.Bg(x+hpPLint,y+1,

      ^#111111,20-hpPLint,1)

    draw.Bg(x,y+1,#CC1122,hpPLint,1)//敌人血条

    >`@x-string.size(hpStr)@,@y+1@

    ^,#CC1122,@hpStr@

    ?foe.armor!0

      ?armorPLint>=0

        draw.Bg(x+armorPLint,y,

        ^#111111,20-armorPLint,1)

      draw.Bg(x,y,#2E4053,armorPLint,1)//敌人护甲

      >`@x-string.size(armorStr)@,@y@

      ^,#2E4053,@armorStr@


//己方buffui

func Abuff_ui(x,y)

  var buffstr=" "

  ?string.IndexOf(buffs.string,≡)!-1

    buffstr=buffstr+"≡"

  ?string.IndexOf(buffs.string,•)!-1

    buffstr=buffstr+"•"

  >`@x@,@y@,#1111CC,@buffstr@

//敌方buffui

//func Bbuff_ui(x,y) 


//时间ui

func time_ui(x,y)

  >`@x+3@,@y@,T i m e

  draw.Box(x,y,13,7,#FFFFFF,3)

  Tttime++

  >`@x+1@,@y+1@,Best:@time.FormatCasual

  ^(loc.bestTime)@

  >`@x+1@,@y+2@,Avg :@time.FormatCasual

  ^(loc.averageTime)@

  >`@x+1@,@y+3@,TtT:@time.FormatCasual

  ^(Tttime)@

  >`@x+1@,@y+4@,Loop:  @count@

  >`@x+1@,@y+5@,Time:@time.FormatCasual

  ^(totaltime)@


//技能冷却ui

func CD_ui(x,y)

  draw.Box(x,y+1,15,2,#FFFFFF,0)

  bashcd=item.GetCooldown("bash")/30

  dashcd=item.GetCooldown("dash")/30

  armcd=item.GetCooldown("skeleton_arm")/30

  bladecd=item.GetCooldown("blade")/30

  hammercd=item.GetCooldown("hammer")/30

  ?bashcd=0 //冲锋盾

    >`@x+1@,@y+1@,#rainFF,(>>) RDY

  :  

    >`@x+1@,@y+1@,(>>) @bashcd@S

  ?dashcd=0 //冲刺盾

    >`@x+10@,@y+1@,#rainFF,(:) RDY

  :  

    >`@x+10@,@y+1@,(:) @dashcd@S

  ?armcd=0  //骷髅手

    >`@x+1@,@y+2@,#rainFF,¯`—≡ RDY

  :    

    >`@x+1@,@y+2@,¯`—≡ @armcd@S

  ?bladecd=0 //堕神

    >`@x+10@,@y+2@,#rainFF,—|——/ RDY

  :  

    >`@x+10@,@y+2@,—|——/ @bladecd@S

  ?hammercd=0 //大锤

    >`@x+1@,@y+3@,#rainFF,——|| RDY

  :  

    >`@x+1@,@y+3@,——|| @hammercd@S


//伤害统计ui

func DMG_ui(x,y)

  >`@x+3@,@y@,DMG Table

  draw.Box(x,y,15,7,#FFFFFF,3)

  ?foe.hp+foe.armor=foe.maxhp+foe.maxarmor

    sHP=foe.hp+foe.armor

    eHP=foe.hp+foe.armor

  ?foe.hp+foe.armor!eHP

    sHP=eHP

    eHP=foe.hp+foe.armor

    DMG=sHP-eHP

    ?DMG>0

      TtDMG=TtDMG+DMG

      LoopDMG=LoopDMG+DMG

      DMGtimes++

//  >`@x+1@,@y+7@,statetime:@foe.time@

//  >`@x+1@,@y+6@,state:@foe.state@

  >`@x+1@,@y+1@,DMG:@DMG@

  var DPS= string.format("DPS:{0,4:0.0}"

  ^,(LoopDMG*1.0/(totaltime/30)))

  var AvgrDMG=string.format("AvgDMG:{0,0:0.0}"

  ^,(LoopDMG*1.0/(DMGtimes+1)))

  >`@x+1@,@y+2@,@DPS@

  >`@x+1@,@y+3@,TtDMG:@transp(TtDMG)@

  >`@x+1@,@y+4@,LoopDMG:@transp(LoopDMG)@

  >`@x+1@,@y+5@,@AvgrDMG@



//战斗()

//func Battle()

 

func switchon()

  on=!on


//主体

func Main()

  //按下Z键可以切换ui开关

  ?key=bumpLBegin

    on = !on

  ?on

    CD_ui(16,0)

    Ahp_ui(0,25)

    Abuff_ui(0,24)

    Bhp_ui(72,25)

    DMG_ui(0,6)

    time_ui(79,0)


Main()


简单用一用还是可以的,还可以在大部分情况下随时手动关闭ui。

限于游戏所给的API,有些东西看似简单,但实际上我连正常的伤害统计都做不出来,不知道作者以后会不会添加相关的接口。

一个人的想法还是有限的,虽然我还有一些计划中的功能要实现,但还是请有想法的人留下自己的想法,即使不懂代码也没关系,我会尽力尝试一下能不能做出来,也欢迎私信或评论区讨论。

Stone Story RPG【石头纪】简单的自用ui代码的评论 (共 条)

分享到微博请遵守国家法律