polserver/testsuite/pol/testpkgs/attack/attackhitscript.src
turleypol e6abc8fcfe
Attackable item (#884)
* 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
2026-07-30 20:27:36 +02:00

27 lines
836 B
Text

use uo;
use os;
use polsys;
use vitals;
program MainHitScript( attacker, defender, weapon, armor, basedamage, rawdamage )
var damage := GetObjProperty( attacker, "#Damage" );
if ( damage )
ApplyDamage( defender, CInt( damage ) );
endif
var pid := GetObjProperty( attacker, "#TestPid" );
if ( pid )
var ev := struct{ type := "HIT",
attacker := attacker,
"attacker.name" := attacker.name,
defender := defender,
"defender.name" := defender.name,
weapon := weapon,
armor := armor,
basedamage := basedamage,
rawdamage := rawdamage,
gameclock := ReadGameClock() };
GetProcess( pid ).SendEvent( ev );
endif
endprogram