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

How do i spawn items using a code that are placed into an Variable?

Status
Not open for further replies.
Level 2
Joined
May 10, 2011
Messages
5
How do i spawn items using a code that are placed into an Variable? And is there a way to just simplify it down to a just few triggers than a few hundred?


Items listed are custom made items.

E.g
Code:
[-ItemSpawner] [runs ItemA]
[-AdminItem] [runs ItemB]

Variable:
ItemA[1] = Claws of attack
ItemA[2] = Helm of knights

ItemB[1] = Hp ring
ItemB[2] = Mp ring
_______________

If it doesnt make sense, then I'll try explaining this way:

How do i make an item to spawn when a player types a specific string:
_
e.g

"-itemspawner 1" [spawns a Claws of attack]
"-adminitems 1" [spawns Hp ring]
_

And is it possible to make it to just a few triggers just in case that i have like 100 custom items.
 
Last edited:
Level 17
Joined
Nov 13, 2006
Messages
1,814
How do i spawn items using a code that are placed into an Variable? And is there a way to just simplify it down to a just few triggers than a few hundred?


Items listed are custom made items.

E.g
Code:
[-ItemSpawner] [runs ItemA]
[-AdminItem] [runs ItemB]

Variable:
ItemA[1] = Claws of attack
ItemA[2] = Helm of knights

ItemB[1] = Hp ring
ItemB[2] = Mp ring
_______________

If it doesnt make sense, then I'll try explaining this way:

How do i make an item to spawn when a player types a specific string:
_
e.g

"-itemspawner 1" [spawns a Claws of attack]
"-adminitems 1" [spawns Hp ring]
_

And is it possible to make it to just a few triggers just in case that i have like 100 custom items.

  • Map init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set itemtypea[1] = Claws of Attack +15
      • Set itemtypea[2] = Kelen's Dagger of Escape
      • Set itemtypeb[1] = Ring of Protection +5
      • Set itemtypeb[2] = Mask of Death
      • Set chatcommand1 = -itemspawner
      • Set chatcommand2 = -adminitems
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Player((Integer A))) controller) Equal to User
              • ((Player((Integer A))) slot status) Equal to Is playing
            • Then - Actions
              • Trigger - Add to Player chat msg <gen> the event (Player - (Player((Integer A))) types a chat message containing chatcommand1 as A substring)
              • Trigger - Add to Player chat msg admin <gen> the event (Player - (Player((Integer A))) types a chat message containing chatcommand2 as A substring)
            • Else - Actions
  • Player chat msg
    • Events
    • Conditions
    • Actions
      • Set String = (Entered chat string)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Length of String) Greater than ((Length of chatcommand1) + 1)
        • Then - Actions
          • Set String1 = (Substring(String, ((Length of chatcommand1) + 1), (Length of String)))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Integer(String1)) Not equal to 0
            • Then - Actions
              • Set Point = (Random point in 1 <gen>)
              • Item - Create itemtypea[(Integer(String1))] at (Random point in 1 <gen>)
              • Custom script: call RemoveLocation(udg_Point)
              • Game - Display to (All players) the text: (Your item code: + String1)
            • Else - Actions
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Length of String) Greater than ((Length of chatcommand2) + 1)
        • Then - Actions
          • Set String1 = (Substring(String, ((Length of chatcommand2) + 1), (Length of String)))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Integer(String1)) Not equal to 0
            • Then - Actions
              • Set Point = (Random point in 2 <gen>)
              • Item - Create itemtypeb[(Integer(String1))] at Point
              • Custom script: call RemoveLocation(udg_Point)
              • Game - Display to (All players) the text: (Your admin code: + String1)
            • Else - Actions
        • Else - Actions
 

Attachments

  • item.w3x
    17.8 KB · Views: 133
Level 9
Joined
Nov 19, 2011
Messages
516
Map init was good but then,...
You made difficult something that is simple. Do it this way:

Add one more variable (Hero) where you got all heroes in game. For e.g. Hero[1] is Player(1) hero. Then just use acction (Create Item for Hero[1]), or if you want to spawn at region use (Create item (YourItem) at random point of (Region)). No need to call point remove, or setting point variable.
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
Map init was good but then,...
You made difficult[b/] something that is simple. Do it this way:

Add one more variable (Hero) where you got all heroes in game. For e.g. Hero[1] is Player(1) hero. Then just use acction (Create Item for Hero[1]), or if you want to spawn at region use (Create item (YourItem) at random point of (Region)). No need to call point remove, or setting point variable.



How do i make an item to spawn when a player types a specific string:

difficulty i created to region instead hero? its +2 row the region thing, i doubt that make more difficult trigger :p
 
Status
Not open for further replies.
Top