> For the complete documentation index, see [llms.txt](https://ersha.gitbook.io/attributeplus-pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ersha.gitbook.io/attributeplus-pro/shu-xing-jiao-ben/shou-ba-shou-jiao-ni-xie-shu-xing-jiao-ben/update-lei-xing.md).

# UPDATE 类型

## 属性效果

制作一个伤害属性加成的属性，公式为 **"{entityA:物理伤害}\*{value}/100"**

<pre class="language-javascript"><code class="lang-javascript">var priority = 105
var combatPower = 5.0
var attributeName = "伤害加成"
var attributeType = "UPDATE"
var placeholder = "updateAttribute"

function onLoad(attr){
  /* UPDATE 类型建议将 setSkipFilter 设为 true */
  attr.setSkipFilter(true)
  /* 设置公式 */
  attr.setFormula("{entityA:物理伤害}*{value}/100")
  return attr
}

function run(attr, entity, handle){
  var value = attr.getRandomValue(entity, handle)
  var additionValue = 0.0
  /* 获取实体 AttributeData 数据 */
  var data = attr.getData(entity, handle)
  /* 清除掉上次增加的属性源,防止属性反复叠加 */
  AttributeAPI.takeSourceAttribute(data, "伤害加成")
  
  if (value > 0){
      /* 获取加成值 */
      var additionValue = attr.getFormulaValue(function(){
      var damageValue = attr.getRandomValue(entity, "物理伤害", handle)
	  return damageValue*value/100
      })
   }

   /* 调用 AttributeAPI 内方法增加属性 */
<strong>   AttributeAPI.addSourceAttribute(data, "伤害加成", Arrays.asList("物理伤害: "+additionValue), false)
</strong>   return false
}
</code></pre>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ersha.gitbook.io/attributeplus-pro/shu-xing-jiao-ben/shou-ba-shou-jiao-ni-xie-shu-xing-jiao-ben/update-lei-xing.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
