Lopus
Advanced User
- Joined
- Jun 17, 2011
- Messages
- 206
- Reaction score
- 9
Dzia?anie skryptu:
- Potw?r zaatakuje dopiero wtedy kiedy to gracz zacznie z nim walczy?.
W Creature.cpp zamie?:
na
Wyszukaj we wszystkich plikach (ctrl+f)
i dodaj nad tym
W Creatureevent.cpp i creatureevent.h
zamie?
na
Teraz przebuduj projekt: Rebuild All
przy zwyk?ej kompilacji moze nie zadzialac, koniecznie daj rebuild all.
data\creaturescripts\creaturescripts.xml
dodaj tam linijki:
data/creaturescripts/scripts/atak.lua
Nast?pnie w data/creaturescripts/scripts/monsterlogin.lua
daj:
Potem w data/creaturescripts/scripts/login.lua dodaj mi?dzy
rejestry:
Gdy juz to zrobisz w pliku .xml danego pokemona zaraz pod </flags> dodaj
Gdy juz to zrobisz w pliku .xml danego pokemona zaraz pod </flags> dodaj
- Potw?r zaatakuje dopiero wtedy kiedy to gracz zacznie z nim walczy?.
W Creature.cpp zamie?:
PHP:
void Creature::onAttacking(uint32_t interval)
{
if(!attackedCreature)
return;
CreatureEventList attackEvents = getCreatureEvents(CREATURE_EVENT_ATTACK);
for(CreatureEventList::iterator it = attackEvents.begin(); it != attackEvents.end(); ++it)
{
if(!(*it)->executeAttack(this, attackedCreature) && attackedCreature)
setAttackedCreature(NULL);
}
if(!attackedCreature)
return;
onAttacked();
attackedCreature->onAttacked();
if(g_game.isSightClear(getPosition(), attackedCreature->getPosition(), true))
doAttacking(interval);
}
PHP:
void Creature::onAttacking(uint32_t interval)
{
if(!attackedCreature)
return;
CreatureEventList attackEvents = getCreatureEvents(CREATURE_EVENT_ATTACK);
for(CreatureEventList::iterator it = attackEvents.begin(); it != attackEvents.end(); ++it)
{
if(!(*it)->executeAttack(this, attackedCreature) && attackedCreature)
{
setAttackedCreature(NULL);
setFollowCreature(NULL);
onAttackedCreatureDisappear(true);
return;
}
}
if(!attackedCreature)
return;
if(g_game.isSightClear(getPosition(), attackedCreature->getPosition(), true))
doAttacking(interval);
}
PHP:
monster->setSpawn(this);
PHP:
CreatureEventList createThing = monster->getCreatureEvents(CREATURE_EVENT_LOGIN);
for(CreatureEventList::iterator it = createThing.begin(); it != createThing.end(); ++it)
(*it)->executeLogin(monster);
zamie?
PHP:
uint32_t CreatureEvent::executeLogin(player* player)
PHP:
uint32_t CreatureEvent::executeLogin(Creature* player)
przy zwyk?ej kompilacji moze nie zadzialac, koniecznie daj rebuild all.
data\creaturescripts\creaturescripts.xml
dodaj tam linijki:
PHP:
<event type="login" name="MonsterLogin" event="script" value="monsterlogin.lua"/>
<event type="attack" name="atak" event="script" value="atak.lua"/>
PHP:
function onAttack(cid, target)
if(isMonster(cid)) then
local storage = getCreatureStorage(cid, 500)
if(storage ~= -1) then
return false
end
elseif(isPlayer(cid) and isMonster(target)) then
local storage = getCreatureStorage(target, 500)
if(storage ~= -1) then
doCreatureSetStorage(target, 500, -1)
end
end
return true
end
daj:
PHP:
function onLogin(cid)
if(isMonster(cid) == false) then
return true
end
doCreatureSetStorage(cid, 500, 1)
return true
end
rejestry:
PHP:
registerCreatureEvent(cid, "atak")
PHP:
<script>
<event name="MonsterLogin"/>
<event name="atak"/>
</script>