#Automation Help

1 messages · Page 1 of 1 (latest)

upbeat geyser
#

Threaded

placid patrol
#

thanks!

upbeat geyser
placid patrol
#

found something looking into the console and testing out a seperate item to just try to get one part working first, resistances (and resistance) are not defined it says so I am guessing I have to set a constant for that

upbeat geyser
#

Your syntax here is wrong (“result” is not a property of an active effect), but there’s also a system bug that will prevent you from supplying changes in a prepare hook

#

You should wait until the next patch on this one

#

Alternatively you can do it now by switching to a postActivate hook and customizing outcome.effects

placid patrol
#

I'm honestly confused where I got result from, I don't even see it in any of the things I was referancing lol

#

ah aura, I looked at it briefly trying to figure out how effects work thats why

placid patrol
placid patrol
#

oh I was being dumb with how I was trying to apply resistances

#

I was overcomplicating it

placid patrol
#

think I am going to take a break from conversion work and just go do a javascript coarse so I can get the fundamentals its all built on down first and avoid as much syntax errors as I keep running into due to poor formatting from not knowing the language

#

(I think this is java script at least, I michael mentioned something I did in a prior thing I was doing was confusing java)

placid patrol
#

I wish I had done this a lot sooner, this is really easy to learn and is helping me understand why things I have been doing have been working lol

placid patrol
#

and with that done I will now try my hand at that again

#

hooks are just functions that are predetermined within foundry right?

placid patrol
#

maybe I will wait for the next patch for that, even after learning how the syntax and stuff works I still spent like 2 hours banging my head against it trying to get it to work with no avail no matter what I tried and the only thing I managed to do was frustrate myself rather than actually getting anything productive done

#

reworked it to be a slightly less powerful passive effect that is always given when the item is invested rather than my original plan of having it be temporary buff that could be triggered once per day, the item is cursed so it shouldn't provide any balance issues as the likelyhood of the players using it longterm is low

placid patrol
#

what would I have to do to call the overflow damage amount from an attack

#

trying to create a attack that triggers a secondary defense which deals some extra damage if successful while also healing the user by a amount equal to the damage from that secondary attack

#

so far I have this

#
this.usage.defenseType = "fortitude";
const attack = await this.actor.weaponAttack(this, mainhand, outcome);
outcome.rolls.push(attack);
const self = this.outcomes.get(this.actor);
self.resources.health = (self.resources.health || 0) +this.damage```
which adds the secondary attack on (though I think it may apply it even if the first attack hits which is something that I want to figure out how to make it not do, it should only trigger if the main attack of the action hits, I have tried adding outcome = true which gives me a error that boons is not defined which really confused me as I don't have the word boons anywhere in my hook, and I also tried outcome = success but that just says success is not defined
gilded gazelle
#

Feels like a less crucible question and more a generic foundry/JS question, it's baby's first macro after all, but nevertheless crucible-sourced and adjusting crucible-specific properties, so putting it here...

I'm trying to write a quick macro so that one of my players can switch his versatile weapon between 1H and 2H without having to open the item configuration each time. He's likely to do this a lot as a 2H-weapon wielding spellcaster, since Crucible doesn't seem to have any reason he can't briefly let go of the weapon to cast a spell with a free hand.

The following works in terms of modifying the underlying value, but doesn't seem to modify the labels in the UI. Is there some 'and refresh the character sheet' call I need to make?

(Aware that hard-coding the Actor and Item IDs is a little crude, but can patch that better later.)

const actor_id = "wKlsFeMWzRBqeNwL"
const item_id = "4eiQh69hUrAS8h5N"
const vweapon = game.actors.get(actor_id).items.get(item_id)

if (vweapon.system.properties.has("versatile")) {
  if (vweapon.system.slot == 3){
    vweapon.system.slot = 1;
  }
  else if (vweapon.system.slot == 1){
    vweapon.system.slot = 3;
  }
}```
placid patrol
placid patrol
#

think I found what I will need to reference for that

placid patrol
#

well I thought I did, I have tried a few ways of calling overflow using the stuff I found in attack-roll.mjs but they all keep pulling up errors even when I try to just console log them

#
    return this.total - this.data.dc;
  }```
and ```get overflow()```
both tell me overflow is a unexpected token
#

ok so its because I was misunderstanding how get works

#

so I need to figure out what the name of the variable that overflow is linked to is, I have tried damage.overflow, damageData.overflow, data.overflow, ect and can't seem to find what the right const name is

#

I am so confused, I feel like I am missing something but I can't figure out what

placid patrol
#

I feel like I am trying to call these wrong but I am not sure what I am doing wrong, shifted over to just trying to make the self healing only trigger on a hit and I can't seem to get it to call the result of the attack either

#

even though I am looking right at where those results are defined in crucible-compiled.mjs since I realized I can just find everything thats in the smaller files all in there together

#

I tried calling them as numerical values since they are shown to each represent a numerical value in there (and that means I can use >= to make it do a if statement if the result is at least the result I want or higher which is useful) as well as by their names that it states in the document

placid patrol
#

think I found it

#

this.usage.damageOverflow is returning a result in console.log rather than a error, its undefined but I think thats just because I don't have to checking on the correct thing

upbeat geyser
#

Sorry I've not been very helpful today @placid patrol - super busy right now with some things but I'm glad you got it solved.

placid patrol
#

your all good, this isn't ultimately your guys focus at the moment as your (rightfully so) focused on getting the actual development of the system and ember progressing. Plus I am bumbling through the code like a elephant in a china store, took a few javascript classes today and yesterday that help me understand the fundamentals of the language so I am able to do a bit better than I was before but this stuff is still quite complex by comparison so I am undoubtedly making quite a few mistakes that someone more experienced wouldn't need to worry about

placid patrol
#

I just ran into something that I don't even know how to begin to understand, I am trying to set up an if statement to only trigger the second attack if the first one hits, so I am using console.log to figure out what does and doesn't work to test for and figure out what to detect for because I was thinking doing if(attack.result >= 6) would work since each attack result is tied to a number with 6 being glance and 7 hit, so in that case it would trigger in any situation that is either a glance or a hit but that didn't seem to work, so I started testing, and console.log(attack.result) gives me some weird stuff, console.log(attack) gives me a summery of the dice

#

but console.log(attack.result) gives this

#

the last 3 are the modifiers to the roll like you would expect

#

you would think those first 3 are the dice rolls

#

but its not

#

thats the dice for it

#

I have no clue what those first 3 numbers do

#

I figured out how to call the result, I have to do attack.data.result but I am still so confused what that is lmao

#

actually I think I figured it out

#

its still rolling the dice for the second attack

#

thats what those dice are

#

when I am calling attack and attack.result and what not I am not calling the main attack

#

I am calling the secondary attack

#

and now I am back to the drawing bored on trying to figure out how to call off the original attack

#

interesting error Invalid line number 8 in 7-line document

upbeat geyser
placid patrol
#

the data mainly as that gives me access to a variety of stuff such as the overflow damage (which I was looking for for my previous thing), right now I am looking to try and detect it so I can detect attack result and set the second attack to only trigger if the first hits

#

not sure why its giving that error, I reset it back to how I had it working before and its still doing it saying theres a unexpected token at the end that isn't there

upbeat geyser
#

roll.isSuccess will tell you if a result hit or not

placid patrol
#

ah yea thats right

#

because of the two nested ones

upbeat geyser
#

if you need more than that, you can check roll.data.result which is a value in AttackRoll.RESULT_TYPES

#

which tells you whether it was a dodge, a parry, a glance, a hit, etc...

placid patrol
#

yea thats what I was trying to get but isSuccess should work as honestly it should probably only trigger on a full hit as I don't think glances count for on hit effects with most other crucible stuff so for parity sake I should probably keep it the same

#

error, roll is not defined

#

oh wait its because I had to put this.roll.isSuccess

#

now its telling me isSuccess is not defined but I think thats just because it doesn't know which roll I am calling

#

that should be a easy fix

#

nvm it is still saying isSuccess is undefined even with me specifiying what role. I will just go ahead and try roll.data.result as that should work the same if I make it test for === 7

#

data is undefined

upbeat geyser
#

@placid patrol let me provide some advice:

I think you're giving me (and perhaps yourself) a little whiplash with the way you are asking for help. Sending a message about every single thing you try, just to move the goalposts of what the problem is with the very next message, makes it very hard to respond with meaningful and helpful advice.

Slow down a bit, spend a bit more time trying to debug or diagnose things yourself, and then if you are still stuck post a message here with a clear summary of the problem that makes it easy for me or someone else to understand and respond to.

placid patrol
#

Yea that's fair I apologize

placid patrol
#

ok I took some time to look over what I have and organize it along with comments explaining my thought process and intent. I tried to troubleshoot with console.log to try and get any format of roll.isSuccess and roll.data.result to return something other than errors or undefined but nothing I tried would, everything else is fully working aside from the testing if the first roll is successful, I have gotten it to test properly if attack (my second roll that triggers off the first) works as well as to properly call its overflow damage, the only issue is I can't figure out is how to get it to call the result of the first attack (which is the attack preprogramed into the action the hook is being input into). I am pretty sure I am just doing something wrong with my sintax but I am not sure what, (I also tried both roll.isSuccess and roll.data.result on their own without this.actor or anything of the sort before it in case it needs to be just that and got the same result).

#
// tests if the first attack is a success, returning error: "ypeError: Cannot read properties of undefined (reading 'isSuccess')"
const originAttack = this.actor.roll.isSuccess;
// defines the defense type of the second attack (working)
this.usage.defenseType = "fortitude";
// defines the second attack (working)
const attack = await this.actor.weaponAttack(this, mainhand, outcome);
if (originAttack === true){
  // triggers the second attack if the first attack is successful, not working because of originAttack currently being broken but otherwise works
  result: outcome.rolls.push(attack);
  const attackResult = attack.data.result;
  const self = this.outcomes.get(this.actor);
  // tests if the second attack is a hit, if it is heals user by an amount equal to the overflow damage of attack 2 (working)
  if(attackResult === 7){
    result: self.resources.health = (self.resources.health || 0) + attack.data.overflow;
  }
};
// just me testing what will output a value and what won't
console.log(originAttack)```
#

I am going to take some time to work on some non hook related stuff for a bit as that should give time to wait for a response and not overload the chat with multiple updates, and it should double as giving me a chance to sorta calm my brain as I enjoy the crucible conversion stuff a lot more than the hooks as I can do that stuff without getting nearly as confused lol

gilded gazelle
# gilded gazelle Feels like a less crucible question and more a generic foundry/JS question, it's...

Figured it out, and I imagine a rookie error everyone makes at some point early in their foundry-automation careers. I was updating the client side but not the server. Fixed with:

const actor_id = "wKlsFeMWzRBqeNwL"
const item_id = "4eiQh69hUrAS8h5N"
const vweapon = game.actors.get(actor_id).items.get(item_id)

if (vweapon.system.properties.has("versatile")) {
  if (vweapon.system.slot == 3){
    vweapon.update({
      system: {
        slot: 1
      }
    });
    ui.notifications.warn("Switched to 1H!");
  }
  else if (vweapon.system.slot == 1){
    vweapon.update({
      system: {
        slot: 3
      }
    });
    ui.notifications.warn("Switched to 2H!");
  }
}
upbeat geyser
# placid patrol ```const mainhand = this.actor.equipment.weapons.mainhand; // tests if the first...

Hey @placid patrol thanks for the more detailed question. What hook are you placing this code inside? the roll(outcome) hook?

There are a few problems I notice:

  1. this.actor.roll is not a property. If you want to look at rolls that have already been made as part of the outcome you need to use outcome.rolls. That is what the first error message you mention is referring to.
  2. You shouldn't perform the second attack via this.actor.weaponAttack unless you actually need to.

I'd recommend you take a look at HOOKS.feintingStrike in crucible/module/hooks/action.mjs for an example of an action which makes an extra attack conditional on some first check being successful.

upbeat geyser
placid patrol
# upbeat geyser Hey <@497357972469579787> thanks for the more detailed question. What hook are y...

I had it under the postActivate hook, not sure why, can't remember but I tried switching it to roll(outcome) as well as switching over to outcome.rolls, and with some troubleshooting with comand.log managed to get to where it is calling the first rolls result. I am not sure if my instance needs weaponAttack, it is a talisman attack using a wand so I imagine it might? but I am not 100% sure, the second attack is meant to more so represent the target of the attack resisting the magical effects that leach their health to heal the attacker (hence the fortitude defense rather than physical).
and feintingStrike was actually ironically where I got the foundation I started working off of from, or another talent similar to it that triggers a second attack I can't remember for sure which talent it was.
I got it functioning though thanks to both the switch to outcome.rolls and the use of the roll(outcome) hook, final fully functional code was this:

const attack = await this.actor.weaponAttack(this, (this.actor.equipment.weapons.mainhand), outcome);
if (outcome.rolls[0].data.result === 7){
  result: outcome.rolls.push(attack);
  const self = this.outcomes.get(this.actor);
  if(attack.data.result === 7){
    result: self.resources.health = (self.resources.health || 0) + (attack.data.damage.overflow += attack.data.damage.base += attack.data.damage.bonus -= attack.data.damage.resistance);
  }
};```
(cleaned it up a little bit because I realized some of my variables were unnecessary)
#

thanks for the help!

placid patrol
#

running into a interesting issue that I have tried to troubleshoot for the past few hours to no avail. I am converting the wraith from 5e which has a life drain ability, to keep the spirit but make it something more within the crucible style I made it deal a bit of wounds alongside successful attacks (equal to half the damage of the attack, though I might change it to a 4th of the attack damage once I playtest if that proves too deadly). I think I figured out how to properly script it, even the console log shows the updated wound value but it doesn't seem to persist at all or show up on the character sheet.
current code is this:

  const lifeDrain = ((outcome.rolls[0].data.damage.base + outcome.rolls[0].data.damage.overflow + outcome.rolls[0].data.damage.bonus - outcome.rolls[0].data.damage.resistance)/2)
  result : outcome.target.system.resources.wounds.value = (outcome.target.system.resources.wounds.value || 0) + lifeDrain;
};```
#

(was trying to use outcome.rolls[0].data.damage.total rather than chaining all the types together but it kept kicking back a error about total being undefined so I just manually simulated it)

#

oh and its under a roll hook on an action, forgot to mention that

upbeat geyser
placid patrol
# upbeat geyser Not at my pc to look right now, but you could look at the behavior of vampiric b...

That's where the basis for this one comes from, the draining is working properly (it's the same system I used on the life leech of the finger wand thing just trying to add the value to the targets wounds rather than the users health and it doesn't need the second attack like that did) I can get it to call the wound value and add the correct value too it (with a call of the wound value after adding them showing the updated value) it just doesn't seem to stay updated as it reverts back to the original value right afterwards. Does the same thing on both .system.resources.wounds as well as _cachedResources.wounds as I tried both since I wasn't sure which one was the one I needed (side note I figured out exploring object property paths through the comand.log is a lot easier than doing so through the files)