The combat pseudo-code isn't? [resolved]

Here you can post threads specific to the current release of the core (099)

Moderator: POL Developer

Post Reply
User avatar
andenixa
Grandmaster Poster
Posts: 105
Joined: Tue Nov 09, 2010 1:33 am

The combat pseudo-code isn't? [resolved]

Post by andenixa »

Hello everyone.
I have implemented the core pseudocode damage calculation (found in doc99), and the basedamage supplied by the core, doesn't match the damage produced by the custom function (its like 25% lower). I didn't do the attack hook, I just wanted to produce my own damage calculation for the core combat.
Does anyone know why it could be?
Last edited by andenixa on Wed Feb 16, 2011 1:44 am, edited 1 time in total.
User avatar
CWO
POL Expert
Posts: 1159
Joined: Sat Feb 04, 2006 5:49 pm
Location: Chicago, IL USA

Re: The combat pseudo-code isn't?

Post by CWO »

Are you sure you calculated it correctly? I just went through the POL source code and compared it to the pseudo code and they match up exactly.
User avatar
andenixa
Grandmaster Poster
Posts: 105
Joined: Tue Nov 09, 2010 1:33 am

Re: The combat pseudo-code isn't?

Post by andenixa »

I practically implemented it line by line. I would be much obliged if you could post the actual pol source snippet there. Perhaps then I could just translate it directly to eScript.
Turley
POL Developer
Posts: 670
Joined: Sun Feb 05, 2006 4:45 am

Re: The combat pseudo-code isn't?

Post by Turley »

User avatar
andenixa
Grandmaster Poster
Posts: 105
Joined: Tue Nov 09, 2010 1:33 am

Re: The combat pseudo-code isn't?

Post by andenixa »

Thanks a lot,
It does look like a pseudo-code you provided, though I didn't dig deep enough.

maybe the weapon damage formula is different.

What I did was:

Code: Select all

var weapon_damage := (RandomDiceRoll( weapon_cfg_elem[weapon.objtype].Damage ) + weapon.dmg_mod) * weapon.quality;

// and then the rest of the damage_multiplier routine applies

But thats an improvisation, perhaps I am wrong.
Turley
POL Developer
Posts: 670
Joined: Sun Feb 05, 2006 4:45 am

Re: The combat pseudo-code isn't?

Post by Turley »

jep thats the problem
UWeapon::get_random_damage()
int dmg = int(tmpl->get_random_damage()) * hp_ / maxhp();
dmg += dmg_mod_;

or in escript:
var descriptor := GetItemDescriptor(weapon.objtype);
var dmg:=CInt(RandomDiceRoll( descriptor.Damage )*(weapon.hp/(descriptor.maxhp+weapon.maxhp_mod))+weapon.dmg_mod)
User avatar
andenixa
Grandmaster Poster
Posts: 105
Joined: Tue Nov 09, 2010 1:33 am

Re: The combat pseudo-code isn't?

Post by andenixa »

Thanks a lot Turley,

This code gives values identical to the core:

Code: Select all

function CalcBaseDamage( who )

    var weapon := who.weapon;

    // just in case
    if( not weapon )
        return 1;
    endif    

    //or in escript:
    var descriptor := GetItemDescriptor(weapon.objtype);

    var random_weapon_die_damage := 
        CInt(RandomDiceRoll( descriptor.Damage ) * (CDbl(weapon.hp)/(descriptor.maxhp+weapon.maxhp_mod))+weapon.dmg_mod);

    var base_damage := random_weapon_die_damage;

    var damage_multiplier := GetAttribute( who, "tactics" ) + 50;       
    damage_multiplier += GetAttribute( who, "strength" ) * 0.2;    

    damage_multiplier *= 0.01;    
    base_damage *= damage_multiplier;

    return CInt(base_damage);

endfunction
PS: GetItemDescriptor() is roughly ~25x times slower than accessing :*:itemdesc
Turley
POL Developer
Posts: 670
Joined: Sun Feb 05, 2006 4:45 am

Re: The combat pseudo-code isn't?

Post by Turley »

andenixa wrote:PS: GetItemDescriptor() is roughly ~25x times slower than accessing :*:itemdesc
mmmh could be never did performance checks. But the function can easily be converted to use itemdesc instead of descriptor.
Post Reply