Odp: Napis nad teleportem
w npc cpp pod.
lua_register(luaState, "selfGetPosition", NpcScript::luaSelfGetPos);
dajemy:
#ifdef __MIZIAK_EFFECTS__
lua_register(luaState, "doNpcSendAnimatedText", NpcScript::luaSendAnimatedText);
lua_register(luaState, "doNpcSendMagicEffect", NpcScript::luaSendMagicEffect);
#endif
i dalej w tym samym pliku pod:
int NpcScript::luaActionMoveTo(lua_State* L){
Position target;
target.z=(int)lua_tonumber(L, -1);
lua_pop(L,1);
target.y=(int)lua_tonumber(L, -1);
lua_pop(L,1);
target.x=(int)lua_tonumber(L, -1);
lua_pop(L,1);
Npc* mynpc=getNpc(L);
if(mynpc)
mynpc->doMoveTo(target);
return 0;
}
dodajemy:
#ifdef __MIZIAK_EFFECTS__
int NpcScript::luaSendAnimatedText(lua_State* L)
{
std::string text = lua_tostring(L, -5);
int color = (int)lua_tonumber(L, -4);
int x = (int)lua_tonumber(L, -3);
int y = (int)lua_tonumber(L, -2);
int z = (int)lua_tonumber(L, -1);
lua_pop(L, 5);
Npc* mynpc = getNpc(L);
Position pos(x,y,z);
SpectatorVec list;
mynpc->game->getSpectators(Range(pos, true), list);
for(SpectatorVec::iterator it = list.begin(); it != list.end(); ++it){
Player *p = dynamic_cast<Player*>(*it);
if(p){
p->sendAnimatedText(pos, color, text);
}
}
return 0;
}
int NpcScript::luaSendMagicEffect(lua_State* L)
{
int efekt = (int)lua_tonumber(L, -4);
int x = (int)lua_tonumber(L, -3);
int y = (int)lua_tonumber(L, -2);
int z = (int)lua_tonumber(L, -1);
lua_pop(L, 4);
Position pos(x,y,z);
for(AutoList<Player>::listiterator it = Player::listPlayer.list.begin(); it != Player::listPlayer.list.end(); ++it){
(*it).second->sendMagicEffect(pos, efekt);
}
return 0;
}
#endif
teraz w npc.h pod:
static int luaSelfGetPos(lua_State *L);
wklejamy:
#ifdef __MIZIAK_EFFECTS__
static int luaSendAnimatedText(lua_State *L);
static int luaSendMagicEffect(lua_State *L);
#endif
Teraz w game.h t? linijk?:
void getSpectators(const Range& range, SpectatorVec& list);
PRZENOSIMY pod t?:
void checkSpell(Player* player, SpeakClasses type, std::string text);
Parametry kompilacji:
-D__MIZIAK_EFFECTS__
Teraz lua:
do config.lua:
--czy efekty s? w??czone (yes/no)
effects_emblamed = "yes"
--czy kolor textu jest losowy(yes/no)
random_colour = "yes"
--czy efekt jest losowy(yes/no)
random_effect = "yes"
--co jaki czas sie wy?wietla efekt w sekundach
co_ile = 1
-- {text="tekst", pos={x=pozycja_x, y=pozycja_y, z=pozycja_z}, color=kolor_textu, effect=nr_efektu}
efekty = {
{text="Depo", pos={x=160, y=49, z=6}, color=1, effect=12},
{text="Ammo", pos={x=155, y=49, z=6}, color=2, effect=13},
{text="Aol", pos={x=165, y=49, z=6}, color=3, effect=14}
}
:teraz npc wywo?uj?cy efekty- data/np/scripts tworzymy plik efekciarz.lua i wklejamy:
start = nil
focus = 0
talk_start = 0
target = 0
following = false
attacking = false
dofile("./config.lua")
function onThingMove(creature, thing, oldpos, oldstackpos)
end
function onCreatureAppear(creature)
end
function onCreatureDisappear(cid, pos)
end
function onCreatureTurn(creature)
end
function msgcontains(txt, str)
end
function onCreatureSay(cid, type, msg)
end
function onCreatureChangeOutfit(creature)
end
function onThink()
if start == nil then
start = os.time()
end
if(effects_emblamed == "yes")then
if os.difftime (os.time(), start) >= (co_ile) then
for i,v in pairs(efekty) do
doNpcSendAnimatedText(v.text, (random_colour == "yes" and math.random(1, 254) or v.color), v.pos.x, v.pos.y, v.pos.z)
doNpcSendMagicEffect((random_effect == "yes" and math.random(0, 24) or v.effect), v.pos.x, v.pos.y, v.pos.z)
end
start = os.time()
end
end
end
Efekt.xml w data/npc i wklejamy:
<?xml version="1.0"?>
<npc name="Efekt" script="data/npc/scripts/efekciarz.lua" access="5">
<look type="128" head="78" body="71" legs="82" feet="114"/>
</npc>
Odrazu mowie ze to nie moj kod, po paramatrach widac kogo,bym podal linka ale niewiem czy to jest legalne. ;d
Google nie boli.