1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef RY_MULTI_TARGET_H
20 #define RY_MULTI_TARGET_H
22 #include "entity_types.h"
24 const float MULTI_TARGET_DISTANCE_UNIT
= 100.f
/ 127.f
;
26 /** A list of targets, which can be packed/unpacked in visual properties (see PROPERTY_TARGET_LIST_x in entity_types.h)
28 * \author Nicolas Vizerie
29 * \author Nevrax France
39 uint8 TargetSlot
; // the slot that is targetted
40 uint8 Info
; // Damage shield for melee 5:3 format (damage shield io : power )
41 // Distance for range attacks (that do not have damage shield) format is 7:1
44 CTarget(uint8 slot
= CLFECOMMON::INVALID_SLOT
, bool resist
= false, uint8 dist
= 0, sint16 deltaHp
= 0) : TargetSlot(slot
), DeltaHP(deltaHp
)
46 Info
= (resist
== 0 ? 0 : 0x80) | (dist
& 0x7f);
48 uint32
getPacked() const;
49 void setPacked(uint32 value
);
51 typedef std::vector
<CTarget
> TTargetVect
;
52 // the list of targets
55 /** create packed version of targets (to store in visual properties)
56 * each VP encodes 2 targets
57 * caller must provide enough room to store the result (assertion is raised otherwise)
59 void pack(uint64
*destVP
, uint numVP
);
60 // build the target from their packed version
61 void unpack(const uint64
*srcVP
, uint numVP
);
68 // *******************************************************************************************
69 inline uint32
CMultiTarget::CTarget::getPacked() const
71 //return (uint16) TargetSlot | ((uint16) (Resist ? 1 : 0) << 15) | ((uint16) Distance << 8);
72 return ((uint32
) TargetSlot
) | ((uint32
) Info
<< 8) | ((uint32
) DeltaHP
<< 16);
75 // *******************************************************************************************
76 inline void CMultiTarget::CTarget::setPacked(uint32 value
)
78 TargetSlot
= uint8(value
);
79 Info
= uint8(value
>> 8);
80 DeltaHP
= sint16(value
>> 16);