diff options
author | Haru <haru@dotalux.com> | 2017-06-03 17:36:58 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-03 17:36:58 +0200 |
commit | 0a4abf01c3b3c41ce169752cd3d6d74766d1eee1 (patch) | |
tree | 50dcdf0d6f5d29664ff90efa280aec7fbd1fa925 | |
parent | d2af893049845c4be0710f8939d09ba87485dddc (diff) | |
parent | 392c4b225dfc99401faeef882b10ce0b6d6a2209 (diff) | |
download | hercules-0a4abf01c3b3c41ce169752cd3d6d74766d1eee1.tar.gz hercules-0a4abf01c3b3c41ce169752cd3d6d74766d1eee1.tar.bz2 hercules-0a4abf01c3b3c41ce169752cd3d6d74766d1eee1.tar.xz hercules-0a4abf01c3b3c41ce169752cd3d6d74766d1eee1.zip |
Merge pull request #1739 from mekolat/pow2
implementation of the exponentiation operator
-rw-r--r-- | db/pre-re/item_db.conf | 2 | ||||
-rw-r--r-- | db/re/item_db.conf | 130 | ||||
-rw-r--r-- | doc/script_commands.txt | 36 | ||||
-rw-r--r-- | npc/custom/quests/thq/THQS_TTShop.txt | 4 | ||||
-rw-r--r-- | npc/dev/test.txt | 13 | ||||
-rw-r--r-- | npc/other/Global_Functions.txt | 8 | ||||
-rw-r--r-- | src/map/script.c | 8 | ||||
-rw-r--r-- | src/map/script.h | 1 |
8 files changed, 117 insertions, 85 deletions
diff --git a/db/pre-re/item_db.conf b/db/pre-re/item_db.conf index b17e57252..82168a1ca 100644 --- a/db/pre-re/item_db.conf +++ b/db/pre-re/item_db.conf @@ -78970,7 +78970,7 @@ item_db: ( bonus2 bIgnoreDefRate,RC_DemiPlayer,20; bonus bUnbreakableWeapon,0; if(getrefine()>5) { - bonus2 bAddRace,RC_DemiPlayer,pow(getrefine()-4,2); + bonus2 bAddRace,RC_DemiPlayer,((getrefine()-4) ** (2)); bonus2 bIgnoreDefRate,RC_DemiPlayer,5; } if(getrefine()>8) { diff --git a/db/re/item_db.conf b/db/re/item_db.conf index 514337801..f10e29289 100644 --- a/db/re/item_db.conf +++ b/db/re/item_db.conf @@ -6419,7 +6419,7 @@ item_db: ( bonus2 bIgnoreDefRate,RC_DemiPlayer,25; bonus bUnbreakableWeapon,0; if(getrefine()>5) { - bonus2 bAddRace,RC_DemiPlayer,pow(min(getrefine(), 14)-3,2); + bonus2 bAddRace,RC_DemiPlayer,((min(getrefine(), 14)-3) ** (2)); bonus2 bIgnoreDefRate,RC_DemiPlayer,5; } if(getrefine()>8) { @@ -9130,7 +9130,7 @@ item_db: ( bonus2 bIgnoreDefRate,RC_DemiPlayer,20; bonus bUnbreakableWeapon,0; if(getrefine()>5) { - bonus2 bAddRace,RC_DemiPlayer,pow(min(getrefine(),14)-4,2); + bonus2 bAddRace,RC_DemiPlayer,((min(getrefine(),14)-4) ** (2)); bonus2 bIgnoreDefRate,RC_DemiPlayer,5; } if(getrefine()>8) autobonus "{ bonus bAspdRate,100; }",70,3000,BF_WEAPON,"{ specialeffect2 EF_POTION_BERSERK; }"; @@ -9165,7 +9165,7 @@ item_db: ( bonus2 bIgnoreDefRate,RC_DemiPlayer,20; bonus bUnbreakableWeapon,0; if(getrefine()>5) { - bonus2 bAddRace,RC_DemiPlayer,pow(min(getrefine(),14)-4,2); + bonus2 bAddRace,RC_DemiPlayer,((min(getrefine(),14)-4) ** (2)); bonus2 bCriticalAddRace,RC_DemiPlayer,5; } if(getrefine()>8) autobonus "{ bonus bAspdRate,100; }",70,3000,BF_WEAPON,"{ specialeffect2 EF_POTION_BERSERK; }"; @@ -9847,7 +9847,7 @@ item_db: ( bonus2 bIgnoreDefRate,RC_DemiPlayer,20; bonus bUnbreakableWeapon,0; if(getrefine()>5) { - bonus2 bAddRace,RC_DemiPlayer,pow(min(getrefine(),14)-4,2); + bonus2 bAddRace,RC_DemiPlayer,((min(getrefine(),14)-4) ** (2)); bonus2 bIgnoreDefRate,RC_DemiPlayer,5; bonus bAspdRate,5; } @@ -11018,7 +11018,7 @@ item_db: ( bonus2 bIgnoreDefRate,RC_DemiPlayer,25; bonus bUnbreakableWeapon,0; if(getrefine()>5) { - bonus2 bAddRace,RC_DemiPlayer,pow(min(getrefine(),14)-3,2); + bonus2 bAddRace,RC_DemiPlayer,((min(getrefine(),14)-3) ** (2)); bonus2 bIgnoreDefRate,RC_DemiPlayer,5; bonus3 bAutoSpell,NPC_CRITICALWOUND,1,50; } @@ -11558,7 +11558,7 @@ item_db: ( EquipLv: 160 View: 4 Script: <" - bonus bAtk,pow(min(getrefine(),15),2); + bonus bAtk,((min(getrefine(),15)) ** (2)); "> }, { @@ -12177,7 +12177,7 @@ item_db: ( bonus2 bIgnoreDefRate,RC_DemiPlayer,20; bonus bUnbreakableWeapon,0; if(getrefine()>5) { - bonus2 bAddRace,RC_DemiPlayer,pow(min(getrefine(),14)-4,2); + bonus2 bAddRace,RC_DemiPlayer,((min(getrefine(),14)-4) ** (2)); bonus2 bIgnoreDefRate,RC_DemiPlayer,5; bonus bAspdRate,10; } @@ -12580,7 +12580,7 @@ item_db: ( EquipLv: 70 View: 4 Script: <" - bonus bAtk,pow(min(getrefine(),15),2); + bonus bAtk,((min(getrefine(),15)) ** (2)); if(BaseLevel>70) { bonus bAtk,(((BaseLevel-70)/10)*5); } "> }, @@ -12606,7 +12606,7 @@ item_db: ( EquipLv: 160 View: 5 Script: <" - bonus bAtk,pow(min(getrefine(),15),2); + bonus bAtk,((min(getrefine(),15)) ** (2)); "> }, { @@ -13434,7 +13434,7 @@ item_db: ( bonus2 bIgnoreDefRate,RC_DemiPlayer,25; bonus bUnbreakableWeapon,0; if(getrefine()>5) { - bonus2 bAddRace,RC_DemiPlayer,pow(min(getrefine(),14)-4,2); + bonus2 bAddRace,RC_DemiPlayer,((min(getrefine(),14)-4) ** (2)); bonus2 bIgnoreDefRate,RC_DemiPlayer,5; } if(getrefine()>8) { @@ -13759,7 +13759,7 @@ item_db: ( EquipLv: 70 View: 5 Script: <" - bonus bAtk,pow(min(getrefine(),15),2); + bonus bAtk,((min(getrefine(),15)) ** (2)); if(BaseLevel>70) { bonus bAtk,(((BaseLevel-70)/10)*5); } "> }, @@ -15011,7 +15011,7 @@ item_db: ( bonus2 bIgnoreDefRate,RC_DemiPlayer,20; bonus bUnbreakableWeapon,0; if(getrefine()>5) { - bonus2 bAddRace,RC_DemiPlayer,pow(min(getrefine(),14)-4,2); + bonus2 bAddRace,RC_DemiPlayer,((min(getrefine(),14)-4) ** (2)); bonus2 bIgnoreDefRate,RC_DemiPlayer,5; bonus bAspdRate,5; } @@ -15770,7 +15770,7 @@ item_db: ( bonus2 bIgnoreDefRate,RC_DemiPlayer,25; bonus bUnbreakableWeapon,0; if(getrefine()>5) { - bonus2 bAddRace,RC_DemiPlayer,pow(min(getrefine(),14)-4,2); + bonus2 bAddRace,RC_DemiPlayer,((min(getrefine(),14)-4) ** (2)); bonus2 bIgnoreDefRate,RC_DemiPlayer,5; } if(getrefine()>8) autobonus "{ bonus bBaseAtk,200; }",30,3000,BF_WEAPON,"{ specialeffect2 EF_BASH3D; }"; @@ -16314,7 +16314,7 @@ item_db: ( View: 10 Script: <" bonus bInt,5; - bonus bMatk,pow(min(getrefine(),15),2); + bonus bMatk,((min(getrefine(),15)) ** (2)); bonus bUnbreakableWeapon,0; "> }, @@ -18462,7 +18462,7 @@ item_db: ( View: 10 Script: <" bonus bInt,5; - bonus bMatk,pow(min(getrefine(),15),2); + bonus bMatk,((min(getrefine(),15)) ** (2)); if(BaseLevel>70) { bonus bMatk,(((BaseLevel-70)/10)*5); } "> }, @@ -19838,7 +19838,7 @@ item_db: ( bonus bCritAtkRate,getrefine() * 2; bonus bUnbreakableWeapon,0; if(getrefine()>5) { - bonus2 bAddRace,RC_DemiPlayer,pow(min(getrefine(),14)-4,2); + bonus2 bAddRace,RC_DemiPlayer,((min(getrefine(),14)-4) ** (2)); bonus2 bIgnoreDefRate,RC_DemiPlayer,5; } if(getrefine()>8) bonus2 bSkillAtk,AC_DOUBLE,20; @@ -20580,7 +20580,7 @@ item_db: ( EquipLv: 160 View: 12 Script: <" - bonus bAtk,pow(min(getrefine(),15),2); + bonus bAtk,((min(getrefine(),15)) ** (2)); "> }, { @@ -21161,7 +21161,7 @@ item_db: ( bonus2 bIgnoreDefRate,RC_DemiPlayer,20; bonus bUnbreakableWeapon,0; if(getrefine()>5) { - bonus2 bAddRace,RC_DemiPlayer,pow(min(getrefine(),14)-4,2); + bonus2 bAddRace,RC_DemiPlayer,((min(getrefine(),14)-4) ** (2)); bonus2 bIgnoreDefRate,RC_DemiPlayer,5; } if(getrefine()>8) { @@ -21200,7 +21200,7 @@ item_db: ( bonus2 bIgnoreDefRate,RC_DemiPlayer,20; bonus bUnbreakableWeapon,0; if(getrefine()>5) { - bonus2 bAddRace,RC_DemiPlayer,pow(min(getrefine(),14)-4,2); + bonus2 bAddRace,RC_DemiPlayer,((min(getrefine(),14)-4) ** (2)); bonus2 bIgnoreDefRate,RC_DemiPlayer,5; } if(getrefine()>8) { @@ -21476,7 +21476,7 @@ item_db: ( EquipLv: 70 View: 12 Script: <" - bonus bAtk,pow(min(getrefine(),15),2); + bonus bAtk,((min(getrefine(),15)) ** (2)); if(BaseLevel>70) { bonus bAtk,(((BaseLevel-70)/10)*5); } "> }, @@ -21502,8 +21502,8 @@ item_db: ( EquipLv: 160 View: 13 Script: <" - bonus bAtk,pow(min(getrefine(),15),2); - bonus bMatk,pow(min(getrefine(),15),2)/2; + bonus bAtk,((min(getrefine(),15)) ** (2)); + bonus bMatk,((min(getrefine(),15)) ** (2))/2; "> }, { @@ -22108,7 +22108,7 @@ item_db: ( bonus2 bIgnoreDefRate,RC_DemiPlayer,20; bonus bUnbreakableWeapon,0; if(getrefine()>5) { - bonus2 bAddRace,RC_DemiPlayer,pow(min(getrefine(),14)-4,2); + bonus2 bAddRace,RC_DemiPlayer,((min(getrefine(),14)-4) ** (2)); bonus2 bIgnoreDefRate,RC_DemiPlayer,5; } if(getrefine()>8) bonus4 bAutoSpellOnSkill,CG_ARROWVULCAN,CG_TAROTCARD,5,100; @@ -22436,7 +22436,7 @@ item_db: ( EquipLv: 70 View: 13 Script: <" - bonus bAtk,pow(min(getrefine(),15),2); + bonus bAtk,((min(getrefine(),15)) ** (2)); if(BaseLevel>70) { bonus bAtk,(((BaseLevel-70)/10)*5); } "> }, @@ -23150,7 +23150,7 @@ item_db: ( bonus2 bIgnoreDefRate,RC_DemiPlayer,20; bonus bUnbreakableWeapon,0; if(getrefine()>5) { - bonus2 bAddRace,RC_DemiPlayer,pow(min(getrefine(),14)-4,2); + bonus2 bAddRace,RC_DemiPlayer,((min(getrefine(),14)-4) ** (2)); bonus2 bIgnoreDefRate,RC_DemiPlayer,5; } if(getrefine()>8) bonus4 bAutoSpellOnSkill,CG_ARROWVULCAN,CG_TAROTCARD,5,100; @@ -23482,7 +23482,7 @@ item_db: ( EquipLv: 70 View: 14 Script: <" - bonus bAtk,pow(min(getrefine(),15),2); + bonus bAtk,((min(getrefine(),15)) ** (2)); if(BaseLevel>70) { bonus bAtk,(((BaseLevel-70)/10)*5); } "> }, @@ -23505,8 +23505,8 @@ item_db: ( EquipLv: 160 View: 14 Script: <" - bonus bAtk,pow(min(getrefine(),15),2); - bonus bMatk,pow(min(getrefine(),15),2)/2; + bonus bAtk,((min(getrefine(),15)) ** (2)); + bonus bMatk,((min(getrefine(),15)) ** (2))/2; "> }, @@ -24270,7 +24270,7 @@ item_db: ( Script: <" bonus bUnbreakableWeapon,0; bonus bInt,5; - bonus bMatk,pow(min(getrefine(),15),2); + bonus bMatk,((min(getrefine(),15)) ** (2)); if(BaseLevel>70) { bonus bMatk,(((BaseLevel-70)/10)*5); } "> }, @@ -24297,7 +24297,7 @@ item_db: ( View: 23 Script: <" bonus bInt,6; - bonus bMatk,pow(min(getrefine(),15),2); + bonus bMatk,((min(getrefine(),15)) ** (2)); bonus bUnbreakableWeapon,0; "> }, @@ -98898,7 +98898,7 @@ item_db: ( bonus3 bAutoSpell,PR_LEXDIVINA,1,20; bonus bUnbreakableWeapon,0; if(getrefine()>5) { - bonus2 bAddRace,RC_DemiPlayer,pow(min(getrefine(),14)-4,2); + bonus2 bAddRace,RC_DemiPlayer,((min(getrefine(),14)-4) ** (2)); bonus2 bIgnoreDefRate,RC_DemiPlayer,5; } if(getrefine()>8) bonus4 bAutoSpellOnSkill,RG_RAID,NPC_WIDEBLEEDING,1,250; @@ -100558,7 +100558,7 @@ item_db: ( bonus2 bIgnoreDefRate,RC_DemiPlayer,20; bonus bUnbreakableWeapon,0; if(getrefine()>5) { - bonus2 bAddRace,RC_DemiPlayer,pow(min(getrefine(),14)-4,2); + bonus2 bAddRace,RC_DemiPlayer,((min(getrefine(),14)-4) ** (2)); bonus2 bIgnoreDefRate,RC_DemiPlayer,5; } if(getrefine()>8) { @@ -100833,7 +100833,7 @@ item_db: ( EquipLv: 70 View: 17 Script: <" - bonus bAtk,pow(min(getrefine(),15),2); + bonus bAtk,((min(getrefine(),15)) ** (2)); if(BaseLevel>70) { bonus bAtk,(((BaseLevel-70)/10)*5); } "> }, @@ -100854,7 +100854,7 @@ item_db: ( WeaponLv: 4 EquipLv: 160 View: 17 - Script: <" bonus bAtk,pow(min(getrefine(),15),2); "> + Script: <" bonus bAtk,((min(getrefine(),15)) ** (2)); "> }, //== Guns ================================================== @@ -101516,7 +101516,7 @@ item_db: ( bonus2 bSkillAtk,GS_TRIPLEACTION,30; bonus bUnbreakableWeapon,0; if(getrefine()>5) { - bonus2 bAddRace,RC_DemiPlayer,pow(min(getrefine(),14)-4,2); + bonus2 bAddRace,RC_DemiPlayer,((min(getrefine(),14)-4) ** (2)); bonus2 bIgnoreDefRate,RC_DemiPlayer,5; } if(getrefine()>8) { @@ -101556,7 +101556,7 @@ item_db: ( bonus2 bSkillAtk,GS_TRIPLEACTION,30; bonus bUnbreakableWeapon,0; if(getrefine()>5) { - bonus2 bAddRace,RC_DemiPlayer,pow(min(getrefine(),10)-4,2); + bonus2 bAddRace,RC_DemiPlayer,((min(getrefine(),10)-4) ** (2)); bonus2 bIgnoreDefRate,RC_DemiPlayer,5; } if (getrefine() > 8) { @@ -101596,7 +101596,7 @@ item_db: ( bonus2 bSkillAtk,GS_TRIPLEACTION,30; bonus bUnbreakableWeapon,0; if(getrefine()>5) { - bonus2 bAddRace,RC_DemiPlayer,pow(min(getrefine(),10)-4,2); + bonus2 bAddRace,RC_DemiPlayer,((min(getrefine(),10)-4) ** (2)); bonus2 bIgnoreDefRate,RC_DemiPlayer,5; } if(getrefine()>8) { @@ -101636,7 +101636,7 @@ item_db: ( bonus2 bSkillAtk,GS_TRIPLEACTION,30; bonus bUnbreakableWeapon,0; if(getrefine()>5) { - bonus2 bAddRace,RC_DemiPlayer,pow(min(getrefine(),10)-4,2); + bonus2 bAddRace,RC_DemiPlayer,((min(getrefine(),10)-4) ** (2)); bonus2 bIgnoreDefRate,RC_DemiPlayer,5; } if(getrefine()>8) { @@ -103482,7 +103482,7 @@ item_db: ( autobonus "{ bonus2 bSkillAtk,NJ_HUUMA,100; bonus2 bSkillAtk,NJ_ISSEN,100; }",50,10000; bonus bUnbreakableWeapon,0; if(getrefine()>5) { - bonus2 bAddRace,RC_DemiPlayer,pow(min(getrefine(),14)-3,2); + bonus2 bAddRace,RC_DemiPlayer,((min(getrefine(),14)-3) ** (2)); bonus2 bIgnoreDefRate,RC_DemiPlayer,5; } if(getrefine()>8) { @@ -103780,8 +103780,8 @@ item_db: ( View: 22 Script: <" bonus bUnbreakableWeapon,0; - bonus bAtk,pow(min(getrefine(),15),2); - bonus bMatk,pow(min(getrefine(),15),2)/2; + bonus bAtk,((min(getrefine(),15)) ** (2)); + bonus bMatk,((min(getrefine(),15)) ** (2))/2; if(BaseLevel>70) { bonus bAtk,(((BaseLevel-70)/10)*5); } "> }, @@ -103805,8 +103805,8 @@ item_db: ( EquipLv: 160 View: 22 Script: <" - bonus bAtk,pow(min(getrefine(),15),2); - bonus bMatk,pow(min(getrefine(),15),2)/2; + bonus bAtk,((min(getrefine(),15)) ** (2)); + bonus bMatk,((min(getrefine(),15)) ** (2))/2; bonus bUnbreakableWeapon,0; "> }, @@ -104421,7 +104421,7 @@ item_db: ( bonus2 bIgnoreDefRate,RC_DemiPlayer,20; bonus bUnbreakableWeapon,0; if(getrefine()>5) { - bonus2 bAddRace,RC_DemiPlayer,pow(min(getrefine(),14)-4,2); + bonus2 bAddRace,RC_DemiPlayer,((min(getrefine(),14)-4) ** (2)); bonus2 bIgnoreDefRate,RC_DemiPlayer,5; } if(getrefine()>6) { @@ -105160,7 +105160,7 @@ item_db: ( EquipLv: 70 View: 2 Script: <" - bonus bAtk,pow(min(getrefine(),15),2); + bonus bAtk,((min(getrefine(),15)) ** (2)); if(BaseLevel>70) { bonus bAtk,(((BaseLevel-70)/10)*5); } "> }, @@ -105190,7 +105190,7 @@ item_db: ( WeaponLv: 4 EquipLv: 160 View: 2 - Script: <" bonus bAtk,pow(min(getrefine(),15),2); "> + Script: <" bonus bAtk,((min(getrefine(),15)) ** (2)); "> }, //== More Cash Shop Items ================================== @@ -125681,7 +125681,7 @@ item_db: ( View: 8 Script: <" bonus bUnbreakableWeapon,0; - bonus bAtk,pow(min(getrefine(),15),2); + bonus bAtk,((min(getrefine(),15)) ** (2)); if(BaseLevel>70) { bonus bAtk,(((BaseLevel-70)/10)*5); } "> }, @@ -125712,7 +125712,7 @@ item_db: ( EquipLv: 160 View: 8 Script: <" - bonus bAtk,pow(min(getrefine(),15),2); + bonus bAtk,((min(getrefine(),15)) ** (2)); bonus bUnbreakableWeapon,0; "> }, @@ -130705,7 +130705,7 @@ item_db: ( WeaponLv: 4 EquipLv: 160 View: 11 - Script: <" bonus bAtk,pow(min(getrefine(),15),2); "> + Script: <" bonus bAtk,((min(getrefine(),15)) ** (2)); "> }, { Id: 18122 @@ -130855,7 +130855,7 @@ item_db: ( EquipLv: 7 View: 11 Script: <" - bonus bAtk,pow(min(getrefine(),15),2); + bonus bAtk,((min(getrefine(),15)) ** (2)); if(BaseLevel>70) { bonus bAtk,(((BaseLevel-70)/10)*5); } "> }, @@ -145978,8 +145978,8 @@ item_db: ( EquipLv: 70 View: 3 Script: <" - bonus bAtk,pow(min(getrefine(),15),2); - bonus bMatk,pow(min(getrefine(),15),2)/2; + bonus bAtk,((min(getrefine(),15)) ** (2)); + bonus bMatk,((min(getrefine(),15)) ** (2))/2; if(BaseLevel>70) { bonus bAtk,(((BaseLevel-70)/10)*5); } "> }, @@ -146002,7 +146002,7 @@ item_db: ( WeaponLv: 4 EquipLv: 160 View: 3 - Script: <" bonus bAtk,pow(min(getrefine(),15),2); "> + Script: <" bonus bAtk,((min(getrefine(),15)) ** (2)); "> }, { Id: 21018 @@ -150177,7 +150177,7 @@ item_db: ( EquipLv: 70 View: 16 Script: <" - bonus bAtk,pow(min(getrefine(),15),2); + bonus bAtk,((min(getrefine(),15)) ** (2)); if(BaseLevel>70) { bonus bAtk,5*((BaseLevel-70)/10); } "> }, @@ -150199,7 +150199,7 @@ item_db: ( EquipLv: 160 View: 16 Script: <" - bonus bAtk,pow(min(getrefine(),15),2); + bonus bAtk,((min(getrefine(),15)) ** (2)); "> }, { @@ -150346,7 +150346,7 @@ item_db: ( View: 7 Script: <" bonus bUnbreakableWeapon,0; - bonus bAtk,pow(min(getrefine(),15),2); + bonus bAtk,((min(getrefine(),15)) ** (2)); if(BaseLevel>70) { bonus bAtk,(((BaseLevel-70)/10)*5); } "> }, @@ -150373,7 +150373,7 @@ item_db: ( EquipLv: 160 View: 7 Script: <" - bonus bAtk,pow(min(getrefine(),15),2); + bonus bAtk,((min(getrefine(),15)) ** (2)); bonus bUnbreakableWeapon,0; "> }, @@ -151053,8 +151053,8 @@ item_db: ( View: 15 Script: <" bonus bUnbreakableWeapon,0; - bonus bAtk,pow(min(getrefine(),15),2); - bonus bMatk,pow(min(getrefine(),15),2)/2; + bonus bAtk,((min(getrefine(),15)) ** (2)); + bonus bMatk,((min(getrefine(),15)) ** (2))/2; if(BaseLevel>70) { bonus bAtk,(((BaseLevel-70)/10)*5); } "> }, @@ -151078,8 +151078,8 @@ item_db: ( EquipLv: 160 View: 15 Script: <" - bonus bAtk,pow(min(getrefine(),15),2); - bonus bMatk,pow(min(getrefine(),15),2); + bonus bAtk,((min(getrefine(),15)) ** (2)); + bonus bMatk,((min(getrefine(),15)) ** (2)); bonus bUnbreakableWeapon,0; "> }, @@ -151185,8 +151185,8 @@ item_db: ( EquipLv: 70 View: 1 Script: <" - bonus bAtk,pow(min(getrefine(),15),2); - bonus bMatk,pow(min(getrefine(),15),2)/2; + bonus bAtk,((min(getrefine(),15)) ** (2)); + bonus bMatk,((min(getrefine(),15)) ** (2))/2; if(BaseLevel>70) { bonus bAtk,(((BaseLevel-70)/10)*5); } "> }, @@ -151227,8 +151227,8 @@ item_db: ( EquipLv: 160 View: 1 Script: <" - bonus bAtk,pow(min(getrefine(),15),2); - bonus bMatk,pow(min(getrefine(),15),2)/2; + bonus bAtk,((min(getrefine(),15)) ** (2)); + bonus bMatk,((min(getrefine(),15)) ** (2))/2; "> }, diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 0ba350ad1..70306ba96 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -730,6 +730,7 @@ the common mathematical operations or conditional operators: strings. - - will subtract two numbers. * - will multiply two numbers. +** - will raise the first number to the power of the second number. / - will divide two numbers. Note that this is an integer division, i.e. 7/2 is not equal 3.5, it's equal 3. % - will give you the remainder of the division. 7%2 is equal to 1. @@ -930,42 +931,45 @@ Precedence | Description | Associativity | ! Logical NOT | | ~ Bitwise NOT (One's Complement) | --------------------------------------------------------------------------- -3 | * Multiplication | Left to right +3 | ** Exponentiation | Left to right +--------------------------------------------------------------------------- +4 | * Multiplication | Left to right | / Division | | % Modulo (remainder) | --------------------------------------------------------------------------- -4 | + Addition | Left to right +5 | + Addition | Left to right | - Subtraction | --------------------------------------------------------------------------- -5 | << Bitwise left shift | Left to right +6 | << Bitwise left shift | Left to right | >> Bitwise right shift | --------------------------------------------------------------------------- -6 | < Less than | Left to right +7 | < Less than | Left to right | <= Less than or equal to | | > Greater than | | >= Greater than or equal to | --------------------------------------------------------------------------- -7 | == Equal to | Left to right +8 | == Equal to | Left to right | != Not equal to | | ~= Regexp match | | ~! Regexp non-match | --------------------------------------------------------------------------- -8 | & Bitwise AND | Left to right +9 | & Bitwise AND | Left to right --------------------------------------------------------------------------- -9 | ^ Bitwise XOR (exclusive or) | Left to right +10 | ^ Bitwise XOR (exclusive or) | Left to right --------------------------------------------------------------------------- -10 | | Bitwise OR (inclusive or) | Left to right +11 | | Bitwise OR (inclusive or) | Left to right --------------------------------------------------------------------------- -11 | && Logical AND | Left to right +12 | && Logical AND | Left to right --------------------------------------------------------------------------- -12 | || Logical OR | Left to right +13 | || Logical OR | Left to right --------------------------------------------------------------------------- -13 | ?: Ternary conditional | Right to left +14 | ?: Ternary conditional | Right to left --------------------------------------------------------------------------- -14 | = Direct assignment | Right to left +15 | = Direct assignment | Right to left (lowest) | += Assignment by sum | | -= Assignment by difference | | *= Assignment by product | + | **= Assignment by power | | /= Assignment by quotient | | %= Assignment by remainder | | <<= Assignment by bitwise left shift | @@ -8028,11 +8032,19 @@ instead if they want it so much. *pow(<number>, <power>) + @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + @ /!\ This command is deprecated @ + @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + Returns the result of the calculation. Example: .@i = pow(2, 3); // .@i will be 8 +This command is deprecated and it should not be used in new scripts, as it is +likely to be removed at a later time. Please use the exponentiation operator, +ie: (2 ** 3) instead of pow(2, 3) + --------------------------------------- *log10(<number>) diff --git a/npc/custom/quests/thq/THQS_TTShop.txt b/npc/custom/quests/thq/THQS_TTShop.txt index c85a9c9fe..96e7346d3 100644 --- a/npc/custom/quests/thq/THQS_TTShop.txt +++ b/npc/custom/quests/thq/THQS_TTShop.txt @@ -67,11 +67,11 @@ function script thqs_trade_token { // 10^0, 10^1, 10^2 @type -= 1; - @price = pow(10, @type); + @price = (10 ** @type); // 10^3, 10^4, 10^5 @type += 3; // So we can use pow later to determine the qt of Zeny - @prize = pow(10, @type); + @prize = (10 ** @type); if( #Treasure_Token < @price ) { mes "You don't have enough tokens!"; diff --git a/npc/dev/test.txt b/npc/dev/test.txt index b711a0a28..b35beb8ed 100644 --- a/npc/dev/test.txt +++ b/npc/dev/test.txt @@ -268,6 +268,19 @@ function script HerculesSelfTestHelper { callsub(OnCheck, "Order of + and *", .@x, 7); + // Binary ** operator + .@x = 2 ** 3; // .@x = 8; + callsub(OnCheck, "Binary ** operator", .@x, 8); + + // Associativity of ** + .@x = 2 ** 3 ** 2; // .@x = (2 ** 3) ** 2; + callsub(OnCheck, "Associativity of **", .@x, 64); + + // Order of ** and * + .@x = 5 * 2 ** 3 * 2; // .@x = 5 * (2 ** 3) * 2; + callsub(OnCheck, "Order of ** and *", .@x, 80); + + // << and >> operators .@x = 1<<3; // .@x = 1*2*2*2; callsub(OnCheck, "Left shift << operator", .@x, 8); diff --git a/npc/other/Global_Functions.txt b/npc/other/Global_Functions.txt index 544e3a672..bc19ff048 100644 --- a/npc/other/Global_Functions.txt +++ b/npc/other/Global_Functions.txt @@ -203,11 +203,11 @@ function script F_SaveQuestSkills { ADV_QSK = 0; ADV_QSK2 = 0; //1st classes quest skills for (.@i = 0; .@i < 14; ++.@i) { - if(getskilllv(144+.@i)) ADV_QSK |= pow(2,.@i); + if(getskilllv(144+.@i)) ADV_QSK |= (2 ** .@i); } //2nd classes quest skills for (.@i = 0; .@i < 19; ++.@i) { - if(getskilllv(1001+.@i)) ADV_QSK2 |= pow(2,.@i); + if(getskilllv(1001+.@i)) ADV_QSK2 |= (2 ** .@i); } return; } @@ -217,7 +217,7 @@ function script F_SaveQuestSkills { function script F_Load1Skills { //1st classes quest skills for(.@i = 0; .@i < 14; ++.@i) { - if(ADV_QSK|pow(2,.@i) == ADV_QSK) skill 144+.@i,1,0; + if(ADV_QSK|(2 ** .@i) == ADV_QSK) skill 144+.@i,1,0; } ADV_QSK = 0; //Clear var return; @@ -228,7 +228,7 @@ function script F_Load1Skills { function script F_Load2Skills { //2nd classes quest skills for (.@i = 0; .@i < 19; ++.@i) { - if(ADV_QSK2|pow(2,.@i) == ADV_QSK2) skill 1001+.@i,1,0; + if(ADV_QSK2|(2 ** .@i) == ADV_QSK2) skill 1001+.@i,1,0; } ADV_QSK2 = 0; //Clear var return; diff --git a/src/map/script.c b/src/map/script.c index 75f747fb6..b2a707bb0 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -136,6 +136,7 @@ const char* script_op2name(int op) { RETURN_OP_NAME(C_ADD); RETURN_OP_NAME(C_SUB); RETURN_OP_NAME(C_MUL); + RETURN_OP_NAME(C_POW); RETURN_OP_NAME(C_DIV); RETURN_OP_NAME(C_MOD); RETURN_OP_NAME(C_NEG); @@ -1035,6 +1036,7 @@ const char* parse_variable(const char* p) || ( p[0] == '|' && p[1] == '=' && (type = C_OR, true) ) // |= || ( p[0] == '&' && p[1] == '=' && (type = C_AND, true) ) // &= || ( p[0] == '*' && p[1] == '=' && (type = C_MUL, true) ) // *= + || ( p[0] == '*' && p[1] == '*' && p[2] == '=' && (type = C_POW, true) ) // **= || ( p[0] == '/' && p[1] == '=' && (type = C_DIV, true) ) // /= || ( p[0] == '%' && p[1] == '=' && (type = C_MOD, true) ) // %= || ( p[0] == '+' && p[1] == '+' && (type = C_ADD_POST, true) ) // post ++ @@ -1058,6 +1060,7 @@ const char* parse_variable(const char* p) case C_L_SHIFT: // <<= case C_R_SHIFT: // >>= + case C_POW: // **= p = script->skip_space( &p[3] ); break; @@ -1424,6 +1427,7 @@ const char* script_parse_subexpr(const char* p,int limit) (op=C_OP3, opl=0, len=1,*p=='?') // ?: || (op=C_ADD, opl=9, len=1,*p=='+') // + || (op=C_SUB, opl=9, len=1,*p=='-') // - + || (op=C_POW, opl=11,len=2,*p=='*' && p[1]=='*') // ** || (op=C_MUL, opl=10,len=1,*p=='*') // * || (op=C_DIV, opl=10,len=1,*p=='/') // / || (op=C_MOD, opl=10,len=1,*p=='%') // % @@ -4146,6 +4150,7 @@ void op_2num(struct script_state* st, int op, int i1, int i2) case C_ADD: ret = i1 + i2; ret64 = (int64)i1 + i2; break; case C_SUB: ret = i1 - i2; ret64 = (int64)i1 - i2; break; case C_MUL: ret = i1 * i2; ret64 = (int64)i1 * i2; break; + case C_POW: ret = (int)pow((double)i1, (double)i2); ret64 = (int64)pow((double)i1, (double)i2); break; default: ShowError("script:op_2num: unexpected number operator %s i1=%d i2=%d\n", script->op2name(op), i1, i2); script->reportsrc(st); @@ -4683,6 +4688,7 @@ void run_script_main(struct script_state *st) { case C_ADD: case C_SUB: case C_MUL: + case C_POW: case C_DIV: case C_MOD: case C_EQ: @@ -23559,7 +23565,7 @@ void script_parse_builtin(void) { // List of mathematics commands ---> BUILDIN_DEF(log10,"i"), BUILDIN_DEF(sqrt,"i"), //[zBuffer] - BUILDIN_DEF(pow,"ii"), //[zBuffer] + BUILDIN_DEF_DEPRECATED(pow,"ii"), //[zBuffer] BUILDIN_DEF(distance,"iiii"), //[zBuffer] // <--- List of mathematics commands BUILDIN_DEF(min, "i*"), diff --git a/src/map/script.h b/src/map/script.h index 8caec961a..fddcf4908 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -235,6 +235,7 @@ typedef enum c_op { C_SUB_PRE, // --a C_RE_EQ, // ~= C_RE_NE, // ~! + C_POW, // ** } c_op; /// Script queue options |