HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Items and Levels for my RPG...

01-21-2007, 08:24 PM#1
doctorlee
How do I make it so a hero may only carry one type of items?
As in, a hero could only carry one weapon in the inventory.
Please help me out.

Another thing is I am making a hero change based on the Chaos abillity.
How do I make a hero keep his stats and level when he changes?
For example, hero A is level 11, 4 Strength, 3 Agility, and 2 Intelligence. He has a skill where it would turn him into hero B. Hero B will have the same level and the stats as Hero A.
01-21-2007, 08:26 PM#2
maximilianx
for the first question, you give each item a type..
like weapons - campaign items
armor - permanent items
shield - miscelanious items..

then you make a trigger that doesnt allow more than one of those types of items in the inventory at a time.
01-21-2007, 09:04 PM#3
doctorlee
I don't really know anything about triggers so could you just write me the whole trigger things?
01-21-2007, 09:08 PM#4
Av3n
Hmmm, trigger it (For both) Here one for items http://www.wc3campaigns.net/showthread.php?t=82126. Go to the Hero section in the trigger editor.

-Av3n
01-21-2007, 09:59 PM#5
doctorlee
Quote:
Originally Posted by Av3n
Hmmm, trigger it (For both) Here one for items http://www.wc3campaigns.net/showthread.php?t=82126. Go to the Hero section in the trigger editor.

-Av3n
That system is actually pretty cool but is there one where I just categorize items into Permanent, Charged, or whatever, and restrict it to one type of item per category?
01-21-2007, 10:26 PM#6
Szythe
I havn't tested this trigger, but I would assume it works.

Miscellanious classification is not unique (use it for misc items such as potions)

Collapse JASS:
function Trig_UniqueClassification_Actions takes nothing returns nothing
    local item i = GetManipulatedItem()
    local unit u = GetManipulatingUnit()
    local itemtype it = GetItemType(i)
    local integer count = 0
    local integer n = 0
    loop
        exitwhen count == 6
        if GetItemType(UnitItemInSlot(u, count)) == it then
            set n = n + 1
        endif
        set count = count + 1
    endloop
    if n >= 2 and GetItemType(i) != ITEM_TYPE_MISCELLANEOUS then
        call UnitRemoveItem(u, i)
    endif
endfunction

function InitTrig_UniqueClassification takes nothing returns nothing
    set gg_trg_UniqueClassification = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_UniqueClassification, EVENT_PLAYER_UNIT_PICKUP_ITEM )
    call TriggerAddAction( gg_trg_UniqueClassification, function Trig_UniqueClassification_Actions )
endfunction

edit: I tested it and there was a bug where misc items could not be carried at all. I would take the 3 mins to fix it but I have to go right now. Someone else please correct it.
01-21-2007, 10:42 PM#7
maximilianx
i <3 gui..
heres the way i would do it using different item classes: three triggers.
variables: BooleanVariable

Trigger:
unit has Permanent
Collapse Events
Unit - A unit Acquires an item
Collapse Conditions
(Item-class of (Item being manipulated)) Equal to Permanent
Collapse Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
BooleanVariable Equal to False
Collapse Then - Actions
Set BooleanVariable = True
Else - Actions
Trigger:
Unit drops permanent
Collapse Events
Unit - A unit Loses an item
Collapse Conditions
(Item-class of (Item being manipulated)) Equal to Permanent
Collapse Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
BooleanVariable Equal to True
Collapse Then - Actions
Set BooleanVariable = False
Else - Actions
Trigger:
drop second permanent
Collapse Events
Unit - A unit Acquires an item
Collapse Conditions
(Item-class of (Item being manipulated)) Equal to Permanent
Collapse Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
BooleanVariable Equal to True
Collapse Then - Actions
Hero - Drop (Item being manipulated) from (Triggering unit)
Else - Actions

this is of course assuming you have a single player rpg here..if not, then youll have to do a bit of editing with arrays and what not.
01-21-2007, 10:49 PM#8
Szythe
Collapse JASS:
function Trig_UniqueClassification_Actions takes nothing returns nothing
    local item i = GetManipulatedItem()
    local item j
    local unit u = GetManipulatingUnit()
    local itemtype it = GetItemType(i)
    local integer count = 0
    local integer n = 0
    loop
        exitwhen count == 6
        if GetItemType(UnitItemInSlot(u, count)) == it then
            if i != UnitItemInSlot(u, count) then
                set j = UnitItemInSlot(u, count)
            endif
            set n = n + 1
        endif
        set count = count + 1
    endloop
    if n >= 2 and GetItemType(i) != ITEM_TYPE_PERMANENT then
        call UnitRemoveItem(u, j)
    endif
endfunction


function InitTrig_UniqueClassification takes nothing returns nothing
    set gg_trg_UniqueClassification = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_UniqueClassification, EVENT_PLAYER_UNIT_PICKUP_ITEM )
    call TriggerAddAction( gg_trg_UniqueClassification, function Trig_UniqueClassification_Actions )
endfunction
Fixed. Just Create a new Trigger and call it UniqueClassification, and convert it to custom text. Then replace the script of the trigger with the script posted above. (Permanent items will not be dropped if you have more than one). For some reason ITEM_TYPE_MISCELLANEOUS didnt correspond to miscellaneous items, so I just changed to permanent and it worked. There appears to be some kind of Blizzard bug with misc. class items, so avoid using that class for any equipment type
01-21-2007, 11:57 PM#9
Av3n
... I told him alrdy. Help him out with the other problem :P

-Av3n
01-23-2007, 12:09 AM#10
doctorlee
Thank you for all the helps!
I need an answer for the second question though...
Help!
01-23-2007, 12:49 AM#11
maximilianx
heh, for that, just make variables
like one for his int
one for his agi
one for his str
one for his level
then once he changes, set the new hero's int, str, agi, and level = the variables
01-23-2007, 01:24 AM#12
doctorlee
Oh, and I know NOTHING about JASS so, what am I suppose to replace what with what on the function? I don't understand...
- EDIT -
How do I also make level requirements or stats requirement to equip items?
01-23-2007, 02:36 AM#13
Av3n
Your thrid question is the
Trigger:
Events Unit Maulipulates Item
Then use reals or integers(forgot which one) in the conditions to check if they can hold it. Also you do't need JASS for the thing max was talkin about

-Av3n
01-23-2007, 04:10 AM#14
doctorlee
You can just copy paste the JASS function right?
Or am I wrong?
I tried the JASS that Szythe gave me and it didn't work.
01-23-2007, 04:38 AM#15
maximilianx
Quote:
Originally Posted by doctorlee
Oh, and I know NOTHING about JASS so, what am I suppose to replace what with what on the function? I don't understand...
- EDIT -
How do I also make level requirements or stats requirement to equip items?

for level requirements..
Events:
unit picks up an item
Conditions
item being manipulated equal to (your item)
Actions
if/then/else
if level of triggering unit less than (level requirement) then drop item from unit's inventory