• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Class changing trigger

Status
Not open for further replies.
Level 5
Joined
Dec 3, 2012
Messages
117
So, in my RPG the players' heroes ahve to be able to change jobs, now I thinhk I have a pretty decent trigger to do this:

  • Swordsman Job Change
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Interact (Basic Skills)
      • (Unit-type of (Target unit of ability being cast)) Equal to Swordsman Job Changer
    • Actions
      • Set TEMPInteger = (Player number of (Owner of (Casting unit)))
      • Set TEMPPlayerGroup = (Player group((Triggering player)))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • JOBLevel[TEMPInteger] Equal to 10
          • HEROClassNr[TEMPInteger] Equal to 0
        • Then - Actions
          • -------- Setting Availabe SP to job lvl. In case of novice to basic job, ignore this. --------
          • Set SkillPointsAvailable[TEMPInteger] = JOBLevel[TEMPInteger]
          • -------- Saving the heroes stats in integer variables. --------
          • Set JOBChangeStats[TEMPInteger] = (Strength of HEROPlayerHero[TEMPInteger] (Exclude bonuses))
          • Set JOBChangeStats[(TEMPInteger + 6)] = (Agility of HEROPlayerHero[TEMPInteger] (Exclude bonuses))
          • Set JOBChangeStats[(TEMPInteger + 12)] = (Intelligence of HEROPlayerHero[TEMPInteger] (Exclude bonuses))
          • -------- Saving the heroes unspent attribute points in integer variables. --------
          • Set JOBChangeUnspentAP[TEMPInteger] = (Unspent skill points of HEROPlayerHero[TEMPInteger])
          • -------- Saving the heroes items in item variables. --------
          • Set JOBChangeItems[TEMPInteger] = (Item carried by HEROPlayerHero[TEMPInteger] in slot 1)
          • Set JOBChangeItems[(TEMPInteger + 6)] = (Item carried by HEROPlayerHero[TEMPInteger] in slot 2)
          • Set JOBChangeItems[(TEMPInteger + 12)] = (Item carried by HEROPlayerHero[TEMPInteger] in slot 3)
          • Set JOBChangeItems[(TEMPInteger + 18)] = (Item carried by HEROPlayerHero[TEMPInteger] in slot 4)
          • Set JOBChangeItems[(TEMPInteger + 24)] = (Item carried by HEROPlayerHero[TEMPInteger] in slot 5)
          • Set JOBChangeItems[(TEMPInteger + 30)] = (Item carried by HEROPlayerHero[TEMPInteger] in slot 6)
          • -------- Saving Abilities --------
          • Set JOBLearnedAbilities[TEMPInteger] = (Ability being cast)
          • -------- Creating new job level hero --------
          • Set TEMPPoint = (Position of HEROPlayerHero[TEMPInteger])
          • Unit - Remove HEROPlayerHero[TEMPInteger] from the game
          • Unit - Create 1 Swordsman (Basic Job) for Player 1 (Red) at TEMPPoint facing Default building facing degrees
          • Set HEROPlayerHero[TEMPInteger] = (Last created unit)
          • Set HEROClassNr[TEMPInteger] = 1
          • Custom script: call RemoveLocation (udg_TEMPPoint)
          • -------- Adding saved Attributes, Unspent AP and items --------
          • -------- Stats --------
          • Hero - Modify Strength of HEROPlayerHero[TEMPInteger]: Set to JOBChangeStats[TEMPInteger]
          • Hero - Modify Agility of HEROPlayerHero[TEMPInteger]: Set to JOBChangeStats[(TEMPInteger + 6)]
          • Hero - Modify Intelligence of HEROPlayerHero[TEMPInteger]: Set to JOBChangeStats[(TEMPInteger + 12)]
          • -------- Unspent AP --------
          • Hero - Modify unspent skill points of HEROPlayerHero[TEMPInteger]: Set to JOBChangeUnspentAP[TEMPInteger] points
          • -------- Items --------
          • Hero - Create (Item-type of JOBChangeItems[TEMPInteger]) and give it to HEROPlayerHero[TEMPInteger]
          • Hero - Create (Item-type of JOBChangeItems[(TEMPInteger + 6)]) and give it to HEROPlayerHero[TEMPInteger]
          • Hero - Create (Item-type of JOBChangeItems[(TEMPInteger + 12)]) and give it to HEROPlayerHero[TEMPInteger]
          • Hero - Create (Item-type of JOBChangeItems[(TEMPInteger + 18)]) and give it to HEROPlayerHero[TEMPInteger]
          • Hero - Create (Item-type of JOBChangeItems[(TEMPInteger + 24)]) and give it to HEROPlayerHero[TEMPInteger]
          • Hero - Create (Item-type of JOBChangeItems[(TEMPInteger + 30)]) and give it to HEROPlayerHero[TEMPInteger]
          • -------- Resetting job level, SP and adding previous job skills (BETA, NOVICE ONLY FOR NOW) --------
          • Set JOBLevel[TEMPInteger] = 1
          • Set SkillPointsAvailable[TEMPInteger] = 1
          • Unit - Add Swordsman Skills (Spellbook) to HEROPlayerHero[TEMPInteger]
          • Unit - Add Novice Skills (Spellbook) to HEROPlayerHero[TEMPInteger]
          • Unit - Add Basic Skills (Container Play Dead) to HEROPlayerHero[TEMPInteger]
          • Unit - Add Basic Skills (Container First Aid) to HEROPlayerHero[TEMPInteger]
          • Unit - Set level of First Aid (Basic Skills) for HEROPlayerHero[TEMPInteger] to 3
          • Selection - Select HEROPlayerHero[TEMPInteger] for (Owner of (Casting unit))
          • Game - Display to TEMPPlayerGroup the text: (|cff9acd32You have changed your job to |r|cffffcc00 + ((Name of HEROPlayerHero[TEMPInteger]) + !|r))
        • Else - Actions
          • Game - Display to TEMPPlayerGroup the text: |cff008000Your job ...
But I can't seem to figure out how to properly save the abilities and ability levels in the spellbook(s) of the removed unit and adding them to the new hero instead of what I have now, seeing as with later job changes heroes will have way more spells and higher spell levels...

I was thinking of saving the abilities in a variable array when learned, but then idk how I'd save the level of the ability
 
Last edited:
Level 3
Joined
Apr 10, 2013
Messages
8
I am unsure what you mean, but you could either use a saving/loading system or you could first initialize all the abilities in variables, and use this
  • Set AbilityLvl[Temp_integer] = (Level of YOURABILITY for YOURUNIT)
to get the level of the chosen ability.
 
Level 6
Joined
Oct 1, 2012
Messages
166
I too don't pretty much get it all. Your skills, I believe, are in spellbooks and added via <add spellbook>, <make spellbook unavailable>, so the spellbooks merge?
Good idea, tho buggs the location of skills in the spellbook sometimes. If you don't care about that, that's good.

Still. You can always make an array of integers, or two even.
The first one would save the skills' ID's (skills are, in fact, integers) so you would have the given skills. If you, as I believe, add them via spellbooks, then you'll need a spellbook skill's ID. You can always make a function which takes the skill's ID and returns the ID of spellbook dummy skill.
As with the skills' lvls, you do the same, but easier - set udg_SkillLvls[index]=GetUnitAbilityLevel(hero, <<ability ID>>) and the, after changing the class, you simply load the skills and their lvls from arrays.

I wrote so much, I hope it's what you need :D
 
Status
Not open for further replies.
Top