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
33 lines
940 B
Text
33 lines
940 B
Text
use uo;
|
|
use os;
|
|
include "sysevent";
|
|
|
|
const DEFAULT_EVENTS := SYSEVENT_DAMAGED | SYSEVENT_LEFTAREA | SYSEVENT_ENTEREDAREA
|
|
| SYSEVENT_ENGAGED | SYSEVENT_DISENGAGED | SYSEVENT_OPPONENT_MOVED;
|
|
const DEFAULT_RANGE := 20;
|
|
|
|
program attackable( item )
|
|
var eventmask := EnableEvents( DEFAULT_EVENTS, DEFAULT_RANGE );
|
|
|
|
while ( true )
|
|
var ev := Wait_For_Event( 1 );
|
|
if ( !item )
|
|
return;
|
|
endif
|
|
if ( !ev )
|
|
continue;
|
|
endif
|
|
|
|
// lets a test replace the event registration of this control script
|
|
if ( ev.type == "configure" )
|
|
DisableEvents( eventmask );
|
|
eventmask := EnableEvents( ev.events, ev.range, ev.evmask );
|
|
GetProcess( GetObjProperty( item, "#TestPid" ) ).SendEvent( struct{ type := "configured" } );
|
|
continue;
|
|
endif
|
|
|
|
if ( ev.type & eventmask )
|
|
GetProcess( GetObjProperty( item, "#TestPid" ) ).SendEvent( ev );
|
|
endif
|
|
endwhile
|
|
endprogram
|