• 🏆 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] Skill Level Up with item buy

Status
Not open for further replies.
Level 20
Joined
Jul 14, 2011
Messages
3,213
Hi Again! This is not multipost. The threads, though they are similar, have different goals.

I tough about making the skills level up by timer, but it's inefficient and hard to achieve. So I changed to the same system GoH uses (I think...) adding Stats and FP (Faith Points) requirements.

I'd like to know how can I improve it. If it includes JASS or vJASS, I'm open to it. (I want to do it perfectly from the beginning, because I'll make this about 100 more times for the other skills)


  • Entangling Roots
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Entanglin Roots
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • FP[(Player number of (Owner of (Triggering unit)))] Greater than or equal to 1
          • (Level of Entangling Roots for (Triggering unit)) Equal to 0
          • (Intelligence of (Triggering unit) (Exclude bonuses)) Greater than or equal to 30
        • Then - Actions
          • Unit - Add Entangling Roots to (Triggering unit)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • FP[(Player number of (Owner of (Triggering unit)))] Less than 1
                  • (Level of Entangling Roots for (Triggering unit)) Equal to 0
                  • (Intelligence of (Triggering unit) (Exclude bonuses)) Less than 30
            • Then - Actions
              • Player - Add 1 to (Owner of (Triggering unit)) Current lumber
              • Game - Display to (All players matching ((Owner of (Triggering unit)) Equal to (Owner of (Triggering unit)))) the text: Unit doesn't meet t...
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of Entangling Roots for (Triggering unit)) Less than or equal to 9
                • Then - Actions
                  • Unit - Increase level of Entangling Roots for (Triggering unit)
                • Else - Actions
                  • Player - Add 1 to (Owner of (Triggering unit)) Current lumber
                  • Game - Display to (All players matching ((Owner of (Triggering unit)) Equal to (Owner of (Triggering unit)))) the text: |cffffd700Entanglin...


- The skill costs 1 lumber.
- The item is still sold if the level is 10 or if the requirements aren't met, that's why I give lumber.
- I use All Players Matching Condition because, I read somewhere that (All Player) doesn't leak, but custom PlayerGroups does...
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
I can't add specific requirements for different skills in the test map you gave to me =/ Or at least, I don't know how
 
grrr trigger has 2 many if then actions that do nothing...
Here is how it can look like. test it please.

Each ability cost 1 lumber. (Can be changed)
Hero with int above 30 can learn it 10 times max. (Can be changed)
Each time he learn spell he will gain + 1 damage. (Can be changed)

Just tell me did you managed to understand code (you have notices imported as well).
It's MUI, leak free, bla bla bla...
 

Attachments

  • test map.w3x
    17.9 KB · Views: 70
Level 33
Joined
Mar 27, 2008
Messages
8,035
It's in the setup trigger, everything is in there.
(After all, all you need to do, is ask...)

As you can see from my previous test map, it has this trigger:

  • SLLUS Setup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- HEROES SKILL SET --------
      • -------- --------
      • -------- PALADIN SKILL SET --------
      • Custom script: set udg_Abilities[1] = 'AHhb'
      • Custom script: set udg_Abilities[2] = 'AHds'
      • Custom script: set udg_Abilities[3] = 'AHre'
      • Custom script: set udg_Abilities[4] = 'AHad'
      • -------- ARCHMAGE SKILL SET --------
      • Custom script: set udg_Abilities[5] = 'AHbz'
      • Custom script: set udg_Abilities[6] = 'AHab'
      • Custom script: set udg_Abilities[7] = 'AHwe'
      • Custom script: set udg_Abilities[8] = 'AHmt'
      • -------- MOUNTAIN KING SKILL SET --------
      • Custom script: set udg_Abilities[9] = 'AHtc'
      • Custom script: set udg_Abilities[10] = 'AHtb'
      • Custom script: set udg_Abilities[11] = 'AHbh'
      • Custom script: set udg_Abilities[12] = 'AHav'
      • -------- --------
      • -------- ITEM ABILITY SET' --------
      • Set ItemAbilities[1] = Holy Light
      • Set ItemAbilities[2] = Divine Shield
      • Set ItemAbilities[3] = Resurrection
      • Set ItemAbilities[4] = Devotion Aura
      • Set ItemAbilities[5] = Blizzard
      • Set ItemAbilities[6] = Brilliance Aura
      • Set ItemAbilities[7] = Summon Water Elemental
      • Set ItemAbilities[8] = Mass Teleport
      • Set ItemAbilities[9] = Thunder Clap
      • Set ItemAbilities[10] = Storm Bolt
      • Set ItemAbilities[11] = Bash
      • Set ItemAbilities[12] = Avatar
      • -------- --------
      • -------- MAX ITEMS --------
      • Set MaxItems = 12
As you can see I set for every skills in that map (there are 3 Heroes, which are Paladin, Archmage and Mountain King)
This will be replaced by your own Heroes' Spell in your own map.
To get its raw code (like the one I used), simply press CTRL + D in your Object Editor -> Abilities Tab.
As you can see my trigger has the 'AHhb' 'AHds' AHre, these are the raw codes for each ability, it has different raw code (not two ability can have the same raw code)

And next, I set ItemAbilities (this is the ability when you pick up certain item)

This will be replaced by all of your Item Abilities in your own map.

But I guess this would be too much for you, just abandon this system, maybe it's hard for you to understand lol.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213

Yeah, I saw every unit has 4 skills... though they can learn any of them.
I also know these codes are the rawcodes of the abilities.
And i know the abilities are associated with the ItemAbilities[Index]...

What I don't get, is the part of adding each skill a level, str, int, agi, and interger variable requirement... or in this case, each 'item' those requirements.


@Kobas, I think the same. I hate having so much 'If/Then/Else' but I think that nothing is worse :p

I tested your map.... I see how it works.... I see it's a lot better than mine in GUI xD ...but i'm not sure... Let me know if i'm wrong, hehe...

JASS:
local integer str = GetHeroStr(u, false)
local integer agi = GetHeroAgi(u, false)
These are needed for other spells.

JASS:
local integer aID = 'A000', //I would have t make bID, cID, dID (I guess) for each skill, since there are a lot of these (About 100, or so)

Also I need to check FP, and I would need to check if some other interger is true before giving the skill/item.

This skill is given by a Monk wich evolves a small quest. The unit needs to complete the quest the right way to receive 1FP to be able to get the skill, otherwise, the hero would have to get 1FP from some other quest and then come back to get the skills., so the real requirement (Only for the 3 skills that monk gives) would be - Quest completed - Stat+30, Fp+1.
I can't imagine how would the trigger look with so much variables and so many skills...

Excuse me for my dumbness :)
 
Yes it will work for agy and str

local integer aID
local means that variable is used only buy function where you generate variable
integer means that it's whole number (1,2,3,-3)
aID is simple a name (short for ability ID, I used that because variable names should be small and dunno I always use something like that)

'A000' is ability RAW code (Ctrl+D in Object editor to see it).
You can just edit this for each new spell like this:
JASS:
local integer aID = 'A000'
//or
local integer aID = 'A001'
//or
local integer aID = 'A002'
Object RAW code is different but always integer, there are functions like set uID = GetUnitTypeId(GetTriggerUnit()) that will store unit RAW code into variable etc etc.

But care to store them into variables (well as everything else) only if you use that few times.
Usually only this can work:
JASS:
//variables go here
//example
local unit u = GetTriggerUnit()
if GetSpellAbilityId() == 'A000' then                         //We check spell
    if GetUnitTypeId(u) == 'n03B' then         //We chck unit (for example this can be Ranger class)
        // Do your actions
    elseif GetUnitTypeId(u) == 'n02A' then         //We chck unit (for example this can be Warrior class)
        // Do your actions
    endif
endif
//Cleaning leaks here
//Example:
call RemoveLocation(p)
set p = null

I hope this helps :)
Well I suggest you to use Jass New Gen you have function list there as well.
Ofc you will learn some things really fast, and for some you will always need help.

Oh small note above when checking equitation use == like that, because = is used, well for "set new value" to that variable :D
I use jass only for week now :razz:
Still I (with help from coders) managed to convert like 50+ GUI triggers into jass and optimize it completely in my project, so I suggest you to start learning it as well :)
I just wanted to show you some basic and important things :)

If you are interested I can link you few to me useful tutorials, scripts or whatever that can help :)
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Ok Ok xD I need a break xD So much info and JASS together :p

I see JASS; and get how it works, and seems simple, but I do nothing in front of a fresh clean white page of custom script :D Is a lot easier to check how a car works, that create it :p

@-Kobas-: Thanks! It helps, mostly for the learning process. I use JNGP. I want to do the same, optimize all my triggers and systems to JASS, but i'm those that learn doing it, and not knowing how to do anything, well.. xD... It's like the snake that bites its tail :p. I've read about 6 tutorials so far... and though I know something, I still don't know how to do anything... :(

@Luorax: Thanks a lot. I see the system, and I see it's efficiency, but in my dumbness, that's all, i just 'see' xD
JASS:
    call RegisterItem('I000','A000') // The Item Raw and the Ability Raw.

I see how it works, but how could I add another requirements to each item/skill?

I would have to do all this and change some values for each item?
JASS:
function Item_System takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local integer int = GetHeroInt(u, false) //use true if you want to include bonuses
    local integer lumb = GetPlayerState( GetOwningPlayer(u) ,PLAYER_STATE_RESOURCE_LUMBER)
    local integer price = 1 // how much lumber will ability learn/level up cost
    local integer id=GetItem(GetItemTypeId(GetManipulatedItem()))
    if IsUnitType(u, UNIT_TYPE_HERO) and id>0 then
        if int > 30 then //we check player lumber > 1 and hero intelligence > 30
            if GetUnitAbilityLevel(u,id) == 0 then
                call UnitAddAbility(u,id) // we add ability
                call RemoveItem(GetManipulatedItem()) // We remove item from hero
            elseif GetUnitAbilityLevel(u,id) == 10 then
                call RemoveItem(GetManipulatedItem()) // We remove item from hero
                call SetPlayerState( GetOwningPlayer(u), PLAYER_STATE_RESOURCE_LUMBER, ( lumb + price ) ) // We add resource back to player
                call DisplayTextToPlayer(GetOwningPlayer(u),0,0,"Hero ability is already max level")
                return // we just skip all actions
            else
                call IncUnitAbilityLevel(u,id) // we increase ability level
                call RemoveItem(GetManipulatedItem())
            endif
        else
            call RemoveItem(GetManipulatedItem()) // We remove item from hero
            call SetPlayerState( GetOwningPlayer(u), PLAYER_STATE_RESOURCE_LUMBER, ( lumb + price ) ) // We add resource back to player
            call DisplayTextToPlayer(GetOwningPlayer(u),0,0,"Hero  intelligence is 2 low")
        endif
    endif
    set u = null
endfunction

[WARNING] I'M USING ALL MY IMAGINATION FROM NOW ON xD
Why don't we store LEVEL, STR, AGI, INT, LUMBER, and FP (I really need this variable into the formula) like Globals, and then set something like

(I know those can't be Globals, xD but you get the point :p Check all those values with a 'Greater than or equal to' whe the unit gets an item, and then do the 'If/Then/Else the previous code has' to add ability and increase level.) I think I'll need to add some value in the middle to prevent the unit the minimum skill requirement get the skill at max level, increaseing the level value needed to each skill level by 2.)

Example:
JASS:
Unit Level Required -For- Skill 'A000' level
12                                 1
14                                 2
16                                 3
18                                 4
and so on...

JASS:
//                              |       Requirements      |
//                |Item| |Abil| |Level||Str||Agi||Int||Lumber||FP|
call RegisterItem('I000','A000',   12,  30,  12,  22,     1,    1)
call RegisterItem('I01A','A0BC',   15,  00,  48,  00,     1,    0)

Would use something like
JASS:
function RegisterItem takes integer itemId,integer abilityId, integer UnitLevel, real str, real agi, real int, integer PLAYER_STATE_RESOURCE_LUMBER, interger FP[Index] returns nothing

xD Omg, I feel like a clown writing stuff like these xD

Besides, that system (with some modif) would work at the same time for Item requirement xD
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
hehehe, I would love it. Thanks a lot. I've been searching for something/someone like this/you for a long time (An Item requirement system)
 
Here it is.
It will check:
- Hero Agility
- Hero Intelligence
- Hero Strength
- Gold
- Lumber

I explained everything so it should not be so complicated for import :)
Oh small note, it's fully working system for any map type, hero type or whatever, so it can be uploaded as resource in Spells section.
Please don't do that, I will work on it a little more and upload improved version myself.


Edit:
Here improved version, you can add hero level into checking now as well :)
http://www.hiveworkshop.com/forums/spells-569/ability-level-up-system-203991/
 

Attachments

  • test map.w3x
    19.6 KB · Views: 89
Last edited:
Level 20
Joined
Jul 14, 2011
Messages
3,213
Omg, i'm checking it. Looks awersome :D I dreamed about this a lot xD haha. Thanks again!. I'll be discussing it in the Spell Section now ;)

EDIT: Hey Kobas, I think that if you make small modifications to that system, you could make a really good Item Requirement System =D
 
Last edited:
Status
Not open for further replies.
Top