• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] GUI Gift Giving Trigger

Status
Not open for further replies.
Level 2
Joined
Mar 21, 2014
Messages
8
I have recently started to map make again, but I'm having a little trouble with this trigger.

  • Give Item 1
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Unit-type of (Hero manipulating item)) Equal to Rich Girl
    • Actions
      • Set Players_LoseItem_Bianca[1] = Player 1 (Red)
      • Set Players_LoseItem_Bianca[2] = Player 2 (Blue)
      • Set Players_LoseItem_Bianca[3] = Player 3 (Teal)
      • Set Players_LoseItem_Bianca[4] = Player 4 (Purple)
      • Set Players_LoseItem_Bianca[5] = Player 5 (Yellow)
      • Set GiveItem1_Bianca[1] = This doesn't amuse me.
      • Set GiveItem1_Bianca[2] = Do you really think I would be interested in that?
      • Set GiveItem1_Bianca[3] = My daddy can buy me something more valuable than that.
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Item-type of (Item being manipulated)) Equal to Broadsword
              • (Item-type of (Item being manipulated)) Equal to Rusty Axe
        • Then - Actions
          • Item - Remove (Item being manipulated)
          • Floating Text - Create floating text that reads GiveItem1_Bianca[(Random integer number between 1 and 3)] at (Position of (Hero manipulating item)) with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
          • Floating Text - Change (Last created floating text): Disable permanence
          • Floating Text - Change the lifespan of (Last created floating text) to 5.00 seconds
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of (Triggering unit)) Equal to Players_LoseItem_Bianca[1]
              • Player_Gift_Bianca[1] Equal to 0
            • Then - Actions
              • Hero - Create Heart Piece Bianca and give it to Heart Level Meter 0166 <gen>
              • Set Player_Gift_Bianca[1] = 1
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Owner of (Triggering unit)) Equal to Players_LoseItem_Bianca[2]
                  • Player_Gift_Bianca[2] Equal to 0
                • Then - Actions
                  • Hero - Create Heart Piece Bianca and give it to Paladin 0168 <gen>
                  • Set Player_Gift_Bianca[2] = 1
                • Else - Actions
        • Else - Actions
and


  • Player Gives Item
    • Events
      • Unit - A unit Loses an item
    • Conditions
    • Actions
      • Set Players_LoseItem_Bianca[1] = (Owner of (Triggering unit))
      • Set Players_LoseItem_Bianca[2] = (Owner of (Triggering unit))
      • Set Players_LoseItem_Bianca[3] = (Owner of (Triggering unit))
      • Set Players_LoseItem_Bianca[4] = (Owner of (Triggering unit))
      • Set Players_LoseItem_Bianca[5] = (Owner of (Triggering unit))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Last dropped item) Equal to (Item carried by (Triggering unit) of type Broadsword)
              • (Last dropped item) Equal to (Item carried by (Triggering unit) of type Rusty Axe)
        • Then - Actions
        • Else - Actions
When player red gives either Broadsword or Rusty Axe to "Rich Girl", the heart piece that goes into the "Heart Level Meter" sometimes goes into the inventory of the Paladin(It should only go to the Paladin if you are player blue) Other players will have the heart piece sent to another units inventory.

I used an array of variables to identify the player color, from player red 1, to player yellow 5.
 
Level 28
Joined
Sep 26, 2009
Messages
2,520
Most likely, the problem is in trigger #2 (Player Gives Item), because there you re-declare which player is saved into Players_LoseItem_Bianca[1-5] array.

Let's say player 2 (Blue) loses an item. Then the second trigger looks like this:
Code:
Set Players_LoseItem_Bianca[1] = Player 2 (Blue)
Set Players_LoseItem_Bianca[2] = Player 2 (Blue)
Set Players_LoseItem_Bianca[3] = Player 2 (Blue)
Set Players_LoseItem_Bianca[4] = Player 2 (Blue)
Set Players_LoseItem_Bianca[5] = Player 2 (Blue)
...
Because owner of (triggering unit) is in this case Player 2.
Then the info may actually get really messed up and be different than you expect.


Imo, in your place I would:
1) get rid of the player array -> there's no need to declare that Player[1] is Player 1 (Red) up to Player[5].
More than that, there is already a function to convert player's index into integer number. Player's index is unique for that player slot (e.g. only Player 1 (Red) can have index 1), so you can use that number as an index for your arrays.

2) Make a trigger which fires during map initialization and declare GiveItem1_Bianca[1-3] in there, as right now you re-declare those sentences everytime Rich Girl picks up an item.

3) If Player_Gift_Bianca can have values only 0 and 1, then change it into boolean, as that makes more sense and is easier to understand.

4) Get rid of the second trigger if it's all it does (mess up player variable and else does nothing)

5) If you were to save Heart Level Meter unit and Paladin unit into variable array, then you could really simplify the trigger.
 
Level 2
Joined
Mar 21, 2014
Messages
8
There's something I don't understand.

When a player gives an item to the rich girl, every player and the rich girl are the (Hero Manipulating item) context. Can they both be (Hero Manipulating item) in the same trigger? There is no "Hero dropped item", besides for the manipulating item context.

So they both use (Hero Manipulating item).


Edit: Nichilus, I have done 2, 4, and I think 5.

I don't quite get 1 and 3. Can I get an example?

This is what I have so far

  • Give Item 1
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Unit-type of (Hero manipulating item)) Equal to Rich Girl
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Item-type of (Item being manipulated)) Equal to Broadsword
              • (Item-type of (Item being manipulated)) Equal to Rusty Axe
        • Then - Actions
          • Item - Remove (Item being manipulated)
          • Floating Text - Create floating text that reads GiveItem1_Bianca[(Random integer number between 1 and 3)] at (Position of (Hero manipulating item)) with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
          • Floating Text - Change (Last created floating text): Disable permanence
          • Floating Text - Change the lifespan of (Last created floating text) to 5.00 seconds
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of (Triggering unit)) Equal to Value
              • Player_Gift_Bianca[1] Equal to False
            • Then - Actions
              • Hero - Create Heart Piece Bianca and give it to UnitArray[1]
              • Set Player_Gift_Bianca[1] = True
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Owner of (Triggering unit)) Equal to Value
                  • Player_Gift_Bianca[2] Equal to False
                • Then - Actions
                  • Hero - Create Heart Piece Bianca and give it to UnitArray[2]
                  • Set Player_Gift_Bianca[2] = True
                • Else - Actions
        • Else - Actions

and

  • Initalization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Variable = Player 1 (Red)
      • Set Talk1_Bianca[1] = Hello
      • Set Talk1_Bianca[2] = Hi
      • Set Talk1_Bianca[3] = Good Morning
      • Set GiveItem1_Bianca[1] = This doesn't amuse me.
      • Set GiveItem1_Bianca[2] = Do you really think I would be interested in that?
      • Set GiveItem1_Bianca[3] = My daddy can buy me something more valuable than that.
      • Set UnitArray[1] = Heart Level Meter 0166 <gen>
      • Set UnitArray[2] = Paladin 0168 <gen>

I'm a little confused with how the Boolean would work for it. Also, for number 1 I'm not sure what you mean.(How I can use convert player's index into integer numbers)
 
Last edited:
Level 28
Joined
Sep 26, 2009
Messages
2,520
I'll start with the boolean.
Booleans can have only 2 values - True and False. You can use booleans to "make a statement" for yourself and check if that statement is true or false.

Instead of Player_Gift_Bianca I'll call this variable Bianca_Got_Gift.
So Bianca_Got_Gift has false value by default. If I gave Bianca a gift, I would change the value to true, because Bianca really got gift from me.

In the conditions
  • Bianca_Got_Gift[1] equal to True
Checks if the value saved inside the variable is same as the value we are checking it with. In this case, we check if the value saved in Bianca_Got_Gift is True.
If it has True value, then you basically check if "True equal to True" -> which is actually true, so the condition passes.
If the value was False, then it would check if False equal to True -> that is obviously not true, it's same like say that 1 is equal to 5... it ain't equal.

Using Booleans in this case is better if only for one reason -> you know that there are only 2 states for the variable. If you use e.g. integer variable, you don't know if Player_Gift_Bianca can have only values 1 and 2; or if it can have values 1 up to 500 or more.

--------------------------------------------------------------------------------
About the player array:
Look. You saved each player into player array like this:
  • Set PlayerArray[1] = Player 1 (Red)
  • Set PlayerArray[2] = Player 2 (Blue)
  • Set PlayerArray[3] = Player 3 (Teal)
Let's look at Player 1 (Red) now -> in the trigger above, this player is saved into PlayerArray with index 1.
Now all data related to Player 1 (Red) have index 1 as well. For example Player_Gift_Bianca that is related to player 1 (Red) has index 1.

But this is completely unnecessary to save each player into player array, more so if they are saved in same order as they are in game slots (e.g. Player 1 (Red) has slot 1 and in the player array is saved with index 1... Player 5 (Yellow) has slot 5 and in array is saved under index 5).

It is better to use Player variable (not array!) and save Owner of (Triggering unit) in that variable (as it is faster to use the varaible than using Owner of (Triggering unit) multiple times).

I'll also make an integer variable called INDEX, into which I convert player's number into index.
Now, I have this piece of code:
  • Actions
    • Set Player_var = (Owner of (Triggering unit))
    • Set INDEX = (Player number of Player_var)
    • Set Player_Gift_Bianca[INDEX] = 1
As you can see, first I saved (Owner of (Triggering unit)) into Player_var variable.
Then I saved Player_var's number into INDEX and finaly, I used the INDEX variable as index for Player_Gift_Bianca.

Let's say that the triggering player is Player 2 (Blue).
So Player 2 (Blue) is saved into Player_var variable, then his number is saved into INDEX variable.
Player 2 (Blue)'s number is always 2. It can never get overwritten by another player!
Then the number 1 is saved into Player_Gift_Bianca[2], since INDEX has value 2.

As you can see, everything is still saved into same variables/arrays, but I no longer need to use Player variable array.

-------------------------------------------------------------------------------------
Now the last thing - why I wrote you could use unit array and save the 2 units inside it:
Ever heard of loops?
If you have repeated code, you can put it inside loop and the code will repeat as many times as you want. This is a very good way if you have same code with the only difference being in indexes.

First, I'll make an integer variable used only by loops. I'll call it "loop_var". Then in actions I'll find under "general" tab the "For integer variable loop".

Now I have this code:
  • Actions
    • Set Player = (Owner of (Triggering unit))
    • For each (Integer loop_var) from 1 to 2, do (Actions)
      • Loop - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • Player Equal to (Player(loop_var))
            • Bianca_Got_Gift[loop_var] Equal to False
          • Then - Actions
            • Hero - Create Tome of Experience and give it to Unit_Array[loop_var]
            • Set Bianca_Got_Gift[loop_var] = True
          • Else - Actions
It may confuse you a bit that I used the "loop_var" as index.
The nice thing about integer loop is that it saves into the variable you chose the first starting value and each time the loop starts new cycle, it increases that value by 1, until the value saved in variable is greater than the end value set up by you, in which case the loop ends.

In the trigger above, the variable used is "loop_var", starting value is '1' and ending value is '2'.
So when the loop starts for the first time, loop_var gets starting value - value 1. After that, executes all the actions inside the loop and because "loop_var" is used there as an index, it actually checks those arrays with index 1.
Now all actions inside the loop have been executed, so "loop_var" value is increased by 1.
Then it checks if "loop_var" value is greater than ending value. Ending value is 2 and value in loop_var is 2 as well - it ain't greater and so the loop starts again, but now with "loop_var" having value 2.
Once all actions are executed yet again, it increases loop_var value to 3. But in the check, loop_var has greater value than the ending value (3 is greater than 2) so the loop ends.

Look at this example:

First, I have a code without loops. As you will see, it is easy to get lost in it and if you want to make change to anything, you have to repeat it X times:
  • ASD
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (RegionA <gen> contains Hero[1]) Equal to True
          • (Hero[1] has an item of type Gem Fragment) Equal to True
        • Then - Actions
          • Hero - Add 1000 experience to Hero[1], Show level-up graphics
          • Unit - Set life of Hero[1] to 100.00%
          • Hero - Create Orb of Frost and give it to Hero[1]
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (RegionA <gen> contains Hero[2]) Equal to True
              • (Hero[2] has an item of type Gem Fragment) Equal to True
            • Then - Actions
              • Hero - Add 1000 experience to Hero[2], Show level-up graphics
              • Unit - Set life of Hero[2] to 100.00%
              • Hero - Create Orb of Frost and give it to Hero[2]
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (RegionA <gen> contains Hero[3]) Equal to True
                  • (Hero[3] has an item of type Gem Fragment) Equal to True
                • Then - Actions
                  • Hero - Add 1000 experience to Hero[3], Show level-up graphics
                  • Unit - Set life of Hero[3] to 100.00%
                  • Hero - Create Orb of Frost and give it to Hero[3]
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (RegionA <gen> contains Hero[4]) Equal to True
                      • (Hero[4] has an item of type Gem Fragment) Equal to True
                    • Then - Actions
                      • Hero - Add 1000 experience to Hero[4], Show level-up graphics
                      • Unit - Set life of Hero[4] to 100.00%
                      • Hero - Create Orb of Frost and give it to Hero[4]
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (RegionA <gen> contains Hero[5]) Equal to True
                          • (Hero[5] has an item of type Gem Fragment) Equal to True
                        • Then - Actions
                          • Hero - Add 1000 experience to Hero[5], Show level-up graphics
                          • Unit - Set life of Hero[5] to 100.00%
                          • Hero - Create Orb of Frost and give it to Hero[5]
                        • Else - Actions
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • (RegionA <gen> contains Hero[6]) Equal to True
                              • (Hero[6] has an item of type Gem Fragment) Equal to True
                            • Then - Actions
                              • Hero - Add 1000 experience to Hero[6], Show level-up graphics
                              • Unit - Set life of Hero[6] to 100.00%
                              • Hero - Create Orb of Frost and give it to Hero[6]
                            • Else - Actions
                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                • If - Conditions
                                  • (RegionA <gen> contains Hero[7]) Equal to True
                                  • (Hero[7] has an item of type Gem Fragment) Equal to True
                                • Then - Actions
                                  • Hero - Add 1000 experience to Hero[7], Show level-up graphics
                                  • Unit - Set life of Hero[7] to 100.00%
                                  • Hero - Create Orb of Frost and give it to Hero[7]
                                • Else - Actions
Now look at the this example where I use loop. You will see that I elegantly made the code easier to take in, easier to understand and also easier to change.
  • YXC
    • Events
    • Conditions
    • Actions
      • For each (Integer loop_var) from 1 to 7, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (RegionA <gen> contains Hero[loop_var]) Equal to True
              • (Hero[loop_var] has an item of type Gem Fragment) Equal to True
            • Then - Actions
              • Hero - Add 1000 experience to Hero[loop_var], Show level-up graphics
              • Unit - Set life of Hero[loop_var] to 100.00%
              • Hero - Create Orb of Frost and give it to Hero[loop_var]
            • Else - Actions
Looking at it now, it may not be that necessary to use the loop if you only have 2 units. But if you have more it's better efficiency-wise and it's more synoptic to use loops.
 
Last edited:
Level 2
Joined
Mar 21, 2014
Messages
8
Alright, I feel like I am getting pretty close.. but I still can't seem to get it to work. (By the way, I'm learning a lot from this. Thank you, you are a great help.)

  • Give Item 1
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Unit-type of (Hero manipulating item)) Equal to Rich Girl
    • Actions
      • For each (Integer loop_var) from 1 to 2, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Item-type of (Item being manipulated)) Equal to Broadsword
                  • (Item-type of (Item being manipulated)) Equal to Rusty Axe
            • Then - Actions
              • Item - Remove (Item being manipulated)
              • Floating Text - Create floating text that reads GiveItem1_Bianca[(Random integer number between 1 and 3)] at (Position of (Hero manipulating item)) with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
              • Floating Text - Change (Last created floating text): Disable permanence
              • Floating Text - Change the lifespan of (Last created floating text) to 5.00 seconds
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Player_var Equal to (Player(loop_var))
                  • Bianca_Got_Gift[loop_var] Equal to False
                • Then - Actions
                  • Hero - Create Heart Piece Bianca and give it to UnitArray[loop_var]
                  • Set Bianca_Got_Gift[loop_var] = True
                • Else - Actions
            • Else - Actions
and

  • Initalization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Player_var = (Owner of (Triggering unit))
      • Set INDEX = (Player number of Player_var)
      • Set Player_Gift_Bianca[INDEX] = 1
      • Set Talk1_Bianca[1] = Hello
      • Set Talk1_Bianca[2] = Hi
      • Set Talk1_Bianca[3] = Good Morning
      • Set GiveItem1_Bianca[1] = This doesn't amuse me.
      • Set GiveItem1_Bianca[2] = Do you really think I would be interested in that?
      • Set GiveItem1_Bianca[3] = My daddy can buy me something more valuable than that.
      • Set UnitArray[1] = Heart Level Meter 0166 <gen>
      • Set UnitArray[2] = Paladin 0168 <gen>
 
Level 28
Joined
Sep 26, 2009
Messages
2,520
Looking at your triggers, error in your updated trigger is that you put player_var and INDEX inside map initialization trigger.
The problem is that "owner of (triggering unit)" is an "answer"/"response" to when some unit fires/starts trigger --> however map initialization happens automatically, there's no unit which starts the trigger, so having
  • Set player_var = owner of (triggering unit)
will return null and so you set
  • Set INDEX = player number of player_var
which is player number of "null" so it will most likely put 0 or leave the previous number in INDEX variable.

Anyway, I'm getting a little lost here. What are you trying to achieve?

If I understand it correctly, then some unit gives to Rich Girl either Broadsword or Rusty Axe, she says something mean and if it's the first time that unit gave her this gift, it will receive heart piece?
 
Level 2
Joined
Mar 21, 2014
Messages
8
Yes, you pretty much have the general idea without me having to say anything.

1. Player (Red to Light Blue) Gives Rich Girl either Broadsword or Rusty Axe.

2. She will say something in response.

3. If it is the first time, then depending on the players slot color(Red, Blue, Teal, etc), the Heart Piece will go into the inventory of a certain unit. Each player has their own certain unit which will keep the heart piece. The unit right now is called "Heart Level Meter" and each player will have one to store Heart Pieces.

I used a Paladin however for Blue instead of the unit "Heart Level Meter", because I wanted to test it really quick to see if the trigger worked.


  • Initalization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Player_Gift_Bianca[INDEX] = 1
      • Set Talk1_Bianca[1] = Hello
      • Set Talk1_Bianca[2] = Hi
      • Set Talk1_Bianca[3] = Good Morning
      • Set GiveItem1_Bianca[1] = This doesn't amuse me.
      • Set GiveItem1_Bianca[2] = Do you really think I would be interested in that?
      • Set GiveItem1_Bianca[3] = My daddy can buy me something more valuable than that.
      • Set UnitArray[1] = Heart Level Meter 0166 <gen>
      • Set UnitArray[2] = Paladin 0168 <gen>

  • Give Item 1
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Unit-type of (Hero manipulating item)) Equal to Rich Girl
    • Actions
      • Set Player_var = (Owner of (Triggering unit))
      • Set INDEX = (Player number of Player_var)
      • For each (Integer loop_var) from 1 to 2, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Item-type of (Item being manipulated)) Equal to Broadsword
                  • (Item-type of (Item being manipulated)) Equal to Rusty Axe
            • Then - Actions
              • Item - Remove (Item being manipulated)
              • Floating Text - Create floating text that reads GiveItem1_Bianca[(Random integer number between 1 and 3)] at (Position of (Hero manipulating item)) with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
              • Floating Text - Change (Last created floating text): Disable permanence
              • Floating Text - Change the lifespan of (Last created floating text) to 5.00 seconds
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Player_var Equal to (Player(loop_var))
                  • Bianca_Got_Gift[loop_var] Equal to False
                • Then - Actions
                  • Hero - Create Heart Piece Bianca and give it to UnitArray[loop_var]
                  • Set Bianca_Got_Gift[loop_var] = True
                • Else - Actions
            • Else - Actions
 
Last edited:
Level 28
Joined
Sep 26, 2009
Messages
2,520
Ok. Now that I know what you are trying to achieve, I remade those triggers to what I think could work best.

I attached a test map so you can look if that's what you want.

I'll post the triggers as well.
  • Map Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Talk1_Bianca[1] = Hello
      • Set Talk1_Bianca[2] = Hi
      • Set Talk1_Bianca[3] = Good Morning
      • Set GiveItem1_Bianca[1] = This doesn't amuse me.
      • Set GiveItem1_Bianca[2] = Do you really think I would be interested in that?
      • Set GiveItem1_Bianca[3] = My daddy can buy me something more valuable than that.
      • Set Bianca_HeartMeter[1] = Hearth Level Meter 0005 <gen>
      • Set Bianca_HeartMeter[2] = Hearth Level Meter 0004 <gen>
Note: I got rid of some unimportant stuff which is not really important to the problem at hand (like setting up players, etc.) - these things are present in this trigger in the map, but they're not posted here as they're unimportant.


  • Bianca Gift Given
    • Events
      • Unit - A unit Loses an item
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Item-type of (Item being manipulated)) Equal to Claws of Attack +15
          • (Item-type of (Item being manipulated)) Equal to Ring of Protection +5
    • Actions
      • Set Bianca_Gift = (Item being manipulated)
      • Set Bianca_Giver = (Triggering unit)
This trigger *remember* the unit which lost an item that can be a potential gift for Bianca. It also remembers what the item (gift) was


  • Bianca Gift Taken
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Triggering unit) Equal to Rich Girl 0000 <gen>
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item being manipulated) Equal to Bianca_Gift
          • Or - Any (Conditions) are true
            • Conditions
              • (Item-type of (Item being manipulated)) Equal to Claws of Attack +15
              • (Item-type of (Item being manipulated)) Equal to Ring of Protection +5
        • Then - Actions
          • Set INDEX = (Player number of (Owner of Bianca_Giver))
          • Item - Remove (Item being manipulated)
          • -------- ------------------------------------------------------------------------------------------------ --------
          • Floating Text - Create floating text that reads GiveItem1_Bianca[(Random integer number between 1 and 3)] above Rich Girl 0000 <gen> with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
          • Floating Text - Change (Last created floating text): Disable permanence
          • Floating Text - Change the lifespan of (Last created floating text) to 5.00 seconds
          • -------- ------------------------------------------------------------------------------------------------ --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Bianca_Got_Gift[INDEX] Equal to False
            • Then - Actions
              • Set Bianca_Got_Gift[INDEX] = True
              • Hero - Create Orb of Frost and give it to Bianca_HeartMeter[INDEX]
            • Else - Actions
        • Else - Actions
          • Hero - Drop (Item being manipulated) from (Triggering unit)
This trigger fires whenever Bianca gets gift. If it's not one of potential gifts for her, she just drops the item on ground.
If it is one of potential gifts, the trigger checks if it is the item given by the unit which lost the gift in the trigger above. If the item and unit are correct, Bianca will say something and if it is first gift from that unit, she will place Orb of Frost inside Heart Meter.


In the test map, you have control of both player 1 and player 2 to check it for both players.
 

Attachments

  • Bianca Gets Gift.w3x
    19.5 KB · Views: 41
Level 2
Joined
Mar 21, 2014
Messages
8
Your map is exactly how I want it. But when I try the triggers on my map which I modified slightly, it doesn't seem to work. (Also, I'm going to reset the "Bianca_Got_Gift" for every player; every 200 seconds of game.) I'm not sure what I'm doing wrong, our triggers are practically identical. Your map works and mine doesn't.


  • Map Setup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Talk1_Bianca[1] = Hello
      • Set Talk1_Bianca[2] = Hi
      • Set Talk1_Bianca[3] = Good Morning
      • Set GiveItem1_Bianca[1] = This doesn't amuse me.
      • Set GiveItem1_Bianca[2] = Do you really think I would be interested in that?
      • Set GiveItem1_Bianca[3] = My daddy can buy me something more valuable than that.
      • Set Bianca_HeartMeter[1] = Heart Level Meter 0166 <gen>
      • Set Bianca_HeartMeter[2] = Heart Level Meter 0168 <gen>
  • Bianca Gift Given
    • Events
      • Unit - A unit Loses an item
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Item-type of (Item being manipulated)) Equal to Broadsword
          • (Item-type of (Item being manipulated)) Equal to Strawberry Seed
    • Actions
      • Set Bianca_Gift = (Item being manipulated)
      • Set Bianca_Giver = (Triggering unit)
  • Bianca Gift Taken
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Rich Girl
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item being manipulated) Equal to Bianca_Gift
          • Or - Any (Conditions) are true
            • Conditions
              • (Item-type of (Item being manipulated)) Equal to Broadsword
              • (Item-type of (Item being manipulated)) Equal to Strawberry Seed
        • Then - Actions
          • Set INDEX = (Player number of (Owner of Bianca_Giver))
          • Item - Remove (Item being manipulated)
          • -------- ------------------------------------------------------------------------------------------------ --------
          • Floating Text - Create floating text that reads GiveItem1_Bianca[(Random integer number between 1 and 3)] above (Triggering unit) with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
          • Floating Text - Change (Last created floating text): Disable permanence
          • Floating Text - Change the lifespan of (Last created floating text) to 5.00 seconds
          • -------- ------------------------------------------------------------------------------------------------ --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Bianca_Got_Gift[INDEX] Equal to False
            • Then - Actions
              • Set Bianca_Got_Gift[INDEX] = True
              • Hero - Create Heart Piece Bianca and give it to Bianca_HeartMeter[INDEX]
            • Else - Actions
        • Else - Actions
          • Hero - Drop (Item being manipulated) from (Triggering unit)
 
Level 28
Joined
Sep 26, 2009
Messages
2,520
Don't you have any older versions of such trigger that could interfere with the new one?

You could try to use debug messages.
  • Game - Display to (All players) the text: Gift Taken
Place various messages in both triggers. E.g. The first message in Gift Given would be "Gave gift" and in Gift Taken would be "Took gift" (or something else, it doesn't matter as long as you understand which trigger fires).
And in both triggers, place another messages throughout the trigger so you can see where your trigger got. Then try it ingame.
(usually it's best to have those messages read '1', next reads '2', etc. so when the trigger runs correctly, messages should appear in numerical order 1-2-3-4 and so on.... if it doesn't, something may be wrong)
  • Game - Display to (All players) the text: 1
  • .... piece of code
  • Game - Display to (All players) the text: 2
  • ... piece of code
  • Game - Display to (All players) the text: 3
Another option could be that you post the map and we take look at it.
 
Level 2
Joined
Mar 21, 2014
Messages
8
I don't see any other trigger which associates with this GiveItem trigger. The only part of the code that doesn't work, is this part

  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • Bianca_Got_Gift[INDEX] Equal to False
    • Then - Actions
      • Set Bianca_Got_Gift[INDEX] = True
      • Hero - Create Heart Piece Bianca and give it to Bianca_HeartMeter[INDEX]
    • Else - Actions
 
Last edited:
Level 28
Joined
Sep 26, 2009
Messages
2,520
I checked the map and it does what it should do. Debug messages are correct as well.

Here's what I did - I picked up Broadsword and/or Strawberry Seed and gave it to Bianca. She got it, said something and heart piece appeared in my heart meter.
Giving her another gift did not give me heart piece as intended.

Apart from debug messages, what I did was add
  • (Unit-type of (Triggering unit)) Not equal to Rich Girl
into conditions of "Bianca Gift Given" trigger, so this trigger is not started when the game removes the gift you gave to Bianca.

However the whole thing worked even before adding this condition.
 
Level 2
Joined
Mar 21, 2014
Messages
8
That is so weird. When I opened my map and tested it(Today without changing anything), everything worked perfectly. I even got the Bianca_Got_Gift to reset as False for every day that passes by. Thank you so much. I have no idea why it didn't work before when I implemented the triggers. But it works now.
 
Status
Not open for further replies.
Top