![]() |
|
|
#1 |
|
Архивный участник
Join Date: May 2005
Posts: 368
|
hello,
i am looking to understand how func[rand] works and how to use it with conditions, here the algo i want to do: Select a random integer between 0 and 3 (i dunno if it is correct) if result <=1 goto L1 if result =2 goto L2 if result >=3 goto L3 and here the syntax i suppose i have to use with AI: Code:
L0 push_parameter 3 // 0 to 3 ? 1 to 3 ? func_call 55 // func[Rand] push_const 1 // if result <= 1 less_equal // goto L1 jump L1 push_const 2 // if result = 2 equal // goto L2 jump L2 or push_const 3 // if result >= 3 equal // goto L3 jump L3 or //--------------------------------------- L1 (FUNCTIONS) jump L4 // goto end L2 (FUNCTIONS) jump L4 // end end L3 (FUNCTIONS) jump L4 // end end //--------------------------------------- L4 (EXIT HANDLER) Tx for your help
|
|
|
|
|
#2 |
|
Архивный участник
Join Date: Oct 2005
Posts: 102
|
Code:
//i0=Rand(4) => i0 E [0,3] push_event //i0 push_const 192 add push_reg_sp fetch_i shift_sp 1 push_const 4 func_call 55 //Rand shift_sp -1 assign shift_sp -1 //i0==1? push_event push_const 192 add fetch_i push_const 1 equal branch_false L1 //goto L1 if not_equal // here a code if i0==1 ... L1 ... |
|
|
|
|
#3 |
|
Архивный участник
Join Date: May 2005
Posts: 368
|
can you explain this part please ?
Code:
push_event //i0 push_const 192 add push_reg_sp fetch_i and finally, can i use the following part to call back i0 each time i need to use it in my stack ? Code:
push_event push_const 192 add fetch_i
|
|
|
|
|
#4 |
|
Архивный участник
Join Date: Feb 2005
Posts: 766
|
Amazing how u said u were gone from good but u keep asking for help here lol...
|
|
|
|
|
#5 | |
|
Архивный участник
Join Date: May 2005
Posts: 368
|
Quote:
|
|
|
|
|
|
#6 |
|
Архивный участник
Join Date: Feb 2005
Posts: 766
|
My shit was the truth, and the truth is all the shit u said before. U insult everyone here, remove ur share posts, insult everyone again, say u'll never post here again yet you keep asking for help.
Oh and the fact that this post can help other ppl (wich it can) doesnt explain the fact that u said u never posted here again yet u keep doing so. |
|
|
|
|
#7 |
|
Архивный участник
Join Date: May 2005
Posts: 99
|
stop me if i say something stupid, but why not use nasc, to compile your own ai code with a language that looks like C
|
|
|
|
|
#8 |
|
Архивный участник
Join Date: Nov 2005
Posts: 28
|
strangely, or not so strangely, i agree with metal
=D |
|
|
|
|
#9 | |
|
Архивный участник
Join Date: May 2005
Posts: 368
|
Quote:
|
|
|
|
|
|
#10 |
|
Архивный участник
Join Date: May 2005
Posts: 99
|
It crash only ? strange.
You can found source code example in l2tools. Then you just have to specify the filename of source code to compile in the command line of nasc, like "nasc ai_mmerged.txt" (will produce a ai.obj in same directory) <fr>il plante betement ? bizard. Tu peux trouver le code source de L2 ('prelude' me semble) dans L2Tools. Pour compiler ensuite, suffit de donner le nom du fichier a compiler dans la ligne de commande de nasc, ex : "nasc ai_mmerged.txt" qui produira un ai.obj dans le meme repertoire</fr> |
|
|
|
|
#11 |
|
Архивный участник
Join Date: May 2005
Posts: 368
|
hello,
i tried nasc but it is not very clear for me for the moment then i tried to do something with the old way: Code:
push_event // i0 push_const 192 add push_reg_sp fetch_i shift_sp 1 push_const 3 // [0-2] func_call 55 // Rand shift_sp -1 assign shift_sp -1 L0 push_event push_const 192 add fetch_i push_const 0 // if rand <= 0 less_equal branch_false L1 shift_sp 1 (DO ACTION 0 IF rand <= 0) shift_sp -1 jump L9 // goto end L1 push_event push_const 192 add fetch_i push_const 0 // if rand = 1 equal branch_false L2 shift_sp 1 (DO ACTION 1 IF rand = 1) shift_sp -1 jump L9 // goto end L2 push_event push_const 192 add fetch_i push_const 2 // if rand >= 2 greater_equal branch_false L3 shift_sp 1 (DO ACTION 2 IF rand >= 2) shift_sp -1 jump L9 // goto end L3 L9 // end btw do you know, if it is possible, to do something like: Code:
class my_class : my_parent_class parameter_define_begin int MyVar 0 parameter_define_end handler X push_parameter MyVar // 0 MyVar = Rand[0-9] push_parameter MyVar // Rand[0-9] result handler_end class_end |
|
|
|
|
#12 |
|
Архивный участник
Join Date: Apr 2005
Posts: 357
|
x=Rand(3)
x=0,1,2 |
|
|
|
|
#13 |
|
Архивный участник
Join Date: May 2005
Posts: 368
|
?
in AI language, how do u write that ? tx
|
|
|
|
|
#14 |
|
Архивный участник
Join Date: Oct 2005
Posts: 175
|
hello, i try to do something, i want the following class use randomly 1 of his 3 skills when we attack him:
Code:
class myclass : parent_class parameter_define_begin int SkillPch0 278018 // s_haste2 int SkillPch1 308226 // s_wind_walk2 int SkillPch2 271107 // s_empower3 int NbSkills 2 parameter_define_end handler 1 // ATTACKED variable_begin "attacker" "damage" "i0" "c0" "myself" "_choiceN" "_code" "_from_choice" variable_end ... push_event // i0 push_const 192 add push_reg_sp fetch_i shift_sp 1 push_parameter NbSkills // 2 [0-2] func_call 55 // Rand shift_sp -1 assign shift_sp -1 L18600 push_event // i0 push_const 192 // add // fetch_i // push_const 0 // if i0 <= 0 less_equal branch_false L18601 shift_sp 1 push_parameter SkillPch0 func_call 155 // func[Skill_GetConsumeMP] shift_sp -1 jump L18603 L18601 push_event // i0 push_const 192 // add // fetch_i // push_const 1 // if i0 = 1 equal branch_false L18602 shift_sp 1 push_parameter SkillPch1 func_call 155 // func[Skill_GetConsumeMP] shift_sp -1 jump L18603 L18602 push_event // i0 push_const 192 // add // fetch_i // push_const 2 // if i0 >= 2 greater_equal branch_false L18603 shift_sp 1 push_parameter SkillPch2 func_call 155 // func[Skill_GetConsumeMP] shift_sp -1 jump L18603 L18603 ... handler_end end_class Tx in advance |
|
|
|
|
#15 |
|
Архивный участник
Join Date: Mar 2005
Posts: 1,143
|
Don't use NASC because the headers are different and your AI code will come out messed up. We had this discussion in irc a while ago, and found out the hard way. If you want, you can generate your code and then edit out the faulty header to make it work. Just look at Digital's post on the AI code in the stickies section. :P
The best way is to probably do it by hand. |
|
|
|
|
#16 |
|
Архивный участник
Join Date: May 2005
Posts: 99
|
i use nasc and make some good things, like monster derby track, sevensigns, and stuff that doesnt exist on official server too.
ofcourse, we must replace some number id of functions/handlers, ... but i have make a program to do it, but it's very more useful to code with nasc instead of make ai code |
|
|
| Thread Tools | Search this Thread |
| Display Modes | |
|
|