Jump to content
  • 0

clone script (item)


miczster

Question


  • Group:  Members
  • Topic Count:  40
  • Topics Per Day:  0.01
  • Content Count:  275
  • Reputation:   7
  • Joined:  10/08/12
  • Last Seen:  

I have a sample script (dota rune, which enables random buffs when passed by)
 

//http://rathena.org/board/topic/57784-request-dota-runes/page__fromsearch__1
guild_vs5,1,1,5    script    Runes    1129,2,2,{
dispbottom "Walkthrough to get Runes.";
end;
 
OnTouch:
    switch( .Runes ){
        Case 1:
            sc_start SC_INCATKRATE,( .Duration * 1000 ),100;
            sc_start SC_INCMATKRATE,( .Duration * 1000 ),100;
            break;
        Case 2:
            skill "AS_CLOAKING",10,1;
            sc_start SC_CLOAKING,( .Duration * 1000 ),10;
            break;
        Case 3:
            sc_start4 SC_REGENERATION,( .Duration * 1000 ),-10,1,0,0;
            break;
        Case 4:
            getmapxy( .@Map$,.@X,.@Y,0,strcharinfo(0) );
            clone .@Map$,.@X,.@Y,"",getcharid(0),getcharid(0),"",1,.Duration;
            clone .@Map$,.@X,.@Y,"",getcharid(0),getcharid(0),"",1,.Duration;
            break;
        Case 5:
            sc_start SC_SpeedUp1,( .Duration * 1000 ),0;
            break;
        default: end;
    }
    announce "[ "+strcharinfo(0)+" ] has gained "+.Names$[.Runes]+".",bc_self,0x00FF00;
    hideonnpc strnpcinfo(0);
    delwaitingroom;
    set .Runes,0;
    set .RuneDelay,gettimetick(2) + .Duration;
    while( .RuneDelay > gettimetick(2) ) sleep2 1000;
    
OnInit:
// Runes Duration in Seconds
set .Duration,30;
 
// Name of Each Runes.
setarray .Names$[1],
                "Double Damage",    //    2 x ATK Rate
                "Invisibility",        //    Cloaking
                "Regeneration",        //    HP / SP Regeneration
                "    Clone",        //    Create 2 Clones
                "    Haste";        //    Improve Movement Speed
            
// Random Coordinate where NPC will Shown Again
setarray .CoordinateX[0],33,52,67,51;
setarray .CoordinateY[0],49,70,47,55;
 
sc_end SC_CLOAKING;
sc_end SC_REGENERATION;
set .Random,rand( getarraysize( .CoordinateX ) );
movenpc strnpcinfo(0),.CoordinateX[ .Random ],.CoordinateY[ .Random ];
hideoffnpc strnpcinfo(0);
if( !.Runes ) set .Runes,rand( 1,( getarraysize( .Names$ ) - 1 ) );
if( .Runes ) waitingroom "   "+.Names$[.Runes],0;
end;
}

 
however I want something like that as an equipment autobonus but I don't know if its possible without source modification.
Is there a build-in code something like that for eqs and if so may I ask how/an example? THX n ADvance !!!

Edited by miczster
Code tag.
Link to comment
Share on other sites

22 answers to this question

Recommended Posts


  • Group:  Forum Moderator
  • Topic Count:  33
  • Topics Per Day:  0.01
  • Content Count:  1268
  • Reputation:   382
  • Joined:  02/03/12
  • Last Seen:  

I think PCkillEvent applies to killing both players and mobs, right? I was thinking of making a separate rate against players...

 

PC = "Player Character" will only effect when players are killed. :)

-	script	Mirage	-1,{
OnNPCKillEvent:
	if(rand(1,.npcpercent)-1||!@m_Eq) end;
	getmapxy( .@Map$,.@X,.@Y,0,strcharinfo(0) );
	clone .@Map$,.@X,.@Y,"Mirage::OnCloneDeath",getcharid(0),getcharid(0),14261,0,30;
	end;

OnPCKillEvent:
	if(rand(1,.pcpercent)-1||!@m_Eq) end;
	getmapxy( .@Map$,.@X,.@Y,0,strcharinfo(0) );
	clone .@Map$,.@X,.@Y,"Mirage::OnCloneDeath",getcharid(0),getcharid(0),14261,0,30;
	end;

OnCloneDeath:
	charcommand "#heal "+strcharinfo(0)+" -9999";
	end;

OnInit:
	set .pcpercent,50; // Player Percent 1=1% 100=100%
	set .npcpercent,20; // Non-player Character 1=1% 100=100%
	end;
}
  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  23
  • Topics Per Day:  0.01
  • Content Count:  127
  • Reputation:   36
  • Joined:  01/21/13
  • Last Seen:  

You can use a function and call it within the item script.

 

{ callfunc "MyFunction" },{ },{ }

 

function    script    MyFunction    {

    // Insert code that would be invoked when equipment is worn

}
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  40
  • Topics Per Day:  0.01
  • Content Count:  275
  • Reputation:   7
  • Joined:  10/08/12
  • Last Seen:  

ohh...so Via you mean I'll replace that // Insert code that would be invoked when equipment is worn to my Case 4 statements??

 

I also want it to be an autobonus like say 5% chance to make an illusion that last for 5 secs.

Edited by miczster
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  23
  • Topics Per Day:  0.01
  • Content Count:  127
  • Reputation:   36
  • Joined:  01/21/13
  • Last Seen:  

Yes; just make sure to add return to the end of your function.



I also want it to be an autobonus like say 5% chance to make an illusion that last for 5 secs.

 

I'm not sure what you mean by "illusion".

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  40
  • Topics Per Day:  0.01
  • Content Count:  275
  • Reputation:   7
  • Joined:  10/08/12
  • Last Seen:  

what I meant illusion is a clone...hehe sorry bout that

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  23
  • Topics Per Day:  0.01
  • Content Count:  127
  • Reputation:   36
  • Joined:  01/21/13
  • Last Seen:  


getmapxy( .@Map$,.@X,.@Y,0,strcharinfo(0) );

            clone .@Map$,.@X,.@Y,"",getcharid(0),getcharid(0),"",1,5000;

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  81
  • Topics Per Day:  0.02
  • Content Count:  1654
  • Reputation:   583
  • Joined:  08/09/12
  • Last Seen:  

You have to create your own 'custom autobonus' in the source file, because I don't know any other script command that could check if a player is attacking except by using Autobonus..

 

Ooorrr... by using OnNPCKillEvent label, so whenever you kill a monster, (plus OnPCKillEvent label if you want it to be also active when you kill a player too), you have a chance (for example 5%) to clone yourself, but it can't happen when you're attacking, only happens after a monster dies. But at least it would be sufficient to create lots of clones by using this way /meh

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  40
  • Topics Per Day:  0.01
  • Content Count:  275
  • Reputation:   7
  • Joined:  10/08/12
  • Last Seen:  

@Via u mean like this?

 

-------------------------------------------------------------------------------------------

function    script    Mirage   {
OnNPCKillEvent:
  getmapxy( .@Map$,.@X,.@Y,0,strcharinfo(0) );
  clone .@Map$,.@X,.@Y,"",getcharid(0),getcharid(0),"",1,30;

 

return;

}

-------------------------------------------------------------------------------------------

 

but how do I apply it in an item_bonus like calling the function(Mirage) with 5% chance when attacking

Edited by miczster
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  40
  • Topics Per Day:  0.01
  • Content Count:  275
  • Reputation:   7
  • Joined:  10/08/12
  • Last Seen:  

You have to create your own 'custom autobonus' in the source file, because I don't know any other script command that could check if a player is attacking except by using Autobonus..

 

Ooorrr... by using OnNPCKillEvent label, so whenever you kill a monster, (plus OnPCKillEvent label if you want it to be also active when you kill a player too), you have a chance (for example 5%) to clone yourself, but it can't h

 

 

You can use a function and call it within the item script.

 

 

{ callfunc "MyFunction" },{ },{ }

 

 

function    script    MyFunction    {

    // Insert code that would be invoked when equipment is worn

}

 

 

appen when you're attacking, only happens after a monster dies. But at least it would be sufficient to create lots of clones by using this way

I combined what Via and nanakiwurtz said and the result is:

post-8638-0-61245200-1365066482_thumb.jpg post-8638-0-45345000-1365066525_thumb.png

it doesnt seem to trigger putting the callfunc in {script}{}{} with onnpckillevent and it only makes illusion(immobile one with -1%hp) with the error on the right...

 

when I placed the callfunc in {}{script}{} instead of {script}{}{}...no errors and it works but I have to unequip then equip it again to summon 1 clone...using the function above this post

Edited by miczster
Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  33
  • Topics Per Day:  0.01
  • Content Count:  1268
  • Reputation:   382
  • Joined:  02/03/12
  • Last Seen:  

{ if(!rand(1,20)-1){ doevent "Mirage::OnNPCKillEvent"; } } , { set @delay,(gettimetick(0)+5000); }, {  }
-	script	Mirage	-1,{
OnNPCKillEvent:
	if(@delay>gettimetick(0)) end;
	getmapxy( .@Map$,.@X,.@Y,0,strcharinfo(0) );
	clone .@Map$,.@X,.@Y,"Mirage::OnCloneDeath",getcharid(0),getcharid(0),"",1,30;
	end;

OnCloneDeath:
	charcommand "#heal "+strcharinfo(0)+" -9999";
	end;
}
Something like this maybe? I know some labels don't work inside functions like OnTimer I'm not sure if OnNPCKillEvent was the same way, so I just made it into an npc. I added a delay so that people can't just equipped it and unequipped it to try and spawn clones.

100/5=20

1,20 is roughly 5% chance.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  40
  • Topics Per Day:  0.01
  • Content Count:  275
  • Reputation:   7
  • Joined:  10/08/12
  • Last Seen:  

Thx for this Skorm. I tested it and I found out that:

1. the script summons a HP(-1%) copy of the character each time you tele to a new map or if you change one equipment (including the blinking eyes(eq with the script))

2. the mapserver tells the same error as above when a -1% clone is summoned [get_percentage():division by zero!(A=0,B=0)]

3. the script for the equipment works but doesnt trigger on random chances, it always summon another clone everytime I kill a mob.

post-8638-0-26139500-1365086929_thumb.jpg

Edited by miczster
Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  33
  • Topics Per Day:  0.01
  • Content Count:  1268
  • Reputation:   382
  • Joined:  02/03/12
  • Last Seen:  

{ if(!rand(1,20)-1){ doevent "Mirage::OnNPCKillEvent"; } } , { set @delay,(gettimetick(0)+5000); }, {  }
-	script	Mirage	-1,{

OnNPCKillEvent:

if(@delay>gettimetick(0)||rand(1,20)-1) end;

getmapxy( .@Map$,.@X,.@Y,0,strcharinfo(0) );

clone .@Map$,.@X,.@Y,"Mirage::OnCloneDeath",getcharid(0),getcharid(0),14261,0,30;

end;

OnCloneDeath:

charcommand "#heal "+strcharinfo(0)+" -9999";

end;

}

I hadn't set the random condition for the OnNPCKillEvent: because I didn't know you wanted it. This should work and I found a different value for the flag that might fix your -1% hp problem.
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  40
  • Topics Per Day:  0.01
  • Content Count:  275
  • Reputation:   7
  • Joined:  10/08/12
  • Last Seen:  

The updated script is better because the chances work but sometimes when I warp to a new map(mostly in towns)I still summon -1%HP clones and they dont disappear until the character relogs(doesnt duplicate anymore if a -1% is currently in the same map though)......

I wanna ask why there is rand(1,20) in both the eq script and in the npc script( I think it makes it pass through two 5% chances b4 it triggers)

I also wanna ask what is 14261 so I can understand a bit how the script is running,..

Edited by miczster
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  40
  • Topics Per Day:  0.01
  • Content Count:  275
  • Reputation:   7
  • Joined:  10/08/12
  • Last Seen:  

{ if(!rand(1,20)-1){ doevent "Mirage::OnNPCKillEvent"; } } , { set @delay,(gettimetick(0)+5000); }, {  }
-	script	Mirage	-1,{
OnNPCKillEvent:
	if(@delay>gettimetick(0)||rand(1,20)-1) end;
	getmapxy( .@Map$,.@X,.@Y,0,strcharinfo(0) );
	clone .@Map$,.@X,.@Y,"Mirage::OnCloneDeath",getcharid(0),getcharid(0),14261,0,30;
	end;

OnCloneDeath:
	charcommand "#heal "+strcharinfo(0)+" -9999";
	end;
}
I hadn't set the random condition for the OnNPCKillEvent: because I didn't know you wanted it. This should work and I found a different value for the flag that might fix your -1% hp problem.

also ...making it a script instead of a function makes it applicable to all characters (even without the eq) which I do not want to happen

Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  33
  • Topics Per Day:  0.01
  • Content Count:  1268
  • Reputation:   382
  • Joined:  02/03/12
  • Last Seen:  

also ...making it a script instead of a function makes it applicable to all characters (even without the eq) which I do not want to happen

Right -.-* Try triggering an event label inside of a function.

If you want the script applicable only to those who've equipped the item, add a temporary character variable.

{ } , { set @m_Eq,1; }, { set @m_Eq,0; }
-	script	Mirage	-1,{
OnNPCKillEvent:
	if(rand(1,20)-1||!@m_Eq) end;
	getmapxy( .@Map$,.@X,.@Y,0,strcharinfo(0) );
	clone .@Map$,.@X,.@Y,"Mirage::OnCloneDeath",getcharid(0),getcharid(0),14261,0,30;
	end;

OnCloneDeath:
	charcommand "#heal "+strcharinfo(0)+" -9999";
	end;
}
Really I'm not sure if the item script is called every time the character attacks, but I do know that's why it randomly spawns clones when you warp. Edited by Skorm
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  40
  • Topics Per Day:  0.01
  • Content Count:  275
  • Reputation:   7
  • Joined:  10/08/12
  • Last Seen:  

also ...making it a script instead of a function makes it applicable to all characters (even without the eq) which I do not want to happen

Right -.-* Try triggering an event label inside of a function.

If you want the script applicable only to those who've equipped the item, add a temporary character variable.

{ } , { set @m_Eq,1; }, { set @m_Eq,0; }
-	script	Mirage	-1,{
OnNPCKillEvent:
	if(rand(1,20)-1||!@m_Eq) end;
	getmapxy( .@Map$,.@X,.@Y,0,strcharinfo(0) );
	clone .@Map$,.@X,.@Y,"Mirage::OnCloneDeath",getcharid(0),getcharid(0),14261,0,30;
	end;

OnCloneDeath:
	charcommand "#heal "+strcharinfo(0)+" -9999";
	end;
}
Really I'm not sure if the item script is called every time the character attacks, but I do know that's why it randomly spawns clones when you warp.

ok ill test this...the odd thing is if I used the script type(only for those who dont have eq) it works perfectly(no more -1 illu) but when I used the function type it behaves badly

Edited by miczster
Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  33
  • Topics Per Day:  0.01
  • Content Count:  1268
  • Reputation:   382
  • Joined:  02/03/12
  • Last Seen:  

Hmm I'm not sure I could probably test it tomorrow sometime.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  40
  • Topics Per Day:  0.01
  • Content Count:  275
  • Reputation:   7
  • Joined:  10/08/12
  • Last Seen:  

Hmm I'm not sure I could probably test it tomorrow sometime.

Just tested it earlier...It WORKS (no more -1%hp clones) but I have some debug/errors on the server manager (idk if theyre harmful for other players)

post-8638-0-05504500-1365924339_thumb.png

 

Hmm I'm not sure I could probably test it tomorrow sometime.

I tried replicating the debug/error and I found out that it happens when you log out and there are still existing clones in game...IDK if its harmful but so far it ddnt crash the game so far...

 

How do I apply it when killing players?

Edited by miczster
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  81
  • Topics Per Day:  0.02
  • Content Count:  1654
  • Reputation:   583
  • Joined:  08/09/12
  • Last Seen:  

Use 'OnPCKillEvent'

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  40
  • Topics Per Day:  0.01
  • Content Count:  275
  • Reputation:   7
  • Joined:  10/08/12
  • Last Seen:  

I think PCkillEvent applies to killing both players and mobs, right? I was thinking of making a separate rate against players...

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  40
  • Topics Per Day:  0.01
  • Content Count:  275
  • Reputation:   7
  • Joined:  10/08/12
  • Last Seen:  

I think PCkillEvent applies to killing both players and mobs, right? I was thinking of making a separate rate against players...

 

PC = "Player Character" will only effect when players are killed. :)

-	script	Mirage	-1,{
OnNPCKillEvent:
	if(rand(1,.npcpercent)-1||!@m_Eq) end;
	getmapxy( .@Map$,.@X,.@Y,0,strcharinfo(0) );
	clone .@Map$,.@X,.@Y,"Mirage::OnCloneDeath",getcharid(0),getcharid(0),14261,0,30;
	end;

OnPCKillEvent:
	if(rand(1,.pcpercent)-1||!@m_Eq) end;
	getmapxy( .@Map$,.@X,.@Y,0,strcharinfo(0) );
	clone .@Map$,.@X,.@Y,"Mirage::OnCloneDeath",getcharid(0),getcharid(0),14261,0,30;
	end;

OnCloneDeath:
	charcommand "#heal "+strcharinfo(0)+" -9999";
	end;

OnInit:
	set .pcpercent,50; // Player Percent 1=1% 100=100%
	set .npcpercent,20; // Non-player Character 1=1% 100=100%
	end;
}

 

WOW thx so much Skorm...Solved!

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  4
  • Reputation:   0
  • Joined:  06/09/13
  • Last Seen:  

Posted · Hidden by Capuche, June 17, 2013 - Post the same thing anywhere
Hidden by Capuche, June 17, 2013 - Post the same thing anywhere

How to make any equipment summon a monster (@summon)  when hp is low, etc...
For example: Summon Dagger (poring will be summoned to help you)
Because i cant find a working one, 
i tried using autoscriptbonus and it doesnt not work!

 

Thanx ! !

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...