use of com.solinia.solinia.Interfaces.ISoliniaNPC in project solinia3-core by mixxit.
the class SoliniaLivingEntity method getCharisma.
@Override
public int getCharisma() {
if (getNpcid() < 1 && !isPlayer())
return 1;
try {
if (getNpcid() > 0) {
ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getNPC(getNpcid());
if (npc == null)
return 1;
int stat = npc.getLevel() * 5;
stat += Utils.getTotalEffectStat(this.getBukkitLivingEntity(), "CHARISMA");
if (stat > getMaxStat("CHARISMA"))
stat = getMaxStat("CHARISMA");
return stat;
}
if (isPlayer()) {
ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt((Player) getBukkitLivingEntity());
if (solplayer == null)
return 1;
int stat = 1;
if (solplayer.getRace() != null)
stat += solplayer.getRace().getCharisma();
stat += solplayer.getTotalItemStat("CHARISMA");
stat += Utils.getTotalEffectStat(this.getBukkitLivingEntity(), "CHARISMA");
stat += Utils.getTotalAAEffectStat(this.getBukkitLivingEntity(), "CHARISMA");
if (stat > getMaxStat("CHARISMA"))
stat = getMaxStat("CHARISMA");
return stat;
}
} catch (CoreStateInitException e) {
return 1;
}
return 1;
}
use of com.solinia.solinia.Interfaces.ISoliniaNPC in project solinia3-core by mixxit.
the class SoliniaSpell method getSpellEffectiveness.
@Override
public float getSpellEffectiveness(LivingEntity caster, LivingEntity victim) throws CoreStateInitException {
// TODO Auto-generated method stub
int resistmodifier = getResistDiff();
int casterlevel = 1;
int targetresist = 0;
boolean isnpccaster = false;
if (caster instanceof Player) {
casterlevel = SoliniaPlayerAdapter.Adapt((Player) caster).getLevel();
} else {
if (Utils.isLivingEntityNPC(caster)) {
ISoliniaLivingEntity solentity = SoliniaLivingEntityAdapter.Adapt((LivingEntity) caster);
ISoliniaNPC casternpc = StateManager.getInstance().getConfigurationManager().getNPC(solentity.getNpcid());
casterlevel = casternpc.getLevel();
isnpccaster = true;
}
}
boolean isnpcvictim = false;
int victimlevel = 1;
if (victim instanceof Player) {
victimlevel = SoliniaPlayerAdapter.Adapt((Player) victim).getLevel();
targetresist = SoliniaPlayerAdapter.Adapt((Player) victim).getResist(Utils.getSpellResistType(getResisttype()));
} else {
if (Utils.isLivingEntityNPC(victim)) {
ISoliniaLivingEntity solentity = SoliniaLivingEntityAdapter.Adapt((LivingEntity) victim);
ISoliniaNPC victimnpc = StateManager.getInstance().getConfigurationManager().getNPC(solentity.getNpcid());
targetresist = solentity.getResists(Utils.getSpellResistType(getResisttype()));
victimlevel = victimnpc.getLevel();
isnpcvictim = true;
}
}
int resist_chance = 0;
int level_mod = 0;
int temp_level_diff = victimlevel - casterlevel;
if (isnpcvictim == false && victimlevel >= 21 && temp_level_diff > 15) {
temp_level_diff = 15;
}
if (isnpcvictim == true && temp_level_diff < -9) {
temp_level_diff = -9;
}
level_mod = temp_level_diff * temp_level_diff / 2;
if (temp_level_diff < 0) {
level_mod = -level_mod;
}
if (isnpcvictim && (casterlevel - victimlevel < -20)) {
level_mod = 1000;
}
// Even more level stuff this time dealing with damage spells
if (isnpcvictim && isDamageSpell() && victimlevel >= 17) {
int level_diff;
level_diff = victimlevel - casterlevel;
level_mod += (2 * level_diff);
}
resist_chance += level_mod;
resist_chance += resistmodifier;
resist_chance += targetresist;
if (resist_chance > 255) {
resist_chance = 255;
}
if (resist_chance < 0) {
resist_chance = 0;
}
int roll = Utils.RandomBetween(0, 200);
if (roll > resist_chance) {
return 100;
} else {
if (resist_chance < 1) {
resist_chance = 1;
}
int partial_modifier = ((150 * (resist_chance - roll)) / resist_chance);
if (isnpcvictim == true) {
if (victimlevel > casterlevel && victimlevel >= 17 && casterlevel <= 50) {
partial_modifier += 5;
}
if (victimlevel >= 30 && casterlevel < 50) {
partial_modifier += (casterlevel - 25);
}
if (victimlevel < 15) {
partial_modifier -= 5;
}
}
if (isnpccaster) {
if ((victimlevel - casterlevel) >= 20) {
partial_modifier += (victimlevel - casterlevel) * 1.5;
}
}
if (partial_modifier <= 0) {
return 100F;
} else if (partial_modifier >= 100) {
return 0;
}
return (100.0f - partial_modifier);
}
}
use of com.solinia.solinia.Interfaces.ISoliniaNPC in project solinia3-core by mixxit.
the class SoliniaSpawnGroup method editSetting.
@Override
public void editSetting(String setting, String value) throws InvalidSpawnGroupSettingException, NumberFormatException, CoreStateInitException, java.io.IOException {
switch(setting.toLowerCase()) {
case "name":
if (value.equals(""))
throw new InvalidSpawnGroupSettingException("Name is empty");
if (value.length() > 25)
throw new InvalidSpawnGroupSettingException("Name is longer than 25 characters");
setName(value);
break;
case "respawntime":
if (Integer.parseInt(value) < 360)
throw new InvalidSpawnGroupSettingException("Minimum respawn time is 360 seconds");
setRespawntime(Integer.parseInt(value));
break;
case "x":
setX(Integer.parseInt(value));
break;
case "y":
setY(Integer.parseInt(value));
break;
case "z":
setZ(Integer.parseInt(value));
break;
case "disabled":
setDisabled(Boolean.parseBoolean(value));
break;
case "npcid":
ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getNPC(Integer.parseInt(value));
if (npc == null)
throw new InvalidSpawnGroupSettingException("Invalid NPCID");
setNpcid(Integer.parseInt(value));
break;
default:
throw new InvalidSpawnGroupSettingException("Invalid SpawnGroup setting. Valid Options are: name, x, y, z, respawntime,npcid");
}
}
use of com.solinia.solinia.Interfaces.ISoliniaNPC in project solinia3-core by mixxit.
the class CommandCreateSpawnGroup method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player))
return false;
Player player = (Player) sender;
if (!player.isOp() && !player.hasPermission("solinia.createspawngroup")) {
player.sendMessage("You do not have permission to access this command");
return false;
}
if (args.length < 2) {
sender.sendMessage("Insufficient arguments: npcid, spawngroupname");
return false;
}
// args
// defaultnpcid
// spawngroupname
int npcid = Integer.parseInt(args[0]);
if (npcid < 1) {
sender.sendMessage("NPCID is invalid");
return false;
}
ISoliniaNPC npc;
try {
npc = StateManager.getInstance().getConfigurationManager().getNPC(npcid);
} catch (CoreStateInitException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
sender.sendMessage(e1.getMessage());
return true;
}
if (npc == null) {
sender.sendMessage("The ID number you provided for the NPC is invalid");
return false;
}
String spawngroupname = "";
int count = 0;
for (String entry : args) {
if (count == 0) {
count++;
continue;
}
spawngroupname += entry;
count++;
}
if (spawngroupname.equals("")) {
sender.sendMessage("Blank name not allowed when creating spawngroup");
return false;
}
spawngroupname.replace(" ", "_");
try {
SoliniaSpawnGroupFactory.Create(spawngroupname, npcid, player.getLocation(), sender.isOp());
sender.sendMessage("SpawnGroup created at your location");
} catch (CoreStateInitException e) {
// TODO Auto-generated catch block
e.printStackTrace();
sender.sendMessage(e.getMessage());
return true;
} catch (SoliniaSpawnGroupCreationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
sender.sendMessage(e.getMessage());
return true;
}
return true;
}
use of com.solinia.solinia.Interfaces.ISoliniaNPC in project solinia3-core by mixxit.
the class CommandCreateNpc method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player) && !(sender instanceof CommandSender))
return false;
if (sender instanceof Player) {
Player player = (Player) sender;
if (!player.isOp() && !player.hasPermission("solinia.createnpc")) {
player.sendMessage("You do not have permission to access this command");
return false;
}
}
if (args.length < 3) {
sender.sendMessage("Insufficient arguments: factionid level npcname");
sender.sendMessage("Note: factionid can be 0 to denote KOS to everything");
return false;
}
int factionid = Integer.parseInt(args[0]);
int level = Integer.parseInt(args[1]);
if (level > 60) {
sender.sendMessage("NPC should not be greater than level 60");
return false;
}
if (factionid < 0) {
sender.sendMessage("Invalid faction id");
return false;
}
try {
if (factionid > 0 && StateManager.getInstance().getConfigurationManager().getFaction(factionid) == null) {
sender.sendMessage("Cannot locate faction id: " + factionid);
return false;
}
} catch (CoreStateInitException e) {
// TODO Auto-generated catch block
e.printStackTrace();
sender.sendMessage(e.getMessage());
return false;
}
String name = "";
int i = 0;
for (String element : args) {
if (i <= 1) {
i++;
continue;
}
name += element;
i++;
}
if (name.equals("")) {
sender.sendMessage("Name of NPC cannot be null");
return false;
}
if (name.length() > 16) {
sender.sendMessage("Name of NPC cannot exceed 16 characters");
return false;
}
name = name.replace(" ", "_");
try {
ISoliniaNPC npc = SoliniaNPCFactory.CreateNPC(name, level, factionid, sender.isOp());
sender.sendMessage("Created NPC: " + npc.getId());
} catch (CoreStateInitException e) {
// TODO Auto-generated catch block
e.printStackTrace();
sender.sendMessage(e.getMessage());
}
return true;
}
Aggregations