Since I'm going to have a bunch during the making of this game, I'll put them all in one place.
First question: Let's say I want to have NPC enemies that wander around the map. I make a text box that says, "I'm gonna beat you up!" and starts a battle with formation 5 after the message. Now I make an NPC, make it onetime usable and make it chase the player. When it contacts the player, it starts the battle. Now let's say I place 5 or 10 of them on the map. After I battle one, they all disappear. Is there any way to make them all fightable separately without having to make each one a separate NPC, or make a separate script for talking to each?
Sent from my iPhone
I have to disagree there, creating lots of duplicate NPCs is not a trivial amount of work. The script you need is short, and you can reuse it for all battle-triggering NPCs.
Attach this script to an NPC, and set the 'Script Argument' to a formation number to trigger.
(OK, luckily I decided to actually test this, and it wasn't as simple as I thought. I didn't realise that it was necessary to add "set npc usable" because "touch" NPCs are REALLY awful.)
If you want the NPC to stay on the map if the player runs from the battle that's easily accomplished too:
Please read the "Note".
Code:
plotscript, npc battle, formation, npcref, begin
# Prevent the NPC from immediately re-triggering and showing another textbox
set npc usable(npcref, false)
wait for textbox
fightformation(formation)
destroy npc(npcref)
end
# Prevent the NPC from immediately re-triggering and showing another textbox
set npc usable(npcref, false)
wait for textbox
fightformation(formation)
destroy npc(npcref)
end
Attach this script to an NPC, and set the 'Script Argument' to a formation number to trigger.
(OK, luckily I decided to actually test this, and it wasn't as simple as I thought. I didn't realise that it was necessary to add "set npc usable" because "touch" NPCs are REALLY awful.)
If you want the NPC to stay on the map if the player runs from the battle that's easily accomplished too:
Code:
# Attach this script to an NPC, and set the 'Script Argument'
# to a formation number to trigger.
# The NPC will be deleted after the battle if you won, and
# is made un-activatable for 1 second if you run.
# The NPC can optionally show a textbox as well as triggering
# this script.
# Note: the NPC reappears if you load a saved game, or
# leave the map and don't have
# "NPC Data: Remember state when leaving" turned on.
plotscript, npc battle, formation, npcref, begin
# Prevent the NPC from immediately re-triggering
set npc usable(npcref, false)
wait for textbox
if (fightformation(formation)) then (
# Won the battle
destroy npc(npcref)
) else (
# Wait one second, then make the NPC deadly again
wait(18)
setnpcusable(npcref, true)
)
end
# to a formation number to trigger.
# The NPC will be deleted after the battle if you won, and
# is made un-activatable for 1 second if you run.
# The NPC can optionally show a textbox as well as triggering
# this script.
# Note: the NPC reappears if you load a saved game, or
# leave the map and don't have
# "NPC Data: Remember state when leaving" turned on.
plotscript, npc battle, formation, npcref, begin
# Prevent the NPC from immediately re-triggering
set npc usable(npcref, false)
wait for textbox
if (fightformation(formation)) then (
# Won the battle
destroy npc(npcref)
) else (
# Wait one second, then make the NPC deadly again
wait(18)
setnpcusable(npcref, true)
)
end
Please read the "Note".
It's here. It really needs to be shown in Custom directly.
Hey, peoples. A couple of quick (I hope) scripting questions.
First, what would be the best way to go about making the hero do something other than alternating his/her standing and attacking sprites after a battle victory? Let's just say it looks kind of
Should I just use scripts to change the hero sprite to something better? How would I go about doing that?
Second, is there any way to make an animated enemy? If so, am I really going to have to get my hands dirty?
And finally, I want to change the gained exp/money textbox from transparent to opaque. It currently looks like this:
and is a little hard to read.
That's it for now, thanks in advance for the feedback!
Sent from my iPhone
First, what would be the best way to go about making the hero do something other than alternating his/her standing and attacking sprites after a battle victory? Let's just say it looks kind of
Should I just use scripts to change the hero sprite to something better? How would I go about doing that?
Second, is there any way to make an animated enemy? If so, am I really going to have to get my hands dirty?
And finally, I want to change the gained exp/money textbox from transparent to opaque. It currently looks like this:
and is a little hard to read.
That's it for now, thanks in advance for the feedback!
Sent from my iPhone
All three have the same answer: Can't be done. Scripts don't run during battles. Best thing to do is to harass James and I into implementing them. Someone has actually requested customisation of the victory animation as a Heart of the OHR request. Customising battle UI elements is part of converting battles to slices, which we are actually working towards. Support for animations is a much harder, more distant goal.
Well, actually, you can fake animated enemies in threes ways. The first is to make the animation an attack animation, using a self-targetting attack. This is pretty difficult as the alignment is tricky, the size isn't the same as the actual enemy sprite, and the attack has to cover up the real sprite. Secondly you can use a transmogrification attack to transform an enemy into an identical one with a different sprite number. This can produce a slow animation and is messy. Thirdly, you could use animated backdrops, but that's limited to static enemies.
Well, actually, you can fake animated enemies in threes ways. The first is to make the animation an attack animation, using a self-targetting attack. This is pretty difficult as the alignment is tricky, the size isn't the same as the actual enemy sprite, and the attack has to cover up the real sprite. Secondly you can use a transmogrification attack to transform an enemy into an identical one with a different sprite number. This can produce a slow animation and is messy. Thirdly, you could use animated backdrops, but that's limited to static enemies.
I'm going to ask some of my own questions here, if that's alright
I'm trying to make a selection menu using slices, but I can't figure out what I'm doing wrong. I'm using the "selected menu item" script to do manipulate slices based on which item is selected. It works on all of them except the first one, and I don't know why, because it's mostly copy and pasted.
Here is my script for it
A lot of it is visual in the slice collection editor and there are a lot of text box conditionals, but it's supposed to highlight a certain box and make a description visible (hence the "set slice visible" commands) based on the menu item selected, and then it unhighlights the rest of the boxes and descriptions each tick. It works fine except for the first item. The set slice width, height, and visible scripts don't even affect the first menu item.
I probably didn't explain that very well, but I'm really stumped here. I've spent the past 2 hours on this and I've hit the last road block I can overcome. Any help is appreciated.[/code]
My pronouns are they/them
Ps. I love my wife
I'm trying to make a selection menu using slices, but I can't figure out what I'm doing wrong. I'm using the "selected menu item" script to do manipulate slices based on which item is selected. It works on all of them except the first one, and I don't know why, because it's mostly copy and pasted.
Here is my script for it
Code:
plotscript, tree choice, begin
playing := false
show text box(31)
wait for text box
open menu(4)
show text box(32)
variable(choice,open,mi)
choice := load slice collection(2)
open := true
while(open) do, begin
mi := selected menu item
switch(mi) do(
case(0) select item(0)
case(1) select item(1)
case(2) select item(2)
)
if(check tag(10)) then(
open := false)
wait(1)
end
free slice(choice)
playing := true
end
script, select item, which, begin
if(which == 0) then(
set slice width(lookup slice(sli:miningicon),27)
set slice height(lookup slice(sli:miningicon),27)
set slice visible(lookup slice(sli:minerdes),on)
set slice width(lookup slice(sli:explodeicon),25)
set slice height(lookup slice(sli:explodeicon),25)
set slice visible(lookup slice(sli:chemistdes),off)
set slice width(lookup slice(sli:athleteicon),25)
set slice height(lookup slice(sli:athleteicon),25)
set slice visible(lookup slice(sli:athletedes),off)
)
else if(which == 1) then(
set slice width(lookup slice(sli:miningicon),25)
set slice height(lookup slice(sli:miningicon),25)
set slice visible(lookup slice(sli:minerdes),off)
set slice width(lookup slice(sli:explodeicon),27)
set slice height(lookup slice(sli:explodeicon),27)
set slice visible(lookup slice(sli:chemistdes),on)
set slice width(lookup slice(sli:athleteicon),25)
set slice height(lookup slice(sli:athleteicon),25)
set slice visible(lookup slice(sli:athletedes),off)
)
else if(which == 2) then(
set slice width(lookup slice(sli:miningicon),25)
set slice height(lookup slice(sli:miningicon),25)
set slice visible(lookup slice(sli:minerdes),off)
set slice width(lookup slice(sli:explodeicon),25)
set slice height(lookup slice(sli:explodeicon),25)
set slice visible(lookup slice(sli:chemistdes),off)
set slice width(lookup slice(sli:athleteicon),27)
set slice height(lookup slice(sli:athleteicon),27)
set slice visible(lookup slice(sli:athletedes),on)
)
end
plotscript, tree choice, begin
playing := false
show text box(31)
wait for text box
open menu(4)
show text box(32)
variable(choice,open,mi)
choice := load slice collection(2)
open := true
while(open) do, begin
mi := selected menu item
switch(mi) do(
case(0) select item(0)
case(1) select item(1)
case(2) select item(2)
)
if(check tag(10)) then(
open := false)
wait(1)
end
free slice(choice)
playing := true
end
script, select item, which, begin
if(which == 0) then(
set slice width(lookup slice(sli:miningicon),27)
set slice height(lookup slice(sli:miningicon),27)
set slice visible(lookup slice(sli:minerdes),on)
set slice width(lookup slice(sli:explodeicon),25)
set slice height(lookup slice(sli:explodeicon),25)
set slice visible(lookup slice(sli:chemistdes),off)
set slice width(lookup slice(sli:athleteicon),25)
set slice height(lookup slice(sli:athleteicon),25)
set slice visible(lookup slice(sli:athletedes),off)
)
else if(which == 1) then(
set slice width(lookup slice(sli:miningicon),25)
set slice height(lookup slice(sli:miningicon),25)
set slice visible(lookup slice(sli:minerdes),off)
set slice width(lookup slice(sli:explodeicon),27)
set slice height(lookup slice(sli:explodeicon),27)
set slice visible(lookup slice(sli:chemistdes),on)
set slice width(lookup slice(sli:athleteicon),25)
set slice height(lookup slice(sli:athleteicon),25)
set slice visible(lookup slice(sli:athletedes),off)
)
else if(which == 2) then(
set slice width(lookup slice(sli:miningicon),25)
set slice height(lookup slice(sli:miningicon),25)
set slice visible(lookup slice(sli:minerdes),off)
set slice width(lookup slice(sli:explodeicon),25)
set slice height(lookup slice(sli:explodeicon),25)
set slice visible(lookup slice(sli:chemistdes),off)
set slice width(lookup slice(sli:athleteicon),27)
set slice height(lookup slice(sli:athleteicon),27)
set slice visible(lookup slice(sli:athletedes),on)
)
end
A lot of it is visual in the slice collection editor and there are a lot of text box conditionals, but it's supposed to highlight a certain box and make a description visible (hence the "set slice visible" commands) based on the menu item selected, and then it unhighlights the rest of the boxes and descriptions each tick. It works fine except for the first item. The set slice width, height, and visible scripts don't even affect the first menu item.
I probably didn't explain that very well, but I'm really stumped here. I've spent the past 2 hours on this and I've hit the last road block I can overcome. Any help is appreciated.[/code]
My pronouns are they/them
Ps. I love my wife
Thanks for clearing that up, by the way, I got the menu to work perfectly. I have a new question now though.
How do I add or subtract percentages to or from a number? The most straightforward would be to multiply it by a decimal, ie. 18 * 0.75, but decimals aren't supported. I found an article about the aim math in the ohr, and I'm trying to emulate it, but I don't know how to add and subtract 75% of the player's aim and enemy's dodge.
My pronouns are they/them
Ps. I love my wife
How do I add or subtract percentages to or from a number? The most straightforward would be to multiply it by a decimal, ie. 18 * 0.75, but decimals aren't supported. I found an article about the aim math in the ohr, and I'm trying to emulate it, but I don't know how to add and subtract 75% of the player's aim and enemy's dodge.
My pronouns are they/them
Ps. I love my wife
0.75 is 75/100, so the trick is to replace X * 0.75 with X * 75 / 100. Due to the operator precedence rules this is the same as (X * 75) / 100, which you might like to write explicitly.
By deferring the division until last you can minimise rounding error.
Now say that you have a more complicated formula like (X * 1.3 + Y * 0.7) / 2. You can do the same thing:
(X * 1.3 + Y * 0.7) / 2
becomes
(X * 130 / 100 + Y * 70 / 100) / 2
becomes
(X * 130 + Y * 70) / 200
By deferring the division until last you can minimise rounding error.
Now say that you have a more complicated formula like (X * 1.3 + Y * 0.7) / 2. You can do the same thing:
(X * 1.3 + Y * 0.7) / 2
becomes
(X * 130 / 100 + Y * 70 / 100) / 2
becomes
(X * 130 + Y * 70) / 200
This thread has a script issue I had earlier that's similar to the one I'm having now. I'm trying to make a menu to act as a skill tree for the player to spend points on new abilities and passive bonuses, etc.
So to do this I've set up some slices with pictures for each ability, and a menu that opens up along with the slice collection. Now each menu item is supposed to correspond to an ability on the tree using "menu item true slot(selected menu item)" just like the script I was making earlier in this thread (which works). A loop checks which slot the cursor is on, then makes a description box visible and attaches the appropriate string(s) to it, or makes the box invisible if no ability is selected.
Here's the whole script for it:
I attached a picture of what it looks like as well. I only came here as a last result, because I absolutely cannot figure this one out. I'm sure I'm just overlooking something, but the issue is, nothing even happens when I open up the menu, so I don't know where to look for problems.
Also, if anyone has recommendations on condensing this script, feel free to share.
Thanks for your time!
My pronouns are they/them
Ps. I love my wife
So to do this I've set up some slices with pictures for each ability, and a menu that opens up along with the slice collection. Now each menu item is supposed to correspond to an ability on the tree using "menu item true slot(selected menu item)" just like the script I was making earlier in this thread (which works). A loop checks which slot the cursor is on, then makes a description box visible and attaches the appropriate string(s) to it, or makes the box invisible if no ability is selected.
Here's the whole script for it:
Code:
plotscript, open skill tree, begin
variable(menuopen,mi)
open menu(3)
box := load slice collection(1)
open := true
$5= ""
$6= ""
$7= ""
while(menuopen) do, begin
mi := menu item true slot(selected menu item)
switch(mi) do(
case(0) select skill(0)
case(1) select skill(1)
case(2) select skill(2)
case(3) select skill(3)
case(4) select skill(4)
)
if(menu is open(3) == false) then(
menuopen := false
)
wait(1)
end
end
plotscript, close skill tree, begin
free slice(box)
open menu(0)
end
script, select skill, which, begin
if(which == 0) then(
set slice visible(lookup slice(sli:desright),off)
set rect fgcol(lookup slice(sli:smithing),0)
set rect fgcol(lookup slice(sli:mining),0)
)
else if(which == 1) then(
clear string(5)
clear string(6)
$5= "As a miner, one of your most essential skills is mining. With this first level, mining, you can mine some basic minerals and use low-level pickaxes."
$6= "Mining I"
set slice text(lookup slice(sli:descriptiontxt1),5)
set slice text(lookup slice(sli:skillname),6)
set slice visible(lookup slice(sli:desright),on)
set rect fgcol(lookup slice(sli:mining),109)
set rect fgcol(lookup slice(sli:prospecting),0)
)
else if(which == 2) then(
clear string(5)
clear string(6)
$5= "Aside from mining, miners must also be able to identify the minerals they receive."
$6= "Prospecting I"
set slice text(lookup slice(sli:descriptiontxt1),5)
set slice text(lookup slice(sli:skillname),6)
set slice visible(lookup slice(sli:desright),on)
set rect fgcol(lookup slice(sli:prospecting),109)
set rect fgcol(lookup slice(sli:mining),0)
set rect fgcol(lookup slice(sli:defender),0)
)
else if(which == 3) then(
clear string(5)
clear string(6)
$5= "Miners take pride in their exceptional defensive abilities. Each point increases your defense bonus."
$6= "Defender I"
set slice text(lookup slice(sli:descriptiontxt1),5)
set slice text(lookup slice(sli:skillname),6)
set slice visible(lookup slice(sli:desright),on)
set rect fgcol(lookup slice(sli:defender),109)
set rect fgcol(lookup slice(sli:prospecting),0)
set rect fgcol(lookup slice(sli:smithing),0)
)
else if(which == 4) then(
clear string(5)
clear string(6)
$5= "Miners use the ores they mine to forge useful armor and weapons. As your level increases, you will be able to create more items with better materials."
$6= "Smithing I"
set slice text(lookup slice(sli:descriptiontxt1),5)
set slice text(lookup slice(sli:skillname),6)
set slice visible(lookup slice(sli:desright),on)
set rect fgcol(lookup slice(sli:smithing),109)
set rect fgcol(lookup slice(sli:defender),0)
)
end
variable(menuopen,mi)
open menu(3)
box := load slice collection(1)
open := true
$5= ""
$6= ""
$7= ""
while(menuopen) do, begin
mi := menu item true slot(selected menu item)
switch(mi) do(
case(0) select skill(0)
case(1) select skill(1)
case(2) select skill(2)
case(3) select skill(3)
case(4) select skill(4)
)
if(menu is open(3) == false) then(
menuopen := false
)
wait(1)
end
end
plotscript, close skill tree, begin
free slice(box)
open menu(0)
end
script, select skill, which, begin
if(which == 0) then(
set slice visible(lookup slice(sli:desright),off)
set rect fgcol(lookup slice(sli:smithing),0)
set rect fgcol(lookup slice(sli:mining),0)
)
else if(which == 1) then(
clear string(5)
clear string(6)
$5= "As a miner, one of your most essential skills is mining. With this first level, mining, you can mine some basic minerals and use low-level pickaxes."
$6= "Mining I"
set slice text(lookup slice(sli:descriptiontxt1),5)
set slice text(lookup slice(sli:skillname),6)
set slice visible(lookup slice(sli:desright),on)
set rect fgcol(lookup slice(sli:mining),109)
set rect fgcol(lookup slice(sli:prospecting),0)
)
else if(which == 2) then(
clear string(5)
clear string(6)
$5= "Aside from mining, miners must also be able to identify the minerals they receive."
$6= "Prospecting I"
set slice text(lookup slice(sli:descriptiontxt1),5)
set slice text(lookup slice(sli:skillname),6)
set slice visible(lookup slice(sli:desright),on)
set rect fgcol(lookup slice(sli:prospecting),109)
set rect fgcol(lookup slice(sli:mining),0)
set rect fgcol(lookup slice(sli:defender),0)
)
else if(which == 3) then(
clear string(5)
clear string(6)
$5= "Miners take pride in their exceptional defensive abilities. Each point increases your defense bonus."
$6= "Defender I"
set slice text(lookup slice(sli:descriptiontxt1),5)
set slice text(lookup slice(sli:skillname),6)
set slice visible(lookup slice(sli:desright),on)
set rect fgcol(lookup slice(sli:defender),109)
set rect fgcol(lookup slice(sli:prospecting),0)
set rect fgcol(lookup slice(sli:smithing),0)
)
else if(which == 4) then(
clear string(5)
clear string(6)
$5= "Miners use the ores they mine to forge useful armor and weapons. As your level increases, you will be able to create more items with better materials."
$6= "Smithing I"
set slice text(lookup slice(sli:descriptiontxt1),5)
set slice text(lookup slice(sli:skillname),6)
set slice visible(lookup slice(sli:desright),on)
set rect fgcol(lookup slice(sli:smithing),109)
set rect fgcol(lookup slice(sli:defender),0)
)
end
I attached a picture of what it looks like as well. I only came here as a last result, because I absolutely cannot figure this one out. I'm sure I'm just overlooking something, but the issue is, nothing even happens when I open up the menu, so I don't know where to look for problems.
Also, if anyone has recommendations on condensing this script, feel free to share.
Thanks for your time!
My pronouns are they/them
Ps. I love my wife
Hey guys. Question time.
I want to make my game end based on a song ending. I guess I could use set timer, but if there's a "song_is_playing" variable I could check, that would be easier and more accurate.
Also, I'm really confused when it comes to slices. I get that they are images displayed on an independent layer from the rest of the game, but I'm stumped as to how they work. I just need to be able to display the remaining time before the song ends somewhere on the screen.
Any help at all would be appreciated.
Sent from my iPhone
I want to make my game end based on a song ending. I guess I could use set timer, but if there's a "song_is_playing" variable I could check, that would be easier and more accurate.
Also, I'm really confused when it comes to slices. I get that they are images displayed on an independent layer from the rest of the game, but I'm stumped as to how they work. I just need to be able to display the remaining time before the song ends somewhere on the screen.
Any help at all would be appreciated.
Sent from my iPhone




