Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for alchemy dude's quest part 2 #2362

Merged
merged 2 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/main/java/emu/grasscutter/game/entity/EntityGadget.java
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@ public boolean startPlatform() {
var route = this.getScene().getSceneRouteById(configRoute.getRouteId());
if (route != null) {
var points = route.getPoints();
if (configRoute.getStartIndex() == points.length - 1) {
configRoute.setStartIndex(0);
}
val currIndex = configRoute.getStartIndex();

Position prevpos;
Expand Down Expand Up @@ -301,6 +304,9 @@ public boolean startPlatform() {
}
configRoute.setStartIndex(I);
this.position.set(points[I].getPos());
if(I == points.length - 1) {
configRoute.setStarted(false);
}
},
(int) time));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1180,7 +1180,7 @@ public int cancelGroupTimerEvent(int groupID, String source) {

Grasscutter.getLogger()
.warn("trying to cancel a timer that's not active {} {}", groupID, source);
return 1;
return 0;
}

// todo use killed monsters instead of spawned entites for check?
Expand Down
9 changes: 2 additions & 7 deletions src/main/java/emu/grasscutter/scripts/ScriptLib.java
Original file line number Diff line number Diff line change
Expand Up @@ -1330,9 +1330,8 @@ public int SetPlatformPointArray(int entityConfigId, int pointArrayId, int[] var
return -1;
}

//TODO check
public int SetPlatformRouteId(int entityConfigId, int routeId){
logger.info("[LUA] Call SetPlatformRouteId {} {}", entityConfigId, routeId);
logger.debug("[LUA] Call SetPlatformRouteId {} {}", entityConfigId, routeId);

val entity = getSceneScriptManager().getScene().getEntityByConfigId(entityConfigId);
if(entity == null){
Expand Down Expand Up @@ -1365,22 +1364,18 @@ public int SetPlatformRouteId(int entityConfigId, int routeId){
return 0;
}

//TODO check
public int StartPlatform(int configId){
logger.debug("[LUA] Call StartPlatform {} ", configId);

val entity = sceneScriptManager.get().getScene().getEntityByConfigId(configId);

if(!(entity instanceof EntityGadget entityGadget)) {
return 1;
}

return entityGadget.startPlatform() ? 0 : 2;
}

//TODO check
public int StopPlatform(int configId){
logger.info("[LUA] Call StopPlatform {} ", configId);
logger.debug("[LUA] Call StopPlatform {} ", configId);
val entity = sceneScriptManager.get().getScene().getEntityByConfigId(configId);
if(!(entity instanceof EntityGadget entityGadget)) {
return 1;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package emu.grasscutter.server.packet.recv;

import emu.grasscutter.Grasscutter;
import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketHandler;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.ClientScriptEventNotifyOuterClass.ClientScriptEventNotify;
import emu.grasscutter.scripts.constants.EventType;
import emu.grasscutter.scripts.data.ScriptArgs;
import emu.grasscutter.server.game.GameSession;
import lombok.val;

@Opcodes(PacketOpcodes.ClientScriptEventNotify)
public class HandlerClientScriptEventNotify extends PacketHandler {

@Override
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
val data = ClientScriptEventNotify.parseFrom(payload);
val scriptManager = session.getPlayer().getScene().getScriptManager();
val args = new ScriptArgs(0, data.getEventType())
.setSourceEntityId(data.getSourceEntityId())
.setTargetEntityId(data.getTargetEntityId());

for (int i = 0; i < data.getParamListCount(); i++) {
switch (i) {
case 0 -> args.setParam1(data.getParamList(i));
case 1 -> args.setParam2(data.getParamList(i));
case 2 -> args.setParam3(data.getParamList(i));
}
}

if(data.getEventType() == EventType.EVENT_AVATAR_NEAR_PLATFORM){
if(data.getParamList(0) == 0) {
Grasscutter.getLogger().debug("Found a zero Param1 for an EVENT_AVATAR_NEAR_PLATFORM. Doing the configID workaround.");
val entity = session.getPlayer().getScene().getEntityById(data.getSourceEntityId());
if(entity == null) {
Grasscutter.getLogger().debug("But it failed.");
} else {
args.setParam1(entity.getConfigId());
}
}
}

scriptManager.callEvent(args);
}

}
Loading