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

Core/Scripts: Gnomish Mind Control Cap and Gnomish Universal Remote #17374

Merged
merged 2 commits into from Oct 14, 2016
Merged

Core/Scripts: Gnomish Mind Control Cap and Gnomish Universal Remote #17374

merged 2 commits into from Oct 14, 2016

Conversation

ghost
Copy link

@ghost ghost commented Jun 15, 2016

Changes proposed:

Implement scripts for Mind Amplification Dish and Gnomish Universal Remote.
Based on the previous PR #16232 by @elecyb and feedback in that PR.

Adds functionality to the following items:

Chances are based on empirical results from wowhead (highly upvoted post):
http://www.wowhead.com/spell=67839/mind-amplification-dish#comments:id=1483300

> 65% of the time - Successful Mind Control.
> 30% of the time - Unsuccessful Mind Control.
<  5% of the time - Backfire

By elecyb & joschiwald

Target branch(es): 3.3.5 / 6.x

Issues addressed: Closes #2562

Tests performed: (Does it build, tested in-game, etc) Builds without issues.

Known issues and TODO list:

  • implement various suggested improvements

class spell_item_universal_remote_SpellScript : public SpellScript
{
PrepareSpellScript(spell_item_universal_remote_SpellScript);

Copy link

@robens robens Jun 15, 2016

Choose a reason for hiding this comment

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

load should also be overrided here with the same check of spell_item_mind_control_cap

Copy link
Author

@ghost ghost Jun 15, 2016

Choose a reason for hiding this comment

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

OK, so you mean it should look like this:

        class spell_item_universal_remote_SpellScript : public SpellScript
        {
            PrepareSpellScript(spell_item_universal_remote_SpellScript);

            bool Load() override
            {
                if (!GetCastItem())
                    return false;
                return true;
            }

            bool Validate(SpellInfo const* /*spellInfo*/) override
            {

Weird that joschiwald did not add it, he wrote the whole section below
// 8344 - Universal Remote (Gnomish Universal Remote)

Copy link

Choose a reason for hiding this comment

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

yes, that's what I meant. You can wait for the original author if you feel like it.

Copy link
Author

Choose a reason for hiding this comment

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

I can add it, if you are as sure about this change as joschiwald is in his comments. ;-)

Copy link

@robens robens Jun 15, 2016

Choose a reason for hiding this comment

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

The probabilities of this being casted by a non-item is really low, but not 0. Joschiwald was focusing the roll chance management/spellinfo validation code with that comment.

If you want more insight about this, debug the castspell call and see if nullptr item is handled somewhere.

Copy link
Contributor

Choose a reason for hiding this comment

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

useless

@joschiwald
Copy link
Contributor

can you update the first spellscript similar to the second one?

});

if (Unit* target = GetHitUnit())
GetCaster()->CastSpell(target, itr->second, true, GetCastItem());
Copy link
Contributor

Choose a reason for hiding this comment

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

itr->second is double, you probably mean itr->first here.

Copy link
Author

Choose a reason for hiding this comment

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

OK. Remember, this is elecyb's code, so I do what you suggest. :-)

@ghost
Copy link
Author

ghost commented Jun 15, 2016

(joschiwald) can you update the first spellscript similar to the second one?

Sure, I will do my best to make them similar in structure.

@ghost ghost changed the title Core/Script: Gnomish Mind Control Cap and Gnomish Universal Remote [WIP] Core/Script: Gnomish Mind Control Cap and Gnomish Universal Remote Aug 12, 2016
@ghost
Copy link
Author

ghost commented Sep 18, 2016

This branch has conflicts that must be resolved

Going to rebase this PR soon to fix those conflicts. Been occupied with other things, but will fix this soon.

@ghost ghost changed the title [WIP] Core/Script: Gnomish Mind Control Cap and Gnomish Universal Remote [WIP] Core/Scripts: Gnomish Mind Control Cap and Gnomish Universal Remote Sep 24, 2016
@ghost ghost changed the title [WIP] Core/Scripts: Gnomish Mind Control Cap and Gnomish Universal Remote [WIP] [3.3.5] Core/Scripts: Gnomish Mind Control Cap and Gnomish Universal Remote Sep 24, 2016
@ghost ghost changed the title [WIP] [3.3.5] Core/Scripts: Gnomish Mind Control Cap and Gnomish Universal Remote [WIP] Core/Scripts: Gnomish Mind Control Cap and Gnomish Universal Remote Sep 24, 2016
return true;
}

void HandleDummy(SpellEffIndex /*effIndex*/)
Copy link
Contributor

@SnapperRy SnapperRy Sep 24, 2016

Choose a reason for hiding this comment

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

I think this would be more fitting for the purpose:

if (Unit* target = GetHitUnit())
{
    uint8 chance = urand(0, 99);
    if (chance < 15)
        GetCaster()->CastSpell(target, SPELL_TARGET_LOCK, true, GetCastItem()); 
    else if (chance < 35)
        GetCaster()->CastSpell(target, SPELL_MOBILITY_MALFUNCTION, true, GetCastItem()); 
    else
        GetCaster()->CastSpell(target, SPELL_CONTROL_MACHINE, true, GetCastItem());
}

Instead of the unordered_map.

Copy link
Contributor

Choose a reason for hiding this comment

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

is more redable btw

Copy link
Author

@ghost ghost Sep 24, 2016

Choose a reason for hiding this comment

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

OK, so that means I can remove

static std::unordered_map<uint32 /*spellId*/, double /*probability*/> const UniversalRemoteActions =
{
    { SPELL_CONTROL_MACHINE,      60.0 },
    { SPELL_MOBILITY_MALFUNCTION, 25.0 },
    { SPELL_TARGET_LOCK,          15.0 }
};

and replace that with enum instead. I will take a look at it as soon as I have done some other work.

enum UniversalRemote
{
    CHANCE_TARGET_LOCK          = 15,
    CHANCE_MOBILITY_MALFUNCTION = 25,

    SPELL_CONTROL_MACHINE       = 8345,
    SPELL_MOBILITY_MALFUNCTION  = 8346,
    SPELL_TARGET_LOCK           = 8347
};
if (Unit* target = GetHitUnit())
{
    uint8 chance = urand(1, 100);
    if (chance <= CHANCE_TARGET_LOCK)
        GetCaster()->CastSpell(target, SPELL_TARGET_LOCK, true, GetCastItem()); 
    else if (chance <= CHANCE_MOBILITY_MALFUNCTION)
        GetCaster()->CastSpell(target, SPELL_MOBILITY_MALFUNCTION, true, GetCastItem()); 
    else
        GetCaster()->CastSpell(target, SPELL_CONTROL_MACHINE, true, GetCastItem());
}

Copy link

Choose a reason for hiding this comment

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

Maybe I'm wrong but the % will change with this code
SPELL_TARGET_LOCK [1, 15] - 15%
SPELL_MOBILITY_MALFUNCTION [16, 25] - 10%
SPELL_CONTROL_MACHINE [26, 100] - 75%

Copy link
Contributor

Choose a reason for hiding this comment

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

GitVerge is right. SPELL_MOBILITY_MALFUNCTION should be changed to 35 instead of 25 :P

Copy link

Choose a reason for hiding this comment

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

I think the correct number is 40 (15+25) and the other 60 for control machine

Copy link
Author

Choose a reason for hiding this comment

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

OK, maybe you're right. I don't know the calculation well enough to tell myself.
(mostly because I overtook the PR from another user to make it completable)

elecyb and others added 2 commits October 15, 2016 01:23
Implement scripts for Mind Amplification Dish and Gnomish Universal Remote

Adds functionality to the following items:

- Mind Amplification Dish (enchant)
- Gnomish Thinking Cap
- Gnomish Mind Control Cap
- Gnomish Universal Remote

By elecyb & joschiwald

Closes #2562
@SnapperRy SnapperRy merged commit b651bf2 into TrinityCore:3.3.5 Oct 14, 2016
@ghost ghost changed the title [WIP] Core/Scripts: Gnomish Mind Control Cap and Gnomish Universal Remote Core/Scripts: Gnomish Mind Control Cap and Gnomish Universal Remote Oct 14, 2016
@ghost ghost deleted the mind_control_cap_universal_remote branch October 15, 2016 00:38
joschiwald pushed a commit that referenced this pull request Oct 3, 2017
…mote (#17374)

(cherry picked from commit b651bf2)

Rename 2016_09_09_20_world.sql to 2016_10_15_00_world.sql
(cherry picked from commit d03b3e2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants