What's new

-Tibia 8.40 Agresywne potwory w Tibi

Status
Not open for further replies.

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?:
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);
}
na
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);
}
Wyszukaj we wszystkich plikach (ctrl+f)
PHP:
 monster->setSpawn(this);
i dodaj nad tym
PHP:
   CreatureEventList createThing = monster->getCreatureEvents(CREATURE_EVENT_LOGIN);
	for(CreatureEventList::iterator it = createThing.begin(); it != createThing.end(); ++it)
	(*it)->executeLogin(monster);
W Creatureevent.cpp i creatureevent.h
zamie?
PHP:
uint32_t CreatureEvent::executeLogin(player* player)
na
PHP:
uint32_t CreatureEvent::executeLogin(Creature* player)
Teraz przebuduj projekt: Rebuild All
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"/>
data/creaturescripts/scripts/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
Nast?pnie w data/creaturescripts/scripts/monsterlogin.lua
daj:
PHP:
function onLogin(cid)
if(isMonster(cid) == false) then
return true
end
doCreatureSetStorage(cid, 500, 1)
return true
end
Potem w data/creaturescripts/scripts/login.lua dodaj mi?dzy
rejestry:
PHP:
registerCreatureEvent(cid, "atak")
Gdy juz to zrobisz w pliku .xml danego pokemona zaraz pod </flags> dodaj
PHP:
<script>
		<event name="MonsterLogin"/>
		<event name="atak"/>
</script>
Gdy juz to zrobisz w pliku .xml danego pokemona zaraz pod </flags> dodaj
 

Raa

Senior User
Joined
Aug 9, 2009
Messages
715
Reaction score
50
Age
29
Odp: Agresywne potwory w Tibi

Jakim prawem to w og?le ma mo?liwo?? dzia?ania?

Zerujesz osob? ?ledzon?, zwracasz pust? warto??.
Potem definiujesz u?ycie zdarzenia onLogin dla potworka, kt?ry si? spawnuje. I piszesz skrypt, kt?ry nadaje im storage 500 o warto?ci 1, a przy atakowaniu zmieniasz t? warto?? na -1.
I jak to ma sprawi?, ?e on zacznie ci? atakowa??
 
Status
Not open for further replies.
Top