190 lines
		
	
	
		
			5.2 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
			
		
		
	
	
			190 lines
		
	
	
		
			5.2 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
| /*
 | |
| 文件名:Attribute.nut
 | |
| 路径:User/Asset/Item/Attribute.nut
 | |
| 创建日期:2025-02-10	07:00
 | |
| 文件用途:属性类
 | |
| */
 | |
| class Attribute {
 | |
|     //最大生命值
 | |
|     HPMax = 0;
 | |
|     //最大魔法值
 | |
|     MPMax = 0;
 | |
|     //生命值回复速度
 | |
|     HPRegenSpeed = 0;
 | |
|     //魔法值回复速度
 | |
|     MPRegenSpeed = 0;
 | |
|     //跳跃力
 | |
|     JumpPower = 0;
 | |
|     //硬直
 | |
|     HitRecovery = 0;
 | |
|     //命中率
 | |
|     Stuck = 0;
 | |
|     //闪避率
 | |
|     StuckResistance = 0;
 | |
| 
 | |
|     //力量
 | |
|     PhysicalAttack = 0;
 | |
|     //智力
 | |
|     MagicalAttack = 0;
 | |
|     //体力
 | |
|     PhysicalDefense = 0;
 | |
|     //精神
 | |
|     MagicalDefense = 0;
 | |
|     //所有属强
 | |
|     AllElementalAttack = 0;
 | |
|     //暗属强
 | |
|     DarkAttack = 0;
 | |
|     //光属强
 | |
|     LightAttack = 0;
 | |
|     //水属强
 | |
|     WaterAttack = 0;
 | |
|     //火属强
 | |
|     FireAttack = 0;
 | |
| 
 | |
|     //物理攻击力
 | |
|     EquipmentPhysicalAttack = 0;
 | |
|     //魔法攻击力
 | |
|     EquipmentMagicalAttack = 0;
 | |
|     //独立攻击力
 | |
|     SeparateAttack = 0;
 | |
|     //物理防御力
 | |
|     EquipmentPhysicalDefense = 0;
 | |
|     //魔法防御力
 | |
|     EquipmentMagicalDefense = 0;
 | |
| 
 | |
|     //攻击速度
 | |
|     AttackSpeed = 0;
 | |
|     //释放速度
 | |
|     CastSpeed = 0;
 | |
|     //移动速度
 | |
|     MoveSpeed = 0;
 | |
|     //跳跃速度
 | |
|     JumpSpeed = 0;
 | |
| 
 | |
|     //物理暴击率
 | |
|     PhysicalCriticalHit = 0;
 | |
|     //魔法暴击率
 | |
|     MagicalCriticalHit = 0;
 | |
| 
 | |
|     //暗属抗
 | |
|     DarkResistance = 0;
 | |
|     //光属抗
 | |
|     LightResistance = 0;
 | |
|     //水属抗
 | |
|     WaterResistance = 0;
 | |
|     //火属抗
 | |
|     FireResistance = 0;
 | |
| 
 | |
|     //属性攻击
 | |
|     ElementalProperty = null;
 | |
| 
 | |
|     constructor(Args) {
 | |
|         ElementalProperty = [];
 | |
| 
 | |
|         //使用装备构造
 | |
|         if (typeof Args == "table") {
 | |
|             foreach(member, val in getconsttable().ATTRIBUTE) {
 | |
|                 if (member != "ElementalProperty") {
 | |
|                     //普通属性
 | |
|                     if (Args.rawin(member)) {
 | |
|                         this[member] = Args[member];
 | |
|                     }
 | |
|                 } else {
 | |
|                     //属性攻击
 | |
|                     if (Args.rawin(member)) {
 | |
|                         switch (Args[member]) {
 | |
|                             case "[dark element]":
 | |
|                                 this[member].push(0);
 | |
|                                 break;
 | |
|                             case "[light element]":
 | |
|                                 this[member].push(1);
 | |
|                                 break;
 | |
|                             case "[water element]":
 | |
|                                 this[member].push(2);
 | |
|                                 break;
 | |
|                             case "[fire element]":
 | |
|                                 this[member].push(3);
 | |
|                         }
 | |
|                     }
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
|         //使用角色构造
 | |
|         else if (typeof Args == "Game_Character") {
 | |
|             local Info = sq_DeepCopy(Args.Info.Attribute[Args.GrowJob]);
 | |
|             Info.rawdelete("filepath");
 | |
|             foreach(Key, Value in Info) {
 | |
|                 // print(Value);
 | |
|                 if (Key == "HPMax" || Key == "MPMax" || Key == "PhysicalAttack" || Key == "MagicalAttack" || Key == "PhysicalDefense" || Key == "MagicalDefense")
 | |
|                     this[Key] = Value * Args.Level;
 | |
|                 else {
 | |
|                     if (this.rawin(Key)) this[Key] = Value;
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     function _typeof() {
 | |
|         return "Attribute";
 | |
|     }
 | |
| 
 | |
| 
 | |
|     function _add(other) {
 | |
|         if (typeof other != "Attribute") throw "属性运算参数错误";
 | |
|         foreach(member, val in getconsttable().ATTRIBUTE) {
 | |
|             if (member != "ElementalProperty") {
 | |
|                 this[member] += other[member];
 | |
|             } else {
 | |
|                 foreach(EleType in other[member]) {
 | |
|                     local index = this["ElementalProperty"].find(EleType);
 | |
|                     if (!index) this["ElementalProperty"].push(EleType);
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
|         return this;
 | |
|     }
 | |
| 
 | |
|     function _sub(other) {
 | |
|         if (typeof other != "Attribute") throw "属性运算参数错误";
 | |
|         foreach(member, val in getconsttable().ATTRIBUTE) {
 | |
|             if (member != "ElementalProperty") {
 | |
|                 this[member] -= other[member];
 | |
|             } else {
 | |
|                 foreach(EleType in other[member]) {
 | |
|                     local index = this["ElementalProperty"].find(EleType);
 | |
|                     if (index) this["ElementalProperty"].remove(index);
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
|         return this;
 | |
|     }
 | |
| 
 | |
|     function _mul(other) {
 | |
|         foreach(member, val in getconsttable().ATTRIBUTE) {
 | |
|             if (member != "ElementalProperty") {
 | |
|                 this[member] *= other;
 | |
|             }
 | |
|         }
 | |
|         return this;
 | |
|     }
 | |
| 
 | |
|     function _div(other) {
 | |
|         foreach(member, val in getconsttable().ATTRIBUTE) {
 | |
|             if (member != "ElementalProperty") {
 | |
|                 this[member] /= other;
 | |
|             }
 | |
|         }
 | |
|         return this;
 | |
|     }
 | |
| 
 | |
|     function Show() {
 | |
|         foreach(member, val in getconsttable().ATTRIBUTE) {
 | |
|             if (member != "ElementalProperty") {
 | |
|                 print(getconsttable().ATTRIBUTE[member] + " : " + this[member]);
 | |
|             } else {
 | |
|                 print(getconsttable().ATTRIBUTE[member] + " : ");
 | |
|                 print(this[member]);
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| } |