Skip to content

Commit

Permalink
feat(pkuxkx): 优化 HP 摘要,响应式布局适配窄屏并减少不必要的刷屏
Browse files Browse the repository at this point in the history
  • Loading branch information
dzpao committed Nov 20, 2023
1 parent a23e794 commit cd4d77f
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 67 deletions.
43 changes: 28 additions & 15 deletions mud/pkuxkx/plugins/basic/char/gmcp.tin
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ event.Define {char/nofight} {无参} {$MODULE} {角色脱离战斗};
};

#var {gmcp-name-map} {
{HP} {
{经验} {经验} {combat_exp} {经验}
{潜能} {潜能} {potential} {潜能}
{HP主要} {
{最大内力} {最大内力} {max_neili} {最大内力}
{内力} {当前内力} {neili} {当前内力}
{最大精力} {最大精力} {max_jingli} {最大精力}
Expand All @@ -42,12 +40,17 @@ event.Define {char/nofight} {无参} {$MODULE} {角色脱离战斗};
{有效精神} {有效精神} {eff_jing} {有效精神}
{精神} {当前精神} {jing} {当前精神}
{真气} {当前真气} {vigour/qi} {当前真气}
{忙} {忙} {is_busy} {忙}
{战斗中} {战斗中} {is_fighting} {战斗中}
}

{HP次要} {
{经验} {经验} {combat_exp} {经验}
{潜能} {潜能} {potential} {潜能}
{真元} {真元} {vigour/yuan} {真元}
{食物} {食物} {food} {食物}
{饮水} {饮水} {water} {饮水}
{忙} {忙} {is_busy} {忙}
{战意} {战意} {fighter_spirit} {战意}
{战斗中} {战斗中} {is_fighting} {战斗中}
}

{档案} {
Expand All @@ -70,7 +73,8 @@ event.Define {char/nofight} {无参} {$MODULE} {角色脱离战斗};
#alias {char.gmcp.status} {
#local busy {};
#local fight {};
#local hasHP {0};
#local hasHP1 {0};
#local hasHP2 {0};
#local hasScore {0};

#local id {$gGMCP[Status][id]};
Expand All @@ -89,15 +93,12 @@ event.Define {char/nofight} {无参} {$MODULE} {角色脱离战斗};
#foreach {*gGMCP[Status][]} {key} {
#local value {$gGMCP[Status][$key]};

#local name {$gmcp-name-map[HP][$key]};
#local name {$gmcp-name-map[HP主要][$key]};
#if { "$name" != "" } {
#local hasHP {1};

#if { "$name" == "{当前.*|经验|潜能|食物|饮水}" } {
speedo.Set {$name} {$value} {true} {10};
};
#local hasHP1 {1};

#if { "$name" == "当前%*" } {
speedo.Set {$name} {$value} {true} {10};
#local bakName {@str.Replace{$name;当前;上次}};
#local pctName {@str.Replace{$name;当前%*;&1百分比}};
#var char[HP][$bakName] {$char[HP][$name]};
Expand Down Expand Up @@ -126,6 +127,18 @@ event.Define {char/nofight} {无参} {$MODULE} {角色脱离战斗};
#continue;
};

#local name {$gmcp-name-map[HP次要][$key]};
#if { "$name" != "" } {
#var char[HP][$name] {$value};
#if { "$name" == "{经验|潜能}" } {
speedo.Set {$name} {$value} {true} {600};
};
#elseif { "$name" == "{食物|饮水}" } {
speedo.Set {$name} {$value} {true} {10};
};
#continue;
};

#local name {$gmcp-name-map[档案][$key]};
#if { "$name" != "" } {
#local hasScore {1};
Expand All @@ -150,22 +163,22 @@ event.Define {char/nofight} {无参} {$MODULE} {角色脱离战斗};
warnLog 未能识别的 GMCP 状态信息 $key => $value;
};

#if { $hasHP } {
#if { $hasHP1 + $hasHP2 > 0 } {
#foreach {*needUpdate[]} {key} {
#if { "$key" == "%*百分比" } {
#local current {@str.Replace{$key;%*百分比;当前&1}};
#local maxName {@str.Replace{$key;%*百分比;最大&1}};
#local scale {@if{"$key" == "{内力|精力}百分比";2;1}};
#math char[HP][$key] { $char[HP][$current] * 100 / $char[HP][$maxName] * $scale };
#math char[HP][$key] { $char[HP][$current] * 100 / $char[HP][$maxName] / $scale };
};
#elseif { "$key" == "%*健康度" } {
#local effName {@str.Replace{$key;%*健康度;有效&1}};
#local maxName {@str.Replace{$key;%*健康度;最大&1}};
#math char[HP][$key] { $char[HP][$effName] * 100 / $char[HP][$maxName] };
};
};
#if { $hasHP1 } {char.HPSummarize};
event.Emit char/hpbrief;
char.HPSummarize;
};

#if { $hasScore } {event.Emit char/score};
Expand Down
118 changes: 66 additions & 52 deletions mud/pkuxkx/plugins/basic/char/hp.tin
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ hp -neili 格式:
#local color {<168>};
#local combat {};
#local safety {};
#local width {@prompt.ScreenWidth{}};

#if { $char[HP][气血百分比] < 30 || $char[HP][精神百分比] < 70 } {
#local safety {危险};
Expand Down Expand Up @@ -362,66 +363,79 @@ hp -neili 格式:
#else {
#local 每秒气血变化 {};
};
#format 气血 {气血: %s%s/%s}
{@__char_hp_colorit__{$char[HP][气血百分比]}} {${每秒气血变化}}
{@__char_hp_colorit__{$char[HP][气血健康度]}};

#local 每秒精神变化 {@speedo.GetSpeed{当前精神}};
#if { ${每秒精神变化} > 0 } {
#local 每秒精神变化 {(<128>${每秒精神变化}<298>)};
};
#elseif { ${每秒精神变化} < 0 } {
#local 每秒精神变化 {(<118>${每秒精神变化}<298>)};
};
#else {
#local 每秒精神变化 {};
#local 内力 {};
#if { $width >= 50 || $char[HP][当前内力] > $char[HP][上次内力] } {
#local 每秒内力变化 {@speedo.GetSpeed{当前内力}};
#if { ${每秒内力变化} > 0 } {
#local 每秒内力变化 {(<128>${每秒内力变化}<298>)};
};
#elseif { ${每秒内力变化} < 0 } {
#local 每秒内力变化 {(<118>${每秒内力变化}<298>)};
};
#else {
#local 每秒内力变化 {};
};
#format 内力 { 内力: %s%s} {@__char_hp_colorit__{$char[HP][内力百分比]}} {${每秒内力变化}};
};

#local 每秒内力变化 {@speedo.GetSpeed{当前内力}};
#if { ${每秒内力变化} > 0 } {
#local 每秒内力变化 {(<128>${每秒内力变化}<298>)};
};
#elseif { ${每秒内力变化} < 0 } {
#local 每秒内力变化 {(<118>${每秒内力变化}<298>)};
};
#else {
#local 每秒内力变化 {};
#local 精神 {};
#if { $width >= 80 } {
#local 每秒精神变化 {@speedo.GetSpeed{当前精神}};
#if { ${每秒精神变化} > 0 } {
#local 每秒精神变化 {(<128>${每秒精神变化}<298>)};
};
#elseif { ${每秒精神变化} < 0 } {
#local 每秒精神变化 {(<118>${每秒精神变化}<298>)};
};
#else {
#local 每秒精神变化 {};
};
#format 精神 { 精神: %s%s/%s}
{@__char_hp_colorit__{$char[HP][精神百分比]}} {${每秒精神变化}}
{@__char_hp_colorit__{$char[HP][精神健康度]}};
};

#local 每秒精力变化 {@speedo.GetSpeed{当前精力}};
#if { ${每秒精力变化} > 0 } {
#local 每秒精力变化 {(<128>${每秒精力变化}<298>)};
};
#elseif { ${每秒精力变化} < 0 } {
#local 每秒精力变化 {(<118>${每秒精力变化}<298>)};
};
#else {
#local 每秒精力变化 {};
#local 精力 {};
#if { ($width >= 100 && [email protected]{}) || $char[HP][当前精力] > $char[HP][上次精力] || $char[HP][精力百分比] < 30 } {
#local 每秒精力变化 {@speedo.GetSpeed{当前精力}};
#if { ${每秒精力变化} > 0 } {
#local 每秒精力变化 {(<128>${每秒精力变化}<298>)};
};
#elseif { ${每秒精力变化} < 0 } {
#local 每秒精力变化 {(<118>${每秒精力变化}<298>)};
};
#else {
#local 每秒精力变化 {};
};
#format 精力 { 精力: %s%s} {@__char_hp_colorit__{$char[HP][精力百分比]}} {${每秒精力变化}};
};

#nop 气血恢复的数值展示为每分钟可以恢复的最大血量的倍数(以百分比形式);
#local {气血恢复} {@math.Int{@math.Eval{$char[STATUS][气血恢复] * 100 * 60 / $char[HP][最大气血]}}};

#nop 气血治疗的数值展示为每分钟可以治疗的最大血量的倍数(以百分比形式);
#local {气血治疗} {@math.Int{@math.Eval{$char[STATUS][气血治疗] * 100 * 60 / $char[HP][最大气血]}}};

#local summarize {};
#if { "$char[HP][战斗中]" == "true" } {
#format summarize {<099>$color〔HP摘要〕<298>气血: %s%s/%s 内力: %s%s 回气: %s/%s 精神: %s%s/%s 食水: %s/%s$combat<099>}
{@__char_hp_colorit__{$char[HP][气血百分比]}} {${每秒气血变化}} {@__char_hp_colorit__{$char[HP][气血健康度]}}
{@__char_hp_colorit__{$char[HP][内力百分比]}} {${每秒内力变化}}
{@__char_hp_colorit__{${气血恢复}}} {@__char_hp_colorit__{${气血治疗}}}
{@__char_hp_colorit__{$char[HP][精神百分比]}} {${每秒精神变化}} {@__char_hp_colorit__{$char[HP][精神健康度]}}
{$char[HP][食物]} {$char[HP][饮水]}
#local 回气 {};
#if { $width >= 110 || @char.InCombat{} } {
#nop 气血恢复的数值展示为每分钟可以恢复的最大血量的倍数(以百分比形式);
#local {气血恢复} {@math.Int{@math.Eval{$char[STATUS][气血恢复] * 100 * 60 / $char[HP][最大气血]}}};
#nop 气血治疗的数值展示为每分钟可以治疗的最大血量的倍数(以百分比形式);
#local {气血治疗} {@math.Int{@math.Eval{$char[STATUS][气血治疗] * 100 * 60 / $char[HP][最大气血]}}};
#format {回气} { 回气: %s/%s} {@__char_hp_colorit__{${气血恢复}}} {@__char_hp_colorit__{${气血治疗}}};
};
#else {
#local jingli {@if{$chat[HP][精力百分比] < 30;{@__char_hp_colorit__{$char[HP][精力百分比]} ${每秒精力变化}}}};
#format summarize {<099>$color〔HP摘要〕<298>气血: %s%s/%s 内力: %s%s 回气: %s/%s 精神: %s%s/%s $jingli食水: %s/%s(%s/%s)$combat<099>}
{@__char_hp_colorit__{$char[HP][气血百分比]}} {${每秒气血变化}} {@__char_hp_colorit__{$char[HP][气血健康度]}}
{@__char_hp_colorit__{$char[HP][内力百分比]}} {${每秒内力变化}}
{@__char_hp_colorit__{${气血恢复}}} {@__char_hp_colorit__{${气血治疗}}}
{@__char_hp_colorit__{$char[HP][精神百分比]}} {${每秒精神变化}} {@__char_hp_colorit__{$char[HP][精神健康度]}}
{$char[HP][食物]} {$char[HP][饮水]}
{@speedo.GetSpeed{食物;60}} {@speedo.GetSpeed{饮水;60}};

#local 食水 {};
#if { $width >= 110 } {
#if { @char.InCombat{} } {
#format {食水} { 食水: %s/%s} {$char[HP][食物]} {$char[HP][饮水]};
};
#else {
#format {食水} { 食水: %s/%s(%s/%s)}
{$char[HP][食物]} {$char[HP][饮水]}
{@speedo.GetSpeed{食物;60}} {@speedo.GetSpeed{饮水;60}};
};
};

#local summarize {<099>$color〔HP摘要〕<298>${气血}${内力}${回气}${精神}${精力}${食水}$combat<099>};
#showme $summarize;
};

Expand All @@ -435,7 +449,7 @@ hp -neili 格式:

#func {__char_hp_colorit__} {
#local percent {@math.Int{@defaultNum{%1;0}}};
#return {@util.Grade{$percent;<218>;15;<118>;30;<238>;60;<138>;90;<128>;101;<168>}$percent%<298>};
#return {@util.Grade{$percent;<218>;15;<118>;30;<238>;60;<138>;90;<128>;101;<168>}$percent%%<298>};
};

#alias {char.GetHP} {
Expand Down Expand Up @@ -514,7 +528,7 @@ hp -neili 格式:
// #@ char.InCombat
// 如果角色正处于战斗中,则返回真,否则返回假。无参数。
// };
#func {char.IsIdle} {
#func {char.InCombat} {
#if { "$char[HP][战斗中]" == "true" } {
#return 1;
};
Expand Down

0 comments on commit cd4d77f

Please sign in to comment.