• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[General] How to check ih a hero has Inventory active

Status
Not open for further replies.
Level 2
Joined
Dec 8, 2011
Messages
8
Hi, I want to set trigger that will check if a heros inventory is active or not..

so If inventory(hero) on triggering unit = true

please help
 
Level 12
Joined
Jan 30, 2009
Messages
1,067
I think he means if the hero's inventory is not blocked such as it is on many units by default.
 
Level 12
Joined
Jan 30, 2009
Messages
1,067
Uh such as some units only have 2 active inventory slots, so they can only hold 2 items. That's basically the way I understand it, except instead of holding 2, it would be holding 0.

Man, my project The Last Sa'rin isn't going anywhere here on Warcraft 3. I'm unable to teach myself JASS, so I am done with it. I am going to move it to an engine called RPG Maker, which uses a language called Ruby which is much simpler to learn, and so i'll go with it. Also I can distribute it stand-alone and not be WC3 reliant, and if I so wanted to, I could charge money for it royalty-free. I most likely wouldn't do that, though, lol. That, and it's all retro-SNES-2D which makes my heart ache and want to plug in my SNES and play it. I've been stalking your spell request thread too, ^^
 
Level 2
Joined
Dec 8, 2011
Messages
8
What I have is a evolving hero, starts with no inventory slots, once it gets to level 10 becomes a stronger hero with inventory slots... I want to have a trigger that checks If inventory(hero) on triggering unit = true or not.
 
Level 12
Joined
Jan 30, 2009
Messages
1,067
I played with it, but it's been about a year since I really played with the world editor...

But it looks to me like he's going to have to make 2 heroes, one with inventory (hero) and one without, and save all the skills, etc. in a variable. Then when the unit hits level 10, replace the unit.

EDIT: I'm trying to create this for him, but I've never done something like this before, so it's taking some time, lol. I'll upload a little example testmap thing once I get it working. :)

EDIT2: Well, about 2 hours is enough time for me to try and work on this. I give up on it. I don't know why it's not working. I had it work once, but it crashed, then it never worked again.

This is what I came up with, perhaps someone can find the error and make it work for you, mate. And By the way, YES I KNOW THE HERO SKILLS JUST STORES THE ABILITY NAMES. I planned to fix that later, as that was just for testing purposes, but as I couldn't get the switch to happen in the first place, I'm too lazy to bother fixing it. You just need to set it after you learn a skill based on the skill you learn...


Variables are:
facing - real
Hero - unit
HeroAttributes - int array
HeroLevel - int
HeroSkills - ability array
HeroSP's - int
HeroXP - int
loopA - int
point - point
skill_level - int array

  • Init
    • Events
      • Time - Elapsed game time is 0.01 seconds
    • Conditions
    • Actions
      • -------- Set your variables. --------
      • -------- This following variable will be set differently depending on how your player receives the hero. --------
      • -------- If you use some sort of Picking system, you would set it at the time of picking, for example, and not in init trigger. --------
      • Set Hero = Mountain King2 0001 <gen>
      • -------- This stores your hero's data. Attributes are under "Update" trigger --------
      • Set HeroLevel = (Hero level of Hero)
      • Set HeroSPs = (Unspent skill points of Hero)
      • Set HeroSkills[1] = Storm Bolt
      • Set HeroSkills[2] = Thunder Clap
      • Set HeroSkills[3] = Bash
      • Set HeroSkills[4] = Avatar
  • Update
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • Set HeroAttributes[1] = (Strength of Hero (Exclude bonuses))
      • Set HeroAttributes[2] = (Agility of Hero (Exclude bonuses))
      • Set HeroAttributes[3] = (Intelligence of Hero (Exclude bonuses))
      • Set HeroXP = (Hero experience of Hero)
      • Set HeroSPs = (Unspent skill points of Hero)
      • Set HeroLevel = (Hero level of Hero)
  • Learn Skill
    • Events
      • Unit - A unit owned by Player 1 (Red) Learns a skill
    • Conditions
    • Actions
      • For each (Integer loopA) from 1 to 4, do (Actions)
        • Loop - Actions
          • Set skill_level[loopA] = (Level of HeroSkills[loopA] for Hero)
  • Add Inventory
    • Events
      • Unit - A unit Gains a level
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • HeroLevel Equal to 10
        • Then - Actions
          • Set HeroXP = (Hero experience of Hero)
          • Set point = (Position of (Triggering unit))
          • Set facing = (Facing of (Triggering unit))
          • Unit - Remove Hero from the game
          • Unit - Create 1 Mountain King for Player 1 (Red) at point facing facing degrees
          • Set Hero = (Last created unit)
          • Selection - Select Hero for Player 1 (Red)
          • Hero - Set Hero experience to HeroXP, Hide level-up graphics
          • Hero - Modify Strength of Hero: Set to HeroAttributes[1]
          • Hero - Modify Agility of Hero: Set to HeroAttributes[2]
          • Hero - Modify Intelligence of Hero: Set to HeroAttributes[3]
          • Hero - Modify unspent skill points of Hero: Set to HeroSPs points
          • Game - Display to (All players) the text: TRIGGER WORKS!!!
          • For each (Integer loopA) from 1 to 4, do (Actions)
            • Loop - Actions
              • Unit - Add HeroSkills[loopA] to (Triggering unit)
              • Unit - Set level of HeroSkills[loopA] for Hero to skill_level[loopA]
        • Else - Actions
Sorry I couldn't be of more help.
 
Last edited:
Level 12
Joined
Jan 30, 2009
Messages
1,067
@maker - I didn't think so, but I did it for testing purposes, so that it would let me know how the variables were working. It's a good thing I did too, cuz they were all screwed up for a while there.

So everything I did there was a complete waste of time and could have been one with that one line? D:
 
Level 12
Joined
Jan 30, 2009
Messages
1,067
Aph, I tried that, that ability is weird. It didn't work when I did it like that. I couldn't simply disable the ability and give it at level 10. If you can do it, and test it to be working, please do, I'd love to see it.
 
Level 2
Joined
Dec 8, 2011
Messages
8
Aph, I tried that, that ability is weird. It didn't work when I did it like that. I couldn't simply disable the ability and give it at level 10. If you can do it, and test it to be working, please do, I'd love to see it.

I created 3 heroes , first one has no Inventory but once it reaches level 10 it is replaced with the second one that has an inventory.
 
Level 12
Joined
Jan 30, 2009
Messages
1,067
I'm glad you were able to figure out how to do it. I couldn't do it for the life of me, one of the reasons I stopped messing with the World Editor. lol.
 
Level 2
Joined
Dec 8, 2011
Messages
8
Aph, I tried that, that ability is weird. It didn't work when I did it like that. I couldn't simply disable the ability and give it at level 10. If you can do it, and test it to be working, please do, I'd love to see it.

Here is how I did the heros
function Trig_Upgrade_1_Copy_Conditions takes nothing returns boolean
if ( not ( GetHeroLevel(GetTriggerUnit()) >= 10 ) ) then
return false
endif
return true
endfunction

function Trig_Upgrade_1_Copy_Func007001 takes nothing returns boolean
return ( GetUnitTypeId(GetTriggerUnit()) == 'UC41' )
endfunction

function Trig_Upgrade_1_Copy_Func008001 takes nothing returns boolean
return ( GetUnitTypeId(GetTriggerUnit()) == 'EC43' )
endfunction

function Trig_Upgrade_1_Copy_Func009001 takes nothing returns boolean
return ( GetUnitTypeId(GetTriggerUnit()) == 'EC45' )
endfunction

function Trig_Upgrade_1_Copy_Func010001 takes nothing returns boolean
return ( GetUnitTypeId(GetTriggerUnit()) == 'UC47' )
endfunction

function Trig_Upgrade_1_Copy_Func011001 takes nothing returns boolean
return ( GetUnitTypeId(GetTriggerUnit()) == 'EC49' )
endfunction

function Trig_Upgrade_1_Copy_Func012001 takes nothing returns boolean
return ( GetUnitTypeId(GetTriggerUnit()) == 'OC51' )
endfunction

function Trig_Upgrade_1_Copy_Func013001 takes nothing returns boolean
return ( GetUnitTypeId(GetTriggerUnit()) == 'OC53' )
endfunction

function Trig_Upgrade_1_Copy_Func014001 takes nothing returns boolean
return ( GetUnitTypeId(GetTriggerUnit()) == 'OC55' )
endfunction

function Trig_Upgrade_1_Copy_Func015001 takes nothing returns boolean
return ( GetUnitTypeId(GetTriggerUnit()) == 'OC57' )
endfunction

function Trig_Upgrade_1_Copy_Func016001 takes nothing returns boolean
return ( GetUnitTypeId(GetTriggerUnit()) == 'EC60' )
endfunction

function Trig_Upgrade_1_Copy_Func017001 takes nothing returns boolean
return ( GetUnitTypeId(GetTriggerUnit()) == 'HC62' )
endfunction

function Trig_Upgrade_1_Copy_Func018001 takes nothing returns boolean
return ( GetUnitTypeId(GetTriggerUnit()) == 'HC64' )
endfunction

function Trig_Upgrade_1_Copy_Func019001 takes nothing returns boolean
return ( GetUnitTypeId(GetTriggerUnit()) == 'HC66' )
endfunction

function Trig_Upgrade_1_Copy_Func020001 takes nothing returns boolean
return ( GetUnitTypeId(GetTriggerUnit()) == 'HC68' )
endfunction

function Trig_Upgrade_1_Copy_Func021001 takes nothing returns boolean
return ( GetUnitTypeId(GetTriggerUnit()) == 'HC70' )
endfunction

function Trig_Upgrade_1_Copy_Func022001 takes nothing returns boolean
return ( udg_NewHeroType == 'eC30' )
endfunction

function Trig_Upgrade_1_Copy_Func029003001 takes nothing returns boolean
return ( udg_SavedItems[GetForLoopIndexA()] != GetItemTypeId(null) )
endfunction

function Trig_Upgrade_1_Copy_Actions takes nothing returns nothing
set udg_Player7 = ( udg_Player7 + 1 )
set udg_NewHeroType = 'eC30'
set udg_NewHeroPlayer = GetOwningPlayer(GetTriggerUnit())
set udg_NewHeroPoint = GetUnitLoc(GetTriggerUnit())
set udg_NewHeroFacing = GetUnitFacing(GetTriggerUnit())
set bj_forLoopAIndex = 1
set bj_forLoopAIndexEnd = 6
loop
exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
set udg_SavedItems[GetForLoopIndexA()] = GetItemTypeId(UnitItemInSlotBJ(GetTriggerUnit(), GetForLoopIndexA()))
set bj_forLoopAIndex = bj_forLoopAIndex + 1
endloop
if ( Trig_Upgrade_1_Copy_Func007001() ) then
set udg_NewHeroType = 'UC42'
else
call DoNothing( )
endif
if ( Trig_Upgrade_1_Copy_Func008001() ) then
set udg_NewHeroType = 'EC44'
else
call DoNothing( )
endif
if ( Trig_Upgrade_1_Copy_Func009001() ) then
set udg_NewHeroType = 'Emoo'
else
call DoNothing( )
endif
if ( Trig_Upgrade_1_Copy_Func010001() ) then
set udg_NewHeroType = 'UC48'
else
call DoNothing( )
endif
if ( Trig_Upgrade_1_Copy_Func011001() ) then
set udg_NewHeroType = 'EC50'
else
call DoNothing( )
endif
if ( Trig_Upgrade_1_Copy_Func012001() ) then
set udg_NewHeroType = 'Ofar'
else
call DoNothing( )
endif
if ( Trig_Upgrade_1_Copy_Func013001() ) then
set udg_NewHeroType = 'OC54'
else
call DoNothing( )
endif
if ( Trig_Upgrade_1_Copy_Func014001() ) then
set udg_NewHeroType = 'Obla'
else
call DoNothing( )
endif
if ( Trig_Upgrade_1_Copy_Func015001() ) then
set udg_NewHeroType = 'OC58'
else
call DoNothing( )
endif
if ( Trig_Upgrade_1_Copy_Func016001() ) then
set udg_NewHeroType = 'EC61'
else
call DoNothing( )
endif
if ( Trig_Upgrade_1_Copy_Func017001() ) then
set udg_NewHeroType = 'HC63'
else
call DoNothing( )
endif
if ( Trig_Upgrade_1_Copy_Func018001() ) then
set udg_NewHeroType = 'HC65'
else
call DoNothing( )
endif
if ( Trig_Upgrade_1_Copy_Func019001() ) then
set udg_NewHeroType = 'HC67'
else
call DoNothing( )
endif
if ( Trig_Upgrade_1_Copy_Func020001() ) then
set udg_NewHeroType = 'HC69'
else
call DoNothing( )
endif
if ( Trig_Upgrade_1_Copy_Func021001() ) then
set udg_NewHeroType = 'HC71'
else
call DoNothing( )
endif
if ( Trig_Upgrade_1_Copy_Func022001() ) then
return
else
call DoNothing( )
endif
call RemoveUnit( GetTriggerUnit() )
call CreateNUnitsAtLoc( 1, udg_NewHeroType, udg_NewHeroPlayer, udg_NewHeroPoint, udg_NewHeroFacing )
call IssueImmediateOrderBJ( GetLastCreatedUnit(), "holdposition" )
call CreateItemLoc( 'IC78', GetUnitLoc(GetLastCreatedUnit()) )
call UnitAddItemSwapped( GetLastCreatedItem(), GetLastCreatedUnit() )
call SetPlayerHandicapXPBJ( udg_NewHeroPlayer, 125.00 )
set bj_forLoopAIndex = 1
set bj_forLoopAIndexEnd = 6
loop
exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
if ( Trig_Upgrade_1_Copy_Func029003001() ) then
call UnitAddItemByIdSwapped( udg_SavedItems[GetForLoopIndexA()], GetLastCreatedUnit() )
else
call DoNothing( )
endif
set bj_forLoopAIndex = bj_forLoopAIndex + 1
endloop
call AddSpecialEffectLocBJ( GetUnitLoc(GetLastCreatedUnit()), "Abilities\\Spells\\Human\\ReviveHuman\\ReviveHuman.mdl" )
call AddSpecialEffectLocBJ( GetUnitLoc(GetLastCreatedUnit()), "Abilities\\Spells\\Other\\Levelup\\Levelupcaster.mdl" )
endfunction

//===========================================================================
function InitTrig_Upgrade_1_Copy takes nothing returns nothing
set gg_trg_Upgrade_1_Copy = CreateTrigger( )
call TriggerRegisterPlayerUnitEventSimple( gg_trg_Upgrade_1_Copy, Player(0), EVENT_PLAYER_HERO_LEVEL )
call TriggerRegisterPlayerUnitEventSimple( gg_trg_Upgrade_1_Copy, Player(1), EVENT_PLAYER_HERO_LEVEL )
call TriggerRegisterPlayerUnitEventSimple( gg_trg_Upgrade_1_Copy, Player(2), EVENT_PLAYER_HERO_LEVEL )
call TriggerRegisterPlayerUnitEventSimple( gg_trg_Upgrade_1_Copy, Player(6), EVENT_PLAYER_HERO_LEVEL )
call TriggerRegisterPlayerUnitEventSimple( gg_trg_Upgrade_1_Copy, Player(7), EVENT_PLAYER_HERO_LEVEL )
call TriggerRegisterPlayerUnitEventSimple( gg_trg_Upgrade_1_Copy, Player(8), EVENT_PLAYER_HERO_LEVEL )
call TriggerAddCondition( gg_trg_Upgrade_1_Copy, Condition( function Trig_Upgrade_1_Copy_Conditions ) )
call TriggerAddAction( gg_trg_Upgrade_1_Copy, function Trig_Upgrade_1_Copy_Actions )
endfunction
 
Status
Not open for further replies.
Top