The following warnings occurred:
Warning [2] Use of undefined constant SAPI_NAME - assumed 'SAPI_NAME' (this will throw an Error in a future version of PHP) - Line: 3388 - File: inc/functions.php PHP 7.4.33-nmm6 (Linux)
File Line Function
/inc/functions.php 3388 errorHandler->error
/showthread.php 116 build_archive_link
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm6 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/inc/functions.php 3324 build_forum_breadcrumb
/showthread.php 195 build_forum_breadcrumb
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm6 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/showthread.php 195 build_forum_breadcrumb






Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with damages
Author Message
Snaigel
Journeyman
*

Posts: 75
Likes Given: 0
Likes Received: 1 in 1 posts
Joined: Jan 2017
Reputation: 0



Post: #1
Problem with damages
Hi, I have a weapon with this trigger (because in my server all the weapons damage will work like this)

Quote:ON=@Damage
SRC.DAMAGE <eval <R250,310>/<SRC.ARMOR>*10>

So it should calculate the damage with that formula: 250,310 divided by armor, for example 100, and then multiplied by 10: like this the final damage would be: 25 to 31 to a player or npc with 100 armor.

It seems to work as I want but with a problem: I still get some random numbers like 7, 9 etc, just sometimes, like some skill or something is interfering.. maybe parrying or tactics or even the armor?

Is there something I can write in the trigger so it ignores ANYTHING else?

Thanks in advanceTongue
12-19-2019 04:00 PM
Find all posts by this user Like Post Quote this message in a reply
Snaigel
Journeyman
*

Posts: 75
Likes Given: 0
Likes Received: 1 in 1 posts
Joined: Jan 2017
Reputation: 0



Post: #2
RE: Problem with damages
Nevermind, I changed it to ON=@Hit trigger and put it on an event, because otherwise it doesn't work, But only works if I simply put:

Quote:SRC.DAMAGE <R250,310>
//succesfully does 250 to 310 damage

but when I write formulas like

Quote:<eval <R250,310>/<SRC.ARMOR>*10>
or
<floatval <R250,310>/<SRC.ARMOR>*10>

any of this works, it never divides, I tried a lot of combinations and only multiplies (killing the npc im testing with, because I do tons of damage)

So annoying, I just cant make this ultra mega simple formula work....

EDIT: After a lot of tests I'm pretty sure I am writing the formula in a wrong way, symbols not in right place etc or not the right symbols. Can someone help??
(This post was last modified: 12-20-2019 09:53 AM by Snaigel.)
12-20-2019 09:14 AM
Find all posts by this user Like Post Quote this message in a reply
Coruja
Sphere Developer
*****

Posts: 987
Likes Given: 5
Likes Received: 226 in 187 posts
Joined: Jul 2012
Reputation: 7

Dimension Shard

Post: #3
RE: Problem with damages
Usually all percentage formulas are calculated using "muldiv" order (multiply -> divide) and not divide -> multiply. Both formulas should work, as 250/50*10=50 is the same of 250*10/50=50, but using proper order will return more precise results

Also note that @Damage on weapon is called when the weapon got damaged (receive damage) and not when it cause damage. It was also called at the hit moment because when you hit someone with the weapon, this will also make the weapon get damaged (lose durability). But to deal with ~hit~ damages you must use char trigger @Hit and not the item trigger @Damage

And after use combat formula calculate the damage, sphere will also calculate the resist. So you're using a custom damage formula that already apply the resist, but later sphere will also apply the internal resist formula again. To avoid this 2nd resist formula you must set the flag dam_fixed on @Hit, this will make sphere skip next formulas like bonus damage, resist calculation, etc

So to get the best result, you should probably use something like this
Code:
[EVENT e_char_trigger]
ON=@Hit
ARGN1 = <eval (<R250,310>*10)/<SRC.ARMOR>>  // damage value
ARGN2 |= dam_fixed  // damage flags
12-20-2019 10:42 AM
Find all posts by this user Like Post Quote this message in a reply
Snaigel
Journeyman
*

Posts: 75
Likes Given: 0
Likes Received: 1 in 1 posts
Joined: Jan 2017
Reputation: 0



Post: #4
RE: Problem with damages
Thanks for the answer. I tried it and it is still not dividing by the armor of the NPC that I'm trying with, only multiplying. I tried with your formula and also the ones I tried before but using mul and then div.

I know it's not dividing because I kill the test NPC in a single blow, which shouldn't happen with that formula because the NPC has 500hitpoints and 100 armor and that formula should do 25 to 31 dmg to a NPC with 100 armor. I checked the NPC stats and it's correct Confused. Idk what is happening

I honestly think that dividing by SRC.ARMOR in this kind of trigger is just not working in sphere, because the formula is correct
(This post was last modified: 12-20-2019 08:16 PM by Snaigel.)
12-20-2019 08:03 PM
Find all posts by this user Like Post Quote this message in a reply
Coruja
Sphere Developer
*****

Posts: 987
Likes Given: 5
Likes Received: 226 in 187 posts
Joined: Jul 2012
Reputation: 7

Dimension Shard

Post: #5
RE: Problem with damages
Debugging is always the best solution to find whats wrong on the code

The formula ~seems~ to be correct, but it's returning wrong result, so its wrong. And a simple debug can easily find whats wrong
Code:
ON=@Hit
SAY (<R250,310>*10)/<SRC.ARMOR>

I just replaced ARGN1 with SAY and removed the "eval", of corse the formula will not work using this, but this will make it print the formula using SAY and will reveal what value is wrong
12-22-2019 05:01 AM
Find all posts by this user Like Post Quote this message in a reply
Snaigel
Journeyman
*

Posts: 75
Likes Given: 0
Likes Received: 1 in 1 posts
Joined: Jan 2017
Reputation: 0



Post: #6
RE: Problem with damages
Okay will test it, thanks

https://imgur.com/FVYEHXu

yeap dividing by zero!! src.armor is wrong?

https://imgur.com/FVYEHXu

yeap dividing by zero!! src.armor is wrong?
(This post was last modified: 12-22-2019 06:53 AM by Snaigel.)
12-22-2019 06:43 AM
Find all posts by this user Like Post Quote this message in a reply
Snaigel
Journeyman
*

Posts: 75
Likes Given: 0
Likes Received: 1 in 1 posts
Joined: Jan 2017
Reputation: 0



Post: #7
RE: Problem with damages
Any ideas?Shock
12-24-2019 02:05 PM
Find all posts by this user Like Post Quote this message in a reply
Coruja
Sphere Developer
*****

Posts: 987
Likes Given: 5
Likes Received: 226 in 187 posts
Joined: Jul 2012
Reputation: 7

Dimension Shard

Post: #8
RE: Problem with damages
That's weird, try use ".xshow armor" and click on the char to check if the value is really 0

Also note that if you have COMBATF_ELEMENTAL_ENGINE combat flag enabled on sphere.ini this will make all chars always have ARMOR=0 and use only RES* properties, so in this case you will have to update the formula to use all 5 <RES*> properties instead <ARMOR>
12-24-2019 04:48 PM
Find all posts by this user Like Post Quote this message in a reply
Snaigel
Journeyman
*

Posts: 75
Likes Given: 0
Likes Received: 1 in 1 posts
Joined: Jan 2017
Reputation: 0



Post: #9
RE: Problem with damages
Yes!! when I use "xshow armor" it says the objetive has "0" armor.

I think I don't have COMBATF_ELEMENTAL_ENGINE enabled in sphere.ini

Quote: // Extra combat flags to control the fight (default:0, 0.55i compatible)
// COMBATF_NODIRCHANGE 00001 // Not rotate player when fighting (like was in 0.51a)
// COMBATF_FACECOMBAT 00002 // Allow faced combat only (recommended)
// COMBATF_PREHIT 00004 // Allow prehit for close combat. first hit is instant (delay 0.1sec)
// COMBATF_ELEMENTAL_ENGINE 00008 // Use DAM*/RES* to split damage/resist into Physical/Fire/Cold/Poison/Energy (AOS) instead use old AR (pre-AOS)
// COMBATF_MAXITEMDURABILITY 00010 // Make damageable items get destroyed when lose max durability instead current durability
// COMBATF_DCLICKSELF_UNMOUNTS 00020 // Unmount horse when dclicking self while in warmode
// COMBATF_ALLOWHITFROMSHIP 00040 // Allow attacking opponents from ships
// COMBATF_NOPETDESERT 00080 // Allow pet owner attack own pet without make it desert its owner
// COMBATF_ARCHERYCANMOVE 00100 // Allow firing bow while moving
// COMBATF_STAYINRANGE 00200 // Abort attack swing when out of range instead of waiting to come back in range
// COMBATF_ATTACKONNOTICE 00400 // Make target instantly attack back when notice someone trying to attack it
// COMBATF_NPC_NOATTACKMSG 00800 // Disable *is attacking* message on NPCs
// COMBATF_STACKARMOR 01000 // If a region is covered by more than one armor part, all AR will count
// COMBATF_NOPOISONHIT 02000 // Disables old (55i like) poisoning style (0~100% chance based on Poisoning skill for monsters, or 50% chance for poisoned weapons)
//CombatFlags=02|020|080|0400|02000


Tried with RESPHYSICAL, and now it works and does the maths properly!!. This works for me as an alternative if I can't fix the ARMOR problem, so you helped a lot
12-24-2019 05:33 PM
Find all posts by this user Like Post Quote this message in a reply
Coruja
Sphere Developer
*****

Posts: 987
Likes Given: 5
Likes Received: 226 in 187 posts
Joined: Jul 2012
Reputation: 7

Dimension Shard

Post: #10
RE: Problem with damages
RESPHYSICAL is only used when COMBATF_ELEMENTAL_ENGINE is enabled, so maybe it doesn't help because this value is not used on combat (unless you use it manually, like on your custom formula)

Anyway, try using <AR> instead <ARMOR>
(This post was last modified: 12-25-2019 04:20 AM by Coruja.)
12-25-2019 04:16 AM
Find all posts by this user Like Post Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 4 Guest(s)