Mangos script Functions
The player-> send_vendorlist (_ creature-> getguid () function of NPC selling goods ());
Send_vendorlist (_ creature-> getguid () selling NPC
Send_trainerlist (_ creature-> getguid () Trainer
Send_bankerlist (_ creature-> getguid () Bank
Send_tabardlist (_ creature-> getguid () unknown
Send_auctionlist (_ creature-> getguid () Auction House
Send_taw.ist (_ creature-> getguid () flying instructor
Send_spresurrect () soul doctor resurrection
For more information, see mangos_source \ SRC \ bindings \ universal \ scripts \ SC _defines.h.
--------------------------------------------------------------------
Mangos (non-EMU) monster AI tutorial crazy cast
Simple monster AI tutorials all come to DIY their own monster AI
Simple monster AI tutorials all come to DIY their own monster AI
Prerequisites: C ++CodeAt least the most basic code, such as "and", "or", and "not.
Tools Required: mangos code, script code,. net2003, one person, one computer, cola, fries ............
It is estimated that you have already put on a physical monster and want to vomit? Let's simply compile a magic monster.
First, you can open \ scriptdev \ SRC \ bindings \ universal \ scripts \ custom \ AI to find a monster's AI, the dog's AI, named SC _kobold.cpp.
After opening it with VC, you can see the code in it.
Quote:
# Include ".../../SC _defines.h" \ This is a required header file
Structmangos_dll_declkoboldai: publicscriptedai \ This is a declaration of AI
{
Koboldai (CREATURE * C): scriptedai (c) {}\\. Just change the name.
Voidattackstart (Unit * Who) \ gets the attack target
{
If (m_creature-> getvictim () = NULL) \ still copy
{
Docast (WHO, 3110); // fireboltcastingonattacker (3110-idofspell) magic is used here, ID is 3110
If (WHO-> gettypeid () = typeid_player) \ indicates whether the ID is an attacker.
{
Debug_log ("koboldiscastingspellonplayer % s", (player *) WHO)-> getname ());
}
Else
{
Debug_log ("koboldiscastingspelloncreature ");
}
Dostartattack (WHO); \ Run the above script attack
}
}
}:
Creatureai * getai_kobold (CREATURE * _ creature) \ I don't explain it. I just copied it and renamed it.
{
Returnnewkoboldai (_ creature );
}
Voidaddsc_kobold () \ do not explain, anyway, copy the name
{
Script * newscript;
Newscript = newscript;
Newscript-> name = "Kobold ";
Newscript-> getai = getai_kobold;
M_scripts [nrscripts ++] = newscript;
}
If you want to attack a player with a monster, you can do this after if (WHO-> gettypeid () = typeid_player ).ArticleAs long as it is determined that the player is under the attack, for example:
Quote:
If (WHO-> gettypeid () = typeid_player) \ indicates whether the ID is an attacker.
{
Docast (WHO, 3110); \ this way, you can determine that the player is using a fireball attack.
}
Else
{
Dogohome (); \ if not, let the monster run back to his birth point
}
Of course, it is not a good thing to allow monsters to continuously put magic on them. You can obtain the blood and magic volume of monsters and use this simple rule to put magic on them.
Quote:
If (WHO-> gettypeid () = typeid_player) \ determine whether the attacker is a player
{Uint32chealth = m_creature-> gethealth () ;\\ get the current volume of monsters
Uint32cmaxhealth = m_creature-> getmaxhealth () ;\\ get the maximum volume of monsters
Uint32cpower = m_creature-> getpower (power_mana); \ get the current magic volume of monsters
Uint32cmaxpower = m_creature-> getmaxpower (power_mana); \ get the maximum magic volume of monsters
If (cpower)> (cmaxpower * 0.8) \ can you see it? If the current magic volume is greater than the maximum magic volume by 0.8, that is, more than 80%, execute the following script. What is the following? View by yourself
{
Docast (WHO, 3110); \ generates a fireball attack
}
Else \ if not, if the above judgment does not match, the attack is not a player, then it will not be released. Execute the following script.
{
Dogohome (); \ Run back to your birth point
}
}
Of course, it can also be combined to determine, such as the strange HP to the total number of 80%, while the magic is larger than the total number of 80%.
Quote:
If (chealth <(cmaxhealth * 0.8) & (cpower> (cmaxpower * 0.8) \ blame the current HP is less than 80% of the total HP, And the magic is greater than 80% of the total HP
If (chealth <(cmaxhealth * 0.5) & (chealth> (cmaxhealth * 0.3) \ blame the current HP for less than 50%, but greater than 30%, that is, during the period from 50% to 30%
Let's write a complete one and stop translating it. After reading the above translation, I think I have really failed.
Quote:
# Include ".../../SC _defines.h"
Structmangos_dll_decldragonmmai: publicscriptedai
{
Dragonmmai (CREATURE * C): scriptedai (c ){}
Voidattackstart (Unit * Who)
{
If (m_creature-> getvictim () = NULL)
{
Docast (WHO, 3110 );
If (WHO-> gettypeid () = typeid_player)
{
Uint32chealth = m_creature-> gethealth ();
Uint32cmaxhealth = m_creature-> getmaxhealth ();
Uint32cpower = m_creature-> getpower (power_mana );
Uint32cmaxpower = m_creature-> getmaxpower (power_mana );
If (chealth <(cmaxhealth * 0.99) & (chealth> (cmaxhealth * 0.65 )))
{
If (cmaxpower) <(cmaxpower * 0.8 ))
{
M_creature-> say ("Dark! ", Lang_universal );
Docast (WHO, 26029 );
}
Else
{
Dogohome ();
}
Dostartattack (WHO );
}
}
}
}
};
Creatureai * getai_dragonmm (CREATURE * _ creature)
{
Returnnewdragonmmai (_ creature );
}
Voidaddsc_dragonmm ()
{
Script * newscript;
Newscript = newscript;
Newscript-> name = "dragonmm ";
Newscript-> getai = getai_dragonmm;
M_scripts [nrscripts ++] = newscript;
}
Do you know how to write it? Okay, open. net2003, and then open the mangos solution. Of course, the script code should be integrated. Then, click Ai In the scripts of the script project on the right side, right-click the AI folder, and right-click it. Then, add a new item, and set the location to a new name, click the C ++ file (*. CPP ). Then add your code.
After writing AI, you must add your ai Script Name in script \ scriptmgr. cpp; otherwise, the script cannot be loaded.
Find
Quote:
// Creatureai
Externvoidaddsc_kobold ();
Add the following code below:
Quote:
Externvoidaddsc_dragonmm ();
Find again
Quote:
// Creatureai
Addsc_kobold ();
Add the following code below:
Quote:
Addsc_dragonmm ();
Of course, the script name can be changed at will, as long as you change it.
Okay, and then compile. As long as the syntax is correct, it will be okay. Eat French fries, drink cola, compile and put it back into mangos. Then, go to MySQL to open the mangos database, go to creature_template, find the blame for adding the script, and then add your script name in the last line of it. OK. Try the game.
Now there are two major problems with the use of scripts to put the blame spell. One is that the magic direction of the monster is wrong, and the other is that some people use the skills that are okay. But little DIY meets your own desires.
Homework: compile more than one monster that will release the spell. It is required that different magic values can be released in the case that HP is 100%-80%, 80%-60%, 60%-20%, and-respectively, if your magic value is less than 50%, it will not be cast.
Class!
------------------------------------------------------------------------------