Set continuous movement attribute by default for house portals
Can be disabled with "disable_movecont" attribute
This commit is contained in:
parent
8bf15d9226
commit
c0054efbf7
4 changed files with 85 additions and 7 deletions
|
|
@ -1,5 +1,5 @@
|
|||
/***************************************************************************
|
||||
* (C) Copyright 2003-2018 - Arianne *
|
||||
* (C) Copyright 2003-2024 - Arianne *
|
||||
***************************************************************************
|
||||
***************************************************************************
|
||||
* *
|
||||
|
|
@ -19,7 +19,7 @@ public class SettingsProperties {
|
|||
/** property used for double-tap direction to initiate auto-walk. */
|
||||
public static final String DOUBLE_TAP_AUTOWALK_PROPERTY = "move.doubletapautowalk";
|
||||
|
||||
/** Property for continuous movement through map changes & portals (currently disabled for portals). */
|
||||
/** Property for continuous movement through map changes & portals. */
|
||||
public static final String MOVE_CONTINUOUS_PROPERTY = "move.continuous";
|
||||
|
||||
/** property for display HP bar */
|
||||
|
|
|
|||
|
|
@ -199,6 +199,7 @@ public final class Actions {
|
|||
// indicates player is using auto-walk
|
||||
public static final String AUTOWALK = "autowalk";
|
||||
// indicates player is using continuous movement
|
||||
// TODO: rename to "ontransfer_cont"
|
||||
public static final String MOVE_CONTINUOUS = MOVE_CONTINUOUS_PROPERTY;
|
||||
public static final String COND_STOP = "conditional_stop";
|
||||
|
||||
|
|
|
|||
|
|
@ -3,16 +3,28 @@
|
|||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/***************************************************************************
|
||||
* Copyright © 2007-2024 - Faiumoni e. V. *
|
||||
***************************************************************************
|
||||
***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
package games.stendhal.server.core.config.zone;
|
||||
|
||||
import static games.stendhal.common.constants.Actions.MOVE_CONTINUOUS;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
//
|
||||
//
|
||||
|
||||
import games.stendhal.server.core.engine.SingletonRepository;
|
||||
import games.stendhal.server.core.engine.StendhalRPZone;
|
||||
import games.stendhal.server.entity.EntityFactoryHelper;
|
||||
import games.stendhal.server.entity.mapstuff.portal.HousePortal;
|
||||
|
|
@ -49,6 +61,10 @@ public class PortalSetupDescriptor extends EntitySetupDescriptor {
|
|||
*/
|
||||
protected boolean replacing;
|
||||
|
||||
/** Temporary cache of portal IDs that are house portal destinations. */
|
||||
private static final List<String> housePortalDests = new ArrayList<>();
|
||||
|
||||
|
||||
/**
|
||||
* Create a portal setup descriptor.
|
||||
*
|
||||
|
|
@ -141,6 +157,47 @@ public class PortalSetupDescriptor extends EntitySetupDescriptor {
|
|||
associatedZones = zones;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if portal is destination for a house portal and updates attributes.
|
||||
*
|
||||
* @param zone
|
||||
* Zone where portal is located.
|
||||
* @param portal
|
||||
* Portal to be checked.
|
||||
*/
|
||||
private void checkHouseDest(final StendhalRPZone zone, final Portal portal) {
|
||||
String id = "";
|
||||
if (!(portal instanceof HousePortal)) {
|
||||
id = zone.getName() + ":" + identifier.toString();
|
||||
if (housePortalDests.contains(id)) {
|
||||
// ID was cached earlier, add attribute & remove from cache
|
||||
portal.put(MOVE_CONTINUOUS, "");
|
||||
housePortalDests.remove(id);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!portal.has(MOVE_CONTINUOUS)) {
|
||||
// ignore house portals without continuous movement
|
||||
return;
|
||||
}
|
||||
|
||||
final String zname = destinationZone.toString();
|
||||
final String pname = destinationIdentifier.toString();
|
||||
id = zname + ":" + pname;
|
||||
|
||||
final StendhalRPZone destZone = SingletonRepository.getRPWorld().getZone(zname);
|
||||
final Portal destPortal = destZone != null ? destZone.getPortal(pname) : null;
|
||||
|
||||
if (destPortal != null) {
|
||||
// portal exists in world, add attribute
|
||||
destPortal.put(MOVE_CONTINUOUS, "");
|
||||
} else {
|
||||
// cache for update on creation
|
||||
housePortalDests.add(id);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// SetupDescriptor
|
||||
//
|
||||
|
|
@ -163,6 +220,12 @@ public class PortalSetupDescriptor extends EntitySetupDescriptor {
|
|||
}
|
||||
|
||||
try {
|
||||
// set this attribute to disable default continuous movement in house & house destination portals
|
||||
final boolean overrideMoveCont = attributes.containsKey("disable_movecont");
|
||||
if (overrideMoveCont) {
|
||||
attributes.remove("disable_movecont");
|
||||
}
|
||||
|
||||
final Portal portal = (Portal) EntityFactoryHelper.create(className,
|
||||
getParameters(), getAttributes());
|
||||
if (portal == null) {
|
||||
|
|
@ -171,6 +234,10 @@ public class PortalSetupDescriptor extends EntitySetupDescriptor {
|
|||
return;
|
||||
}
|
||||
|
||||
if (overrideMoveCont) {
|
||||
portal.remove(MOVE_CONTINUOUS);
|
||||
}
|
||||
|
||||
portal.setPosition(getX(), getY());
|
||||
portal.setIdentifier(getIdentifier());
|
||||
|
||||
|
|
@ -184,6 +251,9 @@ public class PortalSetupDescriptor extends EntitySetupDescriptor {
|
|||
((HousePortal) portal).setAssociatedZones(associatedZones);
|
||||
}
|
||||
|
||||
// update house portal destination attributes
|
||||
checkHouseDest(zone, portal);
|
||||
|
||||
// Set facing direction for portal used as destination.
|
||||
if (portal.has("face")) {
|
||||
portal.setFaceDirection(portal.get("face"));
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* $Id$ */
|
||||
/***************************************************************************
|
||||
* (C) Copyright 2003-2023 - Stendhal *
|
||||
* (C) Copyright 2003-2024 - Stendhal *
|
||||
***************************************************************************
|
||||
***************************************************************************
|
||||
* *
|
||||
|
|
@ -12,6 +12,8 @@
|
|||
***************************************************************************/
|
||||
package games.stendhal.server.entity.mapstuff.portal;
|
||||
|
||||
import static games.stendhal.common.constants.Actions.MOVE_CONTINUOUS;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -81,6 +83,9 @@ public class HousePortal extends AccessCheckingPortal {
|
|||
put(DOOR_ID, doorId);
|
||||
put(OWNER, "");
|
||||
put(LOCK_NUMBER, 0);
|
||||
// should be safe to assume player ends up on opposite side of house portal destination
|
||||
put(MOVE_CONTINUOUS, "");
|
||||
|
||||
store();
|
||||
}
|
||||
|
||||
|
|
@ -96,6 +101,8 @@ public class HousePortal extends AccessCheckingPortal {
|
|||
super.setDestination(get(DESTINATION_ZONE), idToObject(DESTINATION_ID));
|
||||
super.setIdentifier(idToObject(PORTAL_REFERENCE));
|
||||
setRejectedMessage("The door is locked.");
|
||||
// should be safe to assume player ends up on opposite side of house portal destination
|
||||
put(MOVE_CONTINUOUS, "");
|
||||
|
||||
store();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue