I need some scripting help with menus again.
What should happpen:
you choose an option from the menu and it is executed.
What does happen:
The hero imediatly turns right. The running option is always executed, regardless of what is choosen from the menu.
I don't know if I'm either using the menu-handle things worng, or if there's a mistake in the use of the if-clauses.
Thanks for your help in advence!
This is the (rather long) script:
[script]
include, Battlesystem.hsi
include, plotscr.hsd
global variable (0, ActiveHero)
#the global var goes from 1 to 4 to loop throug
#the positions of the active fighter
plotscript, Battle, begin
# This is the Instead-of-Battle script named Battle.txt
suspend caterpillar
suspend player
fade screen out
wait
# prepare for going back
variable (LastX)
LastX := hero X (me)
variable (LastY)
LastY := hero Y (me)
variable (LastMap)
LastMap := current map #remembers where the heros came from
teleport to map (2)
wait
# Setting things up
variable (Pos1) #HeroAtPosition1
variable (Pos2)
variable (Pos3)
variable (Pos4)
# Me
#Pos1 := hero by slot (0)
# Here X ans Y for hero:
set hero position (me, 14, 2)
wait for hero (me)
#set hero picture (me, 0, outside battle)
#Wait for hero (me)
set hero direction (me, west)
Wait for hero (me)
wait (8)
# Hero 2
#Pos1 := hero by slot (0)
set hero position (1, 14, 3)
wait for hero (1)
#set hero picture (1, 0, outside battle)
#Wait for hero (1)
set hero direction (1, west)
Wait for hero (1)
wait (8)
# Hero 3
#Pos1 := hero by slot (0)
set hero position (2, 14, 4)
wait for hero (2)
#set hero picture (2, 0, outside battle)
#Wait for hero (2)
set hero direction (2, west)
Wait for hero (2)
wait (8)
# Hero 4
#Pos1 := hero by slot (0)
set hero position (3, 14, 5)
wait for hero (3)
wait for hero (3)
#set hero picture (3, 0, outside battle)
#Wait for hero (3)
set hero direction (3, west)
Wait for hero (3)
wait (8)
put camera (10,3)
wait for camera
# start the Battle
fade screen in
wait
###############################
# Do Stuff here, as long as
# Enemie and you have HP
###############################
variable (id) # wich hero is active?
id := hero by slot(ActiveHero)
# variables for attacks, skills ect. Not in use
variable (Attk1)
variable (Attk2)
variable (Attk3)
variable (Attk4)
# showing the HP (replace later by bar, add MP bar as well)
variable (ActiveHeroHP)
ActiveHeroHP := get hero stat (ActiveHero,0,current stat)
# Show Hero's HP
show value (ActiveHeroHP)
# Menu wich shows the hero's Attacks
variable (HeroM) # Menu variable handle for certain Hero
if (id == 0) then ( HeroM := 1) # Hero 0 (Name) gets Menu 1
else if (id == 1) then ( HeroM := 2)
else if (id == 2) then ( HeroM := 3)
variable (BattleM)
SetVariable (BattleM, OpenMenu (HeroM,0))
# Menu item handle variables depend of the open Menu,
# so actually it depends on the active hero
variable (Choice1)
variable (Choice2)
variable (Waiting)
variable (Running)
Choice1 := first menu item(BattleM)
Choice2 := next menu item(Choice1)
#Choice3 := next menu item(Choice2)
#Choice4 := next menu item(Choice3)
Waiting := next menu item(Choice2) #change Choice3
Running := next menu item(Waiting)
variable (DoDamage) # Damage amount an attack deals
variable (DoMPCost) # MP amount an attack costs
#Special = get menu item extra(Choice1, extra 2)
#Ideas:
# 0 = target one;
#1= target all;
#2= usable from above;
#3= enviroment effect;
if (selected menu item (BattleM) == Choice1) then
(
DoDamage := get menu item extra(Choice1, extra 0)
DoMPCost := get menu item extra(Choice1, extra 1)
walk hero (ActiveHero, 1, west)
wait for hero
# Number depends on Hero!
set hero picture (ActiveHero,4,outside battle)
wait for hero
set hero direction (ActiveHero, north)
wait for hero
set hero direction (ActiveHero, east)
wait for hero
set hero direction (ActiveHero, south)
wait for hero
set hero direction (ActiveHero, west)
wait for hero
#close menu(BattleM)
)
else if (selected menu item (BattleM) == Choice2) then
(
DoDamage := get menu item extra(Choice2, extra 0)
DoMPCost := get menu item extra(Choice2, extra 1)
walk hero (ActiveHero, 1, west)
wait for hero
# Number depends on Hero!
set hero picture (ActiveHero,5,outside battle)
wait for hero
set hero direction (ActiveHero, north)
wait for hero
set hero direction (ActiveHero, east)
wait for hero
set hero direction (ActiveHero, south)
wait for hero
set hero direction (ActiveHero, west)
wait for hero
# Number depends on Hero!
set hero picture (ActiveHero,0,outside battle)
wait for hero
walk hero (ActiveHero, 1, east)
wait for hero
set hero direction(ActiveHero, west)
wait for hero
#close menu(BattleM)
)
else if (selected menu item (BattleM) == Waiting) then
(
# Number depends on Hero!
set hero picture (ActiveHero,8,outside battle)
wait for hero
set hero direction (ActiveHero, north)
wait for hero
set hero direction (ActiveHero, east)
wait for hero
set hero direction (ActiveHero, south)
wait for hero
set hero direction (ActiveHero, west)
wait for hero
)
else if (selected menu item (BattleM) == Running) then
(
walk hero (ActiveHero, east ,2)
wait for hero
)
else ()
##################################
# End of Battle, you've won:
# Enemie Hp are 0 or below
#################################
wait(16)
#Reset the scene
fade screen out
wait
camera follows hero (me)
wait for camera
# Change the hero pictures back to
# map appropriate ones
# If you rearrange the party,
# the party slot numbers do not change.
set hero picture (me,0,outsidebattle)
if (hero by slot(1) == 1) then (
reset hero picture (1,outsidebattle)
)
if (hero by slot(2) == 2) then (
reset hero picture (1,outsidebattle)
)
if (hero by slot(3) == 3) then (
reset hero picture (1,outsidebattle)
)
# go back to last map
teleport to map (lastMap)
set hero position (me, LastX,LastY)
Wait for hero (me)
fade screen in
wait
resume player
resume caterpillar
###################################
# End of Battle, you lost
# Your HP are 0 -> Game Over Script
####################################
end
[/script]







