![]() |
|
|
#7 |
|
Архивный участник
Join Date: Sep 2005
Posts: 1,014
|
The NASC syntax looks like C1... isnt using objects (myself, gg) but in the compiled code is using C4 ids, and in some functions use objects and others not... looks like he was trying to do a mix or whatever...
For those who try to learn... here the correct code.. C1 NASC Code:
class warrior_flee : warrior {
handler:
EventHandler NO_DESIRE() {
AddMoveAroundDesire(40,20);
}
EventHandler ATTACKED(attacker,damage) {
if (Rand(2) == 1) Say("Text1");
else Say("Text2");
AddFleeDesire(attacker,30);
}
}
C1 AI.OBJ Code:
class warrior_flee : warrior handler 0 // NO_DESIRE variable_begin "myself" "_choiceN" "_code" "_from_choice" variable_end shift_sp 1 push_const 40 push_const 20 func_call 0 // func[AddMoveAroundDesire] shift_sp -2 shift_sp -1 handler_end handler 1 // ATTACKED variable_begin "attacker" "damage" "myself" "_choiceN" "_code" "_from_choice" variable_end shift_sp 1 push_const 2 func_call 55 // func[Rand] shift_sp -1 push_const 1 equal branch_false L1 L0 shift_sp 1 S0. "Text1" push_string S0 func_call 37 // func[Say] shift_sp -1 shift_sp -1 jump L2 L1 shift_sp 1 S1. "Text2" push_string S1 func_call 37 // func[Say] shift_sp -1 shift_sp -1 L2 shift_sp 1 push_event // attacker push_const 36 add fetch_i push_const 30 func_call 6 // func[AddFleeDesire] shift_sp -2 shift_sp -1 handler_end class_end C4 NASC Code:
class warrior_flee : warrior {
handler:
EventHandler NO_DESIRE() {
myself->AddMoveAroundDesire(40,20);
}
EventHandler ATTACKED(attacker,damage) {
if (gg->Rand(2) == 1) myself->Say("Text1");
else myself->Say("Text2");
myself->AddFleeDesire(attacker,30);
}
}
Code:
class 1 warrior_flee : warrior
handler 0 9 // NO_DESIRE
variable_begin
"myself"
"_choiceN"
"_code"
"_from_choice"
variable_end
push_event // myself
push_const 704
add
fetch_i
push_const 40
push_const 20
func_call 184680455 // func[AddMoveAroundDesire]
shift_sp -2
shift_sp -1
handler_end
handler 1 46 // ATTACKED
variable_begin
"attacker"
"damage"
"myself"
"_choiceN"
"_code"
"_from_choice"
variable_end
push_event // gg
push_const 632
add
fetch_i
push_const 2
func_call 218169344 // func[Rand]
shift_sp -1
push_const 1
equal
push_reg_sp
fetch_i
branch_false L1
L0
push_event // myself
push_const 704
add
fetch_i
S0. "Text1"
push_string S0
func_call 184614973 // func[Say]
shift_sp -1
shift_sp -1
jump L2
L1
push_event // myself
push_const 704
add
fetch_i
S1. "Text2"
push_string S1
func_call 184614973 // func[Say]
shift_sp -1
shift_sp -1
L2
push_event // myself
push_const 704
add
fetch_i
push_event // attacker
push_const 48
add
fetch_i
push_const 30
func_call 184680461 // func[AddFleeDesire]
shift_sp -2
shift_sp -1
handler_end
class_end
|
|
|
|
|