Changing attributes when conditions change

Forgewright
01 Jul 2015, 23:40My player character has combat attributes like "attackbonus' and agility. He can also fly which I want to be able to increase the attributes when flying. I know the script but can't get the {}()+'s right.
How do I say...
(player.attackbonus) = (player.attackbonus + 3)
How do I say...
(player.attackbonus) = (player.attackbonus + 3)
HegemonKhan
01 Jul 2015, 23:56if (player.flying) {
player.attackbonus = player.attackbonus + 3
}
to set, re-set, alter, change, adjust an Attribute:
Object_name.Attribute_name = Value_or_Expression
example (simple Value): player.strength = 25
Addition Expresssion:
simple:
Object_name.Attribute_name = Object_name.Attribute_name + numeric_Value
example: player.strength = player.strength + 7
complex (example):
player.damage = player.weapon.damage + player.weapon.damage * player.strength / 100 - (orc.armor.resistance + orc.armor.resistance * orc.endurance / 100)
Subtraction (simple Value example):
player.strength = player.strength - 4
Multiplication (simple Value example):
player.strength = player.strength * 6
Division (simple Value example):
player.strength = player.strength / 3
------------
to do a conditional:
if (Object_name.Attribute_name OPERATOR Value_or_Expression) {
Object_name.Attribute_name = Value_or_Expression
}
OPERATORS:
addition: +
subtration: -
multiplication: *
division: /
modulus: %
greater than: >
lesser than: <
greater than or equal to: >=
lesser than or equal to: <=
equals: =
not equals 1: <>
not equals 2: not xxx = xxx
comparison: =
concatenating: +
---------
the parenthesis are for a condition of a Script~Function~command, example: if (xxx)
the scripting block of a Function~Method is the squiggle brackets, an example: if (xxx) { scripting }
adammadam
02 Jul 2015, 00:10well in the GUI when you click "add script" you can choose the one which says "set variable or attribute" and then it should look like this


Forgewright
02 Jul 2015, 05:19Thank you. I think I am having trouble because I use the combatlib.asxl on the forum in my game. It is a bit advanced for me. Every time I attack a monster I get a bunch of errors from that asxl file. Maybe because I don't use the combatinitialize script in a "true" state and don't have all the attributes associated with that library. I'll have to try again.
Hopefully it is as simple as you showed me.
Hopefully it is as simple as you showed me.

Forgewright
02 Jul 2015, 06:43I used...
I get.....
Heres the whole script(which works great until I added the variable code for the atts.

I get.....
Heres the whole script(which works great until I added the variable code for the atts.

Forgewright
02 Jul 2015, 06:44Here's the attributes....

The Pixie
02 Jul 2015, 06:48Looks like you have spelt player.damagebonus as player.damgebonus. Quest sees player.damgebonus, notes there is no such attribute, so returns null, which is an object. It then complains because it cannot add an integer (Int32) to an object.

Forgewright
02 Jul 2015, 08:12Doah!!! Works like a charm now.....
HegemonKhan
02 Jul 2015, 13:09stupid spelling~typo errors... those are fun... so hard to spot~find... laughs.