Adding a new Creature to the Database

Hello everyone,

First of all im pretty new to TrinityCore, programming (C++ and Perl) and databases and want to thank you guys for your support and work on Trinity.

Iam impressed of what you created /emoticons/default_smile.png

My TrinityCore server is running fine.

Now to my little problem:

I wrote a creature script as it is explained in the example folder (Hope so).

The script itself works, spells etc., but i wanted to use some of the phrases which are also listed in the example creature.

For example my creature should say “Let the games begin.” when some gets infight with it, also with the sound.

enum Says

{
SAY_AGGRO = 0, //16037 “Let the games begin.”
SAY_RANDOM = 1, //8831 “I see endless suffering. I see torment. I see rage. I see everything.”
SAY_BERSERK = 2, //8647 “$N, I sentance you to death!”
SAY_PHASE = 3, //11415 “The suffering has just begun!”
SAY_EVADE = 4 //11051 “Help $N! I’m under attack!”
};
But when i spawn my creature and get into battle, i get the following Message in the Worldserver.exe multiple times:

CreatureTextMgr: Could not find TextGroup 100 for Creature Lady Jaina Proudmoore

<Entry 42000, GUID 213380> in creature_texttable. Ignoring.

It is not only 100. It is (i think so) for all of my Sayings.

After hours of trying to find the mistake in my script or in my database and the use of Google and your forum i couldnt find any solution for this.

Where are these TextGroups and how can i fix this.

I need your help. If it is that simpe i will hate myself afterwards enough /emoticons/default_wink.png

Thanks for any help. I Try to improve

— Canned message start —

This thread is not related to the official Trinity codebase and was moved to the Custom Code section.

Please read the stickies next time.

— Canned message end —

May also to think about SmartScripts.

And may you make a pastebin of your code for better understanding.

Hey Magni,

thanks for participating /emoticons/default_smile.png

this is my script right now. It is not finished ^^ and im up for any good changes or ideas. And first it is just for learing purpose.

  • Mein erster Versuch ein Script zu schreiben. 26.06.2014
    */

/* ScriptData
Name: firsttry
SD%Complete: 0
SDComment: first try to write my on script.
SDCategory: Script try.
EndScriptData */

#include “ScriptMgr.h”
#include “ScriptedCreature.h”
#include “ScriptedGossip.h”
#include “Player.h”

enum Says
{
SAY_AGGRO = 0, //16037 “Let the games begin.”
SAY_RANDOM = 1, //8831 “I see endless suffering. I see torment. I see rage. I see everything.”,
// “Muahahahaha”,
// “These mortal infedels my lord, they have invaded your sanctum and seek to steal your secrets.”,
// “You are already dead.”,
// “Where to go? What to do? So many choices that all end in pain, end in death.”
SAY_BERSERK = 2, //8647 “$N, I sentance you to death!”
SAY_PHASE = 3, //11415 “The suffering has just begun!”
SAY_EVADE = 4 //11051 “Help $N! I’m under attack!”
};

enum Spells
{
SPELL_BUFF = 48469, // Mark of the wild
SPELL_FIRE_NOVA = 36278, // Blast Wave
SPELL_FIRE_BOLT = 71504, // Fireblast
SPELL_PYROBLAST = 64698, // Pyroblast
SPELL_SHADOW_VOLLEY = 72908, // Frostvolley
SPELL_BERSERK = 72525, // 240% more dmg and 160% cast speed.
SPELL_BERSERK_UEBER = 67996, // Arcane Barrage ca. 11k dmg
SPELL_FRENZY = 72737 // Increased Attackspeed 30%.
};

enum Events
{
EVENT_BUFF = 1,
EVNET_FIRE_NOVA = 2,
EVENT_PYROBLAST = 3,
EVENT_SHADOW_VOLLEY = 4,
EVENT_BERSERK = 5
};

enum Factions
{
FACTION_WORGEN = 24
};

#define GOSSIP_ITEM

class overpowered_creature : public CreatureScript
{
public:

   overpowered_creature()
       :  CreatureScript("overpowered_creature")
   {
   }

   struct overpowered_creatureAI : public ScriptedAI
   {
		overpowered_creatureAI(Creature* creature) : ScriptedAI(creature) { }
		
    uint32 m_uiSayTimer;                                    // Timer for random chat
        uint32 m_uiRebuffTimer;                                 // Timer for rebuffing
        uint32 m_uiSpell1Timer;                                 // Timer for spell 1 (Firenova) when in combat
        uint32 m_uiSpell2Timer;                                 // Timer for spell 2 (Pyroblast) when in combat
        uint32 m_uiSpell3Timer;                                 // Timer for spell 3 (Shadowvolley) when in combat
        uint32 m_uiBerserkTimer;                                // Timer until we go into Beserk (enraged) mode
        uint32 m_uiPhase;                                       // The current battle phase we are in
        uint32 m_uiPhaseTimer;                                  // Timer until phase transition

void Reset() OVERRIDE
{
m_uiPhase = 1; // Start in phase 1
m_uiPhaseTimer = 60000; // 60 seconds
m_uiSpell1Timer = 8000; // 5 seconds
m_uiSpell2Timer = 19000; // 19 seconds
m_uiSpell3Timer = urand(10000, 20000); // between 10 and 20 seconds
m_uiBerserkTimer = 90000; // 90 seconds

            me->RestoreFaction();
		}

		void EnterCombat(Unit* who) OVERRIDE
		{
			Talk(SAY_AGGRO, who);
		}

		void AttackStart(Unit* who) OVERRIDE
		{
			ScriptedAI::AttackStart(who);
		}
		
		void EnterEvadeMode() OVERRIDE
		{
			//Spruch beim verlassen des Kampfes.
			Talk(SAY_EVADE);
		}
		
		void UpdateAI(uint32 uiDiff) OVERRIDE
		{
			
			if (!me->GetVictim())
			{
				//Zufälliger Spruch aus Random
				if (m_uiSayTimer <= uiDiff)//uiDiff vielleicht eine Differenz ? 
				{
					Talk(SAY_RANDOM);
					m_uiSayTimer = 45000; //Nach 45 Sekunden wird erneut etwas zufälliges Gesagt
				}
				else
				{
					m_uiSayTimer -= uiDiff;
				}
				
				//Rebuff Timer
				if (m_uiRebuffTimer <= uiDiff)
				{
					DoCast(me, SPELL_BUFF);
					m_uiRebuffTimer = 120000; //Rebuff again in 15 minutes
				}
				
			}
		
			//Return since we have no target. Da wir uns außerhablb des Kampfes befinden, soll der weitere Code-Teil übersprunden werden.
			if (!UpdateVictim())
			{
				return;
			}
			
			//Timer für Spell nummer 1
			if (m_uiSpell1Timer <= uiDiff)
			{
				//Cast spell auf das derzeitige Ziel/opfer.
				if (rand()%30 > 10)
				{
					DoCastVictim(SPELL_FIRE_BOLT);
				}
				else if (me->IsWithinDist(me->GetVictim(), 30.0f))//Nut sure about the range here, yet.
				{
					DoCastVictim(SPELL_FIRE_NOVA);
				}
			
				m_uiSpell1Timer = 8000;
			
			}
			
			if (m_uiSpell2Timer <= uiDiff)
			{
				DoCastVictim(SPELL_PYROBLAST);
				m_uiSpell2Timer = 20000;
			}
			else
			{
				m_uiSpell2Timer -= uiDiff;
			}
		
			//Berserktimer
			if (m_uiPhase > 1)
			{
				// Timer für Zauber nummer 3 (Berserker)
				if (m_uiSpell3Timer <= uiDiff)
				{
					DoCastVictim(SPELL_SHADOW_VOLLEY);
					m_uiSpell3Timer = 30000;
				}
				else
				{
					m_uiSpell3Timer -= uiDiff;
				}
			
				if (m_uiBerserkTimer <= uiDiff)
				{
					Talk(SAY_BERSERK, me->GetVictim());
					DoCastVictim(SPELL_BERSERK_UEBER);
					
					m_uiBerserkTimer = 30000;
				}
				else
				{
					m_uiBerserkTimer -= uiDiff;
				}
			}
			else if (m_uiPhase == 1)
			{
				if(m_uiPhaseTimer <= uiDiff)
				{
					//Nextphase !
					++m_uiPhase;
					Talk(SAY_PHASE);
					DoCast(me, SPELL_FRENZY);
					DoCast(me, SPELL_BERSERK);
				}
				else
				{
					 m_uiPhaseTimer -= uiDiff;
				}
				
			}
			
			
			//Talk(uiDiff);

			DoMeleeAttackIfReady();
			
		}
	};
	
	
	CreatureAI* GetAI(Creature* creature) const OVERRIDE
	{
		return new overpowered_creatureAI(creature);
	}

};

void AddSC_overpowered_creature()
{
new overpowered_creature();
}

This is my creature_template entry maybe it is also important to see:

VALUES (42000, 0, 0, 0, 0, 0, 30863, 0, 0, 0, ‘Lady Jaina Proudmoore’, ‘Alex TestMob’, NULL, 0, 83, 83, 2, 24, 24, 0, 1, 1, 1, 3, 370, 531, 0, 343, 35, 2000, 0, 8, 64, 2048, 8, 0, 0, 0, 0, 0, 365, 542, 84, 7, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 700000, 750000, ‘’, 0, 3, 1, 529.505, 80, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 617299839, 2, ‘overpowered_creature’, 12340);

Thanks for your help.

Did you add the creature_text entries into the DB for that creature?

Yep i did these in creature_text:

VALUES (42000, 0, 0, ‘Let the games begin.’, 12, 1, 100, 0, 0, 16037, ‘overpowered SAY_AGGRO’);
VALUES (42000, 2, 0, ’ I see endless suffering. I see torment. I see rage. I see everything.', 12, 1, 0, 0, 0, 8647, ‘overpowered SAY_BERSERK’);
VALUES (42000, 1, 0, ‘$N, I sentance you to death!’, 12, 0, 100, 0, 0, 8831, ‘overpowered SAY_RANDOM’);
VALUES (42000, 3, 0, ‘The suffering has just begun!’, 12, 0, 100, 0, 0, 11415, ‘overpowered SAY_PHASE’);
VALUES (42000, 4, 0, ‘Help $N! I’m under attack!’, 12, 0, 100, 0, 0, 11051, ‘overpowered SAY_EVADE’);

Just a hint, not related in any way to your problem: Use higher ID for your custom NPCs, otherwise there is a risk that they are overwritten later by a TC update by a official id.

Have you checked if your SQL queries was really accepted? I’m asking because I have seen there is an additional field at the end after comment: BroadcastTextID. May your SQL queries ended in an error ?

Edit:

I think you are not using the latest version of TC. Because your SQL queries are not up to date and f.ex. in the code you would have to replace

OVERRIDE by override regarding the C++11 standards TC is using now.

Edit2:

Just have tested your script. On an actual TC core there are no errors. However as your script is not yet finished, there is a kind of endless loop in it.

INSERT INTO `creature_template`
(`entry`, `difficulty_entry_1`, `difficulty_entry_2`, `difficulty_entry_3`, `KillCredit1`, `KillCredit2`, `modelid1`, `modelid2`, `modelid3`, `modelid4`, `name`, `subname`, `IconName`, `gossip_menu_id`, `minlevel`, `maxlevel`, `exp`, `faction`, `npcflag`, `speed_walk`, `speed_run`, `scale`, `rank`, `mindmg`, `maxdmg`, `dmgschool`, `attackpower`, `dmg_multiplier`, `baseattacktime`, `rangeattacktime`, `unit_class`, `unit_flags`, `unit_flags2`, `dynamicflags`, `family`, `trainer_type`, `trainer_spell`, `trainer_class`, `trainer_race`, `minrangedmg`, `maxrangedmg`, `rangedattackpower`, `type`, `type_flags`, `lootid`, `pickpocketloot`, `skinloot`, `resistance1`, `resistance2`, `resistance3`, `resistance4`, `resistance5`, `resistance6`, `spell1`, `spell2`, `spell3`, `spell4`, `spell5`, `spell6`, `spell7`, `spell8`, `PetSpellDataId`, `VehicleId`, `mingold`, `maxgold`, `AIName`, `MovementType`, `InhabitType`, `HoverHeight`, `Health_mod`, `Mana_mod`, `Armor_mod`, `RacialLeader`, `questItem1`, `questItem2`, `questItem3`, `questItem4`, `questItem5`, `questItem6`, `movementId`, `RegenHealth`, `mechanic_immune_mask`, `flags_extra`, `ScriptName`, `VerifiedBuild`)
VALUES (242000, 0, 0, 0, 0, 0, 30863, 0, 0, 0, 'Lady Jaina Proudmoore', 'Alex TestMob', NULL, 0, 83, 83, 2, 24, 0, 1, 1, 1, 3, 370, 531, 0, 343, 35, 2000, 0, 8, 64, 2048, 8, 0, 0, 0, 0, 0, 365, 542, 84, 7, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 700000, 750000, '', 0, 3, 1, 529.505, 80, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 617299839, 2, 'overpowered_creature', 12340);


INSERT INTO `creature_text` (`entry`, `groupid`, `id`, `text`, `type`, `language`, `probability`, `emote`, `duration`, `sound`, `comment`, `BroadcastTextID`) VALUES
 (242000, 0, 0, 'Let the games begin.', 12, 1, 100, 0, 0, 16037, 'overpowered SAY_AGGRO', 0),
 (242000, 2, 0, ' I see endless suffering. I see torment. I see rage. I see everything.', 12, 1, 0, 0, 0, 8647, 'overpowered SAY_BERSERK',0),
 (242000, 1, 0, '$N, I sentance you to death!', 12, 0, 100, 0, 0, 8831, 'overpowered SAY_RANDOM',0),
 (242000, 3, 0, 'The suffering has just begun!', 12, 0, 100, 0, 0, 11415, 'overpowered SAY_PHASE',0),
 (242000, 4, 0, 'Help $N! I'm under attack!', 12, 0, 100, 0, 0, 11051, 'overpowered SAY_EVADE',0);

You mean that behind for example ‘overpowered SAY_AGGRO’ is an additional field ?

I Didn`t saw any field behind the comment.

But somehow i never saw a field called BroadcastTextID.

I dont think that my SQL queries ended in an error but im not sure /emoticons/default_wink.png

I can`t check it right now cause im at work, I will check that when im home again.

I copied the creature_text entries from other creatures and changed them for my creature. I thought that should work. Maybe im wrong.

Im sure you are right with the fact that iam not using the latest version of TC. Cause i never updated my server since I set it up around 4 months ago.

Because im not sure how to update it.

But in my opinion this have nothing todo with the version. It should still work or not ? I mean i followed the steps from my local version on how to create a new creature + script.

I will try to update my TC but im not sure if i will get it right …

is there a tutorial for updating the core ?

Thanks

I know this is a minor thing but you have ‘sentence’ mispelled in your script.

Not trying to troll. I just know when I see something mispelled in a game, it bugs me.

drmike,

i have not misspelled ‘sentence’. The point is that not written it, and I didnt corrected it, cause it didnt bothered me.

It is an spelling mistake made by the creature of the “example_creature.cpp”.

And i think it is correct in the database so it is not ‘sentance’ there /emoticons/default_smile.png

Thanks anyway ^^

Thanks Magnuss for testing my script and that it “works” for you /emoticons/default_dry.png

It would be cool if it would work for me aswell.

I will try to update my Core and hope it will work then.

Is there any guide for updating the core and database ? Cause as I mentioned, I never did that before.

Thanks guys

Yeah, the exact same one you should have followed in the first place. on the wiki.

Okay,

i will just install the new 335.54 build + database. I think that should work.

Thanks Paradox

Okay thanks all of you.

My little beginner Script finaly works almost perfect.

But it works ^^

Now i can start to advance my Script /emoticons/default_smile.png