1186 | | case TARGET_TOTEM_EARTH: |
1187 | | case TARGET_TOTEM_WATER: |
1188 | | case TARGET_TOTEM_AIR: |
1189 | | case TARGET_TOTEM_FIRE: |
| 1186 | // destination around caster |
| 1187 | case TARGET_DEST_CASTER_FRONT_LEFT: |
| 1188 | case TARGET_DEST_CASTER_BACK_LEFT: |
| 1189 | case TARGET_DEST_CASTER_BACK_RIGHT: |
| 1190 | case TARGET_DEST_CASTER_FRONT_RIGHT: |
| 1191 | case TARGET_DEST_CASTER_FRONT: |
| 1192 | case TARGET_DEST_CASTER_BACK: |
| 1193 | case TARGET_DEST_CASTER_RIGHT: |
| 1194 | case TARGET_DEST_CASTER_LEFT: |
| 1195 | case TARGET_DEST_CASTER_RANDOM: |
| 1196 | case TARGET_DEST_CASTER_RADIUS: |
| 1197 | { |
| 1198 | float x, y, z, angle, dist; |
| 1199 | |
| 1200 | if (m_spellInfo->EffectRadiusIndex[i]) |
| 1201 | dist = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i])); |
| 1202 | else |
| 1203 | dist = 3.0f;//do we need this? |
| 1204 | if (cur == TARGET_DEST_CASTER_RANDOM) |
| 1205 | dist *= rand_norm(); // This case we need to consider caster size |
| 1206 | else |
| 1207 | dist -= m_caster->GetObjectSize(); // Size is calculated in GetNearPoint(), but we do not need it |
| 1208 | //need a new function to remove this repeated work |
| 1209 | |
| 1210 | switch(cur) |
| 1211 | { |
| 1212 | case TARGET_DEST_CASTER_FRONT_LEFT: angle = -M_PI/4; break; |
| 1213 | case TARGET_DEST_CASTER_BACK_LEFT: angle = -3*M_PI/4; break; |
| 1214 | case TARGET_DEST_CASTER_BACK_RIGHT: angle = 3*M_PI/4; break; |
| 1215 | case TARGET_DEST_CASTER_FRONT_RIGHT:angle = M_PI/4; break; |
| 1216 | case TARGET_DEST_CASTER_FRONT: angle = 0.0f; break; |
| 1217 | case TARGET_DEST_CASTER_BACK: angle = M_PI; break; |
| 1218 | case TARGET_DEST_CASTER_RIGHT: angle = M_PI/2; break; |
| 1219 | case TARGET_DEST_CASTER_LEFT: angle = -M_PI/2; break; |
| 1220 | default: angle = rand_norm()*2*M_PI; break; |
| 1221 | } |
| 1222 | |
| 1223 | m_caster->GetClosePoint(x, y, z, 0, dist, angle); |
| 1224 | m_targets.setDestination(x, y, z); // do not know if has ground visual |
| 1225 | TagUnitMap.push_back(m_caster); // may remove this in the future, if unitmap is empty, push m_caster |
| 1226 | }break; |
| 1227 | |
| 1228 | // destination around target |
| 1229 | case TARGET_DEST_TARGET_FRONT: |
| 1230 | case TARGET_DEST_TARGET_BACK: |
| 1231 | case TARGET_DEST_TARGET_RIGHT: |
| 1232 | case TARGET_DEST_TARGET_LEFT: |
| 1233 | case TARGET_DEST_TARGET_RANDOM: |
| 1234 | case TARGET_DEST_TARGET_RADIUS: |
| 1235 | { |
| 1236 | Unit *target = m_targets.getUnitTarget(); |
| 1237 | if(!target) |
| 1238 | { |
| 1239 | sLog.outError("SPELL: no unit target for spell ID %u\n", m_spellInfo->Id); |
| 1240 | break; |
| 1241 | } |
| 1242 | |
| 1243 | float x, y, z, angle, dist; |
| 1244 | |
| 1245 | if (m_spellInfo->EffectRadiusIndex[i]) |
| 1246 | dist = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i])); |
| 1247 | else |
| 1248 | dist = 3.0f;//do we need this? |
| 1249 | if (cur == TARGET_DEST_TARGET_RANDOM) |
| 1250 | dist *= rand_norm(); // This case we need to consider caster size |
| 1251 | else |
| 1252 | dist -= target->GetObjectSize(); // Size is calculated in GetNearPoint(), but we do not need it |
| 1253 | //need a new function to remove this repeated work |
| 1254 | |
| 1255 | switch(cur) |
| 1256 | { |
| 1257 | case TARGET_DEST_TARGET_FRONT: angle = 0.0f; break; |
| 1258 | case TARGET_DEST_TARGET_BACK: angle = M_PI; break; |
| 1259 | case TARGET_DEST_TARGET_RIGHT: angle = M_PI/2; break; |
| 1260 | case TARGET_DEST_TARGET_LEFT: angle = -M_PI/2; break; |
| 1261 | default: angle = rand_norm()*2*M_PI; break; |
| 1262 | } |
| 1263 | |
| 1264 | target->GetClosePoint(x, y, z, 0, dist, angle); |
| 1265 | m_targets.setDestination(x, y, z); // do not know if has ground visual |
| 1266 | TagUnitMap.push_back(m_caster); // may remove this in the future, if unitmap is empty, push m_caster |
| 1267 | }break; |
| 1268 | |
| 1269 | // destination around destination |
| 1270 | case TARGET_DEST_DEST_RANDOM: |
| 1271 | { |
| 1272 | if(!(m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION)) |
| 1273 | { |
| 1274 | sLog.outError("SPELL: no destination for spell ID %u\n", m_spellInfo->Id); |
| 1275 | break; |
| 1276 | } |
| 1277 | float x, y, z, dist, px, py, pz; |
| 1278 | dist = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i])); |
| 1279 | x = m_targets.m_destX; |
| 1280 | y = m_targets.m_destY; |
| 1281 | z = m_targets.m_destZ; |
| 1282 | m_caster->GetRandomPoint(x, y, z, dist, px, py, pz); |
| 1283 | m_targets.setDestination(px, py, pz); |
| 1284 | TagUnitMap.push_back(m_caster); |
| 1285 | }break; |
| 1286 | case TARGET_SELF2: |
| 1287 | { |
| 1288 | TagUnitMap.push_back(m_caster); |
| 1289 | }break; |
| 1290 | |