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

Custom Experience System

Status
Not open for further replies.

Ardenian

A

Ardenian

Hello, I would like to create a custom Experience System for my ORPG, so that I am able to calculate how many creeps Heroes have to kill to reach the next Level and so on. Required Experience each Level I would set with the standard gameplay constants.

Why I aks, I have Problems with the experience split. I tried to create an experience System with Triggers, but I can´t find a solution to give experience to, for example, each Hero within 500 range of the killer of an Unit.
 

Ardenian

A

Ardenian

Spell Section have it :)
For the within 500 range, just use unit group

Uhm, which one ? There are several...

And to unitgroup, how does the Trigger looks like ? 'Add every unit around killing unit to unit group ' ?

EDIT: okay, found it, quite simple...
 
Last edited by a moderator:
Level 21
Joined
Mar 27, 2012
Messages
3,232
Note that unit groups leak, meaning that the memory they take is not normally given back when you stop using them. Over time leaks build up, causing severe lag and eventually crashing the map.

There's 2 ways to fix it.

In GUI you can make a custom script line before every "Pick units in group" line. The line would be "set bj_wantDestroyGroup = true"(without the " signs).
If you need the group for more than a moment, then you have to story it in a variable and destroy it later.
 

Ardenian

A

Ardenian

Note that unit groups leak, meaning that the memory they take is not normally given back when you stop using them. Over time leaks build up, causing severe lag and eventually crashing the map.

There's 2 ways to fix it.

In GUI you can make a custom script line before every "Pick units in group" line. The line would be "set bj_wantDestroyGroup = true"(without the " signs).
If you need the group for more than a moment, then you have to story it in a variable and destroy it later.

Well thats my current Trigger:
  • expgain
    • Ereignisse
      • Einheit - A unit Stirbt
    • Bedingungen
      • (Owner of (Triggering unit)) Gleich Spieler 12 (Braun)
    • Aktionen
      • Einheitengruppe - Add all units of (Units within 750.00 of (Position of (Dying unit))) to heroexpgroup
      • Einheitengruppe - Pick every unit in heroexpgroup and do (Held - Add (25 x (Level of (Triggering unit))) experience to (Picked unit), Verbergen level-up graphics)
      • Einheitengruppe - Remove all units from heroexpgroup
So i just add that custom line between 'Add Units' and 'Pick every Unit' ?

Like this ?
function Trig_expgain_Conditions takes nothing returns boolean
if ( not ( GetOwningPlayer(GetTriggerUnit()) == Player(11) ) ) then
return false
endif
return true
endfunction

function Trig_expgain_Func002002 takes nothing returns nothing
call AddHeroXPSwapped( ( 25 * GetUnitLevel(GetTriggerUnit()) ), GetEnumUnit(), false )
endfunction
set bj_wantDestroyGroup = true
function Trig_expgain_Actions takes nothing returns nothing
call GroupAddGroup( GetUnitsInRangeOfLocAll(750.00, GetUnitLoc(GetDyingUnit())), udg_heroexpgroup )
call ForGroupBJ( udg_heroexpgroup, function Trig_expgain_Func002002 )
call GroupClear( udg_heroexpgroup )
endfunction

//===========================================================================
function InitTrig_expgain takes nothing returns nothing
set gg_trg_expgain = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_expgain, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddCondition( gg_trg_expgain, Condition( function Trig_expgain_Conditions ) )
call TriggerAddAction( gg_trg_expgain, function Trig_expgain_Actions )
endfunction

EDIT: Map cannot be saved and exp-Trigger is deactivated ?
Btw, I used a variable, so no need for this custom script ?
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
You want something like this:
  • Experience
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Set TempUnit = (Triggering unit)
      • Set TempLocation = (Position of TempUnit)
      • Set TempGroup = (Units within 750.00 of TempLocation matching ((TempUnit belongs to an enemy of (Owner of (Matching unit))) Equal to True))
      • Unit Group - Pick every unit in TempGroup and do (Actions)
        • Loop - Actions
          • Hero - Add (25 x (Level of TempUnit)) experience to (Picked unit), Show level-up graphics
      • Custom script: call DestroyGroup(udg_TempGroup)
      • Custom script: call RemoveLocation(udg_TempLocation)
Leakless... as far as I know.
Should work fine.

btw you cannot call any statements outside of function bodies
 

Ardenian

A

Ardenian

You want something like this:
  • Experience
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Set TempUnit = (Triggering unit)
      • Set TempLocation = (Position of TempUnit)
      • Set TempGroup = (Units within 750.00 of TempLocation matching ((TempUnit belongs to an enemy of (Owner of (Matching unit))) Equal to True))
      • Unit Group - Pick every unit in TempGroup and do (Actions)
        • Loop - Actions
          • Hero - Add (25 x (Level of TempUnit)) experience to (Picked unit), Show level-up graphics
      • Custom script: call DestroyGroup(udg_TempGroup)
      • Custom script: call RemoveLocation(udg_TempLocation)
Leakless... as far as I know.
Should work fine.

Okay, thank you, added this Trigger now.

btw you cannot call any statements outside of function bodies
What do you mean ?
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
function Trig_expgain_Func002002 takes nothing returns nothing
call AddHeroXPSwapped( ( 25 * GetUnitLevel(GetTriggerUnit()) ), GetEnumUnit(), false )
endfunction
set bj_wantDestroyGroup = true
function Trig_expgain_Actions takes nothing returns nothing
call GroupAddGroup( GetUnitsInRangeOfLocAll(750.00, GetUnitLoc(GetDyingUnit())), udg_heroexpgroup )
call ForGroupBJ( udg_heroexpgroup, function Trig_expgain_Func002002 )
call GroupClear( udg_heroexpgroup )
endfunction

You cannot do a "call" or "set" outside a function.
You end the function and then set a variable.
That is impossible to execute. I suggest you to let other people handle jass or learn it to use any of it.
No offense, just a good advise.

also do a custom script at the end of the trigger with this text "set udg_TempUnit = null"
I think that units also leak in that way, but I am not sure.
 

Ardenian

A

Ardenian

You cannot do a "call" or "set" outside a function.
You end the function and then set a variable.
That is impossible to execute. I suggest you to let other people handle jass or learn it to use any of it.
No offense, just a good advise.

also do a custom script at the end of the trigger with this text "set udg_TempUnit = null"
I think that units also leak in that way, but I am not sure.

Alright! Guess there will be a coder in recruitment then...
 

Ardenian

A

Ardenian

Umm.. If you want to split it nicely, add (Exp Get/Number of Unit in Group) to Picked Unit.. This make sense

Uhm, but then I could have used the common blizzard system and with this customized trigger I would customized only range, as far as I understand...
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
Umm.. If you want to split it nicely, add (Exp Get/Number of Unit in Group) to Picked Unit.. This make sense

If you want to do it perfectly, you have a starting value, a level factor value, a level constant value and a increased level constant value and have it all saved in arrays.
With this you can register the experience given for each unit/unit-type as a formula. I can imagine that a level 1 orc warrior doesnt give the same exp as a level 1 superior nature elemental.
If you use levels for a different kind of thing, you need better systems.
 

Ardenian

A

Ardenian

If you want to do it perfectly, you have a starting value, a level factor value, a level constant value and a increased level constant value and have it all saved in arrays.
With this you can register the experience given for each unit/unit-type as a formula. I can imagine that a level 1 orc warrior doesnt give the same exp as a level 1 superior nature elemental.
If you use levels for a different kind of thing, you need better systems.

Yes, I understand and totally agree. Just sad I have no clue about array and hash tables and so on...
 
Status
Not open for further replies.
Top