Toggle Commands, Why not?

Valkyra

Super Cool Person
Staff member
Moderator
Aug 31, 2010
160
2
18
Murica
#2
Look at how it's done in JediSelfBuffCommand.cpp ( I think it's called.) in the commands directory in creature.

Basically it just checks to see if the buff already exists upon command activation, with creature->hasBuff(<crc>);

So you can do different codeblock mechanics using that if else statement.
 
Oct 10, 2017
103
1
18
#4
Ok, I was checking the "doJediSelfBuffCommand" using the "ForceRun1" file... :

The Run Buff ends when you hit again "ForceRun1" but
now i only need how to stop the visual effect when FR1 finishes.




Code:
/*
                Copyright <SWGEmu>
        See file COPYING for copying conditions. */

#ifndef FORCERUN1COMMAND_H_
#define FORCERUN1COMMAND_H_

#include "JediQueueCommand.h"

class ForceRun1Command : public JediQueueCommand {
public:

    ForceRun1Command(const String& name, ZoneProcessServer* server)
    : JediQueueCommand(name, server) {
        // BuffCRC's, first one is used.
        buffCRC = BuffCRC::JEDI_FORCE_RUN_1;

        // If these are active they will block buff use
        blockingCRCs.add(BuffCRC::JEDI_FORCE_RUN_2);
        blockingCRCs.add(BuffCRC::JEDI_FORCE_RUN_3);

        // Skill mods.
        skillMods.put("force_run", 1);
        skillMods.put("slope_move", 33);

    }

    int doQueueCommand(CreatureObject* creature, const uint64& target, const UnicodeString& arguments) const {
    int res = creature->hasBuff(buffCRC) ? NOSTACKJEDIBUFF : doJediSelfBuffCommand(creature);

        if (res == NOSTACKJEDIBUFF) {
            return doJediSelfBuffCommand(creature);
        }
        
        // Return if something is in error.
        if (res != SUCCESS) {
            return res;
        }

        // SPECIAL - For Force Run.
        if (creature->hasBuff(STRING_HASHCODE("burstrun")) || creature->hasBuff(STRING_HASHCODE("retreat"))) {
            creature->removeBuff(STRING_HASHCODE("burstrun"));
            creature->removeBuff(STRING_HASHCODE("retreat"));
        }

        // Return.
        return SUCCESS;
    }

};
#endif //FORCERUN1COMMAND_H_
 

thrax989

New Member
May 3, 2015
10
0
1
#7
Hello, still requesting for an answer...
Do this for Forcerun1-3

Remove this line - int res = creature->hasBuff(buffCRC) ? NOSTACKJEDIBUFF : doJediSelfBuffCommand(creature);
Update with this line - int res = doJediSelfBuffCommand(creature);

By removing the creature->hasBuff(buffCRC) ? NOSTACKJEDIBUFF : you can click the skill on or off any time making it so you can toggle it.
 
Oct 10, 2017
103
1
18
#8
Do this for Forcerun1-3

Remove this line - int res = creature->hasBuff(buffCRC) ? NOSTACKJEDIBUFF : doJediSelfBuffCommand(creature);
Update with this line - int res = doJediSelfBuffCommand(creature);

By removing the creature->hasBuff(buffCRC) ? NOSTACKJEDIBUFF : you can click the skill on or off any time making it so you can toggle it.

Hey Thrax. The problem isn't toggle the command but remove its ForceRun Effect while is OFF.
The code i put is to toggle forcerun1. You don't need to remove anything else.