Non-threaded

Forums » Advanced Editor Forum » Read Thread

Get help from the experts on variables, scripts, items, and other scary things.

items that add to stats

2 years ago
I am trying to have items found throughourt my game that would add to the character stats like, Attack if a weapon, defence if armour etc. I am struggling to find some scripting or whatever I would need to do this. Could someone please point me in the right direction? is it a variable or is it item scripting or something?

items that add to stats

2 years ago
Any stat is a variable already.

If you're not sure how to adjust variables yet, you may be getting ahead of yourself (once again) with this game that is heavily dependant on them.

items that add to stats

2 years ago
Perhaps ITEMSTATE in scripting can help you.

items that add to stats

2 years ago
He's already seen that article.

He just needs to put in a script saying that if the item is held, increase the variable.

If he understands what a variable is and how to use it on the most basic level, he would already know this. But he doesn't and he won't or can't learn so we're going right back around in this circle again.

Maybe @Gryphon is still willing to try and help her little buddy, maybe not, but I've got too much reading to do over the next week.

items that add to stats

2 years ago
I do feel it is something that I do know already but i was looking for something to jog my memory. I guess i'll figure it out eventually. Thanks for the help anyway.

items that add to stats

2 years ago

Yeah, sure!

If you want the item to add the bonus whenever it's in the player's inventory, you should use the global script page and ITEMSTATE commands.  (Something like this:  "IF $ITEMSTATE1 = 1 THEN %STRENGTH := %STRENGTH + 1")

If you only want the item to add a bonus when used, you could put a similar string of code into the item's individual script, but this would be trickier to smooth out with the rest of your variables.

I recommend re-reading all of the advanced scripting articles (especially the one Ogre posted), and then playing around with the global script and item scripts until you're familiar with how you can use them.  Then, you'll be better able to figure the most efficient way to customize item-stat modification for your specific game.

*his

items that add to stats

2 years ago
Hi Gryphon, Thank you for that information. I tried using that script and added it into the Global page under scripts but changed the '%STRENGTH' to the variable I wanted it to add to and it still didnt work. I know I am doing something wrong but once I work it out I will be sweet lol.

My aim is to have an item add 5 to a variable that I have made when the item is in the inventory.

I'll just keep playing around until it works. Thank you again

items that add to stats

2 years ago
Try global link script instead of page script maybe? And the page may need to be loaded again once you pick up the item for the change to take effect.

Also obviously make sure you're using the correct number for the item you're trying to change the state of.

items that add to stats

2 years ago
I have this 'IF $ITEMSTATE1 = 1 THEN %PLYRATK := %ATTACK + 5' written in the Global Page Script, I will remove it from there and add to the Global link script (is there a difference?) and see if that changes anything. PLYRATK is a variable I set up to show the players attack, thats probably quite obvious though. That variable is set to 1 as standard but I have also set up different classes and have made it so when a class is chosen it adds a value to the PLYRATK variable of 10 using restrictions again you probably know what I mean, so that totals 11. The itemstate script I have shown you above changes the total from 11 to 5, not adds it together but only when I have added item 1 and 2 to the inventory not just item 1..

I am playing around to try fix this but maybe you might get what i'm trying to say and help with a solution, but then it's probably just me not understanding properly.

items that add to stats

2 years ago
https://chooseyourstory.com/help/articles/article.aspx?ArticleId=42

Global link executes once at link is clicked, global page executes once a page is loaded.

If your result is 5 that most likely means your attack value is empty. I'd assume %Attack is actually populated whenever the user goes to attack, and is not just a set value.

items that add to stats

2 years ago
Let me delete some of the scripts, variables and stuff and ill start again cause i think im confusing myself

items that add to stats

2 years ago
https://chooseyourstory.com/story/the-maze~21

That's the game if you want to try and figure out what he's doing. I don't see any variables for Attack etc, but he may have just deleted them.

items that add to stats

2 years ago
yes i did just delete alot of stuff lol

items that add to stats

2 years ago
If i had known you could do that I wouldnt of delted everything lol

items that add to stats

2 years ago
Admins can view games in edit mode, but Killa knows more about item scripting, I never use them.

You should feel free to message him with questions any time.

items that add to stats

2 years ago
Damn wish i had never deleted them now, 1 of you might of been able to check out what I was saying and tell me where I was going wrong.

items that add to stats

2 years ago
While experimenting, I highly suggest you make variables visible, as well, if you haven't already. That helps a lot in seeing what variables are doing.

items that add to stats

2 years ago
Is this a setting that is automatically turned on or do I have to manually do that?

items that add to stats

2 years ago
When you make the variable there's a checkbox to have it always visible on the page.

items that add to stats

2 years ago
oh yeah I see that, thanks

items that add to stats

2 years ago
You don't need a lot of that $PAGETEXT stuff you have in global to display them if you just check the box.

items that add to stats

2 years ago
Do I just make a variable for HP, Attack, Defence etc and have it show on the page instead?

items that add to stats

2 years ago
That's the easiest way, at least at this stage. If you want to add some special formatting or something later you can use $PAGETEXT, but it might just confuse things now while you're changing things around and experimenting.

items that add to stats

2 years ago
ok thank you let me try this methos see if i can get my head around it

items that add to stats

2 years ago
EDIT: Don't worry I figured it out :) I restarted creating all the vaRiable but having them show on every page while im experimenting and I've found when I create a variable for health and max health and set them both to start with 20. They still start with 0, any ideas why this might be?

items that add to stats

2 years ago
Usually this is because you've changed their value in a script... somewhere...

items that add to stats

2 years ago
I didnt reload the page like a dumbass

items that add to stats

2 years ago
I Just need to work out how to set a script or whatever to make it so that when an item is added to the inventory it adds a value to a variable

items that add to stats

2 years ago
I don't think there's a script for that action. However, you could add a script to the page where the item is found. You could use an IF statement and say that IF the ITEMSTATE is 1, add the value. When the reader gets to the page the first time, the ITEMSTATE will be 0. But when the reader picks up the item, it will reload the page and should execute that script.

Beware, however, if you just add, that it will add EVERY time the page is loaded...

items that add to stats

2 years ago
Would I need to create a variable for the item itself so I can add it into the script?

I have read through the scripting pages a few times but can't seem to figure it out.

I have the items made and set to appear on the pages I want them to, I have the variables made that I want the items to add value to, I just don't think I have the correct script.

I was also trying to do it on a global script but a page script makes more sense now you've mentioned it.



items that add to stats

2 years ago
$ITEMSTATE is already the variable that checks whether the item is held.

items that add to stats

2 years ago
Can you tell us the exact thing you are typing, and where?

items that add to stats

2 years ago
and you identify the item by using the ID number..

so this is how it would start 'IF $ITEMSTATE1 = 1 THEN ... I don't know to type after

I have 2 variables PLYRATK and also PLYRATKMAX (these were taken from How to use Characters, Weapons and Combat Rounds) and I want it to add 5 to the value of the 2 variables I mentioned..obviously only when the item is in the inventory so if its dropped then theyw ont have to bonus for not having the item anymore, and like ogre says I wouldnt want it to keep adding to the vavle.. only once and only when its in the inventory if that makes sense.

I was typing it into the global script but ogre kindly advised I should just put it on the page script instead.

items that add to stats

2 years ago
IF $ITEMSTATE1 = 1
THEN
%PLYRATK := %PLYRATK + 5
%PLYRATKMAX := %PLYRATKMAX + 5

You'll also need a script subtracting these if you ever have the item taken away.

If it doesn't work, try $ITEMSTATE01, can't remember if that makes a difference or not.

And just be aware if the player is going to be returning to that page multiple times, it will effect the variable every time unless you take other steps to prevent that.

items that add to stats

2 years ago
That help massively, thank you very much, do you know the script to have it taken away it the item is dropped or something?

items that add to stats

2 years ago
You'd check if the item state is zero, and then subtract 5 from each of those variables the same way.

items that add to stats

2 years ago
so id write this?

IF $ITEMSTATE1 = 1
THEN
%PLYRATK := %PLYRATK + 5
%PLYRATKMAX := %PLYRATKMAX + 5
IF $ITEMSTATE1 = 0
THEN
%PLYRATK := %PLYRATK - 5
%PLYRATKMAX := %PLYRATKMAX - 5

items that add to stats

2 years ago
Yes, but you only need whichever half of that is relevant on the pages the player will be picking them up or putting them down.

Of course if they can do this anywhere it gets a little more complicated. You actually would be better with a global script in that case because it would need to be able to check on every page, but you'd need another set of variables at that point to make sure it didn't just keep adding or subtracting every time a page loaded.

items that add to stats

2 years ago
Oh I see, thats where I was going wrong. I was trying to use that script to allow the player do do it anywhere. I will just make it so they can change it at certain points for now rather than anywhere.

items that add to stats

2 years ago
I typed this into the page cript and when you go to the game is takes 5 off the PLYRATK variable and even if you add item into inventory it stays the same but it should be removing it off the variable at all, only if the value was dded first by having in the inventory to begin with. Hope this makes sense.

IF $ITEMSTATE1 = 1
THEN
%PLYRATK := %PLYRATK + 5
%PLYRATKMAX := %PLYRATKMAX + 5
IF $ITEMSTATE1 = 0
THEN
%PLYRATK := %PLYRATK - 5
%PLYRATKMAX := %PLYRATKMAX - 5

items that add to stats

2 years ago
With two statements you need a BEGIN and END. Also, I'm pretty sure it's ITEMSTATE01

In other words, for the last part,
IF $ITEMSTATE1 = 0
THEN
%PLYRATK := %PLYRATK - 5
%PLYRATKMAX := %PLYRATKMAX - 5

The only portion in the THEN fragment is the first line, so the last line is always being executed. You need:

IF $ITEMSTATE1 = 0
THEN
BEGIN
%PLYRATK := %PLYRATK - 5
%PLYRATKMAX := %PLYRATKMAX - 5
END

There's other issues with the subtraction, but that's theory, and I'll post about that a little later when I have more time.

items that add to stats

2 years ago
Thank you, I would really appreciate that if you could when you get a minute please

I have typed this in there now:

IF $ITEMSTATE1 = 1
THEN
BEGIN
%PLYRATK := %PLYRATK + 5
%PLYRATKMAX := %PLYRATKMAX + 5
END
IF $ITEMSTATE1 = 0
THEN
BEGIN
%PLYRATK := %PLYRATK - 5
%PLYRATKMAX := %PLYRATKMAX - 5
END

and it just took 5 off the variable and doesnt do anything else even if i pick up and drop the item. I don't know if this issue is going to be covered in what you explain to me later but thats sissue I am having now.

Just so you are aware whn you enter the page I am having this issue with I have set a variable cahnge aswell to increase the variable but i dont know if that would cause any issues or not.

items that add to stats

2 years ago
Commended by mizal on 9/9/2021 2:10:51 PM
Ok, first, I’ll take a step back and think about the overall processing and theory behind what you’re trying to do. You want to have a bonus when a person has a certain item in their inventory to an attack. Before we even get to the details of that: 1. Is there more than one item that can generate a bonus in the game? 2. If there is more than one item, are the bonuses different for each item? 3. Can there be more than one item used at a single time? 4. If so, do the item bonuses stack, or should the game calculate just the highest bonus item? 5. Is there a max to the total bonus? 6. Can the bonus go negative? 7. Are there other potential modifiers to the attack bonus (location, option chosen)? I ask all these questions because the answers to them would determine how I would set up the variables and the process for the attack. This could be anything from zero variables to a whole stack of them (variables, not cats). If there is just one item, I would make this simpler and not even attempt to track anything. When the attack occurs, in the code for the attack, I’d simply add something simple using the ITEMSTATE option. For example, if success occurs when the attack is greater than 10 and having the item gives you a bonus of 5, I might do something like: IF %ATTACK + ($ITEMSTATE01 * 5) > 0 THEN attack success In this case, if the reader does not have the item, ITEMSTATE is zero, so it adds nothing. If the reader has the item, ITEMSTATE is 1, so five gets added to the attack attempt. I’m not 100% sure this actually works, I haven’t tried to use ITEMSTATE this way, but I think it would work. So… If you’re going to have more than one item or variable item bonuses, it might depend on how often you have attacks how you calculate the attack (yes, I really wish functions were available here, but they’re not). The problem with what we’ve discussed here is that if you just add to the bonus, any time that action happens, it will continue to add: In this case, if the just add five to the bonus when the reader has the item in their inventory, then ANY time that page is loaded, it will add five. So if I pick up the item and hit reload, I’m now at +10. If I try and use the item in my inventory, the page will tell me I can’t use it, then reload the page: +15. If I navigate to another room and return to this page: yes, now it’s +20. So just openly adding 5 isn’t going to work logistically in the long run. This is why so many questions about options. You could have a variable that just has attackbonus. Before you use it, you could load it with a stack of IF statements: %ATTACKBNS = 0 IF $ITEMSTATE01 = 1 THEN %ATTACKBNS = 5 IF $ITEMSTATE02 = 1 THEN %ATTACKBNS = %ATTACKBNS + 3 IF $ITEMSTATE03 = 1 THEN %ATTACKBNS = %ATTACKBNS + 4 And so on. You would need to do that calculation before each attack. That may be the simplest way to approach this, then you aren’t trying to make adjustments on the fly every time an item is picked up or put down (though you could do that, likely through ghost pages and scripts). Hope that helps!

items that add to stats

2 years ago
Thank you for all the information, that has really helped me think more about what I am doing and it teaches me alot. in answer to your questions first..

1. Yes, there will be several items that can grant additional bonus', if you imagine in an RPG game you could start with a weapon that grants an addtional 5 attack and then later on you could find a new weapon that grants an additional 10 attack instead. So my idea would be to drop the item that grants 5 attack when the item that grants 10 is picked up so you wont have a combination bonus of both the 5 and 10 added to your attack. (I imagine the same process could be done for a defensive stat aswell?).

2. I believe my answer to question 1 should of answered this question aswell.

3. Yes, for instance the player will start off with 3 items, a weapon granting an additional attack bonus and 2 pieces of armour granting additional defence bonus' and these figures could all be different like +5 attack, +7 defence and +3 defence.

4. I would like to implement them stacking instead of the game taking the highest bonus.

5. I don't believe there will be a max to the total bonus, I am not intending on there being anything that could max it out.

6. I was planning on having the bonus' go into a negative state, I will give an example, I have allowed for the reader to choose class types. One class you can choose from would be a beserker class which enables the reader to be granted a higher attack when damaged, in common cases this class would have a relatively low defence and I am going to include certain monsters that could possibly drain defensive stats (if I can work that out).

7. Yes, for instance, there will be a basic attack and defence set at 1 a piece and when a class is chosen then I have set a variable modification to add additional values to the attack, defence, health etc.

So what I am looking for is when an item is put in the inventory it adds a value to the health, attack or defence variable, and when it's dropped I would like the value to be removed as the item is no longer there.

I wouldnt want it to add each time the page is loaded though.

Thanks again for putting your thought and time into typing all that, I hope my answers can give you more of a insight to what i am trying to achieve.

items that add to stats

2 years ago
Okay, so here's my opinion, worth exactly what you paid for it:

Don't use items at all. Instead, use scripting and links. That gives you a lot more control over what happens. For example, on the page where you can find a sword, add a link that says "Pick up and equip sword." In the script for that link, set the attack bonus to 5. There, done. Sure, the reader won't see the sword, but trust they can remember the sword.

On another page that has a big sword, you can add a link to "Pick up and equip big sword." In that script, don't add to the attack bonus, just set it to 10. Done. You can even make it so that the reader can only use the link once so it disappears.

To me, that's the simplest and easiest way to do what you want.

However, if you want more complicated, I'd still use scripts, just with a pile of variables. For example, you could have a variable DAGGER. That value will be a 1 or 0 depending on if the reader has chose to use the item. On the page where you find the dagger, I'd still give them a link to Equip and pick up the dagger. In that script, I'd set the attack bonus to 3 and DAGGER to 1. Then, on other pages (in the global script), I'd add an IF statement so that IF DAGGER == 1 then display, "You are using a dagger" (using PAGETEXT).

For the fancy part: On the page where you find the sword, I would hide the link to pick up the sword when the condition DAGGER is 1. I'd add another link to drop the dagger (that's only visible when DAGGER is 1). In that script, I'd set the DAGGER to 0. This does, however, create an instance where once the dagger is dropped, it is gone forever (unless you decide to add MORE links on that page, and also include a way to track what room the dagger was dropped in -- way more effort than it sounds like).

Now if you're doing to do this and have more than one available defensive item, you will probably need a variable for each area: DEFHEAD, DEFHANDS, DEFBODY, and so on. Then you can do the same as above, adjusting scripts for each body part.

P.S. The complex way is going to require A LOT of writing scripts. The simple way may be the way to go as you try out and learn the system.

Good luck!

items that add to stats

2 years ago
Thank you for confirming that. That helps alot, I will probably use the easier way for now until I understnad it more and im more experienced :)

items that add to stats

2 years ago
Pagescript executes when the page loads, and link scripts execute when a link is click. No script is executed when you pick up/drop an item, so you wont notice a change until the next page, when it checks if the item exists.

Your script will also add or remove every single time a page is loaded if they're holding the item. What you'd really want to do is have your base damage, your current damage, and then any buffs applied per page. Holding the item is a buff, and anything else you want could be a buff really.

%PLYRBASE := 10
%PLYRATK := %PLYRBASE

IF $ITEMSTATE1 = 1
THEN
BEGIN
%PLYRATK := %PLYRATK + 5
END

Now you don't need to worry about removing the buff, since the check is on each page, so the page after they lose an item the buff is gone.

You don't need a max for an attack. Having a max/normal variable is meant to represent that value has a current and max value (like health). Unless you're doing something like removing attack whenever they attack, it doesn't serve a purpose.

(Note you can set your %PLYRBASE outside of the global page script, I just put it hear to show what it could be)

items that add to stats

2 years ago
Thanks to you to for putting the effort in to respond to me.

I will try this script and see if I can get it to work.

Yes that is the reason I have a max attack lol, I havent gone as far as to work out anything reagarding that yet.

%PLYRBASE := 1
%PLYRATK := %PLYRBASE

IF $ITEMSTATE01 = 1
THEN
BEGIN
%PLYRATK := %PLYRATK + 5
END

when I use this script and come to the page the item is on, It seems to not take into account the variable modification that I set. So it will add 5 but where the base is set at 1, the variable change is to add 10, then the item should add 5 on top of that so the total being 16 but the total comes to 6, 1 for the base and 5 for the item.

I take it I use this script on a global page script so that the Item can be dropped at any point to remove the added value of that item?

items that add to stats

2 years ago
Quick update.. I am using the below in the global page script and its changing the variable on every page, If I can stop that and only make it change when the item is either in or out of inventory that would solve my issue I believe.

IF $ITEMSTATE01 = 1
THEN
BEGIN
%PLYRATK := %PLYRATK + 5
END
IF $ITEMSTATE01 = 0
THEN
BEGIN
%PLYRATK := %PLYRATK - 5
END

items that add to stats

2 years ago
This can be done, but honestly what I'm wondering is why not let the player just use the item for a one time buff, and then all you need to worry about is taking it away when they're not holding it?

items that add to stats

2 years ago
I think that would actually work because the player techincally wont use that item again once they find an upgrade.

How do I make it a 1 time buff?

How do I make the system take it away when the item is dropped?

Where where I put this aswell?

items that add to stats

2 years ago
First look at the items and see the places where you can control what happens when they're used.

The go back to that same article on ITEMSTATE and read the part on ITEMUSED.

The last part I know how to do in theory but I'd have to be able to sit down and mess with the editor to get it exactly right, and I can't do that right now.

items that add to stats

2 years ago
Thats fair enough thank you, If i use the item though will the item dissapear from the inventory?

items that add to stats

2 years ago
No, not unless you force it to via script. And if you do, it will appear wherever it was when the story started.

items that add to stats

2 years ago
that sounds a bit intense for my level right now though

items that add to stats

2 years ago
Good thing you don't want the item to disappear from the inventory then.

items that add to stats

2 years ago
Do you know why this script

%MONSTHP := %MONSTHP - %PLYRATK
%ARROWS := %ARROWS – 1
%PLYRATK := %PLYRATK

Would give me this error message

Did not recognize '-'. Line=2 Col=20

it clearly doesnt like the hyphon for some reason, any idea why?

Don't worry about it I fixed it, Im stupid!

items that add to stats

2 years ago
"when I use this script and come to the page the item is on, It seems to not take into account the variable modification that I set. So it will add 5 but where the base is set at 1, the variable change is to add 10, then the item should add 5 on top of that so the total being 16 but the total comes to 6, 1 for the base and 5 for the item. "

...Then don't set the base there? Obviously its going to over-write any of your other stat changes. I already said you dont have to set the base in that script. The entire reason we have a base and a current attack is so you can make permanent changes to the base.

items that add to stats

2 years ago
thanks for all your help everyone I really appreciate it :)

items that add to stats

2 years ago
Welp guess I'll just ban the OP account now that he's gone and made yet another.

items that add to stats

2 years ago
Nothing escapes her watchful eyes!