mirror of
https://github.com/polserver/polserver
synced 2026-08-13 08:23:08 -04:00
* introduced Attackable wrapper class for opponents to be able to also attack items * changed set_opponent to use Attackable moved first logic into Attackable * added dynamic property which returns a pointer of the object instead of a copy like the current imp. needed to be able to eg store a vector * send engage/disengage events send hp status bar * send attackable item flag in world item pkt * apply damage for items + evid_damaged * react to statrequests * adapted is_attackable and do attack_effects * fixed clear_opponent_of * fixed clear_opponent_of * allow attack pkt * apply damage * items need to keep track of the opponents to be able to cleanup on destroy * updated dynproperties * updated dynprops a bit more. made the structs trivial copyable updated concept to not repeat the types * run hitscript, cleanup * listhostiles and attack_once accept now Attackable * set opponent when dblclicked * dont let hp underflow * only attack if you are in warmode * evid_opponent_moved for attackable items * if its the same opponent dont send engaged events again added test for listhostiles with two mobs * allow attackable item for setopponent * some tests npc vs item * missing files * fixed clang tidy complain * test for enter/left area * do not send hp updates while char gets created and not yet added to the world * testclient fight packets * client event constants * added client tests for attacking npc and item * increase damage * removed leftover comment * when an attackable item was destroyed the opponents where not correctly cleared * orphan check for is_attackable * moved statmsg for items * init member * moved send_hightlight back into if statement check before dereferencing * use range version of statmsg * adapted em params * comparison operator made explicit constructors for symmetry return damage in Item::apply_damage * get rid of bools * split attack method a bit * use constants for F3 flag * destroy item on hit if hp reaches 0 if no controlscript exists * only toplevel items are attackable small refactoring more tests * more tests * even more tests * docs
107 lines
2.6 KiB
XML
107 lines
2.6 KiB
XML
<?xml version="1.0"?>
|
|
<?xml-stylesheet type="text/xsl" href="attack.xslt" ?>
|
|
<!DOCTYPE ESCRIPT SYSTEM "attack.dtd">
|
|
<ESCRIPT>
|
|
<header>
|
|
<topic>Pseudocode for the core combat system.</topic>
|
|
<datemodified>07/30/2026</datemodified>
|
|
</header>
|
|
<pre>
|
|
if( Attack sys hook is loaded )
|
|
call hook
|
|
if hook returned 1, exit
|
|
endif
|
|
|
|
if( weapon is projectile )
|
|
if( consume ammo hook is loaded)
|
|
call it
|
|
else
|
|
try to comsume projectile
|
|
if none, exit
|
|
endif
|
|
endif
|
|
|
|
if( opponent is mobile )
|
|
repsys effects
|
|
endif
|
|
|
|
if( weapon is projected )
|
|
play sound and animations
|
|
else
|
|
play attack anim
|
|
endif
|
|
|
|
if( CombatAdvancement sys hook is loaded )
|
|
call it
|
|
else
|
|
THE CORE DOESN'T ADVANCE ANY SKILLS
|
|
endif
|
|
|
|
if (opponent is item)
|
|
play hit sounds and anims
|
|
damage weapon (1 in 100 chance to lose 1 hp)
|
|
|
|
damage = random_weapon_dice_damage * weapon_hp / max_weapon_hp + weapon_damage_mod
|
|
damage_multiplier = tactics + 50
|
|
damage_multiplier += strength * 0.2
|
|
damage_multiplier *= 0.01
|
|
damage *= damage_multiplier
|
|
if( weapon has no hit script )
|
|
play hit animation
|
|
applydamage(damage)
|
|
else
|
|
run hit script
|
|
endif
|
|
return
|
|
endif
|
|
|
|
hit_chance = (weapon_attribute + 50.0) / (2.0 * opponent_weapon_attribute + 50.0)
|
|
hit_chance += hitchance_mod * 0.001
|
|
hit_chance -= opponent_evasionchance_mod * 0.001
|
|
|
|
if( random_float(1.0) < hit_chance )
|
|
play hit sounds and anims
|
|
damage weapon (1 in 100 chance to lose 1 hp)
|
|
|
|
damage = random_weapon_dice_damage * weapon_hp / max_weapon_hp + weapon_damage_mod
|
|
damage_multiplier = tactics + 50
|
|
damage_multiplier += strength * 0.2
|
|
damage_multiplier *= 0.01
|
|
damage *= damage_multiplier
|
|
|
|
if( opponent has shield )
|
|
call ParryAdvancement sys hook
|
|
|
|
parry_chance = opponent_parry_skill / 200.0
|
|
parry_chance += opponent_parrychance_mod * 0.001
|
|
if( random_float(1.0) < parry_chance )
|
|
display parry success
|
|
damage -= opponent_shield_ar
|
|
endif
|
|
endif
|
|
|
|
if( weapon has no hit script )
|
|
choose armor piece hit based on zone coverage percentage
|
|
blocked = armor piece ar + character ar_mod
|
|
absorbed = blocked / 2
|
|
blocked -= absorbed
|
|
absorbed += random_int(blocked+1)
|
|
damage -= absorbed
|
|
if( damage >= 2.0 )
|
|
damage *= 0.5
|
|
endif
|
|
1 in 100 chance for armor piece to lose 1 hp
|
|
play hit animation
|
|
applydamage(damage)
|
|
else
|
|
choose armor piece hit based on zone coverage percentage
|
|
calc base & raw damage (exactly like above if no hit script)
|
|
run hit script
|
|
(Core doesn't damage armor if hitscript, do it in the script)
|
|
endif
|
|
else
|
|
play weapon miss sound
|
|
call hitmiss hook
|
|
endif
|
|
</pre>
|
|
</ESCRIPT>
|