Fixed issue with determining a valid location.

This commit is contained in:
Cekis
2018-03-23 16:03:01 -07:00
committed by CekisSWG
parent 5bf67c75d5
commit b8187b7b5f
9 changed files with 16 additions and 11 deletions
@@ -449,7 +449,7 @@ public class beast extends script.base_script
if (isIdValid(master))
{
location masterLoc = getLocation(master);
if(isValidLocation(masterLoc, 1.0f))
if(isValidLocation(masterLoc))
setHomeLocation(self, masterLoc);
}
return SCRIPT_CONTINUE;
@@ -17653,6 +17653,11 @@ public class base_class
* @return True if there's nothing within radius of the position
*/
public static native boolean isValidLocation(location loc, float radius);
public static boolean isValidLocation(location loc){
if(loc != null && isValidLocation(getValidLocation(loc, 0f, loc, 0f)))
return isValidLocation(loc, 0f);
return false;
}
/**
* Find a valid point inside the corral that's near the given point
* @param corralCenter The center of the 'corral' that we'd like the object to be inside
@@ -918,7 +918,7 @@ public class ai_lib extends script.base_script
}
location myLoc = getLocation(npc);
location targetLoc = getLocation(target);
if(isValidLocation(myLoc, 0f) && isValidLocation(targetLoc, 0f)) {
if(isValidLocation(myLoc) && isValidLocation(targetLoc)) {
if (myLoc.x < targetLoc.x) {
myLoc.x -= rand(20f, 40f);
} else {
@@ -6686,7 +6686,7 @@ public class utils extends script.base_script
location testLoc;
for (obj_id obj : allObjects) {
testLoc = getLocation(trial.getTop(obj));
if(testLoc == null || !isValidLocation(testLoc, 1f)){
if(testLoc == null || !isValidLocation(testLoc)){
continue;
}
if (testLoc.x < x1 || testLoc.x > x2 || testLoc.z < z1 || testLoc.z > z2) {
@@ -254,14 +254,14 @@ public class combat_base extends script.base_script
atkRslt.weapon = weaponData.id;
atkRslt.actionName = getStringCrc(toLower(actionName));
atkRslt.useLocation = true;
if(isValidLocation(targetLoc,1f)) {
if(targetLoc != null && isValidLocation(targetLoc)) {
atkRslt.targetLocation = new vector(targetLoc.x, targetLoc.y, targetLoc.z);
atkRslt.targetCell = targetLoc.cell;
}
else {
location tl = getLocation(target);
if(!isValidLocation(tl, 1f)){
LOG("heroics","IG-88 could not identify the target's (" + target + ":" + getPlayerFullName(target) + ") location (" + targetLoc.toString() + ") to attack it.");
if(!isValidLocation(tl)){
LOG("combat","Could not identify the target's (" + target + ":" + getPlayerFullName(target) + ") location (" + targetLoc + ") to attack it.");
}
atkRslt.targetLocation = new vector(tl.x, tl.y, tl.z);
atkRslt.targetCell = tl.cell;
@@ -896,7 +896,7 @@ public class combat_base extends script.base_script
{
if (weaponData.weaponType == WEAPON_TYPE_DIRECTIONAL)
{
if(actionData != null && isValidLocation(actionData.targetLoc, 1f)) {
if(actionData != null && isValidLocation(actionData.targetLoc)) {
defenders = pvpGetTargetsInCone(self, self, actionData.targetLoc, length, width);
}
else{
@@ -620,7 +620,7 @@ public class mission_bounty extends script.systems.missions.base.mission_dynamic
}
else
{
if(isValidLocation(locSpawnLocation, 1f)) {
if(isValidLocation(locSpawnLocation)) {
location locDestination = locations.getBountyLocation(locSpawnLocation.area);
setObjVar(self, "locDestination", locDestination);
fltDelay = rand(100, 300);
@@ -744,7 +744,7 @@ public class npc_lair_ai extends script.theme_park.poi.base
utils.setScriptVar(self, "npc_lair.pathingToConverse", true);
location destLoc = new location(getLocation(partner));
location myLoc = getLocation(self);
if(myLoc == null || !isValidLocation(myLoc, 1f)){
if(myLoc == null || !isValidLocation(myLoc)){
return SCRIPT_CONTINUE;
}
if (myLoc.x < destLoc.x)
@@ -445,7 +445,7 @@ public class target_creature extends script.base_script
{
location there = getLocation(enemy);
location here = getLocation(self);
if (!isValidLocation(there, 0f) || !isValidLocation(here, 0f) || there.cell != here.cell || utils.getDistance2D(here, there) > 60)
if (!isValidLocation(there) || !isValidLocation(here) || there.cell != here.cell || utils.getDistance2D(here, there) > 60)
{
target_dummy.removeAttackerFromCombat(self, enemy);
}
@@ -830,7 +830,7 @@ public class treasure_map extends script.base_script
for (int i = 0; (i < 30) && !goodLoc; i++)
{
treasureLoc = locations.getGoodLocationOutsideOfRegion(closestCity, 1, 1, 8000);
if (!isValidLocation(treasureLoc, 10.f) || treasureLoc == null || locations.isInCity(treasureLoc))
if (!isValidLocation(treasureLoc) || treasureLoc == null || locations.isInCity(treasureLoc))
{
continue;
}