• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Make heroes buy items?

Status
Not open for further replies.
Level 5
Joined
Sep 14, 2004
Messages
66
How can I make computer heroes buy random items from a shop when they comes within range with the shop?

I have this code so far:
Events:
Unit - A unit comes within 300.00 of Item Shop 2 0087 <gen>

Conditions:
Or - Any (Conditions) are true
Conditions
(Owner of (Triggering unit)) Equal to Player 4 (Purple)
(Owner of (Triggering unit)) Equal to Player 5 (Yellow)
(Owner of (Triggering unit)) Equal to Player 6 (Orange)
(Owner of (Triggering unit)) Equal to Player 7 (Green)

Actions:
????????

Maybe this isn't possible without special coding...
 
Level 6
Joined
Jun 16, 2004
Messages
237
I believe these have something to do with it, but not sure. They may be only for unit production buildings, not shops.

Code:
native IssueNeutralImmediateOrder       takes player forWhichPlayer, unit neutralStructure, string unitToBuild returns boolean
native IssueNeutralImmediateOrderById   takes player forWhichPlayer,unit neutralStructure, integer unitId returns boolean
native IssueNeutralPointOrder           takes player forWhichPlayer,unit neutralStructure, string unitToBuild, real x, real y returns boolean
native IssueNeutralPointOrderById       takes player forWhichPlayer,unit neutralStructure, integer unitId, real x, real y returns boolean
native IssueNeutralTargetOrder          takes player forWhichPlayer,unit neutralStructure, string unitToBuild, widget target returns boolean
native IssueNeutralTargetOrderById      takes player forWhichPlayer,unit neutralStructure, integer unitId, widget target returns boolean

You need to use JASS/Custom Script to access them.
 
Level 5
Joined
Sep 14, 2004
Messages
66
Well I've never used custom scripts in map making....Is that a difficult procedure? I really want my little cpu heroes to buy items :), it would be so cool..I've already (through triggers) programmed them to back if they're attacked by towers and to return to fountain of life when their HP is low. (I'm making a 2-player AOS kind of map where you're two teams fighting each other with periodically sent units).

Adding heroes to buy items would really be the ultimate.
 
Level 5
Joined
Jun 9, 2004
Messages
181
Well u can't force a hero to buy items, but u can make them to appear as they were buying items:

Make the hero to go to the shop
wait for condition -> hero is in 250 range of the shop
create item for hero
order hero to attack move to the battle.

You can even make them to pay for the items (set player's gold = current gold - item price), but u cannot make them to use up 1 item from the shop, so if the stock max of the item is 1, and the hero buys it, it will remain there. (well maybe u can try: neutral building - remove item of type, and then neutral building - add item of type. Perhaps it resets the amount of items left, but don't expect anything - i never tried it.)

In my AOS (divine battle) i use these triggers (and i use the foutain thingy too, but AI heroes got instantly healed at the fountain to make them appear more frequently on the Bfield.)
 
Level 5
Joined
Sep 14, 2004
Messages
66
Heh heh, well that sounds cool. The item remove thing won't be neccessary on my map because the items are limitless, but the idea sounds to work, you just have to check if they have enough money :) .

It would be a little "cheaty" otherwise :p

Thanks man you solved my prob, I will upload my map as soon as I get this to work!
 
Status
Not open for further replies.
Top