![]() |
|
|
#1 |
|
Архивный участник
Join Date: Feb 2005
Posts: 100
|
How do I go about checking if the mobile has more than 95% of hitpoints left in ai.obj?
I've tried this code, but it wouldn't parse the ai.obj :[ push_event // myself push_const 28 add fetch_i // sm push_const 2400 add fetch_i // hp push_const 344 add fetch_d push_event // myself push_const 28 add fetch_i // sm push_const 2400 add fetch_i // max_hp push_const 1000 add fetch_d push_const 1xx.xx0000 div push_const xx.xx0000 mul greater shift_sp 1 func_call 175 // func[Despawn] shift_sp -1 |
|
|
|
|
#2 |
|
Архивный участник
Join Date: Oct 2005
Posts: 18
|
Code:
push_event // myself push_const 28 add fetch_i // sm push_const 2400 add fetch_i // hp push_const 344 add fetch_d push_event // myself push_const 28 add fetch_i // sm push_const 2400 add fetch_i // max_hp push_const 1000 add fetch_d push_const 1xx.xx0000 div push_const xx.xx0000 mul greater shift_sp 1 func_call 175 // func[Despawn] shift_sp -1 From a semantic point although you make the fetches and the correct calculations and you have in the stack the boolean result of hp>90*maxhp/100 you do not use it (at least not in the above code) and the function Despawn is called no matter what. If you want to call despawn only if the hp are less than 95% of the maxhp then you should add a branch_true <label> after the greater statement to jump over the despawn function. In which handler do you have the above code? |
|
|
|
|
#3 |
|
Архивный участник
Join Date: Feb 2005
Posts: 100
|
in the handler 17 for 'warrior' class, and the advice of yours was really useful, thanks
|
|
|
|
|
#4 |
|
Архивный участник
Join Date: Feb 2005
Posts: 100
|
alright, I've been trying for quite some time and now it just crashes the server quite often :[
This is what I've got at this very moment: handler 17 // OUT_OF_TERRITORY variable_begin "myself" "_choiceN" "_code" "_from_choice" variable_end push_event // myself push_const 28 add fetch_i // sm push_const 2400 add fetch_i // hp push_const 344 add fetch_d push_event // myself push_const 28 add fetch_i // sm push_const 2400 add fetch_i // max_hp push_const 1000 add fetch_d push_const 1xx.xx0000 div push_const xx.xx0000 mul greater branch_false L75002 L75001 shift_sp 1 push_event // myself push_const 28 add fetch_i // start_x push_const 2428 add fetch_i push_event // myself push_const 28 add fetch_i // start_y push_const 2432 add fetch_i push_event // myself push_const 28 add fetch_i // start_z push_const 2436 add fetch_i func_call 46 // func[InstantTeleport] shift_sp -4 shift_sp -1 L75002 handler_end The idea is that the mobs, that get dragged out of spawn area get teleported back if their amount of remaining health points is greater than 95% of total health. |
|
|
|
|
#5 | ||
|
Архивный участник
Join Date: Oct 2005
Posts: 18
|
Code:
handler 17 // OUT_OF_TERRITORY variable_begin "myself" "_choiceN" "_code" "_from_choice" variable_end push_event // myself push_const 28 add fetch_i // sm push_const 2400 add fetch_i // hp push_const 344 add fetch_d push_event // myself push_const 28 add fetch_i // sm push_const 2400 add fetch_i // max_hp push_const 1000 add fetch_d push_const 1xx.xx0000 div push_const xx.xx0000 mul greater branch_false L75002 L75001 shift_sp 1 push_event // myself push_const 28 add fetch_i // start_x push_const 2428 add fetch_i push_event // myself push_const 28 add fetch_i // start_y push_const 2432 add fetch_i push_event // myself push_const 28 add fetch_i // start_z push_const 2436 add fetch_i func_call 46 // func[InstantTeleport] shift_sp -4 shift_sp -1 L75002 handler_end func_call 46 // func[InstantTeleport] (rv, event[myself][sm],int(x),int(y),int(z)) the function uses 4 arguments so the stack must be like this before you call it: Quote:
Quote:
alter your code by adding the following after the label L75001: L75001 shift_sp 1 [highlight=red:5a498c9f6d]push_event // myself push_const 28 add fetch_i // sm push_const 2400 add fetch_i [/highlight:5a498c9f6d] push_event // myself push_const 28 add fetch_i // start_x push_const 2428 add fetch_i push_event // myself push_const 28 add fetch_i // start_y push_const 2432 add fetch_i push_event // myself push_const 28 add fetch_i // start_z push_const 2436 add fetch_i func_call 46 // func[InstantTeleport] shift_sp -4 shift_sp -1 L75002 handler_end I hope the above will solve your problem |
||
|
|
|
|
#6 |
|
Архивный участник
Join Date: Feb 2005
Posts: 100
|
I do appreciate. thanks!
|
|
|
| Thread Tools | Search this Thread |
| Display Modes | |
|
|