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

Trigger need help like Pilllage or Transmute etc

Status
Not open for further replies.
Level 2
Joined
Apr 22, 2013
Messages
8
Hello guys

i need help for creating trigger. When player 1 or some spesific players atack to enemy or buildings or creeps trigger must steal each atack %100 gold and lumber cost. Example atacking a human farm. Start stole gold and coin at the last total 80 gold and 20 wood.

a unit atack
atacker unit player 1 (units + hero)
give player 1 to gold lumber cost %100

Thanks
Sorry for my bad english
 
Level 17
Joined
Mar 21, 2011
Messages
1,597
So.. what you are trying to say:

You get x% amount of gold and lumber (based off the buildings cost) whenever you hit a building, where x is the percentage damage dealt to the building?
So, if a Humans Farm building cost is 80 gold and 20 lumber, and your unit deals 25% of the buildings maximum hp per hit, you get 20 gold and 5 lumber per hit?
 
Level 2
Joined
Apr 22, 2013
Messages
8
Example farm have 500 healt and one unit kill 50 damage with 10 hit
10 hit x 50 dmg = 500 healt

Each hit like this
First Hit 50 Damage to Building 8 gold 2 lumber
Second Hit 50 Damage to Building 8 gold 2 lumber
Third Hit 50 Damage to Building 8 gold 2 lumber
...
Ten Hit 50 Damage to Building 8 gold 2 lumber


total 10 hit for 500 healt 80 gold 20 lumber
 
Level 2
Joined
Apr 22, 2013
Messages
8
nice question

but i dont need too deep variation. it can be continue stealin gold farm. its stealin coin from total coins pool.

imagine
250 dmg 40 gold 10 wood
player repair building to full healt 500
now 250 dmg x2 hit = 500 hp 80 gold and 20 wood

and you totally stole 120 gold 30 wood
 
Level 2
Joined
Apr 22, 2013
Messages
8
Pillage doest work with some spells. Example Arrows. Searing arrow, cold arrow, black arrow etc. Pillage doesnt work with them.
 
Level 17
Joined
Mar 21, 2011
Messages
1,597
Well, get a unit indexer into your map, create 2 integer arrays for gold and wood

  • set id = Custom value of unit
  • set gold[id] = 80
  • set lumber[id] = 20
You either create your own simple OnDamage trigger or use a damage engine.

  • Unit - Unit takes damage
  • ----------------------
  • set id = Custom value of damaged unit
  • set bounty = (damage dealt / current hp of damaged unit) * gold[id]
  • same for wood...
  • set gold[id] = gold[id] - bounty
  • Same for wood...
  • Payer - Increase player property (gold) by bounty
  • Same for wood...
Something like that will do the work
 
Level 2
Joined
Apr 22, 2013
Messages
8
thanks for your answer

can we change this values static to dynamic? Farm is just simple example. is there a too much unit have.
i dont know about triggers but can we imagine like that ? im not sure its work but just thinking together.


Variables

Atacker unit = player 1 (hero,tower,unit etc)
Atacked unit = Whatever

set gold[id] = atacked unit gold cost
set lumber[id] = atacked unit lumber cost

Triggers

Unit begin atack atacker to atacked
if all condition true

set bounty gold = (damage dealt / current hp of atacked unit) * gold[id]
set bounty wood = (damage dealt / current hp of atacked unit) * lumber[id]

Payer 1 add gold = bounty gold
Payer 1 add lumber = bounty lumber
 
Level 2
Joined
Apr 22, 2013
Messages
8
i dont have enough knowlage about world editor or triggers. im sorry but dont do this things alone. i need help for complete this ones.
 
Level 17
Joined
Mar 21, 2011
Messages
1,597
UnitType[0] = Farm
Gold[0] = 80
Wood[0] = 20

UnitType[1] = Castle
GoldBounty[1] = 200
WoodBounty[1] = 50

UnitType[2] = Tower
GoldBounty[2] = 100
WoodBounty[2] = 10



Unit enters playable map area

--->

for each integer j from 0 to YOUR_MAXIMUM_INDEX (in this case 2)
if Unit type of triggering unit equal to UnitType[j] then
set id = custom value of triggering unit
set gold[id] = GoldBounty[j]
set wood[id] = WoodBounty[j]
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
for each integer j from 0 to YOUR_MAXIMUM_INDEX (in this case 2)
A hash table could be used to perform this step with O(1) complexity rather than O(n). This would be more scaleable. The idea being one can map values to the unit type using the hash table.

Additionally one has to be careful using too many unit enters playable map area events as it can cause path finding and other systems to break. Try to use one such event shared between all systems.
 
Status
Not open for further replies.
Top