Magic

Magic

190k Downloads

Attributes applied to mobs not functioning properly?

NightScythe1 opened this issue ยท 24 comments

commented
dragon_stat_randomiser:
  icon: enchanted_book
  actions:
    cast:
    - class: CheckRequirements
      requirement:
        attribute:
          attribute: dragon_generated
          max: 0.5
      actions:
        - class: ModifyEntity
          mage:
            attributes:
              dragon_generated: 1
              health_dragon: ceil(rand(0,12))
              defence_dragon: ceil(rand(0,12))
              power_dragon: ceil(rand(0,12))
              speed_dragon: ceil(rand(0,12))
              agility_dragon: ceil(rand(0,12))
  parameters:
    bypass_undo: true
    target: other

the following spell is intended to apply a randomised number to these attributes on a Magic Mob (made as a workaround to my last issue) but it has some weird functionality-

  1. Upon initial cast it works as intended, giving each stat a random value 0-12
  2. However, this randomised stat then re-rolls and randomises 0-12 again after any reloads and '/magic load'
  3. The randomised stat is set back to 0 when the server restarts

Is there a way to ensure the randomised stat is saved/will stay the same after the spell is first used?

commented

This is working for me:


test:

  actions:

    cast:

    - class: CustomProjectile

      actions:

        - class: ModifyProperties

          modify_target: "mage"

          modify:

          - property: attributes.ag

            value: rand(0,5)

        - class: Cast

          as_target: true

          spell: check

  parameters:

    target: other

    range: 32



check:

  actions:

    cast:

    - class: AreaOfEffect

      actions:

        - class: Message

          message_target: true

          message: "$ag"

  parameters:

    target: self

    target_self: false

    range: 5

    radius: 10

    y_radius: 10

Thank you so much for this!!! I'll give it a test as soon as i'm home. Do these stats remain after reloads & server restarts?

commented

haven't tested that part, but i assume - yes
upd: NO

commented

well now i'm dissapointed: is it not just 1 single action reverting itself on restart, but it's actually every action?

commented

something here is definetly broken, these actions are not supposed to revert on restart - it's just breaks the whole purpose of them

commented

Have you tried ModifyAttributes instead of ModifyProperties?

Sorry if I'm not totally following, I'm honestly a little hazy on the difference between the two, especially when using the latter to modify attributes :|

commented

Have you tried ModifyAttributes instead of ModifyProperties?

Sorry if I'm not totally following, I'm honestly a little hazy on the difference between the two, especially when using the latter to modify attributes :|

Tried it now and it also does not work. I assume attributes itself are broken?

commented

Also tried it on both magic and vanilla mobs - same result. So it's not a magic mob's template overwriting the data i guess

commented

This is working for me:

I tried using this spell but it doesn't seem to work at all for me, it doesn't change the mob's stat and always prints '0'. The only things I changed from your original example was the attribute name-

test:
  actions:
    cast:
    - class: CustomProjectile
      actions:
        - class: ModifyProperties
          modify_target: "mage"
          modify:
          - property: attributes.health_dragon
            value: rand(0,5)
        - class: Cast
          as_target: true
          spell: check
  parameters:
    target: other
    range: 32

check:
  actions:
    cast:
    - class: AreaOfEffect
      actions:
        - class: Message
          message_target: true
          message: "$health_dragon"
  parameters:
    target: self
    target_self: false
    range: 5
    radius: 10
    y_radius: 10
commented

Just another update, I actually did manage to get ModifyAttributes to work on the mob, it sets the random stat without being changed on reloads and /magic load, but it does still reset upon server restart (as @PhvntxmX said in #1226)

    - class: ModifyAttribute
      bypass_undo: true
      attribute: health_dragon
      value: ceil(rand(0,12)) 
commented
  1. Upon initial cast it works as intended, giving each stat a random value 0-12
  2. However, this randomised stat then re-rolls and randomises 0-12 again after any reloads and '/magic load'
  3. The randomised stat is set back to 0 when the server restarts

Is there a way to ensure the randomised stat is saved/will stay the same after the spell is first used?

This also occurs if using SpawnEntity instead. Still struggling to find a way to allow Magic Mobs to keep set-stats after restarts & to allow placeholders for some of these equations.

    - class: SpawnEntity
      type: monstrous_nightmare
      mage:
        attributes:
          speed_dragon: ceil(rand(0,12))
commented

its just how rand function behaves, i think solution is just to store "ceil(rand(0,12)" into a ModifyVariable action's variables and use them for your ModifyEntity action

commented

its just how rand function behaves, i think solution is just to store "ceil(rand(0,12)" into a ModifyVariable action's variables and use them for your ModifyEntity action

No luck with this unfortunately :( I tried adding the following to the start of the spell:

    - class: ModifyVariable
      variable: hprand
      value: ceil(rand(0,12))

and calling it back later via

        - class: ModifyEntity
          mage:
            attributes:
              health_dragon: hprand

(varying with 'hprand' and '@hprand' and '$hprand') but it doesn't seem to work at all, and the stat remains at 0

commented

It doesn't fix the problem obviously, but I'm sure it'll work as a temporary solution

commented

What about using command action and /mage command instead of this?

commented

I'll give it a try now!

commented

No luck, unfortunately. It works on players, but not on mobs.

commented

that's really strange, i need to test it myself...

commented

This is working for me:

test:
  actions:
    cast:
    - class: CustomProjectile
      actions:
        - class: ModifyProperties
          modify_target: "mage"
          modify:
          - property: attributes.ag
            value: rand(0,5)
        - class: Cast
          as_target: true
          spell: check
  parameters:
    target: other
    range: 32

check:
  actions:
    cast:
    - class: AreaOfEffect
      actions:
        - class: Message
          message_target: true
          message: "$ag"
  parameters:
    target: self
    target_self: false
    range: 5
    radius: 10
    y_radius: 10
commented

"ag" attribute will change every cast as expected, but you can add checkrequirements to prevent it

commented

Update: from my testing so far, MagicMob attributes, edits, stats, etc, can be saved with save_non_player_mages: true set in config!

commented

Well that makes sense!

Just keep in mind that is off by default for performance/storage reasons.

It's maybe not a huge deal, but this will cause a file (or db row, or whatever player data storage you're using) to get created for every magic mob you spawn.

commented

Ahh I see, that makes sense. Could there be a way to differentiate/decide if particular mobs get their stats saved? I'm mostly just trying to make sure owned pets (or anything with the persist tag) don't get wiped. I assume this will be an issue as dragons are naturally spawning mobs that need to be tamed? (i.e. every wild dragon ever spawned will have a file generated)

commented

Yeah that's kind of my concern .... are the naturally spawned ones persistent also, or do they not persist until tamed?

Either way it sounds like a special flag to save mobs would be nice.

Alternately I should really look into using the persistent data container on mobs for this kind of thing, I can't remember if magic does anything with that or not.

commented

Naturally spawned dragons don't have the persistent tag until they're tamed, the interaction spell they have (like philbert's) applies the persist: true tag to them and thankfully this seems to stick/remain on server restarts, even if the save_non_player_mages is set to false. With this false, they seems they keep most vanilla attributes and tags even if they're set with magic, it was just things that are solely magic/magic integrated that got wiped (e.g. disguises, attributes)