22 #ifndef NUVIE_ACTORS_ACTOR_H 23 #define NUVIE_ACTORS_ACTOR_H 25 #include "ultima/shared/std/containers.h" 26 #include "ultima/shared/std/string.h" 27 #include "ultima/nuvie/misc/actor_list.h" 28 #include "ultima/nuvie/core/map.h" 29 #include "ultima/nuvie/core/obj_manager.h" 38 #define ACTOR_NO_READIABLE_LOCATION -1 45 #define ACTOR_HAND_2 6 47 #define ACTOR_NOT_READIABLE 8 51 ACTOR_ALIGNMENT_DEFAULT = 0,
52 ACTOR_ALIGNMENT_NEUTRAL = 1,
53 ACTOR_ALIGNMENT_EVIL = 2,
54 ACTOR_ALIGNMENT_GOOD = 3,
55 ACTOR_ALIGNMENT_CHAOTIC = 4,
59 #define ACTOR_FORCE_MOVE 1 60 #define ACTOR_IGNORE_OTHERS 2 61 #define ACTOR_OPEN_DOORS 4 62 #define ACTOR_IGNORE_DANGER 8 63 #define ACTOR_IGNORE_MOVES 0x10 64 #define ACTOR_IGNORE_PARTY_MEMBERS 0x20 // only used in Actor::check_move. In U6, player diagonal movement 68 #define ACTOR_PUSH_ANYWHERE 0 69 #define ACTOR_PUSH_HERE 1 70 #define ACTOR_PUSH_FORWARD 2 72 #define ACTOR_SHOW_BLOOD true 73 #define ACTOR_FORCE_HIT true 75 #define ACTOR_STATUS_PROTECTED 0x1 76 #define ACTOR_STATUS_PARALYZED 0x2 77 #define ACTOR_STATUS_ASLEEP 0x4 78 #define ACTOR_STATUS_POISONED 0x8 79 #define ACTOR_STATUS_DEAD 0x10 80 #define ACTOR_STATUS_ATTACK_EVIL 0x20 81 #define ACTOR_STATUS_ATTACK_GOOD 0x40 82 #define ACTOR_STATUS_IN_PARTY 0x80 83 #define ACTOR_STATUS_ALIGNMENT_MASK 0x60 85 #define ACTOR_MOVEMENT_HIT_FLAG 0x8 86 #define ACTOR_MOVEMENT_FLAGS_OLD_ALIGNMENT_MASK 0x60 88 #define ACTOR_OBJ_FLAG_ 89 #define ACTOR_NO_ERROR 0 90 #define ACTOR_OUT_OF_MOVES 1 91 #define ACTOR_BLOCKED 2 92 #define ACTOR_BLOCKED_BY_OBJECT 3 93 #define ACTOR_BLOCKED_BY_ACTOR 4 95 #define ACTOR_MAX_READIED_OBJECTS 8 97 #define ACTOR_WT_FOLLOW 1 98 #define ACTOR_WT_PLAYER 2 99 #define ACTOR_WT_RANGED 4 100 #define ACTOR_WT_RETREAT 7 101 #define ACTOR_WT_ASSAULT 8 103 #define ACTOR_CHANGE_BASE_OBJ_N true 105 #define ACTOR_VEHICLE_ID_N 0 106 #define ACTOR_AVATAR_ID_N 1 108 #define INV_EXCLUDE_READIED_OBJECTS false 109 #define INV_INCLUDE_READIED_OBJECTS true 111 #define ACTOR_MD_OBJ_FLAG_HYPOXIA 6 112 #define ACTOR_MD_OBJ_FLAG_FRENZY 7 114 #define ACTOR_MD_STATUS_FLAG_COLD 0 119 class ActorPathFinder;
133 typedef enum { ATTACK_TYPE_NONE, ATTACK_TYPE_HAND, ATTACK_TYPE_THROWN, ATTACK_TYPE_MISSLE } AttackType;
148 AttackType attack_type;
150 uint16 missle_tile_num;
153 bool breaks_on_contact;
162 typedef uint8 ActorErrorCode;
166 Actor *blocking_actor;
169 typedef uint8 ActorMoveFlags;
188 return (a1->level > a2->level);
194 return (a1->dex > a2->dex);
200 return (a1->moves > a2->moves);
208 DEBUG(0, LEVEL_WARNING,
"%s (%d) has 0 dex!\n", a1->get_name(), a1->id_n);
212 DEBUG(0, LEVEL_WARNING,
"%s (%d) has 0 dex!\n", a2->get_name(), a2->id_n);
214 return (a1->moves / a1->dex > a2->moves / a2->dex);
220 void operator()(
const MapCoord &cmp_loc2) {
226 return (loc1.distance(cmp_loc) < loc2.distance(cmp_loc));
259 uint8 movement_flags;
283 ActorAlignment alignment;
285 uint8 body_armor_class;
286 uint8 readied_armor_class;
290 ReadiedObj *readied_objects[ACTOR_MAX_READIED_OBJECTS];
308 virtual bool init(uint8 obj_status = NO_OBJ_STATUS);
309 void init_from_obj(
Obj *obj,
bool change_base_obj =
false);
311 bool is_avatar()
const {
312 return id_n == ACTOR_AVATAR_ID_N;
314 bool is_onscreen()
const {
315 return MapCoord(x, y, z).is_visible();
317 bool is_in_party()
const {
318 return ((status_flags & ACTOR_STATUS_IN_PARTY) == ACTOR_STATUS_IN_PARTY);
320 bool is_in_vehicle()
const;
321 bool is_visible()
const {
324 bool is_alive()
const {
325 return (status_flags & ACTOR_STATUS_DEAD) ? false :
true;
327 bool is_nearby(
const Actor *other)
const;
328 bool is_nearby(uint8 actor_num)
const;
329 bool is_nearby(
const MapCoord &where, uint8 thresh = 5)
const;
330 bool is_at_position(
const Obj *obj)
const;
331 virtual bool is_passable()
const;
332 bool is_temp()
const {
335 virtual bool isFlying()
const {
338 virtual bool isNonBlocking()
const {
350 virtual bool doesOccupyLocation(uint16 lx, uint16 ly, uint8 lz,
bool incDoubleTile =
true,
bool incSurroundingObjs =
true)
const;
353 bool is_met()
const {
354 return talk_flags & 0x01;
356 bool is_poisoned()
const {
357 return status_flags & ACTOR_STATUS_POISONED;
359 bool is_invisible()
const {
360 return obj_flags & OBJ_STATUS_INVISIBLE;
362 virtual bool is_immobile()
const;
363 virtual bool is_sleeping()
const {
364 return status_flags & ACTOR_STATUS_ASLEEP;
366 virtual bool is_paralyzed()
const {
367 return status_flags & ACTOR_STATUS_PARALYZED;
369 virtual bool is_protected()
const {
370 return status_flags & ACTOR_STATUS_PROTECTED;
372 virtual bool is_charmed()
const {
373 return obj_flags & OBJ_STATUS_CHARMED;
375 virtual bool is_cursed()
const {
376 return obj_flags & OBJ_STATUS_CURSED;
378 virtual bool get_corpser_flag()
const {
381 bool is_hit()
const {
382 return movement_flags & ACTOR_MOVEMENT_HIT_FLAG;
385 void set_name(
const char *actor_name) {
388 const char *get_name(
bool force_real_name =
false);
390 void get_location(uint16 *ret_x, uint16 *ret_y, uint8 *ret_level)
const;
393 uint16 get_tile_num()
const;
394 Tile *get_tile()
const;
395 virtual uint16 get_downward_facing_tile_num()
const;
396 uint8 get_actor_num()
const {
399 uint8 get_talk_flags()
const {
402 virtual ActorTileType get_tile_type()
const {
406 uint16 get_frame_n()
const {
409 uint16 get_old_frame_n()
const {
412 uint16 get_x()
const {
415 uint16 get_y()
const {
418 uint8 get_z()
const {
422 uint8 get_strength()
const {
425 uint8 get_dexterity()
const {
428 uint8 get_intelligence()
const {
431 uint8 get_hp()
const {
434 virtual uint8 get_hp_text_color()
const {
437 virtual uint8 get_str_text_color()
const {
440 virtual uint8 get_dex_text_color()
const {
444 uint8 get_level()
const {
447 uint16 get_exp()
const {
450 uint8 get_magic()
const {
453 ActorAlignment get_alignment()
const {
456 uint8 get_old_alignment()
const {
457 return ((movement_flags & ACTOR_MOVEMENT_FLAGS_OLD_ALIGNMENT_MASK) >> 5) + 1;
459 sint8 get_moves_left()
const {
462 virtual uint8 get_maxhp()
const {
465 virtual uint8 get_maxmagic()
const {
468 bool get_obj_flag(uint8 bitFlag)
const {
469 return bitFlag < 8 ? (obj_flags & (1 << bitFlag)) :
false;
471 bool get_status_flag(uint8 bitFlag)
const {
472 return bitFlag < 8 ? (status_flags & (1 << bitFlag)) :
false;
475 uint16 get_base_obj_n()
const {
478 virtual void change_base_obj_n(uint16 val) {
479 base_obj_n = obj_n = val;
482 void set_obj_n(uint16 val) {
485 void set_frame_n(uint16 val) {
488 void set_strength(uint8 val) {
491 void set_dexterity(uint8 val) {
494 void set_intelligence(uint8 val) {
497 void set_hp(uint8 val);
498 void set_level(uint8 val) {
501 void set_exp(uint16 val) {
502 exp = clamp_max(val, 9999);
504 void set_magic(uint8 val) {
507 void set_alignment(ActorAlignment a) {
510 void set_old_alignment(ActorAlignment a) {
511 if (a > 0 && a < 5) {
512 movement_flags |= (a - 1) << 5;
515 uint8 get_light_level()
const;
516 void add_light(uint8 val);
517 void subtract_light(uint8 val);
522 void set_moves_left(sint8 val);
523 void set_dead_flag(
bool value);
524 virtual void update_time() {
525 set_moves_left(get_moves_left() + get_dexterity());
527 void set_poisoned(
bool poisoned);
528 virtual void set_paralyzed(
bool paralyzed) {
531 virtual void set_protected(
bool val) {
534 virtual void set_charmed(
bool val) {
537 virtual void set_corpser_flag(
bool val) {
540 virtual void set_cursed(
bool val) {
543 virtual void set_asleep(
bool val) {
546 void set_obj_flag(uint8 bitFlag,
bool value);
547 void set_status_flag(uint8 bitFlag,
bool value);
548 void set_hit_flag(
bool val);
550 void set_invisible(
bool invisible);
551 void set_custom_tile_num(uint16 obj_num, uint16 tile_num);
553 uint8 get_worktype();
554 uint8 get_sched_worktype();
555 virtual void set_worktype(uint8 new_worktype,
bool init =
false);
556 uint8 get_combat_mode()
const {
559 void set_combat_mode(uint8 new_mode);
560 virtual void revert_worktype() { }
562 NuvieDir get_direction()
const {
565 void set_direction(sint16 rel_x, sint16 rel_y);
566 virtual void set_direction(NuvieDir d);
567 void face_location(
const MapCoord &loc);
568 virtual void face_location(uint16 lx, uint16 ly);
569 void face_actor(
Actor *a);
571 void set_talk_flags(uint8 newflags) {
572 talk_flags = newflags;
574 uint8 get_flag(uint8 bitflag);
575 void set_flag(uint8 bitflag);
576 void clear_flag(uint8 bitflag);
579 void set_error(ActorErrorCode err);
583 const list<Obj *> &get_surrounding_obj_list()
const {
584 return surrounding_objects;
586 void add_surrounding_obj(
Obj *obj);
587 void unlink_surrounding_objects(
bool make_objects_temporary =
false);
589 bool moveRelative(sint16 rel_x, sint16 rel_y, ActorMoveFlags flags = 0);
590 virtual bool move(uint16 new_x, uint16 new_y, uint8 new_z, ActorMoveFlags flags = 0);
591 virtual bool check_move(uint16 new_x, uint16 new_y, uint8 new_z, ActorMoveFlags flags = 0);
592 bool check_moveRelative(sint16 rel_x, sint16 rel_y, ActorMoveFlags flags = 0);
594 virtual bool can_be_moved();
595 virtual bool can_be_passed(
const Actor *other,
bool ignoreParty =
false)
const;
596 virtual void update();
597 void set_in_party(
bool state);
602 void delete_pathfinder();
603 virtual void pathfind_to(
const MapCoord &d);
604 void pathfind_to(uint16 gx, uint16 gy, uint8 gz = 255);
606 virtual void preform_worktype() {
612 Obj *get_weapon_obj(sint8 readied_obj_location);
613 void attack(sint8 readied_obj_location,
MapCoord target,
Actor *foe =
nullptr);
614 const CombatType *get_weapon(sint8 readied_obj_location);
615 void attract_to(
Actor *target);
616 void repel_from(
Actor *target);
618 void hit(uint8 dmg,
bool force_hit =
false);
619 void reduce_hp(uint8 amount);
620 virtual void die(
bool create_body =
true);
621 void resurrect(
const MapCoord &new_position,
Obj *body_obj =
nullptr);
622 uint8 get_range(uint16 target_x, uint16 target_y);
623 bool weapon_can_hit(
const CombatType *weapon, uint16 target_x, uint16 target_y);
624 virtual bool weapon_can_hit(
const CombatType *weapon,
Actor *target, uint16 *hit_x, uint16 *hit_y) {
625 *hit_x = target->get_x();
626 *hit_y = target->get_y();
629 void display_condition();
633 const U6LList *get_inventory_list()
const;
634 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);
635 uint32 inventory_count_objects(
bool inc_readied_objects)
const;
636 uint32 inventory_count_object(uint16 obj_n);
637 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);
638 bool is_double_handed_obj_readied();
639 Obj *inventory_get_readied_object(uint8 location);
640 sint16 inventory_get_readied_obj_n(uint8 location) {
641 return (inventory_get_readied_object(location) ==
nullptr ? -1 : inventory_get_readied_object(location)->obj_n);
643 virtual Obj *inventory_get_food(
Obj *container = 0) {
646 const CombatType *inventory_get_readied_object_combat_type(uint8 location);
647 bool inventory_add_object(
Obj *obj,
Obj *container = 0,
bool stack =
true);
648 bool inventory_add_object_nostack(
Obj *obj,
Obj *container = 0) {
649 return inventory_add_object(obj, container,
false);
651 void inventory_del_all_objs();
652 bool inventory_remove_obj(
Obj *obj,
bool run_usecode =
true);
653 Obj *inventory_new_object(uint16 obj_n, uint32 qty, uint8 quality = 0);
654 uint32 inventory_del_object(uint16 obj_n, uint32 qty, uint8 quality);
655 float inventory_get_max_weight()
const {
658 float get_inventory_weight()
const;
659 float get_inventory_equip_weight();
660 void inventory_drop_all();
661 void all_items_to_container(
Obj *container_obj,
bool stack);
662 bool can_carry_weight(
Obj *obj)
const;
663 bool can_carry_weight(
float obj_weight)
const;
664 virtual bool can_carry_object(uint16 obj_n, uint32 qty = 0)
const;
665 virtual bool can_carry_object(
Obj *obj)
const;
667 virtual uint8 get_object_readiable_location(
Obj *obj);
668 virtual const CombatType *get_object_combat_type(uint16 objN) {
672 bool can_ready_obj(
Obj *obj);
673 bool add_readied_object(
Obj *obj);
674 void remove_readied_object(
Obj *obj,
bool run_usecode =
true);
675 void remove_readied_object(uint8 location,
bool run_usecode =
true);
677 void remove_all_readied_objects();
678 bool has_readied_objects();
679 sint8 count_readied_objects(sint32 obj_n = -1, sint16 frame_n = -1, sint16 quality = -1);
681 virtual void twitch() {
684 bool push(
Actor *pusher, uint8 where = ACTOR_PUSH_ANYWHERE);
687 uint16 get_obj_n()
const {
690 virtual void clear();
691 virtual bool morph(uint16 obj_n);
693 bool get_schedule_location(
MapCoord *loc)
const;
694 bool is_at_scheduled_location()
const;
695 int get_number_of_schedules()
const {
696 return num_schedules;
698 Schedule *get_schedule(uint8 index);
699 virtual bool will_not_talk()
const {
702 uint16 get_custom_tile_num(uint16 obj_num)
const;
705 void loadSchedule(
const unsigned char *schedule_data, uint16 num);
706 virtual bool updateSchedule(uint8 hour,
bool teleport =
false);
707 uint16 getSchedulePos(uint8 hour);
711 void inventory_parse_readied_objects();
713 virtual const CombatType *get_hand_combat_type()
const {
717 virtual void set_ethereal(
bool val) {
720 virtual void print();
721 virtual void handle_lightsource(uint8 hour) {
724 virtual const char *get_worktype_string(uint32 wt)
const {
729 uint16 get_tile_num(uint16 obj_num)
const;
730 uint8 get_num_light_sources()
const {
731 return light_source.
size();
738 const char *get_actor_alignment_str(ActorAlignment alignment);
Definition: map_window.h:73
Definition: usecode.h:151
Definition: game_clock.h:49
Definition: actor_manager.h:42
Definition: detection.h:27
Path
Definition: game.h:75
Definition: u6_usecode.h:67
Definition: u6_llist.h:46
size_type size() const
Definition: array.h:315
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
Definition: containers.h:38