Changing attributes when conditions change

Forgewright
My 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)

HegemonKhan
if (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
well 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
attack bonus.png

Forgewright
Thank 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.

Forgewright
I used...
flyingcode.PNG

I get.....
flyingscripterror.PNG

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

Forgewright
Here's the attributes....

playerattributes.PNG

The Pixie
Looks 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
Doah!!! Works like a charm now.....

HegemonKhan
stupid spelling~typo errors... those are fun... so hard to spot~find... laughs.

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums