HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

cant have double items

12-30-2004, 03:02 AM#1
Mothmann
EDIT - just realized i was in the repository. could someone move this -EDIT

ok i use to have a map that i accomplished this in. but i've deleted that map and now i've forgotten how to do it.

first off. i have a bunch of permenant items set to ITEM TYPE varibles with arrays.
examples
Set Weaps[1] = Sword
Set Weaps[2] = Bow
Weaps being the variable. the numbers being the arrays. sword/bow being the items.

now im trying to make it to where a hero can only hold 1 item set in the Weaps varible.
example
the hero has a bow in his inventory. when he picks up a sword it detects he already has the bow so it makes him automatically drop the sword.

im having problems tho. i can only get it to drop the item even if he doesn't already have one.

heres my code im working with but i will completly rewrite it works.

Already Has A Weapon
Events
Unit - A unit Acquires an item
Conditions
Actions
For each (Integer A) from 1 to 50, do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Item-type of (Item being manipulated)) Equal to Weaps[(Integer A)]
((Triggering unit) has an item of type Weaps[(Integer A)]) Equal to True
Then - Actions
Hero - Drop (Item being manipulated) from (Triggering unit)
Else - Actions


i know exactly what would fix this but i cant find it. if i could have a codition that said. Number of items being carried by triggering unit of TYPE = 2 then it would be so easy. but i cant find that codition with OF TYPE in it. i can only find the integer comparision (Unit - Count items being carried) which doesn't include OF TYPE.




wait i just remembered how i did it before. i set a integer or real varible that is changed to +1 whenever the player picks up a weaps item. then have a check everytime the unit picks up a weaps item to see if its 2 or more and if it is then have it drop. that probably doesn't make much sense but if u really want to know i will explain more.

i would still rather do it kinda like the way above cause its easier and less time consuming. so if anybody can help me out with the way above i would still like it.


EDIT - here this works in case anybody wanna do this

weapsheld is a interger varible with a array of 12 (for 12 players)

Set WeapsHeld 1up
Events
Unit - A unit Acquires an item
Conditions
Actions
For each (Integer A) from 1 to 50, do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Item-type of (Item being manipulated)) Equal to Weaps[(Integer A)]
Then - Actions
Set WeapsHeld[(Player number of (Triggering player))] = (WeapsHeld[(Player number of (Triggering player))] + 1)
Else - Actions


WeapsHead Force Drop
Events
Unit - A unit Acquires an item
Conditions
WeapsHeld[(Player number of (Triggering player))] Greater than or equal to 2
Actions
For each (Integer A) from 1 to 50, do (If ((Item-type of (Item being manipulated)) Equal to Weaps[(Integer A)]) then do (Hero - Drop (Item being manipulated) from (Triggering unit)) else do (Do nothing))

then you have to set a trigger up to set weapsheld to -1 when an weaps item is lost
01-11-2005, 09:26 AM#2
ABM
Weapon gain
Events
Unit - A unit Acquires an item
Conditions
((Triggering unit) is A Hero) Equal to True
Or - Any (Conditions) are true
Conditions
(Item-type of (Item being manipulated)) Equal to Bone Mace
(Item-type of (Item being manipulated)) Equal to Stone Mace
(Item-type of (Item being manipulated)) Equal to Iron Mace
(Item-type of (Item being manipulated)) Equal to |c00ec0000Mithril Mace|r
(Item-type of (Item being manipulated)) Equal to Bone Axe
(Item-type of (Item being manipulated)) Equal to Stone Axe
(Item-type of (Item being manipulated)) Equal to Iron Axe
(Item-type of (Item being manipulated)) Equal to |c00ec0000Mithril Axe|r
Actions
*If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Owner of (Triggering unit)) Equal to Player 1 (Red)
*Then - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
WeaponsOwned[1] Equal to 2
Then - Actions
Item - Move (Item being manipulated) to (Position of (Triggering unit))
Set WeaponsOwned[1] = 2
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
WeaponsOwned[1] Equal to 0
Then - Actions
Set WeaponsOwned[1] = 1
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
WeaponsOwned[1] Equal to 1
Then - Actions
Set WeaponsOwned[1] = 2
Else - Actions
*Else - Actions
Do nothing

*If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Owner of (Triggering unit)) Equal to Player 2 (Blue)
*Then - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
WeaponsOwned[2] Equal to 2
Then - Actions
Item - Move (Item being manipulated) to (Position of (Triggering unit))
Set WeaponsOwned[2] = 2
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
WeaponsOwned[2] Equal to 0
Then - Actions
Set WeaponsOwned[2] = 1
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
WeaponsOwned[2] Equal to 1
Then - Actions
Set WeaponsOwned[2] = 2
Else - Actions
*Else - Actions
Do nothing

u only need to repeat this trigger for every player (12 time) and add all your weapon once in the condition:
Or - Any (Conditions) are true
Conditions
(Item-type of (Item being manipulated)) Equal to Bone Mace
(Item-type of (Item being manipulated)) Equal to Stone Mace
(Item-type of (Item being manipulated)) Equal to Iron Mace
(Item-type of (Item being manipulated)) Equal to |c00ec0000Mithril Mace|r
(Item-type of (Item being manipulated)) Equal to Bone Axe
(Item-type of (Item being manipulated)) Equal to Stone Axe
(Item-type of (Item being manipulated)) Equal to Iron Axe
(Item-type of (Item being manipulated)) Equal to |c00ec0000Mithril Axe|r

look complicated because it is written as text and not neat but it is much more simple than making array(50) for item with integer A and all.
01-12-2005, 08:11 PM#3
weaaddar
Except its very complicated. A good Trigger should run with on a variable list without me having as an end user having to do squat. I shouldn't have to copy and paste code. I should only have to modify an external list and have this code operate off of it. It looks cleaner, and should allow for easier debugging as if one item bugs it means that the code loop is wrong, I don't have to check each if statement, only one.

for something so simple on a short range list (10 entries if you have the pateince) this may be a good idea. But for a more complicated system explictly coding per defination midcode is downright painful and makes it very hard for an end user to add your system into his map without screwups. Don't believe me try recoding my RPG engine.
01-12-2005, 09:45 PM#4
ABM
sorry here is a better version

Weapon gain
Events
Unit - A unit Acquires an item
Conditions
((Triggering unit) is A Hero) Equal to True
Or - Any (Conditions) are true
Conditions
(Item-type of (Item being manipulated)) Equal to Bone Mace
(Item-type of (Item being manipulated)) Equal to Stone Mace
(Item-type of (Item being manipulated)) Equal to Iron Mace
(Item-type of (Item being manipulated)) Equal to Bone Axe
(Item-type of (Item being manipulated)) Equal to Stone Axe
(Item-type of (Item being manipulated)) Equal to Iron Axe

Actions
If Then Else:
------If - Conditions
WeaponsOwned[player number of (owner of trigering unit)] Equal to 2
------ Then - Actions
Item - Move (Item being manipulated) to (Position of (Triggering unit))
Set WeaponsOwned[player number of(owner of triggering unit] = 2
------Else - Actions
If - Conditions
WeaponsOwned[player number of(owner of triggering unit] Equal to 0
Then - Actions
Set WeaponsOwned[player number of(owner of triggering unit] = 1
Else - Actions
If - Conditions
WeaponsOwned[player number of(owner of triggering unit] Equal to 1
Then - Actions
Set WeaponsOwned[player number of(owner of triggering unit] = 2
Else - Actions
Do nothing


this should be shorter and better :)
01-15-2005, 11:23 AM#5
mogmiester
There is an easier way... first of all make a variable array with 12 slots. Call it weapon, and another array size 12 called triggerdrop. Both should be integers.

Events
Unit - A unit Acquires an item
Conditions
((Triggering unit) is A Hero) Equal to True
Or - Any (Conditions) are true
Conditions
(Item-type of (Item being manipulated)) Equal to Bone Mace
(Item-type of (Item being manipulated)) Equal to ...etc. etc
Actions
If weapon[player number of owner of triggering unit - 1] = 1 Then
Set triggerdrop[player number of owner of triggering unit - 1] = 1
Hero - Drop (Item being manipulated) from (Triggering unit)
Else
Set weapon[player number of owner of triggering unit - 1] = 1

This checks the array to see if the hero is wielding a weapon, and if so tells him to drop the weapon, and if not if sets weapon[player number of owner of triggering unit - 1] = 1 so the next time he tries to pick up a weapon it doesnt allow him to. the variable refers to the player number - 1 because it returns a 1 for player 1, but the array starts at 0. There is also a drop trigger, which is

Events
Unit - A unit Loses an item
Conditions
((Triggering unit) is A Hero) Equal to True
Or - Any (Conditions) are true
Conditions
(Item-type of (Item being manipulated)) Equal to Bone Mace
(Item-type of (Item being manipulated)) Equal to ...etc. etc
Actions
If triggerdrop[player number of owner of triggering unit - 1] = 1 Then
Set triggerdrop[player number of owner of triggering unit - 1] = 0
Else
weapon[player number of owner of triggering unit - 1] = 0

Because if you drop thitem through triggers, it still runs the unit loses an item event, then all you have to do is check if the drop was triggered. This is the easiest and quickest way i have found
01-17-2005, 05:38 PM#6
Mothmann
i forgot i made this post and forgot to check up on it but i figured it out not to long after posting this. i posted it up there but it was sloppy cause i didn't know how to do the CODE /CODE things then. heres it like this and the actually triggers are written better and less buggy i think too.

heres what i used. its similiar to the ones on here.

first WeapsHeld is a integer with an array. Weaps is a item group(i was wrong its a item type variable) i think? during initialization it presets every item i want to be classified as a weapon (right now just 50) to this variable.

this code sets the weapsheld to +1 whenever he picks up a weapon.

Code:
Set WeapsHeld 1up
    Events
        Unit - A unit Acquires an item
    Conditions
    Actions
        For each (Integer A) from 1 to 50, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Item-type of (Item being manipulated)) Equal to Weaps[(Integer A)]
                    Then - Actions
                        Set WeapsHeld[(Player number of (Owner of (Triggering unit)))] = (WeapsHeld[(Player number of (Owner of (Triggering unit)))] + 1)
                        Skip remaining actions
                    Else - Actions

this one sets WeapsHeld to -1 whenever he drops one

Code:
Set WeapsHeld 1down
    Events
        Unit - A unit Loses an item
    Conditions
    Actions
        For each (Integer A) from 1 to 50, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Item-type of (Item being manipulated)) Equal to Weaps[(Integer A)]
                    Then - Actions
                        Set WeapsHeld[(Player number of (Owner of (Triggering unit)))] = (WeapsHeld[(Player number of (Owner of (Triggering unit)))] - 1)
                    Else - Actions

then this code forces the drop if he already has 1 weapon. this and the drop set is seperate for reasons in the code that are exclusive to my map that im not including.

Code:
WeapsHeld Force Drop
    Events
        Unit - A unit Acquires an item
    Conditions
        WeapsHeld[(Player number of (Owner of (Triggering unit)))] Greater than or equal to 2
    Actions
        For each (Integer A) from 1 to 50, do (If ((Item-type of (Item being manipulated)) Equal to Weaps[(Integer A)]) then do (Hero - Drop (Item being manipulated) from (Triggering unit)) else do (Do nothing))
01-18-2005, 08:33 PM#7
mogmiester
Quote:
Originally Posted by Mothmann
i forgot i made this post and forgot to check up on it but i figured it out not to long after posting this. i posted it up there but it was sloppy cause i didn't know how to do the CODE /CODE things then. heres it like this and the actually triggers are written better and less buggy i think too.

heres what i used. its similiar to the ones on here.

first WeapsHeld is a integer with an array. Weaps is a item group i think? during initialization it presets every item i want to be classified as a weapon (right now just 50) to this variable.

this code sets the weapsheld to +1 whenever he picks up a weapon.

Code:
Set WeapsHeld 1up
    Events
        Unit - A unit Acquires an item
    Conditions
    Actions
        For each (Integer A) from 1 to 50, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Item-type of (Item being manipulated)) Equal to Weaps[(Integer A)]
                    Then - Actions
                        Set WeapsHeld[(Player number of (Owner of (Triggering unit)))] = (WeapsHeld[(Player number of (Owner of (Triggering unit)))] + 1)
                        Skip remaining actions
                    Else - Actions

this one sets WeapsHeld to -1 whenever he drops one

Code:
Set WeapsHeld 1down
    Events
        Unit - A unit Loses an item
    Conditions
    Actions
        For each (Integer A) from 1 to 50, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Item-type of (Item being manipulated)) Equal to Weaps[(Integer A)]
                    Then - Actions
                        Set WeapsHeld[(Player number of (Owner of (Triggering unit)))] = (WeapsHeld[(Player number of (Owner of (Triggering unit)))] - 1)
                    Else - Actions

then this code forces the drop if he already has 1 weapon. this and the drop set is seperate for reasons in the code that are exclusive to my map that im not including.

Code:
WeapsHeld Force Drop
    Events
        Unit - A unit Acquires an item
    Conditions
        WeapsHeld[(Player number of (Owner of (Triggering unit)))] Greater than or equal to 2
    Actions
        For each (Integer A) from 1 to 50, do (If ((Item-type of (Item being manipulated)) Equal to Weaps[(Integer A)]) then do (Hero - Drop (Item being manipulated) from (Triggering unit)) else do (Do nothing))
Trust me, i tried that and it doesnt work. Use my method, as its cleaner and easier, as well as no need to init weapons, as there is only one trigger
01-20-2005, 11:44 PM#8
Mothmann
Quote:
Originally Posted by mogmiester
Trust me, i tried that and it doesnt work. Use my method, as its cleaner and easier, as well as no need to init weapons, as there is only one trigger

what are you talking about??? im using it right now?

and your way is cleaner because you only have 2 weapons. when you have over a hundred then it wont be. and i will have probably have around 500 weapons. and your way wont work with my map because i left out parts of those triggers that are only used in my map specifically and i couldn't add those into yours. i need all 3 parts for my map.

did you amke sure to set the weaps variable like this??
weaps is actually a item type variable. i was wrong earlier

Code:
Set Items
    Events
        Map initialization
    Conditions
    Actions
        Set Weaps[1] = Dull Sword
        Set Weaps[2] = Bow
        Set Weaps[3] = B.F.S.
        Set Weaps[4] = Fire Blade
        Set Weaps[5] = Flame Sword
        Set Weaps[6] = Ice Blade
        Set Weaps[7] = Sharp Sword
        Set Weaps[8] = Short Sword
        Set Weaps[9] = Swift Blade
        Set Weaps[10] = Crazy Bow
        Set Weaps[11] = Insane Bow
        Set Weaps[12] = WICKED SICK Bow
02-01-2005, 05:54 PM#9
mogmiester
In the conditions, the ... is for all your weapons. This only requires one trigger, becuase it checks for EVERY single weapon. If you really want to init. the items, then ignore the conditions, and put an if statement into a loop
02-01-2005, 08:20 PM#10
Guest
Code:
WeapsHeld Force Drop
    Events
        Unit - A unit Acquires an item
    Conditions
        WeapsHeld[(Player number of (Owner of (Triggering unit)))] Greater than or equal to 2
    Actions
        For each (Integer A) from 1 to 50, do (If ((Item-type of (Item being manipulated)) Equal to Weaps[(Integer A)]) then do (Hero - Drop (Item being manipulated) from (Triggering unit)) else do (Do nothing))
[/quote]

very nice but the condition i dont know how to make it cause i cant find the right comparisation :S :(
02-07-2005, 06:06 PM#11
MercyfulJester
Quote:
Originally Posted by Mothmann
what are you talking about??? im using it right now?

and your way is cleaner because you only have 2 weapons. when you have over a hundred then it wont be. and i will have probably have around 500 weapons. and your way wont work with my map because i left out parts of those triggers that are only used in my map specifically and i couldn't add those into yours. i need all 3 parts for my map.

did you amke sure to set the weaps variable like this??
weaps is actually a item type variable. i was wrong earlier

Code:
Set Items
    Events
        Map initialization
    Conditions
    Actions
        Set Weaps[1] = Dull Sword
        Set Weaps[2] = Bow
        Set Weaps[3] = B.F.S.
        Set Weaps[4] = Fire Blade
        Set Weaps[5] = Flame Sword
        Set Weaps[6] = Ice Blade
        Set Weaps[7] = Sharp Sword
        Set Weaps[8] = Short Sword
        Set Weaps[9] = Swift Blade
        Set Weaps[10] = Crazy Bow
        Set Weaps[11] = Insane Bow
        Set Weaps[12] = WICKED SICK Bow

I'm sorry to say this Mothmann, but I did everything you told and it doesn't seem to work. I'll re-check to see if I missed anything, but I doubt it.