PDA

View Full Version : AI Help


Thalone
18.07.2007, 21:58
ok so im making a seal stone converter. My question is now:

How do i get the output of this

push_const 6360
func_call 184680579 // func[OwnItemCount]

into a separate variable. such as "blue1"

Thanks for the help

Forcer
18.07.2007, 22:10
i don't understand.
You mean push_const 6360 as blue1?

Thalone
18.07.2007, 22:15
Im trying to convert this:

class ancient_trader : citizen {
handler:
EventHandler MENU_SELECTED(ask, i0, i1, i2, i3, reply, talker) {
if ((ask == 1) && (reply == 1)) {
i1 = OwnItemCount(talker, 6360);
i2 = OwnItemCount(talker, 6361);
i3 = OwnItemCount(talker, 6362);
i0 = (((i1*3)+(i2*5))+(i3*10));
if (i0 == 0) ShowPage(talker, "seal_stone_none.htm");
else {
GiveItem1(talker, @adena_of_ancient, i0);
DeleteItem1(talker, 6360, i1);
DeleteItem1(talker, 6361, i2);
DeleteItem1(talker, 6362, i3);
ShowPage(talker, "seal_stone_thx.htm");
}
}
}
}

Sauron
19.07.2007, 00:15
into what?

FidoW
19.07.2007, 02:07
ha... i know i saw that before...

https://postpacific.loc-online.com/forums/showthread.php?t=4426&highlight=seal_stone_none

Thalone
19.07.2007, 02:40
into C4 AI...
i cant figure out how to do this:
"i1 = OwnItemCount(talker, 6360);"
basicly use the function OwnItemCount and return the results into i1
Im horrible at AI so im using HF's guide but im stuck at that point

Sauron
19.07.2007, 03:19
ahh you want the compiled code.

"i1 = OwnItemCount(talker, 6360);" is something like this...

~~~~ this is C1 ~~~~

push_event
push_const 196 // i1
add
push_reg_sp
fetch_i
shift_sp 1
push_event
push_const 32 // talker
add
fetch_i
push_const 6360
func_call 81 // OwnItemCount
shift_sp -2
assign
shift_sp -1

~~~~ and this is C4 ~~~~

push_event
push_const 264 // i1
add
push_reg_sp
fetch_i
push_event
push_const 704 // myself
add
fetch_i
push_event
push_const 40 // talker
add
fetch_i
push_const 6360
func_call 184680579 // OwnItemCount
shift_sp -2
assign4
shift_sp -1

Thalone
19.07.2007, 03:57
awesome, thank you! 1 more question and i should be done... How exactly do i do arithmetic in AI? Im trying to follow HF's AI guide in the sticky section but unfortunately he doesnt add something like this.

this is what i need to do:
i0 = (((i1*3)+(i2*5))+(i3*10));

this is what im thinking it would look kind of like:

push_event
push_const 260 // i0
add
push_reg_sp
fetch_i
push_event
push_const 264 // i1
push_const 3
mul

but i dont know what comes next... shift_sp -2 ?

Thanks for the help!

This is what I have so far:


class 1 ancient_trader : citizen
parameter_define_begin
string fnHi "aa_guy.htm"
string fnDontHave "aa_guy_none.htm"
string fnComplete "aa_guy_done.htm"
parameter_define_end
handler 3 12 // TALKED
variable_begin
"talker"
"myself"
"_choiceN"
"_code"
"_from_choice"
variable_end

push_event // myself
push_const 704
add
fetch_i
push_event // talker
push_const 40
add
fetch_i
push_parameter fnHi
func_call 184680516 // func[ShowPage]
shift_sp -2
shift_sp -1
handler_end

handler 32 0 // MENU_SELECTED
variable_begin
"talker"
"myself"
"i0"
"i1"
"i2"
"i3"
"i4"
"i5"
"reply"
"_choiceN"
"_code"
"_from_choice"
variable_end

push_event // reply
push_const 164
add
fetch_i4
push_const 1
equal
branch_false L1


push_event
push_const 264 // i1
add
push_reg_sp
fetch_i
push_event
push_const 704 // myself
add
fetch_i
push_event
push_const 40 // talker
add
fetch_i
push_const 6360
func_call 184680579 // OwnItemCount
shift_sp -2
assign4
shift_sp -1

push_event
push_const 268 // i2
add
push_reg_sp
fetch_i
push_event
push_const 704 // myself
add
fetch_i
push_event
push_const 40 // talker
add
fetch_i
push_const 6361
func_call 184680579 // OwnItemCount
shift_sp -2
assign4
shift_sp -1

push_event
push_const 272 // i3
add
push_reg_sp
fetch_i
push_event
push_const 704 // myself
add
fetch_i
push_event
push_const 40 // talker
add
fetch_i
push_const 6362
func_call 184680579 // OwnItemCount
shift_sp -2
assign4
shift_sp -1

push_const 6360
push_const i1
func_call 184746114 // func[DeleteItem1]
shift_sp -2

push_const 6361
push_const i2
func_call 184746114 // func[DeleteItem1]
shift_sp -2

push_const 6362
push_const i3
func_call 184746114 // func[DeleteItem1]
shift_sp -2

push_const 5575
push_const i0
func_call 184746111 // func[GiveItem1]
shift_sp -2

L1
handler_end

class_end

Sauron
19.07.2007, 04:49
you need 2 variables or const and an operator

(((i1*3)+(i2*5))+(i3*10)) would be

i1 3 * i2 5 * + i3 10 * +

push_event // i0
push_const 260
add
push_reg_sp
fetch_i
push_event // i1
push_const 264
add
fetch_i4
push_const 3
mul
push_event // i2
push_const 268
add
fetch_i4
push_const 5
mul
add
push_event // i3
push_const 272
add
fetch_i4
push_const 10
mul
add
assign4
shift_sp -1


class 1 ancient_trader : citizen
handler 32 202 // MENU_SELECTED
variable_begin
"ask"
"i0"
"i1"
"i2"
"i3"
"reply"
"talker"
"myself"
"_choiceN"
"_code"
"_from_choice"
variable_end

push_event // ask
push_const 160
add
fetch_i4
push_const 1
equal
push_reg_sp
fetch_i
branch_false L3
push_event // reply
push_const 164
add
fetch_i4
push_const 1
equal
and
L3
branch_false L2
L1
push_event // i1
push_const 264
add
push_reg_sp
fetch_i
push_event // myself
push_const 704
add
fetch_i
push_event // talker
push_const 40
add
fetch_i
push_const 6360
func_call 184680579 // func[OwnItemCount]
shift_sp -2
assign4
shift_sp -1
push_event // i2
push_const 268
add
push_reg_sp
fetch_i
push_event // myself
push_const 704
add
fetch_i
push_event // talker
push_const 40
add
fetch_i
push_const 6361
func_call 184680579 // func[OwnItemCount]
shift_sp -2
assign4
shift_sp -1
push_event // i3
push_const 272
add
push_reg_sp
fetch_i
push_event // myself
push_const 704
add
fetch_i
push_event // talker
push_const 40
add
fetch_i
push_const 6362
func_call 184680579 // func[OwnItemCount]
shift_sp -2
assign4
shift_sp -1
push_event // i0
push_const 260
add
push_reg_sp
fetch_i
push_event // i1
push_const 264
add
fetch_i4
push_const 3
mul
push_event // i2
push_const 268
add
fetch_i4
push_const 5
mul
add
push_event // i3
push_const 272
add
fetch_i4
push_const 10
mul
add
assign4
shift_sp -1
push_event // i0
push_const 260
add
fetch_i4
push_const 0
equal
branch_false L5
L4
push_event // myself
push_const 704
add
fetch_i
push_event // talker
push_const 40
add
fetch_i
S1. "seal_stone_none.htm"
push_string S1
func_call 184680516 // func[ShowPage]
shift_sp -2
shift_sp -1
jump L6
L5
push_event // myself
push_const 704
add
fetch_i
push_event // talker
push_const 40
add
fetch_i
push_const 5575
push_event // i0
push_const 260
add
fetch_i4
func_call 184746111 // func[GiveItem1]
shift_sp -3
shift_sp -1
push_event // myself
push_const 704
add
fetch_i
push_event // talker
push_const 40
add
fetch_i
push_const 6360
push_event // i1
push_const 264
add
fetch_i4
func_call 184746114 // func[DeleteItem1]
shift_sp -3
shift_sp -1
push_event // myself
push_const 704
add
fetch_i
push_event // talker
push_const 40
add
fetch_i
push_const 6361
push_event // i2
push_const 268
add
fetch_i4
func_call 184746114 // func[DeleteItem1]
shift_sp -3
shift_sp -1
push_event // myself
push_const 704
add
fetch_i
push_event // talker
push_const 40
add
fetch_i
push_const 6362
push_event // i3
push_const 272
add
fetch_i4
func_call 184746114 // func[DeleteItem1]
shift_sp -3
shift_sp -1
push_event // myself
push_const 704
add
fetch_i
push_event // talker
push_const 40
add
fetch_i
S2. "seal_stone_thx.htm"
push_string S2
func_call 184680516 // func[ShowPage]
shift_sp -2
shift_sp -1
L6
L2
handler_end

class_end

Thalone
19.07.2007, 05:29
You are awesome! Thank you very much!