Hello.
Somebody can help me in new function? The new function must disappear monster when he stand on field.
Here is code.
Actions.Cpp
And actions.h
The script must be look like this
Ye i have function onStepIn.
Thanks and sorry for my bad english ; P...
Somebody can help me in new function? The new function must disappear monster when he stand on field.
Here is code.
Actions.Cpp
Code:
//doMonsterRemoverhealth(uid,health)
lua_register(luaState, "doMonsterRemoverhealth", ActionScript::luaActiondoMonsterRemoverhealth);
Code:
int ActionScript::luaActiondoMonsterRemoverhealth(lua_State *L)
{
//dodoMonsterRemoverhealth(uid,health)
int removerhealth = (int)internalGetNumber(L);
unsigned int cid = (unsigned int)internalGetNumber(L);
ActionScript *action = getActionScript(L);
const KnownThing* tmp = action->GetMonsterByUID(cid);
if(tmp){
Monster *monster = (Monster*)(tmp->thing);
int tmp = monster->health - removerhealth;
if(tmp <= 0){
monster->health = 1;
}
else if(tmp > monster->healthmax){
monster->health = monster->healthmax;
}
else{
monster->health = tmp;
}
monster->sendStats();
SpectatorVec list;
SpectatorVec::iterator it;
action->game->getSpectators(Range(monster->pos,true), list);
for(it = list.begin(); it != list.end(); ++it) {
monster* p = dynamic_cast<Monster*>(*it);
if(p)
p->removerMonsterHealth(monster);
}
}
else{
lua_pushnumber(L, -1);
std::cout << "luadoMonsterRemoverhealth: monster not found" << std::endl;
return 1;
}
lua_pushnumber(L, 0);
return 1;
}
And actions.h
Code:
static int luaActionDoMonsterRemoverhealth(lua_State *L);
The script must be look like this
Code:
function onStepIn(cid, item, frompos, item2, topos)
if item.uid == 11111 then
doMonsterRemoverHealth(cid,99999999)
else
return 0
end
return 1
end
Ye i have function onStepIn.
Thanks and sorry for my bad english ; P...