Welcome to AC Web.
Results 1 to 8 of 8
  1. #1

    Creature Script TC


    REGISTER! (FREE)
    Registered members see less ads
    and also gain access to other great features.
    I wrote this:

    Code:
    class custom_script : public CreatureScript
    {
    public:
        custom_script() : CreatureScript("wolf_script") { }
    
        struct custom_scriptAI : public ScriptedAI
        {
            custom_scriptAI(Creature* creature) : ScriptedAI(creature) {}
    
            void JustDied(Unit *player)
            {
                printf("\nPlayer %s has slain %s", player->GetName().c_str(), me->GetName().c_str());
            }
        }
    
        CreatureAI* GetAI(Creature* creature) const override
        {
            return new custom_scriptAI(creature);
        }
    };
    
    void AddSC_custom_script()
    {
    	new custom_script();
    }
    I copy/paste from TC existing scripts, but does not seems to work...
    Any idea please?
    Kinda new into CreatureScript

    - - - Updated - - -

    up

  2. #2
    Have you assigned script into creature_template in DB and scriptloader in Core?

  3. #3
    Check that you added void AddSC_custom_script() to custom_script_loader

    Check that you assigned script into creature_template

    Run into world DB ->
    UPDATE creature_template SET ScriptName = 'wolf_script' WHERE entry = YOURID;
    And add override to JustDied ->

    void JustDied(Unit *player) to -> void JustDied(Unit *player) override
    I think that override is your problem.
    Last edited by sexipriest; 12-10-2019 at 10:19 AM.

  4. #4
    also use the new syntax for creature scripts

    script can be simplified to

    Code:
        struct wolf_script : public ScriptedAI
        {
            wolf_script(Creature* creature) : ScriptedAI(creature) {}
    
            void JustDied(Unit *player)
            {
                printf("\nPlayer %s has slain %s", player->GetName().c_str(), me->GetName().c_str());
            }
        }
    
    void AddSC_custom_script()
    {
       RegisterCreatureAI(wolf_script);
    }
    make sure ScriptMgr.h is included

  5. #5
    I've already fixed this, thank you all.

    Quote Originally Posted by Ckabot View Post
    also use the new syntax for creature scripts

    script can be simplified to

    Code:
        struct wolf_script : public ScriptedAI
        {
            wolf_script(Creature* creature) : ScriptedAI(creature) {}
    
            void JustDied(Unit *player)
            {
                printf("\nPlayer %s has slain %s", player->GetName().c_str(), me->GetName().c_str());
            }
        }
    
    void AddSC_custom_script()
    {
       RegisterCreatureAI(wolf_script);
    }
    make sure ScriptMgr.h is included
    This did not work to me,
    Code:
    "wolf_script" is not declared.

  6. #6
    Give some info how you fixed it. Where was the problem ? It can be helpfull for other people's.

  7. #7
    I don't know how I fixed this,

    I think I added:

    #include "ScriptedGossip.h"
    #include "GossipDef.h"

  8. #8

    REGISTER! (FREE)
    Registered members see less ads
    and also gain access to other great features.
    probably need public: before constructor

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •