• 🏆 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!

Anachron's inventory system

Status
Not open for further replies.
Level 6
Joined
Apr 26, 2007
Messages
225
I'm having another problem... because of my lack of knowlage on vJass so i decided to make a question tread about it. I will put my questions in order as i need awnsers and will put SOLVED if they have been awnsered. I think only people familiar with this system will be awnser, sadly. If somoene is willing to take a look and check to awnser me i would apreciate it but it could take a long time...

1. In my map there are casters, ranged heros, melee hero. I wan all of them to use different items, like a caster will be able to use a staff and not a sword while a ranged unit will use a bow.How can i make this system use the 12 slots but that they all have 3 different type so only some class use them. SOLVED

2. How can i make my hero unable to dual weild weapons.
 
Last edited:
Level 6
Joined
Apr 26, 2007
Messages
225
I sure hope hes gona answer because he say in the read me to read a vJass manual... But i dont have time for this thats why am asking for help. I have a personal life to take care of and cant really map often.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
Well I am not very familiar with his system, I suppose I could take a look at his code and see how it would be implemented, but it would be quite a bit of work to set up a test for this sort of thing. It would be so much easier if we could just get the person who actually made the system to give some feedback on the situation.

I would send him a private message, it also wouldn't hurt to post the code for the inventory system and your own attempts at the script in hidden JASS tags (so it doesn't take up the entire screen).
 
1. In my map there are casters, ranged heros, melee hero. I wan all of them to use different items, like a caster will be able to use a staff and not a sword while a ranged unit will use a bow.How can i make this system use the 12 slots but that they all have 3 different type so only some class use them. UNSOLVED
You can use

JASS:
set ci.onCheckAct = check // Do this for every itemtype inside the Test trigger (tetsmap).

//and the function returns a value whether you can pick this item or not.
function check takes unit theUnit, item theItem returns boolean
    //Check the item type and unit type if the item can be used.
    if GetUnitType(theUnit) == 'utyp' and GetItemType(theItem) == 'ityp' then
         return false // Hero of type utyp can't pickup items of type 'ityp'
    endif

    return true //Unit can take item
endfunction

For more advanced questions, please care that I left mapping. I will only help a few times since this question has been coming around for a few times and I never really answered it.

If you really are not familiar with vJass, I suggest not to use my exploded version of a beast of an inventory system.
 
Level 6
Joined
Apr 26, 2007
Messages
225
Thanks for the answer, i'm not totaly sure of what do do with what you gave me but i understand most of it, exept the first line. I can manage witht his system even without vjass knowlage as i could do everything i waned with it for now. All i have left to do is try to make a set and a forged item (recipe). Shouldnt be too hard to figure it out.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
From what I see he uses ci.onCheckAct to run a function that is derived from a function interface. This is why he uses check instead of function check. Now that he's got the function callback setup, he can declare the function.

Now whenever... an item is picked up? The item will be ran through as theItem and the unit that is picking it up will be passed as theUnit. There is a mistake, though, the if-statement should read:

JASS:
if GetUnitTypeId(theUnit)=='utyp' and GetItemTypeId(theItem)=='ityp' then

I'm not too sure on how/when ci.onCheckAct is executed but perhaps Anachron will bless us with his presence again.
 
I'm not too sure on how/when ci.onCheckAct is executed but perhaps Anachron will bless us with his presence again.
It's executed 2 function calls behind the pickup event, and it's the fastest way to get to the action of item pickups that still care about inventory conditions & events. After this call forging, stacking and indexing will be done, so whenever this function returns false, the item will cause the owner to give an error and to be dropped, on true it will be picked up and it will continune with the next action.
 
Level 6
Joined
Apr 26, 2007
Messages
225
So i just wan to make sure i got it right. If i have 2 heros, A001 and A002 (just an exemple) and four items, I001 to I004 and A001 can use I001 and I002 while the other can use the 2 other items it should look like this?

JASS:
set ci.onCheckAct = check 

function check takes unit theUnit, item theItem returns boolean
    if GetUnitType(theUnit) == 'A001' and GetItemType(theItem) == 'I003' then
         return false
    endif

    return true
endfunction

function check takes unit theUnit, item theItem returns boolean
    if GetUnitType(theUnit) == 'A001' and GetItemType(theItem) == 'I004' then
         return false
    endif

    return true
endfunction

function check takes unit theUnit, item theItem returns boolean
    if GetUnitType(theUnit) == 'A002' and GetItemType(theItem) == 'I001' then
         return false
    endif

    return true
endfunction

function check takes unit theUnit, item theItem returns boolean
    if GetUnitType(theUnit) == 'A001' and GetItemType(theItem) == 'I002' then
         return false
    endif

    return true
endfunction

EDIT: guess not... it tells me i redeclared a function..

EDIT2: actualy, if i just copy and paste your code un the map and save without touching it, it gives an error. I create a new trigger for this right?
I also tried to put set ci.onCheckAct = check to an item in my item trigger but it tells me it's not a part of custom inventory.
 
Last edited:
Level 6
Joined
Apr 26, 2007
Messages
225
Well i dont have knowlage of jass but i can manage with the link you gave me i think. I might not know jass but i can read it and guess it pretty easily i guess it's a gift i have lol
 
Level 6
Joined
Apr 26, 2007
Messages
225
You dint tell me the same thing here than you told the guy in the other tread. You tell where to put the scripts in the other tread and that made me figure out how it work. I might not know jass but when i see it i can read it mostly i just cant write it and i dont know the order of things so i need to know where to add script when am told to...

Can you just tell me if the script in CustomInventory is declared in or after line 29

(is
JASS:
private function interface iOnCheck takes CustomItem ciObj, unit ciUnit returns boolean
before or after the script?)
 
Yes, but when you don't know the order, you don't know how to work with the language.
Because a well written code is easy understandable.

Seriously, learn vJass before using my system, I am not able to give everyone support when you don't even know the language it's written in.

Also I was just nice to give you the scripts, because in fact, the answer should not have the code, but include the solution steps to get the code.

If you have another problem, please do notice that I will not give you any answer before you learned how to properly code things in vJass.

I wrote it into the readme and about 20x in the thread already, I don't get why you don't respect that.
 
Level 6
Joined
Apr 26, 2007
Messages
225
I know you told me i should learn jass before but i said i dont have the time for it. I barely have time to make maps and i only do it so my friends and i can play them. Learning jass would make me give up or would take too long for me to finish the map then. I rather try to figure out things because i already tried learning jass and it dint do any good. It's like any language, when i learned english or like am learning spanish right now it dont work for me if i just try a tutorial on the internet i have to learn it by practicing and actualy reading it and figuring it out. I'm that type of learner i guess... i alreadt figured a bit of jass and i might end up elarning it but its not a tutorial thats gona help.

Ill admit i'm having a hard time with your system because now even with your code i'm not sure what to modify but try to guess and i got a few errors already in that line
if GetItemTypeId(ciObj.getHandle()) == 'itype' then
hope ill get it to work somehow.
 
Level 6
Joined
Apr 26, 2007
Messages
225
I know you stop helping me, i just think someone else mgith answer thats why i posted on the other tread. I appreciate you try help and i know you dont have the time or are not willing to help someone who dont know vjass but other persons might help me.
 
Last edited:
Level 18
Joined
Jan 21, 2006
Messages
2,552
Anachron said:
Because a well written code is easy understandable.

As is a well written sentence.

if GetItemTypeId(ciObj.getHandle()) == 'itype' then

Well ciObj.getHandle (which by the way is an awful name for a public struct) refers to the actual item that is being manipulated by the inventory system - the raw-code 'itype' is first of all invalid because a raw-code can contain only 4 characters. I believe his original code read 'ityp' - though this is a completely made-up item type. How could Anachron possibly know what the raw-code of the items in your game are. He gave you an example. You have to find the raw-code of the item (press Ctrl+D in the Object Editor to display raw values) and then use that in place of 'ityp'. Remember the ' ' marks are essential.

I know you stop helping me, i just think someone else mgith answer thats why i posted on the other tread. I appreciate you try help and i know you dont have the time or are not willing to help someone who dont know vjass but other persons might help me.

So did you get it working?
 
Level 6
Joined
Apr 26, 2007
Messages
225
I know, what i put in my map is:
JASS:
//inside the trigget CustomItem at line 30
    private function check takes CustomItem ciObj, unit ciUnit returns boolean
        if GetUnitTypeId(ciUnit) == 'H004' then
            if GetItemTypeId(ciObj.getHandle()) == 'Imw1' then
                return false
            endif
        endif
        return true
    endfunction


JASS:
//inside my Item trigger
        set ci = CreateCustomItem('Imw1')
        set ci.class = ITEM_CLASS_HAND
        set ci.dmg = 12
        set ci.str = 2
        set ci.dest = 'Dmw1'
        set ci.icon = "ReplaceableTextures\\CommandButtons\\BTNSteelMelee.blp"
        set ci.name = "Sword of Strength"
        set ci.desc = "|cffFFCC00One hand melee weapon."
        call ci.setOnCheckFunc(check)

and i get the error: Check is not a part of CustomItem

EDIT: the error i get is on this line:
JASS:
//CIEquip line 127
            set pick = pick and ci.check(.inventory.getOwner())
 
Level 6
Joined
Apr 26, 2007
Messages
225
I put the first part in the trigger "CustomItem" at line 30 and it takes up to line 37 and i put the second part in my trigger called "item" where the custom items are created for the system.

If you wish to help me and dont understand why i put them there, read this

EDIT: it telle me to put the first part at line 29, but there's this from 25 to 29 and i think i shouldn't "interupt" that sequence:

JASS:
    private function interface iOnUse 	takes CustomItem ciObj, unit ciUnit returns boolean
    private function interface iOnDrop 	takes CustomItem ciObj, unit ciUnit returns boolean
    private function interface iOnPawn 	takes CustomItem ciObj, unit ciUnit returns boolean
    private function interface iOnPick 	takes CustomItem ciObj, unit ciUnit returns boolean
    private function interface iOnCheck takes CustomItem ciObj, unit ciUnit returns boolean
 
Read carefully. I said the function is from line 29 (its declared there).
You know, with knowing (v)Jass better you wouldn't have such problems to understand me.

Anachron said:
[Put this inside Testing-Items]
JASS:
//: Declared in CustomItem Line 29
    private function check takes CustomItem ciObj, unit ciUnit returns boolean
        if GetUnitTypeId(ciUnit) == 'utyp' then
            if GetItemTypeId(ciObj.getHandle()) == 'itype' then
                return false
            endif
        endif
        return true
    endfunction

And inside the init function you put this in the item creation:
JASS:
        set ci = CreateCustomItem('I001')
        //set ci.class = ITEM_CLASS_TWOHANDER
        //set ci.dmg = 35
        //set ci.str = 7
        //set ci.dest = 'it03'
        //set ci.icon = "ReplaceableTextures\\CommandButtons\\BTNShamanMaster.blp"
        //set ci.name = "Shaman Claw"
        //set ci.desc = "Twohander item."
        //call ci.addSfx("Abilities\\Spells\\Human\\InnerFire\\InnerFireTarget.mdl", "overhead")
        call ci.setOnCheckFunc(check)
 
Level 6
Joined
Apr 26, 2007
Messages
225
Man bein answered by the same answer i dont understand is not cool... I mena if you dont wan to help me dont repost i'm trying really hard to make it work... You got to understand i dont have the time to learn vjass just like you dont have the time to map anymore. I would have to stop mapping for a while to learn it and after am not sure i would wan to remap...
 
Level 6
Joined
Apr 26, 2007
Messages
225
I don't understand jass, what i mean is i dont know what you mean by that...

All i can do is guess: if you say it'd declared at line 29 that means
private function interface iOnCheck takes CustomItem ciObj, unit ciUnit returns boolean
declares it? then i don't know where to put the script you gave me... Is there anything else missing? do i have to make up some other script to declare it or somehting like that?

At least i know how what you gave me "work" (how to make "that" item equipable by "that" hero only or not by "that one". I just cant figure out where to put it. In the item trigger?
 
Level 6
Joined
Apr 26, 2007
Messages
225
you did? you tell me that it's "declared" at line 29 so i put it there. Logicaly it's what anoyone without jass knowlage would do and you then tells me its not there. I dont remember you telling me anywhere else to place it.
 
Level 6
Joined
Apr 26, 2007
Messages
225
For the first part, The Testing-Items trigger don't exist. When i say you answer by something i cant understand, thats what i mean. I create it? It's a way to call another of your trigger that i dont know? I put it in the item trigger too but at top/botom?
For the second part, i put it in the item creation trigger, called Items. I understand i have to add the last line for each item. Thats done.

EDIT: does that have to do with it? I don't see any use to the mountain king.
JASS:
    private function test takes CustomItem ciObj, unit ciUnit returns boolean
        return GetUnitTypeId(ciUnit) == 'Hmkg'
    endfunction
 
Level 6
Joined
Apr 26, 2007
Messages
225
Thats what i call an answer! Great! And i finaly got it working like i wan to. thank you verry much!

EDIT: Sadly i gave you rep for something else already so i cant give you... :s

EDIT2: if i keep on asking questions i have will you answer them? Like how i can make a hero able to dual weild or not. Or not use 2 shields...
 
Last edited:
Level 6
Joined
Apr 26, 2007
Messages
225
Hehe i figured that much... still you should give me credits for what i did without any knowlage of jass! i got it working, got the "requirements" working AT LAST:xxd: and i was able to make it so when you pick a hero your inventory appear.

All thats left to figure out is the dual wield problem, the set and the forging. hope someone else know this system and got time to help a bit.. loll

Cant you like answer like you would to somoene who know jass and ill manage with that? If it doesnt help then i wont ask you anymore cause i will admit that if you answer all my questions it will take you time... It's just that if there's some script to add or somehting like that, if you tell it to me i will be able to "guess" it maybe..

EDIT: by the way, i think am starting to understand a bit of jass. You tought me what declaring is, i know what a function is now and i know a bit about locals and globals, how they work.. Maybe ill learn jass in the process :xxd:
 
Status
Not open for further replies.
Top