• Please note: In an effort to ensure that all of our users feel welcome on our forums, we’ve updated our forum rules. You can review the updated rules here: http://forums.wolflair.com/showthread.php?t=5528.

    If a fellow Community member is not following the forum rules, please report the post by clicking the Report button (the red yield sign on the left) located on every post. This will notify the moderators directly. If you have any questions about these new rules, please contact support@wolflair.com.

    - The Lone Wolf Development Team

Deactivate an Ability?

zarlor

Well-known member
I know that abilActive (which we generally use to check if a user has "activated" and ability) is essentially a read-only variable. What I'm wondering is if there is any other way to to deactivate an ability in code, based on a pick.

So something like:
Code:
   foreach pick in hero where "component.Power"
      eachpick.field[abilActive].value = 0
   nexteach
 
Activation and Deactivation of abilities, Equiping/Unequiping of items, etc, are not something that can be scripted. Essentially, there is no 'state' capabilities in the script. Every time any ability is changed, the entire hero recalculates from the beginning, running all the scripts on all the picks, at all the appropriate timing steps.
 
Fuzzy, that's incorrect. You can create tags or use other settings to indicate whether something should be active or not and have the things that make something go inactive assign those tags/settings to the things that are inactive.

However, the Savage Worlds files have not implemented an overall system for this, the way many of our other game systems have.

zarlor, open Shadowrun 4 or 5, even if you don't have those licensed. In the editor, take a look at the scripts - start on the Qualities - that's the closest equivalent to SW's Edges, so lots of them have scripts.

Take a look at the doneif that they all (should) share at the beginning of their scripts. That setting - activated = 0 or 1, is something you can change in a script. Then, you can use the same activated = 0 doneif that Shadowrun does.
 
Actually, in this case, there is a state capability. It's stored in field[abilActive].value (0 or 1, 1 being Active). It's the field that gets used when something has "Activated by User?" set. It's the checkbox you see on the In-Play tab.
For anything designated as Equippable, it's field[grIsEquip].value (0 or 1, 1 being Equipped). This is the checkbox next to each piece of gear you can equip, mainly weapons and armor.

Does that help?
 
I understand that there are abilActive and grIsEquip fields, but i was under the impression they were essentially read-only during the eval phases.
 
Fuzzy's right, Caped. You'll get an error if you try to do the script I mentioned above that tries to write to abilActive. Specifically the error I get is "Only derived fields can generally be modified via scripts (field 'abilActive')"
 
Last edited:
Oh, duh. I never even thought about something like that working. Now I just have to figure out the other bits I need to do.

Thanks!
 
Last edited:
I'm still getting a bit stumped on this. Here's the Eval script I'm using right now at PreTraits/5000:

Code:
trustme
var modifier as number
modifier = 4

if (tagis[User.HindMajor] <> 0 ) then
      modifier = 0
endif

if (field[abilActive].value <> 0) then
   foreach pick in hero where "(component.Skill | component.Attribute)"
      eachpick.field[trtRoll].value -= modifier
   nexteach

   foreach pick in hero where "component.SPCPower"
      eachpick.field[abilActive].value = 0
   nexteach
endif

First off when I have Allergy selected as a Minor Hindrance on the portfolie I'm not getting the -4 to Attribute rolls, just to Skills.

I also get an error:

"ttempt to access field 'abilActive" that does not exist for thing 'spcArmor'
Location: 'eval' script for Thing 'hinNEAller' (Eval Script #1) near line 16"

(Same error for each power in the portfolio.)

If I select this as a Major Hindrance on the character sheet I still get the -4 on skill rolls showing and the above error pops up and none of the Super Powers deactivate. No doubt it's something obvious I'm missing here (isn't it always?) but I'd sure appreciate the help if anyone can see what I'm messing up.
 
Look at the things you're finding with your

Code:
foreach pick in hero where "component.SPCPower"

search - do they have an abilActive field?

Reminder: that should be written as:

Code:
foreach pick in hero from SPCPower

It's faster for HL to execute that line of code than your original, and both will find the exact same things.
 
They should have an abilActive field, heck they all show up on the In Play tab with a checkbox which is exactly what we check for when using abilActive to see if something is checked.

I'll change up that component line. I had no idea if that made any kind of difference at all. As long as I've been doing this I still feel like a total n00b with it.
 
I just took a look at the compsets, and there's only one that includes the SPCPower component. It's named SPCPower, and contains the following components: SPCPower, Tracker, UserSelect, Domain.

The abilActive field is in the Ability component, so it's not in that compset.
 
I'm at a loss. Maybe Caped has some idea what I should be looking at here, then? I'm feeling completely clueless here.
 
Ok, I think I'm just going to give up on the Deactivating Abilites part, in part because I just can't figure it out but also because I'm not sure that the ANE version of the Allergy Hindrance should actually affect ALL Super Powers anyway. After all, if you have some powers in a Device does your Allergy affect those as well? (In other words, if Superman had a stun gun, would Kryptonite prevent his Stun Gun from working?) Or maybe vice-versa, what if the Allergy is for those things in a Device, so let's say if Namor were flying around in Iron Man's suit, but the suit he had has an Allergy to water (it wasn't waterproof, in other words), would Namor loose his super strength because of the suit's allergy? I'm not sure if there is an official answer for that, but I figure it's better to leave the flexibility of leaving it to the player to deactivate only those things affected by his Allergy.

That being said I still can't see what I'm doing wrong with the first part of my code above.

The way I read what's happening is that I set a modifier variable to equal 4, then I check to see if the user has made this hindrance a Major Hindrance and, if so, I change the modifier to equal 0.

Next I check if the Allergy have been Activated by the user. If it has then I apply whatever my modifier is to all Skills and Attributes, which should mean at a Minor hindrance I'm applying a -4 modifier, but if it's selected as Major I'm applying a modifier of 0. Unfortunately when I select it as Major I'm still getting a -4 being applied. :(

BTW, since Mathias mentioned using just SPCPower above instead of component.SPCPower I tried that syntax with the component.Skill | component.Attribute line as well, but it gives and error of that being an invalid tag expression. Just as an FYI, so I'm still using the component. part.
 
BTW, since Mathias mentioned using just SPCPower above instead of component.SPCPower I tried that syntax with the component.Skill | component.Attribute line as well, but it gives and error of that being an invalid tag expression. Just as an FYI, so I'm still using the component. part.


If you're getting a syntax error, could you please post the code that's giving you an error?
 
Prettum much just the same as above, but I remove the "component." part, as below.

Code:
var modifier as number
modifier = 4

if (tagis[User.HindMajor] <> 0 ) then
      modifier = 0
endif

if (field[abilActive].value <> 0) then
   foreach pick in hero where "(Skill | Attribute)"
      eachpick.field[trtRoll].value -= modifier
   nexteach
endif

It compiles fine, but if you click the checkbox to activate the hindrance it gives an error that it's an invalid tag expression at that point. There is no error if I use component. before Skill and Attribute above, though, on that foreach line.
 
In the "from component" part of a foreach, component is just the Id of the component, without "component." in front of it.

In the "where expression" part of a foreach, expression must be a normal tag expression, so you have to use the normal group.tag format for any tags.

As a reminder, there's a discussion of foreaches in post #7 of this thread: http://forums.wolflair.com/showthread.php?t=21663
 
Thanks. But it's not much of a reminder because I don't normally have any real reason to visit the Pathfinder forum. :) Heck, they already get lots of love there, I don't want to encourage them to get even MORE attention over us Savage Worlders! ;) (Yeah, I know I actually have links pointing to your posts from our Common Code thread here. Half of it is still over my head, though!)
 
Last edited:
Bump, in case anyone has some ideas on this. I'm still getting the -4 on everything whether it's user selected at Minor or Major.
 
CapedCrusader? Mathias? Either of you have some idea on this? It's the last thing I need to complete the Necessary Evil file. :(
 
Back
Top