Public Repository for the Magicbane Shadowbane Emulator
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
3.2 KiB

// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// Magicbane Emulator Project © 2013 - 2022
// www.magicbane.com
package engine.powers.poweractions;
import engine.gameManager.DispatchManager;
import engine.math.Vector3fImmutable;
import engine.mbEnums;
import engine.net.Dispatch;
import engine.net.client.msg.PromptRecallMsg;
import engine.objects.*;
import engine.powers.ActionsBase;
import engine.powers.PowersBase;
import engine.wpak.data.PowerAction;
import static engine.math.FastMath.sqr;
import static engine.math.FastMath.sqrt;
public class RunegateTeleportPowerAction extends AbstractPowerAction {
/**
* ResultSet Constructor
*/
public RunegateTeleportPowerAction(PowerAction powerAction) {
super(powerAction);
}
@Override
protected void _startAction(AbstractCharacter source, AbstractWorldObject awo, Vector3fImmutable targetLoc, int trains, ActionsBase ab, PowersBase pb) {
if (source == null || awo == null || !(awo.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)))
return;
PlayerCharacter pc = (PlayerCharacter) awo;
float dist = 9999999999f;
Building rg = null;
Vector3fImmutable rgLoc;
for (Runegate runegate : Runegate._runegates.values()) {
rgLoc = runegate.gateBuilding.getLoc();
float distanceToRunegateSquared = source.getLoc().distanceSquared2D(rgLoc);
if (distanceToRunegateSquared < sqr(dist)) {
dist = sqrt(distanceToRunegateSquared);
rg = runegate.gateBuilding;
}
}
if (source.getObjectUUID() != pc.getObjectUUID()) {
pc.setTimeStampNow("PromptRecall");
pc.setTimeStamp("LastRecallType", 0); //recall to rg
if (rg != null) {
PromptRecallMsg promptRecallMsgmsg = new PromptRecallMsg();
Dispatch dispatch = Dispatch.borrow(pc, promptRecallMsgmsg);
DispatchManager.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY);
}
} else {
if (rg != null) {
pc.teleport(rg.getLoc());
pc.setSafeMode();
}
}
}
@Override
protected void _handleChant(AbstractCharacter source, AbstractWorldObject target, Vector3fImmutable targetLoc, int trains, ActionsBase ab, PowersBase pb) {
}
@Override
protected void _startAction(AbstractCharacter source, AbstractWorldObject awo, Vector3fImmutable targetLoc,
int numTrains, ActionsBase ab, PowersBase pb, int duration) {
// TODO Auto-generated method stub
}
}