• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Solved] Problems with modifying heroes attribute

Status
Not open for further replies.
Level 12
Joined
Aug 12, 2008
Messages
349
I creating a spell which it increases the hero's attribute by an amount every second but it seems doesn't work. Here goes the trigger:
  • SF cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Spirit Form
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SF_index1 Equal to 0
        • Then - Actions
          • Trigger - Turn on SF loop <gen>
        • Else - Actions
      • Set SF_index1 = (SF_index1 + 1)
      • Set SF_index2 = (SF_index2 + 1)
      • Set SF_check[SF_index2] = False
      • Set SF_caster[SF_index2] = (Triggering unit)
      • Set SF_bonus[SF_index2] = (Level of Spirit Form for SF_caster[SF_index2])
      • Set SF_count[SF_index2] = 0
      • Animation - Change SF_caster[SF_index2]'s vertex coloring to (100.00%, 100.00%, 100.00%) with 50.00% transparency
  • SF loop
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer SF_index3) from 1 to SF_index2, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (SF_caster[SF_index3] is alive) Equal to True
              • SF_count[SF_index3] Less than or equal to 15
            • Then - Actions
              • Set SF_count[SF_index3] = (SF_count[SF_index3] + 1)
              • Hero - Modify Strength of SF_caster[SF_index3]: Add SF_bonus[SF_index3]
              • Hero - Modify Agility of SF_caster[SF_index3]: Add SF_bonus[SF_index3]
              • Hero - Modify Intelligence of SF_caster[SF_index3]: Add SF_bonus[SF_index3]
            • Else - Actions
              • Animation - Change SF_caster[SF_index2]'s vertex coloring to (100.00%, 100.00%, 100.00%) with 0.00% transparency
              • Set SF_totalbonus[SF_index2] = (SF_bonus[SF_index3] x SF_count[SF_index3])
              • Hero - Modify Strength of SF_caster[SF_index3]: Subtract SF_totalbonus[SF_index3]
              • Hero - Modify Agility of SF_caster[SF_index3]: Subtract SF_totalbonus[SF_index3]
              • Hero - Modify Intelligence of SF_caster[SF_index3]: Subtract SF_totalbonus[SF_index3]
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • SF_check[SF_index3] Equal to False
                • Then - Actions
                  • Set SF_check[SF_index3] = True
                  • Set SF_index1 = (SF_index1 - 1)
                • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SF_index1 Equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
          • Set SF_index2 = 0
        • Else - Actions
EDIT: Sorry for subscribing this thread. I was too careless that I put the wrong index at the start. Thus, it's all fix now. How can I delete this thread?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,206
Jay the Editor, you forget the index deallocator routein when the ability is meant to end.

Basically, as the order does not mater (no relations between index slots) you need to replace the slot to remove with the last slot and then say that slot is free.

1. Finish off the spell instance.
2. Decriment the instance counter.
3. Move the instance at instance counter position to the finied spell instance.
4. Decriment the loop integer so that it repeats that index (as it has been assigned a different spell instance).

Might not be as efficient for a lot of parralel arrays compared to static positioning routeins but saves the extra layer of complexity required.
 
Status
Not open for further replies.
Top