22 #ifndef NUVIE_ACTORS_ACTOR_H 23 #define NUVIE_ACTORS_ACTOR_H 25 #include "ultima/shared/std/containers.h" 26 #include "common/str.h" 27 #include "ultima/nuvie/misc/actor_list.h" 28 #include "ultima/nuvie/core/map.h" 29 #include "ultima/nuvie/core/obj_manager.h" 34 #define ACTOR_NO_READIABLE_LOCATION -1 41 #define ACTOR_HAND_2 6 43 #define ACTOR_NOT_READIABLE 8 47 ACTOR_ALIGNMENT_DEFAULT = 0,
48 ACTOR_ALIGNMENT_NEUTRAL = 1,
49 ACTOR_ALIGNMENT_EVIL = 2,
50 ACTOR_ALIGNMENT_GOOD = 3,
51 ACTOR_ALIGNMENT_CHAOTIC = 4,
55 #define ACTOR_FORCE_MOVE 1 56 #define ACTOR_IGNORE_OTHERS 2 57 #define ACTOR_OPEN_DOORS 4 58 #define ACTOR_IGNORE_DANGER 8 59 #define ACTOR_IGNORE_MOVES 0x10 60 #define ACTOR_IGNORE_PARTY_MEMBERS 0x20 // only used in Actor::check_move. In U6, player diagonal movement 64 #define ACTOR_PUSH_ANYWHERE 0 65 #define ACTOR_PUSH_HERE 1 66 #define ACTOR_PUSH_FORWARD 2 68 #define ACTOR_SHOW_BLOOD true 69 #define ACTOR_FORCE_HIT true 71 #define ACTOR_STATUS_PROTECTED 0x1 72 #define ACTOR_STATUS_PARALYZED 0x2 73 #define ACTOR_STATUS_ASLEEP 0x4 74 #define ACTOR_STATUS_POISONED 0x8 75 #define ACTOR_STATUS_DEAD 0x10 76 #define ACTOR_STATUS_ATTACK_EVIL 0x20 77 #define ACTOR_STATUS_ATTACK_GOOD 0x40 78 #define ACTOR_STATUS_IN_PARTY 0x80 79 #define ACTOR_STATUS_ALIGNMENT_MASK 0x60 81 #define ACTOR_MOVEMENT_HIT_FLAG 0x8 82 #define ACTOR_MOVEMENT_FLAGS_OLD_ALIGNMENT_MASK 0x60 84 #define ACTOR_OBJ_FLAG_ 85 #define ACTOR_NO_ERROR 0 86 #define ACTOR_OUT_OF_MOVES 1 87 #define ACTOR_BLOCKED 2 88 #define ACTOR_BLOCKED_BY_OBJECT 3 89 #define ACTOR_BLOCKED_BY_ACTOR 4 91 #define ACTOR_MAX_READIED_OBJECTS 8 93 #define ACTOR_WT_FOLLOW 1 94 #define ACTOR_WT_PLAYER 2 95 #define ACTOR_WT_RANGED 4 96 #define ACTOR_WT_RETREAT 7 97 #define ACTOR_WT_ASSAULT 8 99 #define ACTOR_CHANGE_BASE_OBJ_N true 101 #define ACTOR_VEHICLE_ID_N 0 102 #define ACTOR_AVATAR_ID_N 1 104 #define INV_EXCLUDE_READIED_OBJECTS false 105 #define INV_INCLUDE_READIED_OBJECTS true 107 #define ACTOR_MD_OBJ_FLAG_HYPOXIA 6 108 #define ACTOR_MD_OBJ_FLAG_FRENZY 7 110 #define ACTOR_MD_STATUS_FLAG_COLD 0 115 class ActorPathFinder;
129 typedef enum { ATTACK_TYPE_NONE, ATTACK_TYPE_HAND, ATTACK_TYPE_THROWN, ATTACK_TYPE_MISSLE } AttackType;
144 AttackType attack_type;
146 uint16 missle_tile_num;
149 bool breaks_on_contact;
158 typedef uint8 ActorErrorCode;
162 Actor *blocking_actor;
165 typedef uint8 ActorMoveFlags;
184 return (a1->level > a2->level);
190 return (a1->dex > a2->dex);
196 return (a1->moves > a2->moves);
204 DEBUG(0, LEVEL_WARNING,
"%s (%d) has 0 dex!\n", a1->get_name(), a1->id_n);
208 DEBUG(0, LEVEL_WARNING,
"%s (%d) has 0 dex!\n", a2->get_name(), a2->id_n);
210 return (a1->moves / a1->dex > a2->moves / a2->dex);
216 void operator()(
const MapCoord &cmp_loc2) {
222 return (loc1.distance(cmp_loc) < loc2.distance(cmp_loc));
255 uint8 movement_flags;
279 ActorAlignment alignment;
281 uint8 body_armor_class;
282 uint8 readied_armor_class;
286 ReadiedObj *readied_objects[ACTOR_MAX_READIED_OBJECTS];
304 virtual bool init(uint8 obj_status = NO_OBJ_STATUS);
305 void init_from_obj(
Obj *obj,
bool change_base_obj =
false);
307 bool is_avatar()
const {
308 return id_n == ACTOR_AVATAR_ID_N;
310 bool is_onscreen()
const {
311 return MapCoord(x, y, z).is_visible();
313 bool is_in_party()
const {
314 return ((status_flags & ACTOR_STATUS_IN_PARTY) == ACTOR_STATUS_IN_PARTY);
316 bool is_in_vehicle()
const;
317 bool is_visible()
const {
320 bool is_alive()
const {
321 return (status_flags & ACTOR_STATUS_DEAD) ? false :
true;
323 bool is_nearby(
const Actor *other)
const;
324 bool is_nearby(uint8 actor_num)
const;
325 bool is_nearby(
const MapCoord &where, uint8 thresh = 5)
const;
326 bool is_at_position(
const Obj *obj)
const;
327 virtual bool is_passable()
const;
328 bool is_temp()
const {
331 virtual bool isFlying()
const {
334 virtual bool isNonBlocking()
const {
346 virtual bool doesOccupyLocation(uint16 lx, uint16 ly, uint8 lz,
bool incDoubleTile =
true,
bool incSurroundingObjs =
true)
const;
349 bool is_met()
const {
350 return talk_flags & 0x01;
352 bool is_poisoned()
const {
353 return status_flags & ACTOR_STATUS_POISONED;
355 bool is_invisible()
const {
356 return obj_flags & OBJ_STATUS_INVISIBLE;
358 virtual bool is_immobile()
const;
359 virtual bool is_sleeping()
const {
360 return status_flags & ACTOR_STATUS_ASLEEP;
362 virtual bool is_paralyzed()
const {
363 return status_flags & ACTOR_STATUS_PARALYZED;
365 virtual bool is_protected()
const {
366 return status_flags & ACTOR_STATUS_PROTECTED;
368 virtual bool is_charmed()
const {
369 return obj_flags & OBJ_STATUS_CHARMED;
371 virtual bool is_cursed()
const {
372 return obj_flags & OBJ_STATUS_CURSED;
374 virtual bool get_corpser_flag()
const {
377 bool is_hit()
const {
378 return movement_flags & ACTOR_MOVEMENT_HIT_FLAG;
381 void set_name(
const char *actor_name) {
384 const char *get_name(
bool force_real_name =
false);
386 void get_location(uint16 *ret_x, uint16 *ret_y, uint8 *ret_level)
const;
389 uint16 get_tile_num()
const;
390 Tile *get_tile()
const;
391 virtual uint16 get_downward_facing_tile_num()
const;
392 uint8 get_actor_num()
const {
395 uint8 get_talk_flags()
const {
398 virtual ActorTileType get_tile_type()
const {
402 uint16 get_frame_n()
const {
405 uint16 get_old_frame_n()
const {
408 uint16 get_x()
const {
411 uint16 get_y()
const {
414 uint8 get_z()
const {
418 uint8 get_strength()
const {
421 uint8 get_dexterity()
const {
424 uint8 get_intelligence()
const {
427 uint8 get_hp()
const {
430 virtual uint8 get_hp_text_color()
const {
433 virtual uint8 get_str_text_color()
const {
436 virtual uint8 get_dex_text_color()
const {
440 uint8 get_level()
const {
443 uint16 get_exp()
const {
446 uint8 get_magic()
const {
449 ActorAlignment get_alignment()
const {
452 uint8 get_old_alignment()
const {
453 return ((movement_flags & ACTOR_MOVEMENT_FLAGS_OLD_ALIGNMENT_MASK) >> 5) + 1;
455 sint8 get_moves_left()
const {
458 virtual uint8 get_maxhp()
const {
461 virtual uint8 get_maxmagic()
const {
464 bool get_obj_flag(uint8 bitFlag)
const {
465 return bitFlag < 8 ? (obj_flags & (1 << bitFlag)) :
false;
467 bool get_status_flag(uint8 bitFlag)
const {
468 return bitFlag < 8 ? (status_flags & (1 << bitFlag)) :
false;
471 uint16 get_base_obj_n()
const {
474 virtual void change_base_obj_n(uint16 val) {
475 base_obj_n = obj_n = val;
478 void set_obj_n(uint16 val) {
481 void set_frame_n(uint16 val) {
484 void set_strength(uint8 val) {
487 void set_dexterity(uint8 val) {
490 void set_intelligence(uint8 val) {
493 void set_hp(uint8 val);
494 void set_level(uint8 val) {
497 void set_exp(uint16 val) {
498 exp = clamp_max(val, 9999);
500 void set_magic(uint8 val) {
503 void set_alignment(ActorAlignment a) {
506 void set_old_alignment(ActorAlignment a) {
507 if (a > 0 && a < 5) {
508 movement_flags |= (a - 1) << 5;
511 uint8 get_light_level()
const;
512 void add_light(uint8 val);
513 void subtract_light(uint8 val);
518 void set_moves_left(sint8 val);
519 void set_dead_flag(
bool value);
520 virtual void update_time() {
521 set_moves_left(get_moves_left() + get_dexterity());
523 void set_poisoned(
bool poisoned);
524 virtual void set_paralyzed(
bool paralyzed) {
527 virtual void set_protected(
bool val) {
530 virtual void set_charmed(
bool val) {
533 virtual void set_corpser_flag(
bool val) {
536 virtual void set_cursed(
bool val) {
539 virtual void set_asleep(
bool val) {
542 void set_obj_flag(uint8 bitFlag,
bool value);
543 void set_status_flag(uint8 bitFlag,
bool value);
544 void set_hit_flag(
bool val);
546 void set_invisible(
bool invisible);
547 void set_custom_tile_num(uint16 obj_num, uint16 tile_num);
549 uint8 get_worktype();
550 uint8 get_sched_worktype();
551 virtual void set_worktype(uint8 new_worktype,
bool init =
false);
552 uint8 get_combat_mode()
const {
555 void set_combat_mode(uint8 new_mode);
556 virtual void revert_worktype() { }
558 NuvieDir get_direction()
const {
561 void set_direction(sint16 rel_x, sint16 rel_y);
562 virtual void set_direction(NuvieDir d);
563 void face_location(
const MapCoord &loc);
564 virtual void face_location(uint16 lx, uint16 ly);
565 void face_actor(
Actor *a);
567 void set_talk_flags(uint8 newflags) {
568 talk_flags = newflags;
570 uint8 get_flag(uint8 bitflag);
571 void set_flag(uint8 bitflag);
572 void clear_flag(uint8 bitflag);
575 void set_error(ActorErrorCode err);
580 return surrounding_objects;
582 void add_surrounding_obj(
Obj *obj);
583 void unlink_surrounding_objects(
bool make_objects_temporary =
false);
585 bool moveRelative(sint16 rel_x, sint16 rel_y, ActorMoveFlags flags = 0);
586 virtual bool move(uint16 new_x, uint16 new_y, uint8 new_z, ActorMoveFlags flags = 0);
587 virtual bool check_move(uint16 new_x, uint16 new_y, uint8 new_z, ActorMoveFlags flags = 0);
588 bool check_moveRelative(sint16 rel_x, sint16 rel_y, ActorMoveFlags flags = 0);
590 virtual bool can_be_moved();
591 virtual bool can_be_passed(
const Actor *other,
bool ignoreParty =
false)
const;
592 virtual void update();
593 void set_in_party(
bool state);
598 void delete_pathfinder();
599 virtual void pathfind_to(
const MapCoord &d);
600 void pathfind_to(uint16 gx, uint16 gy, uint8 gz = 255);
602 virtual void preform_worktype() {
608 Obj *get_weapon_obj(sint8 readied_obj_location);
609 void attack(sint8 readied_obj_location,
MapCoord target,
Actor *foe =
nullptr);
610 const CombatType *get_weapon(sint8 readied_obj_location);
611 void attract_to(
Actor *target);
612 void repel_from(
Actor *target);
614 void hit(uint8 dmg,
bool force_hit =
false);
615 void reduce_hp(uint8 amount);
616 virtual void die(
bool create_body =
true);
617 void resurrect(
const MapCoord &new_position,
Obj *body_obj =
nullptr);
618 uint8 get_range(uint16 target_x, uint16 target_y);
619 bool weapon_can_hit(
const CombatType *weapon, uint16 target_x, uint16 target_y);
620 virtual bool weapon_can_hit(
const CombatType *weapon,
Actor *target, uint16 *hit_x, uint16 *hit_y) {
621 *hit_x = target->get_x();
622 *hit_y = target->get_y();
625 void display_condition();
629 const U6LList *get_inventory_list()
const;
630 bool inventory_has_object(uint16 obj_n, uint8 qual = 0,
bool match_quality = OBJ_MATCH_QUALITY, uint8 frame_n = 0,
bool match_frame_n = OBJ_NOMATCH_FRAME_N);
631 uint32 inventory_count_objects(
bool inc_readied_objects)
const;
632 uint32 inventory_count_object(uint16 obj_n);
633 Obj *inventory_get_object(uint16 obj_n, uint8 qual = 0,
bool match_quality = OBJ_MATCH_QUALITY, uint8 frame_n = 0,
bool match_frame_n = OBJ_NOMATCH_FRAME_N);
634 bool is_double_handed_obj_readied();
635 Obj *inventory_get_readied_object(uint8 location);
636 sint16 inventory_get_readied_obj_n(uint8 location) {
637 return (inventory_get_readied_object(location) ==
nullptr ? -1 : inventory_get_readied_object(location)->obj_n);
639 virtual Obj *inventory_get_food(
Obj *container = 0) {
642 const CombatType *inventory_get_readied_object_combat_type(uint8 location);
643 bool inventory_add_object(
Obj *obj,
Obj *container = 0,
bool stack =
true);
644 bool inventory_add_object_nostack(
Obj *obj,
Obj *container = 0) {
645 return inventory_add_object(obj, container,
false);
647 void inventory_del_all_objs();
648 bool inventory_remove_obj(
Obj *obj,
bool run_usecode =
true);
649 Obj *inventory_new_object(uint16 obj_n, uint32 qty, uint8 quality = 0);
650 uint32 inventory_del_object(uint16 obj_n, uint32 qty, uint8 quality);
651 float inventory_get_max_weight()
const {
654 float get_inventory_weight()
const;
655 float get_inventory_equip_weight();
656 void inventory_drop_all();
657 void all_items_to_container(
Obj *container_obj,
bool stack);
658 bool can_carry_weight(
Obj *obj)
const;
659 bool can_carry_weight(
float obj_weight)
const;
660 virtual bool can_carry_object(uint16 obj_n, uint32 qty = 0)
const;
661 virtual bool can_carry_object(
Obj *obj)
const;
663 virtual uint8 get_object_readiable_location(
Obj *obj);
664 virtual const CombatType *get_object_combat_type(uint16 objN) {
668 bool can_ready_obj(
Obj *obj);
669 bool add_readied_object(
Obj *obj);
670 void remove_readied_object(
Obj *obj,
bool run_usecode =
true);
671 void remove_readied_object(uint8 location,
bool run_usecode =
true);
673 void remove_all_readied_objects();
674 bool has_readied_objects();
675 sint8 count_readied_objects(sint32 obj_n = -1, sint16 frame_n = -1, sint16 quality = -1);
677 virtual void twitch() {
680 bool push(
Actor *pusher, uint8 where = ACTOR_PUSH_ANYWHERE);
683 uint16 get_obj_n()
const {
686 virtual void clear();
687 virtual bool morph(uint16 obj_n);
689 bool get_schedule_location(
MapCoord *loc)
const;
690 bool is_at_scheduled_location()
const;
691 int get_number_of_schedules()
const {
692 return num_schedules;
694 Schedule *get_schedule(uint8 index);
695 virtual bool will_not_talk()
const {
698 uint16 get_custom_tile_num(uint16 obj_num)
const;
701 void loadSchedule(
const unsigned char *schedule_data, uint16 num);
702 virtual bool updateSchedule(uint8 hour,
bool teleport =
false);
703 uint16 getSchedulePos(uint8 hour);
707 void inventory_parse_readied_objects();
709 virtual const CombatType *get_hand_combat_type()
const {
713 virtual void set_ethereal(
bool val) {
716 virtual void print();
717 virtual void handle_lightsource(uint8 hour) {
720 virtual const char *get_worktype_string(uint32 wt)
const {
725 uint16 get_tile_num(uint16 obj_num)
const;
726 uint8 get_num_light_sources()
const {
727 return light_source.
size();
734 const char *get_actor_alignment_str(ActorAlignment alignment);
Definition: map_window.h:73
Definition: usecode.h:151
Definition: game_clock.h:47
Definition: actor_manager.h:42
Definition: detection.h:27
Path
Definition: game.h:76
Definition: u6_usecode.h:67
Definition: u6_llist.h:46
size_type size() const
Definition: array.h:316
Out move(In first, In last, Out dst)
Definition: algorithm.h:109
Definition: obj_manager.h:75
Definition: actor_path_finder.h:33
Definition: tile_manager.h:113