Author Topic: Getting the value of Physical Resist from a piece of armor  (Read 2740 times)

0 Members and 1 Guest are viewing this topic.

Offline GrandewdTopic starter

  • Full Member
  • ***
  • Posts: 239
  • Activity:
    0%
  • Reputation Power: 3
  • Grandewd has no influence.
  • Respect: +24
  • Referrals: 0
    • View Profile
Getting the value of Physical Resist from a piece of armor
« on: July 02, 2014, 03:21:43 PM »
0
We have #fr #cr #pr #er to get the values of Fire/Poison/Energy/Cold.
What happened to Physical?  How do I get the value for Physical Resist on a piece of armor?

Thx

Offline Pearls

  • Hero Member
  • *
  • Posts: 557
  • Activity:
    0%
  • Reputation Power: 13
  • Pearls barely matters.Pearls barely matters.
  • Respect: +65
  • Referrals: 1
    • View Profile
Re: Getting the value of Physical Resist from a piece of armor
« Reply #1 on: July 03, 2014, 12:36:54 AM »
0
#AR, just check the EasyUO window on the right to see what else is there :)
XII : "My happiness as a married man is directly related to the amount of sex I have which, in turn, requires that I pretend I like these movies every now and then and that it really doesn't bother me when she tells me about her problems but doesn't want me to give her a solution ;) "

Offline manwinc

  • Elite
  • *
  • *
  • Posts: 2556
  • Activity:
    0%
  • Reputation Power: 32
  • manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!
  • Gender: Male
  • "The Devs Hard at Work"
  • Respect: +123
  • Referrals: 1
    • View Profile
Re: Getting the value of Physical Resist from a piece of armor
« Reply #2 on: July 03, 2014, 01:43:56 AM »
0
Here is my sub for pulling the value of Properties off items.


Code: [Select]
Sub Property
NameSpace Push
Namespace Local Mwinc_Property
set !Item %1
set !Property %2
For !Attempt 1 10
{
Event Property !Item
if Stone in #property
Break
wait 5
}
Str Count #property !Property
if #Strres > 0
{
set !Cnt #Strres
for !Holder 1 !Cnt
{
set !Value2 0
Str Len !Property
set !Length #Strres
Str Pos #property !Property !Holder
set !Start #Strres + !Length
for !Number 1 4
{
Str Mid #Property !Start !Number
if #Strres > 0
set !Value2 #Strres
}
set !Value !Value + !Value2
}
}
Else
set !Value 0
set #Result !Value
Namespace Clear
Namespace pop
Return #Result

And this  below is how you utilize it

Gosub Property (id of item) (String Before Value You Want)

You have to Remember that in order to get EasyUO to Recognize Spaces you have to use the #Spc and parsing to build the string.

Physical Resist = Physical , #Spc , Resist
Fire Resist = Fire , #Spc , Resist
Lower Mana Cost = Lower , #Spc , Mana , #Spc , Cost 

Sample code of how the Sub Works

Code: [Select]
Display Target the Item you wish to see the Physical Resist of
Set #targcurs 1
While #targcurs = 1
wait 1
Gosub Property #Ltargetid Physical , #spc , Resist
Display The Physical Resist is #Result
Halt


You can Disect the Sub if you'd like, but I'll explain the Input/output Values. You can Only Check 1 Property at a time. It uses #Result to return the Value that it found for that Property 0 if the value was 0 or if the property wasn't on the item. It Also reads all Values of the String,

So if you just told it Gosub Property (Id) Resist

It would find Each value after each word "Resist" And sum them up Giving you the total Resists on the piece of armor.

Monkeys and Typewriters!

" Oh I know, We'll make a Boss Encounter that requires 3 keys per player to enter, Then we'll make it not a closed instance so you never know if you are going to pop into a fresh room or a boss that has 1% Health left with 20 dudes smashing its face in, wasting your time and effort"

Offline GrandewdTopic starter

  • Full Member
  • ***
  • Posts: 239
  • Activity:
    0%
  • Reputation Power: 3
  • Grandewd has no influence.
  • Respect: +24
  • Referrals: 0
    • View Profile
Re: Getting the value of Physical Resist from a piece of armor
« Reply #3 on: July 11, 2014, 04:19:46 PM »
0
Hi Manwinc,

Thank you for taking the time to respond, and for yet another reason to more fully understand global namespaces and persistent variables.

If you don't mind, could you possibly explain a couple of things to me:

From your example:

Code: [Select]
NameSpace Push
Namespace Local Mwinc_Property
set !Item %1
set !Property %2
For !Attempt 1 10

1)  I've looked at many scripts that are using global variables, and quite a few of them never use the NameSpace Push/Clear/Pop.  When and why are they sometimes used and other times not?
2)  set !Item %1  (So this sets a namespace variable (!Item) to a normal variable (%1) ) correct?  Why do I do that, ie, where is that %1 variable used?

Sorry if these questions are so very basic, but I don't have a mental image of what's happening there....

Offline manwinc

  • Elite
  • *
  • *
  • Posts: 2556
  • Activity:
    0%
  • Reputation Power: 32
  • manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!
  • Gender: Male
  • "The Devs Hard at Work"
  • Respect: +123
  • Referrals: 1
    • View Profile
Re: Getting the value of Physical Resist from a piece of armor
« Reply #4 on: July 11, 2014, 04:47:31 PM »
0
So, Lets say you are using a sub. And Inside of that Sub you use another Sub.

Code: [Select]
Gosub Test 1 2 3
Halt

Sub Test
Display  % , 1 = %1 $ % , 2 = %2 $ % , 3 = %3
Gosub Test2 4 5 6
Display  % , 1 = %1 $ % , 2 = %2 $ % , 3 = %3
Return

Sub Test2
Return

So, When you use the Gosub Command, it automatically sets the %0 %1 %2 %3 %4 Variables etc, So if you use a Gosub Within A sub, those Variables are going to change from what they originally were as you can see from the example code.

Its just good habit that if you are writing Universal Subs that you go ahead and set ! Variables to the %1-%n

Not Sure how much you've gotten to Play with Namespaces, but I'll give a brief Explanation.

Namespaces are used to "Separate" your Variables from other Variables that are being used throughout the Script, and can also be used to communicate information between Scripts (Bit more Advanced)

The Idea, is that when you use these "Universal" Subs, that they don't Change any of the % Variables, but still perform the task that was given to them.

You start off with a Namespace Push, This "Saves" Whatever the Last Namespace was so at the end of your Sub you Can Namespace Pop, Which Returns it to the original Namespace. What you'll see in most of my subs is what you've already noticed


Code: [Select]
Sub Test
Namespace Push ; Saves whatever the last namespace was
Namespace Local Name_Of_Namespace_Here
set !Var1 %1 ; Saving the %1-%n Variables to ! Variables to you don't lose them if you use a gosub inside the sub
set !Var2 %2
set !Var3 %3
;Actions
Namespace Pop ; REturns the namespace to what it was on the last Namespace Push
Return

The Concept is that if I were to Use the Sub, it would perform the action it was Built to do without Effecting any of the % Variables.
Monkeys and Typewriters!

" Oh I know, We'll make a Boss Encounter that requires 3 keys per player to enter, Then we'll make it not a closed instance so you never know if you are going to pop into a fresh room or a boss that has 1% Health left with 20 dudes smashing its face in, wasting your time and effort"

Tags: