Skip to content

Commit

Permalink
Revert "Add speed: argument to - shoot"
Browse files Browse the repository at this point in the history
This reverts commit d8e084c.
  • Loading branch information
davidcernat committed Sep 27, 2013
1 parent dcd4cb2 commit e1fdaad
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 32 deletions.
Expand Up @@ -1521,7 +1521,7 @@ public void registerCoreMembers() {

// <--[command]
// @Name Shoot
// @Usage shoot [<entity>|...] (origin:<entity>/<location>) (destination:<location>) (height:<#.#>) (gravity:<#.#>) (speed:<#.#>) (script:<name>)
// @Usage shoot [<entity>|...] (origin:<entity>/<location>) (destination:<location>) (height:<#.#>) (gravity:<#.#>) (script:<name>)
// @Required 1
// @Stable stable
// @Short Shoots an entity through the air up to a certain height.
Expand All @@ -1534,7 +1534,7 @@ public void registerCoreMembers() {
// Todo
// -->
registerCoreMember(ShootCommand.class,
"SHOOT", "shoot [<entity>|...] (origin:<entity>/<location>) (destination:<location>) (height:<#.#>) (gravity:<#.#>) (speed:<#.#>) (script:<name>)", 1);
"SHOOT", "shoot [<entity>|...] (origin:<entity>/<location>) (destination:<location>) (height:<#.#>) (gravity:<#.#>) (script:<name>)", 1);

// <--[command]
// @Name ShowFake
Expand Down
Expand Up @@ -51,34 +51,38 @@ else if (arg.matchesArgumentType(dLocation.class))

else if (!scriptEntry.hasObject("destination")
&& arg.matchesArgumentType(dLocation.class)
&& arg.matchesPrefix("destination, d"))
&& arg.matchesPrefix("destination, d")) {

scriptEntry.addObject("destination", arg.asType(dLocation.class));
}

else if (!scriptEntry.hasObject("height")
&& arg.matchesPrimitive(aH.PrimitiveType.Double)
&& arg.matchesPrefix("height, h"))
&& arg.matchesPrefix("height, h")) {

scriptEntry.addObject("height", arg.asElement());
}

else if (!scriptEntry.hasObject("gravity")
&& arg.matchesPrimitive(aH.PrimitiveType.Double)
&& arg.matchesPrefix("gravity, g, velocity, v"))
scriptEntry.addObject("gravity", arg.asElement());
&& arg.matchesPrefix("gravity, g, velocity, v")) {

else if (!scriptEntry.hasObject("speed")
&& arg.matchesPrimitive(aH.PrimitiveType.Double)
&& arg.matchesPrefix("speed, s"))
scriptEntry.addObject("speed", arg.asElement());
scriptEntry.addObject("gravity", arg.asElement());
}

else if (!scriptEntry.hasObject("script")
&& arg.matchesArgumentType(dScript.class))
&& arg.matchesArgumentType(dScript.class)) {

scriptEntry.addObject("script", arg.asType(dScript.class));
}

else if (!scriptEntry.hasObject("entities")
&& arg.matchesArgumentList(dEntity.class))
&& arg.matchesArgumentList(dEntity.class)) {

scriptEntry.addObject("entities", ((dList) arg.asType(dList.class)).filter(dEntity.class));
}

else
dB.echoError(dB.Messages.ERROR_UNKNOWN_ARGUMENT, arg.raw_value);
else dB.echoError(dB.Messages.ERROR_UNKNOWN_ARGUMENT, arg.raw_value);
}

// Use the NPC or player's locations as the origin if one is not specified
Expand Down Expand Up @@ -133,18 +137,16 @@ public void execute(final ScriptEntry scriptEntry) throws CommandExecutionExcept
List<dEntity> entities = (List<dEntity>) scriptEntry.getObject("entities");
final dScript script = (dScript) scriptEntry.getObject("script");

Element height = scriptEntry.getElement("height");
Element gravity = scriptEntry.getElement("gravity");
Element speed = scriptEntry.getElement("speed");
double height = ((Element) scriptEntry.getObject("height")).asDouble();
Element gravity = (Element) scriptEntry.getObject("gravity");

// Report to dB
dB.report(getName(), aH.debugObj("origin", originEntity != null ? originEntity : originLocation) +
aH.debugObj("entities", entities.toString()) +
destination.debug() +
height.debug() +
(gravity != null ? gravity.debug(): "") +
(speed != null ? speed.debug(): "") +
(script != null ? script.debug() : ""));
aH.debugObj("destination", destination) +
aH.debugObj("height", height) +
aH.debugObj("gravity", gravity) +
(script != null ? aH.debugObj("script", script.identify()) : ""));

// Keep a dList of entities that can be called using <entry[name].shot_entities>
// later in the script queue
Expand Down Expand Up @@ -192,7 +194,7 @@ public void execute(final ScriptEntry scriptEntry) throws CommandExecutionExcept
if (defaultGravity.name().equals(entityType)) {

gravity = new Element(defaultGravity.getGravity());
dB.echoDebug("Gravity: " + gravity);
dB.echoApproval("Gravity: " + gravity);
}
}

Expand All @@ -202,16 +204,11 @@ public void execute(final ScriptEntry scriptEntry) throws CommandExecutionExcept
}
}

if (speed == null) {
Vector v1 = lastEntity.getLocation().toVector();
Vector v2 = destination.toVector();
Vector v3 = Velocity.calculate(v1, v2, gravity.asDouble(), height.asDouble());
lastEntity.setVelocity(v3);
}
else {
lastEntity.setVelocity(originLocation.getDirection().multiply(speed.asDouble()));
}
Vector v1 = lastEntity.getLocation().toVector();
Vector v2 = destination.toVector();
Vector v3 = Velocity.calculate(v1, v2, gravity.asDouble(), height);

lastEntity.setVelocity(v3);

// A task used to trigger a script if the entity is no longer
// being shot, when the script argument is used
Expand Down

1 comment on commit e1fdaad

@davidcernat
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the Push command instead. I prefer not to have command arguments that cancel each other out, especially considering that the Gravity argument does something very similar.

Please sign in to comment.