Peasant stealing gold

Dodighead147

New Member
Reaction score
0
Hello... A while ago I posted a thread asking how to make it so periodically a peasant steals gold from you. Thanks to the person who helped me, it works now. Here's the code.
Code:
Initialization
    Events
        Map initialization
    Conditions
    Actions
        Set Unit_Variable = (Random unit from (Units owned by Player 1 (Red) of type Jew))

Code:
Steal
    Events
        Time - Every 150.00 seconds of game time
    Conditions
    Actions
        Unit - Set the custom value of Unit_Variable to (((Custom value of Unit_Variable) + (Player 1 (Red) Current gold)) / 5)
        Player - Set Player 1 (Red) Current gold to (((Custom value of Unit_Variable) - (Player 1 (Red) Current gold)) / 5)

Code:
Killed
    Events
        Unit - A unit Dies
    Conditions
        (Dying unit) Equal to Unit_Variable
    Actions
        Player - Add (Custom value of Unit_Variable) to Player 1 (Red) Current gold
        Trigger - Turn off Steal <gen>


The thing is, I want to make it so when the unit dies, it drops the gold as an item, such as a gold coin. Can anyone help me? (this is a very racist game, just warning you.)
 

Caedin88

New Member
Reaction score
1
Instead of saying

Event - a Unit Dies

Actions - Give player Custom Value of DyingUnit as gold

have it do this

Trigger 1

Event - a Unit Dies

Actions - Create item (model =gold coin // btw item has no ability and does nothing ) @ position of dying unit
Store custom value in a global Integer Array[ index = number of died peasents ]
Add item to an Item Array[index = number of died peasents]

Trigger 2
Event - A unit aquires an item
Condition - Item-type = your item
Actions -
for loop Integer A 1 to NumberOfDeadPeasents
If then else -
If - item being acquired is = to ItemArray[IntegerA]
then - Add IntegerArray[IntegerA] to owner of acquiring Item gold.
else - nothing
 

FireBladesX

Eating my wings!
Reaction score
123
You can set the custom value of items, so basically do what Caedin88 says, but use custom values. If they work. I have had some problems with them in the past, but W/E.

You can throw in some floating text too, such as (|cffffcc00+ ) + (Integer(Custom value of Item Being Manipulated))|r, then set the fades and velocity and such. |cffffcc00xxxx|r makes the text gold.


Edit:
Argh, I'm slow... so I edited my message to not be so repetitive.
Apparently, I said something useful. I'll re-edit my post.
 

Caedin88

New Member
Reaction score
1
You can set the custom value of items. So when a unit aquires the Gold Coin tome, add the custom value of the item to the owner of manipulating unit's current gold.

You can throw in some floating text too, such as (|cffffcc00+ ) + (Integer(Custom value of Item Being Manipulated))|r, then set the fades and velocity and such. |cffffcc00xxxx|r makes the text gold.

Ah I didn't know you could put a custom value on items... This solution is tons better than mine.
 

Dodighead147

New Member
Reaction score
0
Im sorry... im sure these work right? but my brain hurts.. Im very new to this stuff.. Can you run me by this as if i dont know the biggest noob in the world? im sorry I dont get it.
 

FireBladesX

Eating my wings!
Reaction score
123
There's a function:
Item - set custom value of item
Using this, you can set an item to a number, and in this case, you set it to the amount of gold that you want your item to give.

Then, upon aquiring an item, you can do
Floating Text - Create Floating Text above Unit, with the unit being the Manipulating Unit.

For teh text, it's called concendrate strings, or something like that.

For one, you do "+ |cffffcc00". For the other, you do "Conversion - convert Integer to String, custom value of Item Being Manipulated". Then, for the last one, close it with |r. Not really necessary.

Then, you need to do:
Floating Text: Disable Permenance
Floating Text: Set Velocity
Floating Text: Set Lifespan
Floating Text: Change Fade Age
Floating Text: Hide for All Players
Floating Text: Show for Owner of Triggering Unit.

Tell me if I missed something.
By the way, the |cffffcc00 colors the text gold. If you google Hex Codes, you can get a list of colors. The formula is |cffXXXXXXInsert Text Here|r, with |r to end the colored text.
 

Dodighead147

New Member
Reaction score
0
So.. Uhh... This makes it so the peasant killed gives the amount it stole (1/5 of your total money) by amount in gold coin?
 

Caedin88

New Member
Reaction score
1
Im sorry but, wheres Actions?

When you make a trigger, theres 3 parts to it...

Event - Your trigger runs (does stuff) when these things happen

Conditions - Checks, makes sure you are doing the actions to right units and so forth.

Actions - These are the little bits of code that do all the work in a trigger, to create a new action right click on the action button and press Create a new Action. Then manuever to what action you want. The actions are organized neatly and orderly through groupings... such as

Units, Destructibles, Special Effects, Player and so on...

Each grouping contains actions that pertain to that part of the game.

Example say you want to Increase player 1's gold by 50 at the start of the game. You would do this.

Make a new trigger it will look like this.

Code:
Untitled Trigger 001
    Events
    Conditions
    Actions

Right click on Events and press 'New Event'

A box will come up allowing you to choose what event you want to use. Select Map Initialization, this Event basically means when the game starts run this trigger.

You will then have
Code:
Untitled Trigger 001
    Events
        Map initialization
    Conditions
    Actions

You can leave Conditions blank for now because it doesn't pertain to this trigger we are making.

So Right click on Actions and select 'New Action'.

Another box will come up, in the top left choose Player, because adding 50 gold is somthing that affects a player, so it is under Players.

It will have 'Set Property' initially selected, you don't want that because it will set that players gold to the value you enter, not add to it. So scroll down and find 'Add Property'. Change the initial value of 1000 to 50, and Player 1 and Current gold are already selected so press okay to finish this action.

You will then have
Code:
Untitled Trigger 001
    Events
        Map initialization
    Conditions
    Actions
        Player - Add 50 to Player 1 (Red) Current gold

And thats it!

Now for your specific case we will need 2 triggers to get done what we want.

The first one will be easy. It will cause dying units of type 'Jew' to drop an item, and transfer thier custom value ( How much gold they are holding ) to the item.

Code:
Trigger 1
    Events
        Unit - A unit Dies
    Conditions
        (Unit-type of (Triggering unit)) Equal to 'Jew'
    Actions
        Item - Create (ITEM) at (Position of (Triggering unit))
        Item - Set the custom value of (Last created item) to (Custom value of (Triggering unit))

Where as ITEM is equal to the item you make yourself in the object editor.

The second one will be in response to the player picking up the item. The trigger will say, when some one gets an item that has gold on it ( Custom Value ) add that amount of gold to the owner of the unit who got the items current gold.

Basically who ever picks up your gold coins will get the gold that was on the item.

Code:
Trigger 2
    Events
        Unit - A unit Acquires an item
    Conditions
        (Custom value of (Item being manipulated)) Greater than 0
    Actions
        Player - Add (Custom value of (Item being manipulated)) to (Owner of (Hero manipulating item)) Current gold



        Floating Text - Create floating text that reads ((String((Custom value of (Item being manipulated)))) + !) at (Position of (Hero manipulating item)) with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 0.00%), and 0.00% transparency
        Floating Text - Change (Last created floating text): Disable permanence
        Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
        Floating Text - Change the fading age of (Last created floating text) to 4.00 seconds
        Floating Text - Change the lifespan of (Last created floating text) to 5.00 seconds

Now everything about Floating Text is optional, the trigger will still give the right amount of gold to the right player without those Actions. But Floating Text lets our hero who gets the item know how much gold he got.

The first Floating Text Action creates a text that is equal to (Amount of Gold)+!, it then says this Text should be Yellow colored (RGB).

The next Floating Text Action says we want this text to go away over time, and not be there the entire game.

The Third Floating Text Action says we want the text to rise slowly and the fourth says it should fade, together they create a rising fading action for our text.

The final Floating Text Action says 5 seconds after this text is created we want to remove it from the map, if you dont do this you will have lots of unwanted text when you play.

And thats it!
 

Dodighead147

New Member
Reaction score
0
Wow!!! I could not have it explained any better than that!!! REP +!!!! By the way, you should really make a TuT on Triggers like that! That was really really throrough and such good step by step! You rock!
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top