Sign in to follow this  
Eject

Question about a expanded mod system

Recommended Posts

Hello dear modders

 

Is it possible in any way that we can change some settings while the server is running?

I know, Fryia use this option with the dropmod (loottables) and the modsupport.db

There you can turn on and off different rules.

 

For the other mods it would be very aesome to start events like (example) cropmod turn on +3 from harvest and turn it off after 5 hours if the event is finished.

Bountymod...increase the multiplier for some time without restarting all servers 2 times

 

Eject

  • Like 1

Share this post


Link to post
Share on other sites

Of course that is possible. It just depends on how you code things. On Sklotopolis we are using a lot such mods which can be changed during runtime, it is just a bit more complex to code.

Share this post


Link to post
Share on other sites

Use the action-performer / behaviour-provided to make custom actions which reflectively change various object's fields/states. You may need to run some kind of an update method or possibly make your own. Some things can be easily changed with reflection and other not so much. 

 

Here I made a question class (which is run using an action-performer) to instantly change server wheather in-game with gm wand.

question class: https://pastebin.com/uZEA5epN

 

action-performer

Spoiler

package com.Joedobo27.setserverwearther;


import com.wurmonline.server.behaviours.Action;
import com.wurmonline.server.behaviours.ActionEntry;
import com.wurmonline.server.creatures.Creature;
import com.wurmonline.server.items.Item;
import com.wurmonline.server.items.ItemList;
import com.wurmonline.server.questions.ServerWeatherQuestion;
import org.gotti.wurmunlimited.modsupport.actions.ActionPerformer;
import org.gotti.wurmunlimited.modsupport.actions.BehaviourProvider;
import org.gotti.wurmunlimited.modsupport.actions.ModAction;
import org.gotti.wurmunlimited.modsupport.actions.ModActions;

import java.util.Collections;
import java.util.List;
import java.util.logging.Level;

import static com.Joedobo27.setserverwearther.Wrap.Actions.*;

public class SetWeatherAction implements ModAction, BehaviourProvider, ActionPerformer {
    private final short actionId;
    private final ActionEntry actionEntry;

    SetWeatherAction() {
        actionId = (short) ModActions.getNextActionId();
        actionEntry = ActionEntry.createEntry(actionId, "Set Weather", "Weatherizing", new int[]{IGNORERANGE.getId(), QUICK.getId(),
        ALWAYS_USE_ACTIVE_ITEM.getId()});
        ModActions.registerAction(actionEntry);
    }

    @Override
    public short getActionId() {
        return actionId;
    }

    @Override
    public List<ActionEntry> getBehavioursFor(Creature performer, Item object, int tileX, int tileY, boolean onSurface, int tile) {
        if (performer.getPower() >= 4 && object.getTemplateId() == ItemList.wandDeity){
            return Collections.singletonList(actionEntry);
        } else
            return null;
    }

    @Override
    public boolean action(final Action action, final Creature performer, final int tileX, final int tileY, final boolean onSurface, final int tile, final short _actionId, final float counter) {
        if (_actionId == actionId) {
            ServerWeatherQuestion serverWeatherQuestion = new ServerWeatherQuestion(performer);
            serverWeatherQuestion.sendQuestion();
            return true;
        }
        return false;
    }
}

 

 

Edited by joedobo

Share this post


Link to post
Share on other sites

Hello joedobo :)

 

How can i use your example at my server? Can you give me a little help how i have to import this classfile?

 

Eject

Share this post


Link to post
Share on other sites

I tried to clean up that tool and add away to also set server time but I forgot about something important. Client time and server time don't depend on one another (they use different independent functions). When you change server time, the client time doesn't go with it. I'm not sure what to do now as this will mess with season alignment. I don't care because my WU is locked to summer always but I doubt others would be happy if things get jumbled. Dang, I was psyched too as I got harvesting seasons cycle by changing the time (and some additional code to update harvesting stuffs) with a GM time tool.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this