+ With this system, any unit can have their own exp bar and their own levels
On leveling up, you can add your unit any ability you want.
+ Trigger:
CES Initialization
Events
Map initialization
Conditions Actions
Hashtable - Create a hashtable Set CES_Hashtable = (Last created hashtable) -------- EXP String show color -------- Set CES_StringArray[1] = |cff00ff00 -------- EXP String ( EXP_StringArray[2] + EXP + EXP_StringArray[3]) -------- Set CES_StringArray[2] = + Set CES_StringArray[3] = EXP! -------- EXP Bar Color -------- Set CES_StringArray[4] = |cffffcc00 -------- EXP Bar Level Color -------- Set CES_StringArray[5] = |cffccffcc -------- EXP String Size -------- Set CES_Real[1] = 10.00 -------- EXP Show Time -------- Set CES_Real[2] = 2.00 -------- EXP Velocity Disatance -------- Set CES_Real[3] = 50.00 -------- EXP Bar Size (I think it need <= 8) -------- Set CES_Real[4] = 8.00 -------- EXP Sharing Range -------- Set CES_EXPRange = 1000.00 -------- ------- -------- -------- CES_ShareEXP = True => Share EXP, CES_ShareEXP = False => Not share EXP -------- Set CES_ShareEXPBoolean = True -------- Special Effect when unit up level. -------- Set CES_SFX = Abilities\Spells\Demon\DarkPortal\DarkPortalTarget.mdl -------- ------- -------- -------- Level Table -------- -------- Lvl 1 => Lvl 2 Requires 200 EXP -------- Set CES_LevelTable[1] = 200 -------- --------- -------- -------- Lvl 2 => Lvl 3 Requires 500 EXP -------- Set CES_LevelTable[2] = 500 -------- --------- -------- -------- Lvl 3 => Lvl 4 Requires 1000 EXP -------- Set CES_LevelTable[3] = 1000 -------- --------- -------- -------- Lvl 4 => Lvl 5 Requires 2000 EXP -------- Set CES_LevelTable[4] = 2000 -------- --------- -------- -------- Lvl 5 => Lvl 6 Requires 5000 EXP -------- Set CES_LevelTable[5] = 5000 -------- --------- -------- -------- Unit EXP -------- -------- Peasant - 50 EXP -------- Set CES_UnitType = Peasant Set CES_EXP = 50 Trigger - Run CES Save EXP <gen> (checking conditions) -------- Footman - 150 EXP -------- Set CES_UnitType = Footman Set CES_EXP = 150 Trigger - Run CES Save EXP <gen> (checking conditions)
CES Save EXP
Events Conditions Actions
Custom script: set udg_CES_UnitID = udg_CES_UnitType Hashtable - Save CES_EXP as CES_UnitID of 0 in CES_Hashtable
CES Add Unit
Events Conditions Actions
Set CES_UnitID = (Custom value of CES_Unit) Unit Group - Add CES_Unit to CES_Group Hashtable - Save 0 as CES_UnitID of 1 in CES_Hashtable Hashtable - Save 1 as CES_UnitID of 2 in CES_Hashtable Hashtable - Save 100 as CES_UnitID of 3 in CES_Hashtable Set CES_Player = (Owner of CES_Unit) Custom script: if udg_CES_Player == GetLocalPlayer() then Floating Text - Create floating text that reads above CES_Unit with Z offset 0.00, using font size CES_Real[4], color (100.00%, 100.00%, 100.00%), and 0.00% transparency Hashtable - Save Handle Of(Last created floating text) as CES_UnitID of 4 in CES_Hashtable Custom script: endif
CES Remove Unit
Events Conditions Actions
Set CES_UnitID = (Custom value of CES_Unit) Floating Text - Destroy (Load CES_UnitID of 4 in CES_HashtableIf the label is not found, this function returns NULL.) Hashtable - Clear all child hashtables of child CES_UnitID in CES_Hashtable Unit Group - Remove CES_Unit from CES_Group
CES Die Check
Events
Unit - A unit Dies
Conditions Actions
Set CES_Unit2 = (Triggering unit) Set CES_Unit = (Killing unit) Set CES_UnitID = (Custom value of CES_Unit) Custom script: set udg_CES_UnitID2 = GetUnitTypeId(udg_CES_Unit2) Set CES_EXP = (Load CES_UnitID2 of 0 from CES_Hashtable) If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
CES_ShareEXPBoolean Equal to False
Then - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(CES_Unit is alive) Equal to True
Then - Actions
Set CES_Event = 0.00 Set CES_UnitEXP = (Load CES_UnitID of 1 from CES_Hashtable) Set CES_Level = (Load CES_UnitID of 2 from CES_Hashtable) Set CES_EXPRate = (Load CES_UnitID of 3 from CES_Hashtable) Set CES_RealEXP = ((CES_EXP x CES_EXPRate) / 100) Set CES_UnitEXP = (CES_UnitEXP + CES_RealEXP) Set CES_Player = (Owner of CES_Unit) If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
CES_UnitEXP Greater than or equal to CES_LevelTable[CES_Level]
Then - Actions
Special Effect - Create a special effect attached to the origin of CES_Unit using CES_SFX Special Effect - Destroy (Last created special effect) Set CES_UnitEXP = (CES_UnitEXP - CES_LevelTable[CES_Level]) Set CES_Level = (CES_Level + 1) Set CES_Event = 2.00 Hashtable - Save CES_Level as CES_UnitID of 2 in CES_Hashtable
Else - Actions
Hashtable - Save CES_UnitEXP as CES_UnitID of 1 in CES_Hashtable Set CES_Event = 1.00 Custom script: if udg_CES_Player == GetLocalPlayer() then Floating Text - Create floating text that reads (CES_StringArray[1] + (CES_StringArray[2] + ((String(CES_RealEXP)) + CES_StringArray[3]))) above CES_Unit with Z offset 0.00, using font size CES_Real[1], color (100.00%, 100.00%, 100.00%), and 0.00% transparency Floating Text - Set the velocity of (Last created floating text) to CES_Real[3] towards 90.00 degrees Floating Text - Change (Last created floating text): Disable permanence Floating Text - Change the lifespan of (Last created floating text) to CES_Real[2] seconds Floating Text - Change the fading age of (Last created floating text) to CES_Real[2] seconds Custom script: endif
Else - Actions
Else - Actions
Set CES_Point = (Position of CES_Unit2) Set CES_TempGroup = (Units within CES_EXPRange of CES_Point matching ((((Matching unit) is in CES_Group) Equal to True) and ((((Matching unit) belongs to an ally of (Owner of CES_Unit)) Equal to True) and (((Matching unit) is alive) Equal to True)))) Set CES_EXP = (CES_EXP / (Number of units in CES_TempGroup)) Unit Group - Pick every unit in CES_TempGroup and do (Actions)
Loop - Actions
Set CES_Event = 0.00 Set CES_Unit = (Picked unit) Set CES_Player = (Owner of CES_Unit) Set CES_UnitID = (Custom value of CES_Unit) Set CES_UnitEXP = (Load CES_UnitID of 1 from CES_Hashtable) Set CES_Level = (Load CES_UnitID of 2 from CES_Hashtable) Set CES_EXPRate = (Load CES_UnitID of 3 from CES_Hashtable) Set CES_RealEXP = ((CES_EXP x CES_EXPRate) / 100) Set CES_UnitEXP = (CES_UnitEXP + CES_RealEXP) If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
CES_UnitEXP Greater than or equal to CES_LevelTable[CES_Level]
Then - Actions
Special Effect - Create a special effect attached to the origin of CES_Unit using CES_SFX Special Effect - Destroy (Last created special effect) Set CES_UnitEXP = (CES_UnitEXP - CES_LevelTable[CES_Level]) Set CES_Level = (CES_Level + 1) Set CES_Event = 2.00 Hashtable - Save CES_Level as CES_UnitID of 2 in CES_Hashtable
Else - Actions
Hashtable - Save CES_UnitEXP as CES_UnitID of 1 in CES_Hashtable Set CES_Event = 1.00 Custom script: if udg_CES_Player == GetLocalPlayer() then Floating Text - Create floating text that reads (CES_StringArray[1] + (CES_StringArray[2] + ((String(CES_RealEXP)) + CES_StringArray[3]))) above CES_Unit with Z offset 0.00, using font size CES_Real[1], color (100.00%, 100.00%, 100.00%), and 0.00% transparency Floating Text - Set the velocity of (Last created floating text) to CES_Real[3] towards 90.00 degrees Floating Text - Change (Last created floating text): Disable permanence Floating Text - Change the lifespan of (Last created floating text) to CES_Real[2] seconds Floating Text - Change the fading age of (Last created floating text) to CES_Real[2] seconds Custom script: endif
Unit Group - Pick every unit in CES_Group and do (Actions)
Loop - Actions
Set CES_Unit = (Picked unit) Set CES_UnitID = (Custom value of CES_Unit) Set CES_Player = (Owner of CES_Unit) If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(CES_Unit is alive) Equal to True
Then - Actions
Set CES_UnitEXP = (Load CES_UnitID of 1 from CES_Hashtable) Set CES_Level = (Load CES_UnitID of 2 from CES_Hashtable) Set CES_UnitID2 = ((CES_UnitEXP x 100) / CES_LevelTable[CES_Level]) Set CES_String = (CES_StringArray[5] + ((String(CES_Level)) + ()|r > + CES_StringArray[4]))) For each (Integer CES_Int) from 1 to CES_UnitID2, do (Actions)
Loop - Actions
Set CES_String = (CES_String + |)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(CES_UnitID2 mod 2) Equal to 1
Then - Actions
Set CES_String = (CES_String + ||r)
Else - Actions
Set CES_String = (CES_String + |r)
For each (Integer CES_Int) from 1 to (100 - CES_UnitID2), do (Actions)
Loop - Actions
Set CES_String = (CES_String + |)
Set CES_String = (CES_String + <) Custom script: if udg_CES_Player == GetLocalPlayer() then Floating Text - Change the position of (Load CES_UnitID of 4 in CES_HashtableIf the label is not found, this function returns NULL.) to CES_Unit with Z offset 0.00 Floating Text - Change text of (Load CES_UnitID of 4 in CES_HashtableIf the label is not found, this function returns NULL.) to CES_String using font size CES_Real[4] Custom script: endif Set CES_String = <Empty String>
Else - Actions
Custom script: if udg_CES_Player == GetLocalPlayer() then Set CES_String = <Empty String> Floating Text - Change text of (Load CES_UnitID of 4 in CES_HashtableIf the label is not found, this function returns NULL.) to CES_String using font size CES_Real[4] Floating Text - Change the position of (Load CES_UnitID of 4 in CES_HashtableIf the label is not found, this function returns NULL.) to CES_Unit with Z offset 0.00 Custom script: endif
Set CES_SFX = Abilities\Spells\Demon\DarkPortal\DarkPortalTarget.mdl
: Special Effect when unit up level.
-
Set CES_LevelTable[1] = 200 Set CES_LevelTable[2] = 500
: Level Table - Requires EXP to up level
-
Set CES_UnitType = Peasant Set CES_EXP = 50 Trigger - Run CES Save EXP <gen> (checking conditions)
: set EXP of an Unit type when it die.
-
Set CES_Unit = Knight 0001 <gen> Trigger - Run CES Add Unit <gen> (checking conditions)
: Add unit to system.
-
Set CES_Unit = Knight 0001 <gen> Trigger - Run CES Remove Unit <gen> (checking conditions)
: Remove unit from system.
-
CES Massage UP LVL
Events
Game - CES_Event becomes Equal to 2.00
Conditions Actions
Game - Display to (All players) the text: ((Name of CES_Unit) + ( LEVEL UP!!! LEVEL : + (String(CES_Level)))) If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(CES_Unit is A Hero) Equal to True
Then - Actions
Hero - Set CES_Unit Hero-level to CES_Level, Show level-up graphics
Else - Actions
: Game - CES_Event becomes Equal to 2.00 like a UP LEVEL EVENT.
-
CES Massage INC EXP
Events
Game - CES_Event becomes Equal to 1.00
Conditions Actions
Game - Display to (All players) the text: ((Name of CES_Unit) + ('s EXP : + (String(CES_UnitEXP))))
: Game - CES_Event becomes Equal to 1.00 like a INCREASES EXP EVENT.
NEW CHANGELOG
- Floating Text now is more configurable.
- Remove some useless code.
[/hidden]
OLD CHANGELOG
- EXP Bar is no longer show when unit die.
- Floating Text is only shown for owner of unit.
- Unit won't recieve EXP when die.
- Add CES_Event.
- Add some new examples.
- Change somethings in code.
- Change looping time from 0.02 to 0.03
- Just owner of unit can see unit's EXP Bar
- Add EXP Bar Color
+ Credits: Bribe's GUI Unit Indexer
+ Email: Donald_kute@yahoo.com
Rating - 5.00 (4 votes)
(Hover and click)
Moderator Comments
Recommended
08:49, 16th Aug 2012
Magtheridon96: Alrighty, sorry for that last bad review, I was pretty tired at the time.
This doesn't seem to have any major problems.
It would be nice if the floating texts were configurable too.
You are a funny kind of person Doland kute << I laught at the face of danger Mwahahaha..!!
+ REPT 5/5 ;) ;)
So useful ;) ;)
But you should add comment on there, so we can easily modify it ;) ;)
You should change the loop time to 0.03 seconds instead of 0.02 seconds, also, I'd suggest making the bar colour in instead of taking a chunk out of it each level for athestic reasons. Maybe it's just me - but it does look a bit odd with part of the bar missing all the time.
Additionally, where do you run "remove unit"? And in your description you've put "save EXP" twice
Also: Consider making the EXP bar invisible to everybody except either players with units within a nearby radius, or only the owning player, otherwise they can be seen through the fog of war
Humm.. Need fix taged :/ :/
But don't worry, hope you fix it ;) ;) Donald_kute@yahoo.com << i add you on YM, and you must accept it ;) ;)
+ REPT to Tank and Magh too....
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions CES_UnitEXP Greater than or equal to CES_LevelTable[CES_Level] Then - Actions Special Effect - Create a special effect attached to the origin of CES_Unit2 using CES_SFX Special Effect - Destroy (Last created special effect) Set CES_UnitEXP = (CES_UnitEXP - CES_LevelTable[CES_Level]) Set CES_Level = (CES_Level + 1)
This is up level event. You can up level hero ..... in here..........
Dead units with EXP bars are not removed from the EXP bar system and keep it atm, which I imagine lasts until their corpse is removed and then the bar moves to the middle though the first part (it's their when they die) is true, and tested, and gives me the feeling they'd also take EXP from live units.
@FRENGERS:
It would be better if you would make the xp gain vary by yourself, because having it in an EXP system is not a good idea, because other people might want EXP gain to work differently.
EXP Sharing is also something that should be handled in a different resource extending off of this one.
Dead units with EXP bars are not removed from the EXP bar system and keep it atm, which I imagine lasts until their corpse is removed and then the bar moves to the middle though the first part (it's their when they die) is true, and tested, and gives me the feeling they'd also take EXP from live units.
Ok!! I'll do what you say
edit
Update
edit
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions CES_ShareEXPBoolean Equal to False Then - Actions If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions (CES_Unit is alive) Equal to True Then - Actions Set CES_Event = 0.00 Set CES_UnitEXP = (Load CES_UnitID of 1 from CES_Hashtable) Set CES_Level = (Load CES_UnitID of 2 from CES_Hashtable) Set CES_EXPRate = (Load CES_UnitID of 3 from CES_Hashtable) Set CES_RealEXP = ((CES_EXP x CES_EXPRate) / 100) Set CES_UnitEXP = (CES_UnitEXP + CES_RealEXP) Set CES_Player = (Owner of CES_Unit)