Item drop & Hero Selection

Dynamis

New Member
Reaction score
2
All right, so for a new map I have been toying with, I have overcome several obstacles (thanks to your assistance!) and taught myself a little JASS, but there are two remaining issues I have -not- been able to fix on my own.

Firstly;
My hero selection system.
Originally, I had it set to something like this (not an original concept, but I thought it would work).. A Tavern with 12 of the custom heroes I made with each player having a wisp around it.

When someone bought a hero, the wisp that player owned would be killed. The hero would be teleported from the region around the Tavern to the Spawn location and then the Camera would instantly move to that location.

In theory it worked fine, until myself and the wife tested it.
When picking our heroes, the game would lock up, she would lag, then the would get disconnected a few moments later. I even have this problem when TESTING my map alone, no disconnection, just massive lag.

Secondly;
And Item Dropping system.

I have created custom items and added them to the assorted monsters that should drop them, which works fine!..Until.. They respawn. I manually added item drop percentages to each mob, and I now realize that when they respawn, they no longer have that item chance.

So my goal here is to make an item system for say, if you kill a Wolf, then the wolf have a 10% chance to drop item X. If it's a boss, have various items that COULD drop on his list and maybe drop a few? (If not, one is fine! The simpler, the better!)

Lastly, how do I make these items despawn from where they dropped? With my current system, the items would build up quickly on the ground and become rather cluttersome.

Once again, thank you for all assistance in advance!
 

TheTempest

New Member
Reaction score
6
1. Could you post your trigger code?

2. Make a trigger like "A unit dies. Unit-type of dying unit equal to Wolf. If (Integer Comparison (Random Number 1 through 10 equal to 1)) then <Drop Item>"

EDIT: Something like this:

Trigger:
  • Events
    • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Dying unit)) Equal to Giant Wolf // &lt;- Whatever unit you want. Should probably put a check to make sure that the owner is Neutral Hostile.
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Random integer number between 1 and 10) Equal to 1 // &lt;- 10%
        • Then - Actions
          • Set tUnit = (Dying unit)
          • Item - Create &lt;Desired Item&gt; at (Position of tUnit)
          • Set tUnit = No unit
        • Else - Actions
 

Dynamis

New Member
Reaction score
2
1. Could you post your trigger code?

2. Make a trigger like "A unit dies. Unit-type of dying unit equal to Wolf. If (Integer Comparison (Random Number 1 through 10 equal to 1)) then <Drop Item>"

I deleted the entire thing out of anger, but let me redo it, one moment! :)

-Here you go!

Events
Unit - A unit enters Selection Area <gen>

Conditions
(Owner of (Triggering unit)) Equal to Player 1 (Red)
((Triggering unit) is A Hero) Equal to True

Actions
Unit - Kill Wisp 0027 <gen>
Unit - Move (Triggering unit) instantly to (Center of SpawnPoint <gen>)
Camera - Pan camera as necessary for (Owner of (Triggering unit)) to (Center of SpawnPoint <gen>) over 10.00 seconds


Also, how would that item dropping system work? Like, how would the item be destroyed? Could multiples of that action be created?
 

TheTempest

New Member
Reaction score
6
Should be something similar to this (I havn't tested it but it should work)

Trigger:
  • Events
    • Unit - A unit Sells a unit
    • Conditions
      • (Unit-type of (Buying unit)) Equal to Wisp
    • Actions
      • Unit - Move (Sold unit) instantly to (Center of (YOUR-REGION-HERE))
      • Camera - Pan camera for (Owner of (Buying unit)) to (Center of (YOUR-REGION-HERE)) over 0.00 seconds
      • Unit - Kill (Buying unit)
 

Dynamis

New Member
Reaction score
2
1. Could you post your trigger code?

2. Make a trigger like "A unit dies. Unit-type of dying unit equal to Wolf. If (Integer Comparison (Random Number 1 through 10 equal to 1)) then <Drop Item>"

EDIT: Something like this:

Trigger:
  • Events
    • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Dying unit)) Equal to Giant Wolf // &lt;- Whatever unit you want. Should probably put a check to make sure that the owner is Neutral Hostile.
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Random integer number between 1 and 10) Equal to 1 // &lt;- 10%
        • Then - Actions
          • Set tUnit = (Dying unit)
          • Item - Create &lt;Desired Item&gt; at (Position of tUnit)
          • Set tUnit = No unit
        • Else - Actions

Even so, this still wouldn't destroy the item created. If you were to add "Destroy - Last created item" to the end under Else - Actions, would it remember THIS item, or ANY item that was created last?
 

TheTempest

New Member
Reaction score
6
Even so, this still wouldn't destroy the item created. If you were to add "Destroy - Last created item" to the end under Else - Actions, would it remember THIS item, or ANY item that was created last?

It's only making the item in the "then" section of the statement. If you call destroy item in the else then whatever item was created before it would be destroyed (chances are it's some item not even remotely related to the wolf drop)

EDIT: Didn't read the last sentence in your thread, sorry. Just make a trigger that when an item appears somewhere, after 30 seconds if it hasn't been manipulated in any way it's removed.
 

Dynamis

New Member
Reaction score
2
It's only making the item in the "then" section of the statement. If you call destroy item in the else then whatever item was created before it would be destroyed (chances are it's some item not even remotely related to the wolf drop)

EDIT: Didn't read the last sentence in your thread, sorry. Just make a trigger that when an item appears somewhere, after 30 seconds if it hasn't been manipulated in any way it's removed.

How would one do that? I can only find Unit, Player, and related events. Not item, and the non-manipulated condition? Please explain, sorry for all of the questions and my daft-ness!
 

TheTempest

New Member
Reaction score
6
Since item dropping can be done in triggers you can call a trigger for "new item" (setting a variable so iItem = <Last Created Item>)

Then you could fool around with the item, setting it's custom value to the current game time (in seconds).

Have an array containing all the dropped items. When a player picks it up, remove it from the array/list.

Then every second of game time, loop through the array of the stored items. If the current game time > the stored custom value then remove the item (Remember that if a player picks it up it gets removed from the array)

I'm just throwing ideas out there, you can do whatever you feel.
 

Dynamis

New Member
Reaction score
2
Since item dropping can be done in triggers you can call a trigger for "new item" (setting a variable so iItem = <Last Created Item>)

Then you could fool around with the item, setting it's custom value to the current game time (in seconds).

Have an array containing all the dropped items. When a player picks it up, remove it from the array/list.

Then every second of game time, loop through the array of the stored items. If the current game time > the stored custom value then remove the item (Remember that if a player picks it up it gets removed from the array)

I'm just throwing ideas out there, you can do whatever you feel.

I cannot get the item drop trigger or the item removal trigger to work. Currently for the drop trigger I have:

Events
Unit - A unit Dies
Conditions
(Unit-type of (Dying unit)) Equal to Timber Wolf
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Random real number between 0.00 and 2.00) Equal to 1.00
Then - Actions
Item - Create Wolf Fur Jerkin at (Position of (Dying unit))
Else - Actions

Edit- Not even sure how to go about the deletion trigger. My skills aren't quite that advanced yet. Still not sure as to why the item drop is not working as intended or how to implement the item deletion.
 

TheTempest

New Member
Reaction score
6
I cannot get the item drop trigger or the item removal trigger to work. Currently for the drop trigger I have:

Events
Unit - A unit Dies
Conditions
(Unit-type of (Dying unit)) Equal to Timber Wolf
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Random real number between 0.00 and 2.00) Equal to 1.00
Then - Actions
Item - Create Wolf Fur Jerkin at (Position of (Dying unit))
Else - Actions

Edit- Not even sure how to go about the deletion trigger. My skills aren't quite that advanced yet. Still not sure as to why the item drop is not working as intended or how to implement the item deletion.

Trigger:
  • (Random real number between 0.00 and 2.00) Equal to 1.00


A Real number can be 0.121416846846. Basically, having a condition that says Equal to is going to have a REALLLLY slim chance of happening. The chance that it equals exactly 1.0 is probably 0.00000001%. I think what you want to do is

Trigger:
  • (Random real number between 0.00 and 1.00) Less Than or Equal to 0.1


Of course you could also do just a normal integer 1 through 10
 

Dynamis

New Member
Reaction score
2
Trigger:
  • (Random real number between 0.00 and 2.00) Equal to 1.00


A Real number can be 0.121416846846. Basically, having a condition that says Equal to is going to have a REALLLLY slim chance of happening. The chance that it equals exactly 1.0 is probably 0.00000001%. I think what you want to do is

Trigger:
  • (Random real number between 0.00 and 1.00) Less Than or Equal to 0.1


Of course you could also do just a normal integer 1 through 10

Fixed! Thank you very much! May I ask how the deletion trigger would work if an item was unused for ~300 seconds? Variable type, too please! Also, could it work if a hero dropped the same item?
 

TheTempest

New Member
Reaction score
6
Just wrote this JASS script. I'm going to sleep now so I can't finish it, but this is the main part of it.

Good night. (Email me at [email protected] on how it works out)

JASS:
globals 
item array Items
integer array SpawnTime
integer ItemAmt = 0
integer CurrentTime = 0
endglobals

function IncreaseTime takes nothing returns nothing
    set CurrentTime = CurrentTime + 1
endfunction

function AddItem takes item ItemToAdd returns nothing

    set ItemAmt = ItemAmt + 1
    set Items[ItemAmt] = ItemToAdd
    set SpawnTime[ItemAmt] = CurrentTime + 300 // &lt;-- 300 Is the amount of seconds (5 Minutes)
    
endfunction

function ManipulatedItem takes item MItem returns nothing
local integer a = 0
local boolean found = false
    loop
    set a = a + 1
        if(Items[a] == MItem) then
            set Items[a] = null
            set SpawnTime[a] = -1
            set found = true
        endif
        
        exitwhen(found == true)
    endloop

endfunction

function CheckItems takes nothing returns nothing
local integer a = 0
    loop
        set a = a + 1
        exitwhen (a &gt; ItemAmt)
        
        if(SpawnTime[a] &lt;= CurrentTime and Items[a] != null) then
            call RemoveItem(Items[a])
            set Items[a] = null
            set SpawnTime[a] = -1
        endif
    endloop

endfunction
 

Dynamis

New Member
Reaction score
2
Just wrote this JASS script. I'm going to sleep now so I can't finish it, but this is the main part of it.

Good night. (Email me at [email protected] on how it works out)

JASS:
globals 
item array Items
integer array SpawnTime
integer ItemAmt = 0
integer CurrentTime = 0
endglobals

function IncreaseTime takes nothing returns nothing
    set CurrentTime = CurrentTime + 1
endfunction

function AddItem takes item ItemToAdd returns nothing

    set ItemAmt = ItemAmt + 1
    set Items[ItemAmt] = ItemToAdd
    set SpawnTime[ItemAmt] = CurrentTime + 300 // &lt;-- 300 Is the amount of seconds (5 Minutes)
    
endfunction

function ManipulatedItem takes item MItem returns nothing
local integer a = 0
local boolean found = false
    loop
    set a = a + 1
        if(Items[a] == MItem) then
            set Items[a] = null
            set SpawnTime[a] = -1
            set found = true
        endif
        
        exitwhen(found == true)
    endloop

endfunction

function CheckItems takes nothing returns nothing
local integer a = 0
    loop
        set a = a + 1
        exitwhen (a &gt; ItemAmt)
        
        if(SpawnTime[a] &lt;= CurrentTime and Items[a] != null) then
            call RemoveItem(Items[a])
            set Items[a] = null
            set SpawnTime[a] = -1
        endif
    endloop

endfunction

Attempted to use this script, no compiling errors, even with a JASS checker the first time, saved fine, loaded it to test it. Didn't work, so I went back, changed the time from 300 to 10 (to reduce the time waited for testing purposes), attempted to resave and got an error message. Changed it from 10 back to 300, saved with no errors, then when I attempted to host it on battle.net, I got the "Unable to find" error compatibility issue with 1.24. =(

How would this be fixed? Are there any easier alternatives to remove items that drop 5 minutes after they appear if they aren't used?
 

TheTempest

New Member
Reaction score
6
Trigger named "Time". Every second of gameplay this runs a JASS function that increases a variable by 1, essentially keeping our "time". This also does a check for any items.

Trigger:
  • Time
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Custom script: call IncreaseTime( )
      • Custom script: call CheckItems( )


Trigger names "Item is Dropped". Create a variable named ItemDropped with type "item". In your triggers when an item is dropped, do "Set Variable [ItemDropped] = (Last Created Item)". Then, call this trigger. Or, better yet, just copy and paste the custom script into the trigger.

Trigger:
  • Item Is Dropped
    • Events
    • Conditions
    • Actions
      • Custom script: call AddItem(udg_ItemDropped)


Trigger named "Item is Manipulated". Whenever something picks up an item, it is being manipulated. Manipulated items will be removed from the "timer" for removing the items themselves.

Trigger:
  • Item Is Manipulated
    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • Set tItemBeingManipulated = (Item being manipulated)
      • Custom script: call ManipulatedItem(udg_tItemBeingManipulated)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top