• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

XP per hit for 1 unit only

Status
Not open for further replies.
Level 2
Joined
Jul 25, 2010
Messages
21
Hi,

Im making a survival map where i have a worker (Which is a hero) that gains gold per hit on a Gold mine that is enemy and player 11 (Dark green). gain is based on strenght.
But i also want xp per hit so he can lvl without fighting cuz mines are too far away from battle and getting xp would make the map fail (need constant gold income)... so what trigger or jass i need to do that his hit make him gain xp ? ive tried to make it without JASS. Since i didnt find any way to do it i figured it was doable with JASS trigger maybe. Problem is... JASS is chinese to me ....

Thanks in advande :grin:

Note gold gained isnt based on a spell but simple trigger that add to the attaking unit his str to his current gold. Id like to know how to do the same for XP

EDIT: so i made a trigger (GUI) that looked like that
triggerexemple.gif


Gave me this as JASS

-------------------------------------------
function Trig_XP_per_hit_Achak_Copy_Copy_Copy_Copy_Conditions takes nothing returns boolean
if ( not ( GetUnitTypeId(GetAttacker()) == 'H002' ) ) then
return false
endif
if ( not ( GetOwningPlayer(GetAttackedUnitBJ()) == Player(10) ) ) then
return false
endif
return true
endfunction

function Trig_XP_per_hit_Achak_Copy_Copy_Copy_Copy_Func001001001 takes nothing returns boolean
return ( GetUnitTypeId(GetAttacker()) == 'H002' )
endfunction

function Trig_XP_per_hit_Achak_Copy_Copy_Copy_Copy_Func001002 takes nothing returns nothing
call AdjustPlayerStateBJ( 2, GetEnumPlayer(), PLAYER_STATE_RESOURCE_GOLD )
endfunction

function Trig_XP_per_hit_Achak_Copy_Copy_Copy_Copy_Actions takes nothing returns nothing
call ForForce( GetPlayersMatching(Condition(function Trig_XP_per_hit_Achak_Copy_Copy_Copy_Copy_Func001001001)), function Trig_XP_per_hit_Achak_Copy_Copy_Copy_Copy_Func001002 )
endfunction

//===========================================================================
function InitTrig_XP_per_hit_Achak_Copy_Copy_Copy_Copy takes nothing returns nothing
set gg_trg_XP_per_hit_Achak_Copy_Copy_Copy_Copy = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_XP_per_hit_Achak_Copy_Copy_Copy_Copy, EVENT_PLAYER_UNIT_ATTACKED )
call TriggerAddCondition( gg_trg_XP_per_hit_Achak_Copy_Copy_Copy_Copy, Condition( function Trig_XP_per_hit_Achak_Copy_Copy_Copy_Copy_Conditions ) )
call TriggerAddAction( gg_trg_XP_per_hit_Achak_Copy_Copy_Copy_Copy, function Trig_XP_per_hit_Achak_Copy_Copy_Copy_Copy_Actions )
endfunction
-----------------------------------------------------------

so i wanna know how i can change player_state_ressource_gold, 2 to XP
 
Last edited:
Level 2
Joined
Jul 25, 2010
Messages
21
Well thats not actually what i wanna do. i dont want gold per hit, i want XP (The gold per hit trigger is already dealt with and was only more info about the unit :) ). for the gold its easy... to XP per hit isnt
 
Last edited:
Level 7
Joined
Jun 8, 2010
Messages
283
Very easy actually.

  • exp upon hit
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • (Unit-type of (Attacked unit)) Equal to Gold Mine
          • (Unit-type of (Attacking unit)) Equal to Pick-Axe Gold Miner
    • Actions
      • Hero - Add 1 experience to (Attacking unit), Hide level-up graphics
 
Level 16
Joined
May 1, 2008
Messages
1,605
Moin moin =)

No! very bad idea. You will need a "damage detect system".

1) In your examples, the attacker can attack an ally unit and gain exp, maybe this isn't a good idea.

2) "Unit - A unit Is attacked" can be buggy here, because if you click attack and stop it, this was an attack and you get exp. So you can fast click Attack + stop and you get mass exp without attacking.

Greetings
~ The Bomb King > Dr. Boom
 
Level 17
Joined
Jun 17, 2010
Messages
2,275
Moin moin =)

No! very bad idea. You will need a "damage detect system".

1) In your examples, the attacker can attack an ally unit and gain exp, maybe this isn't a good idea.

2) "Unit - A unit Is attacked" can be buggy here, because if you click attack and stop it, this was an attack and you get exp. So you can fast click Attack + stop and you get mass exp without attacking.

Greetings
~ The Bomb King > Dr. Boom

Yes yes, i was just going to state this, Damage detect > unit is attacked. Because an attack is the command to attack, so if u stop mid swing and never make contact and hit, or ur arrow never reaches the target cus he was already killed u will still get the exp. People abuse things like this.
Try this:
Event - A unit is attacked
Action - Add event to (trigger) Triggering unit takes damage
============================================
In the other trigger that gives the exp
Event-
Condition-
Action- Give damaging unit exp
 
Level 2
Joined
Jul 25, 2010
Messages
21
Ok imma try that. and i have another problem. i made a region where only Achak and Achak's miner can cross ( event(unit enter region) Condition(not equal to Achak OR achak's miner) action(Teleport unit to middle of map) ). my cond is achack or achak's miner can go if 1 or the other.. but Achak is getting teleported now whats wrong?
 
Ok imma try that. and i have another problem. i made a region where only Achak and Achak's miner can cross ( event(unit enter region) Condition(not equal to Achak OR achak's miner) action(Teleport unit to middle of map) ). my cond is achack or achak's miner can go if 1 or the other.. but Achak is getting teleported now whats wrong?

You need "AND", not "OR". Here is how it should look like:
  • Trigger
  • Events
    • Unit - A unit enters GoldMine <gen>
  • Conditions
    • And - All (Conditions) are true
      • Conditions
        • (Unit-type of (Triggering unit)) Not Equal to Achak
        • (Unit-type of (Triggering unit)) Not Equal to Achak's Miner
  • Actions
    • Custom script: call SetUnitX (GetTriggerUnit(), 0)
    • Custom script: call SetUnitY (GetTriggerUnit(), 0)
The custom scripts will move your target to the center of the map, without having its orders interrupted and without having the need of using point variables.

Additionally, in case you want them not to retain their orders:
  • Trigger
  • Events
    • Unit - A unit enters GoldMine <gen>
  • Conditions
    • And - All (Conditions) are true
      • Conditions
        • (Unit-type of (Triggering unit)) Not Equal to Achak
        • (Unit-type of (Triggering unit)) Not Equal to Achak's Miner
  • Actions
    • Set Point1 = (Center of (Playable Map Area))
    • Unit - Move (Triggering unit) to Point1
    • Custom script: call RemoveLocation (udg_Point1)
 
Level 2
Joined
Jul 25, 2010
Messages
21
Ok so AND multiple condition works. i was thinking AND condition would require the two condition not one or the other

:piru: Thanks a lot

EDIT: InfinateAnswers : i cant find damaged unit, is this some custom event? cause all i can find is Add gold to ''Damage Source''
 
Level 2
Joined
Jul 25, 2010
Messages
21
ok Warmanta, i understand this
74314887.gif

but i dont get
39667654.gif

issued order with no target... theres actually a target no?
cuz if someone abuse it'll be spamming A (Attack hotkey) left click gold mine be4 the hit actually land aint it?
 
Level 6
Joined
Feb 19, 2010
Messages
182
You can't spam the attack command since it's ability to issue commands is limited to the attack speed of a unit, and can not trigger as fast as the stop command which leads to abuse and only one command can do it so fast and that's the stop command otherwise the other commands you won't have to worry about so much since its usually a lot slower then the stop.
 
Last edited:
Status
Not open for further replies.
Top