Post Pacific

Post Pacific (https://postpacific.loc-online.com/index.php)
-   Темы без сохранившегося раздела (https://postpacific.loc-online.com/forumdisplay.php?f=10001)
-   -   Some question on nasc... And whole ai scripting... (https://postpacific.loc-online.com/showthread.php?t=3214)

drzoom 02.02.2006 06:28

Some question on nasc... And whole ai scripting...
 
HI there.

This is my basic model of sa crystal level up system.

Code:

class mob_sa_quest_st_1 : default_npc
{
handler:
        EventHandler SPELLED(speller, skill_name_id, i0)
        {
                i0=0;
                if(skill_name_id == @s_soul_crystal)
                {
                        i0=1;
                }
        }
       
        EventHandler ATTACKED(attacker, damage, i0, i1)
        {
                i1=0;
                if(damage>myself.sm.hp && i0==1)
                {
                        i1=1;
                }
                i0=0;
                       
        }
        EventHandler MY_DYING(i1)
        {       
                c1 = GetLastAttacker();
                if(i1==1)
                {
                        if(OwnItemCount(c1, @red_soul_crystal_0)>1)
                        {
                                ShowSystemMessage(c1, 977);
                        }
                        if(OwnItemCount(c1, @red_soul_crystal_0)==1)
                        {
                                DeleteItem1(c1, @red_soul_crystal_0,1);
                                GiveItem1(c1, @red_soul_crystal_1,1);
                                ShowSystemMessage(c1, 974);
                        }
                }
        }
}

But can a question is this:
CAN I OPERATE WITH i0 and i1 IN SUCH CONDITION?

Thanks again.

RmzVoid 02.02.2006 06:52

no, use myself.i_ai0
but if many players spelled at one time - last player's spell will be stored in NPC memory.
And you wrong, you should store speller id , and in MY_DYING give item not to last attacker, you mast give item to stored speller.

class mob_sa_quest_st_1 : default_npc
{
handler:
EventHandler CREATED()
{
myself.i_ai0 = 0;
myself.c_ai0 = 0;
}

EventHandler SPELLED(speller, skill_name_id)
{
if(skill_name_id == @s_soul_crystal && myself.sm.hp <= myself.sm.maxhp/2)
{
myself.c_ai0=speller;
}
}

EventHandler ATTACKED(attacker, damage)
{
//don't need anything here
//just
super;
}
EventHandler MY_DYING()
{
c1 = GetLastAttacker();
if( myself.c_ai0 !=0 )
{
if(OwnItemCount(myself.c_ai0, @red_soul_crystal_0)>1)
{
ShowSystemMessage(myself.c_ai0, 977);
}
if(OwnItemCount(myself.c_ai0, @red_soul_crystal_0)==1)
{
DeleteItem1(myself.c_ai0, @red_soul_crystal_0,1);
GiveItem1(myself.c_ai0, @red_soul_crystal_1,1);
ShowSystemMessage(myself.c_ai0, 974);
}
}
}
}

RmzVoid 02.02.2006 06:56

someone say on forum that event handler SPELLED not applies to spell from item such as Soul Crystal

drzoom 02.02.2006 06:56

Thanks, rmzvoid, but... Why EventHandler ATTACKED is empty?
How would we know that after spell there will be final shot?

RmzVoid 02.02.2006 06:57

as i know NPC may dye from anyone, the main part is to spell NPC

RmzVoid 02.02.2006 06:59

anyway you not need use ATTACKED.
Just in MY_DYING

...
if ( myself.c_ai0 == GetLastAttacker() )
{
}
...

drzoom 02.02.2006 07:01

Слушай, а стукни в асю плиз. Я тебя еще немного помучаю:)
203833915
Заранее спасибо:)

toolpunk 02.02.2006 18:12

Quote:

Originally Posted by drzoom
Thanks, rmzvoid, but... Why EventHandler ATTACKED is empty?
How would we know that after spell there will be final shot?

its not empty...
theres a nice little
super;
in it ;)
which will load the standard attacked handler for default_npc if i remember correctly...

drzoom 02.02.2006 19:03

I understood, thks.


All times are GMT. The time now is 15:40.