- Joined
- Dec 6, 2009
- Messages
- 173
Hello, I'm a noob to jass. I have tried making my exp system into vjass but it doesn't work for more than one player, and it's buggy.
Plz tell me how I can make it more efficent and how to make it work properly
All help is appreciated and +rep to anyone helping ofc!
Plz tell me how I can make it more efficent and how to make it work properly
All help is appreciated and +rep to anyone helping ofc!

JASS:
scope CEXP initializer Init
//--------------------------------------------------------------
//--------------------------------------------------------------
//Setting the global exp for units
//--------------------------------------------------------------
//--------------------------------------------------------------
globals
private constant real Radius = 1000
private constant integer ExpLevel = 50
endglobals
private function filter takes nothing returns boolean
local unit u = GetFilterUnit()
local boolean b1 = IsUnitType( u, UNIT_TYPE_DEAD) == FALSE
local boolean b2 = IsUnitType( u, UNIT_TYPE_HERO) == TRUE
local boolean b3 = IsUnitAlly( u, GetOwningPlayer(GetKillingUnit())) == TRUE
local boolean b4 = IsUnitIllusion(u) == FALSE
set u = null
return b1 and b2 and b3 and b4
endfunction
private function GiveXP takes nothing returns nothing
local unit u = GetTriggerUnit()
local unit Killer = GetKillingUnit()
local unit f
local location l = GetUnitLoc(u)
local player p = GetOwningPlayer(Killer)
local group g = CreateGroup()
local integer KilledUnitLevel
local integer KillerLevel
local real ExpGain
local integer ExpGainFinal
set KilledUnitLevel = GetUnitLevel(u)
set KillerLevel = GetUnitLevel(Killer)
set ExpGain = ExpLevel
call GroupEnumUnitsInRangeOfLoc( g, l, Radius, Condition(function filter))
//=============================================================================
if ( KillerLevel == KilledUnitLevel ) then
else
if ( KillerLevel == ( GetUnitLevel(GetEnumUnit()) + 1 ) ) or ( KillerLevel == ( GetUnitLevel(GetEnumUnit()) - 1 ) ) then
set ExpGain = ExpGain * 0.90
else
if ( KillerLevel == ( KilledUnitLevel + 2 )) or ( KillerLevel == ( KilledUnitLevel - 2 ) ) then
set ExpGain = ExpGain * 0.80
else
if ( KillerLevel == ( KilledUnitLevel + 3 )) or ( KillerLevel == ( KilledUnitLevel - 3 ) ) then
set ExpGain = ExpGain * 0.70
else
set ExpGain = 0.00
endif
endif
endif
endif
//=============================================================================
set ExpGainFinal = (R2I(ExpGain))
loop
set f = FirstOfGroup(g)
exitwhen f == null
call AddHeroXP(f, ExpGainFinal, TRUE)
if GetOwningPlayer(f) == GetLocalPlayer() then
call CreateTextTagLocBJ( ( "+" + ( I2S(ExpGainFinal) + "Exp" ) ), l, 50.00, 11.00, 20.00, 20.00, 80.00, 0 )
call SetTextTagVelocity( GetLastCreatedTextTag(), 80.00, 90 )
call SetTextTagPermanent( GetLastCreatedTextTag(), false )
call SetTextTagLifespan( GetLastCreatedTextTag(), 3.00 )
call SetTextTagFadepoint( GetLastCreatedTextTag(), 2.50 )
call GroupRemoveUnit(g, f)
endif
endloop
call DestroyGroup(g)
call RemoveLocation(l)
set g = null
set u = null
set Killer = null
set f = null
endfunction
//===========================================================================
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddAction(t, function GiveXP )
set t = null
endfunction
endscope
-
Custom EXP Setup
-

Events
-


Map initialization
-
-

Conditions
-

Actions
-


-------- --------------------------------------------------------------------------- --------
-


-------- --------------------------------------------------------------------------- --------
-


-------- Set Shared EXP Range --------
-


-------- --------------------------------------------------------------------------- --------
-


-------- --------------------------------------------------------------------------- --------
-


Set EXP_ShareRange = 1000.00
-


-------- --------------------------------------------------------------------------- --------
-


-------- --------------------------------------------------------------------------- --------
-


-------- Set EXP / Unit Level Init --------
-


-------- --------------------------------------------------------------------------- --------
-


-------- --------------------------------------------------------------------------- --------
-


Set EXP_Gain_UnitLVL[1] = 10.00
-


Set EXP_Gain_UnitLVL[2] = 15.00
-


Set EXP_Gain_UnitLVL[3] = 22.00
-


Set EXP_Gain_UnitLVL[4] = 50.00
-


Set EXP_Gain_UnitLVL[5] = 100.00
-


Set EXP_Gain_UnitLVL[6] = 110.00
-


Set EXP_Gain_UnitLVL[7] = 120.00
-


Set EXP_Gain_UnitLVL[8] = 130.00
-


Set EXP_Gain_UnitLVL[9] = 140.00
-


-------- --------------------------------------------------------------------------- --------
-


-------- --------------------------------------------------------------------------- --------
-


-------- Set Specific Unit EXP --------
-


-------- --------------------------------------------------------------------------- --------
-


-------- --------------------------------------------------------------------------- --------
-


Set EXP_Gain_UnitType[1] = Wolf Boss
-


Set EXP_Gain_BossType[2] = (Real((Point-value of EXP_Gain_UnitType[1])))
-


Set EXP_Gain_UnitType[2] = Wolf Boss Big
-


Set EXP_Gain_BossType[5] = (Real((Point-value of EXP_Gain_UnitType[2])))
-


-------- --------------------------------------------------------------------------- --------
-


-------- --------------------------------------------------------------------------- --------
-


-------- Set EXP / Unit Level End --------
-


-------- --------------------------------------------------------------------------- --------
-


-------- --------------------------------------------------------------------------- --------
-
-
-
Custom EXP System
-

Events
-


Unit - A unit Dies
-
-

Conditions
-


((Triggering unit) is A structure) Equal to (==) False
-


((Triggering unit) belongs to an enemy of (Owner of (Killing unit))) Equal to (==) True
-
-

Actions
-


Set EXP_Unit = (Triggering unit)
-



Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
-




If - Conditions
-





(Real((Point-value of EXP_Unit))) Equal to (==) EXP_Gain_BossType[(Level of EXP_Unit)]
-
-




Then - Actions
-





Set TempLoc = (Position of EXP_Unit)
-





Set EXP_GainGroup = (Units within EXP_ShareRange of TempLoc matching ((((Matching unit) belongs to an ally of (Owner of (Killing unit))) Equal to (==) True) and ((((Matching unit) is A Hero) Equal to (==) True) and ((((Matching unit) is alive) Equal to (==) True) and (((Matching
-





Set EXP_UnitKillLVL = (Level of EXP_Unit)
-





Set EXP_Gain = EXP_Gain_BossType[(Level of EXP_Unit)]
-





Custom script: set bj_wantDestroyGroup=true
-





Unit Group - Pick every unit in EXP_GainGroup and do (Actions)
-






Loop - Actions
-







Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
-








If - Conditions
-









EXP_UnitKillLVL Equal to (==) (Level of (Picked unit))
-
-








Then - Actions
-








Else - Actions
-









Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
-










If - Conditions
-











Multiple ConditionsOr - Any (Conditions) are true
-












Conditions
-













EXP_UnitKillLVL Equal to (==) ((Level of (Picked unit)) + 1)
-













EXP_UnitKillLVL Equal to (==) ((Level of (Picked unit)) - 1)
-
-
-
-










Then - Actions
-










Else - Actions
-











Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
-












If - Conditions
-













Multiple ConditionsOr - Any (Conditions) are true
-














Conditions
-















EXP_UnitKillLVL Equal to (==) ((Level of (Picked unit)) + 2)
-















EXP_UnitKillLVL Equal to (==) ((Level of (Picked unit)) - 2)
-
-
-
-












Then - Actions
-












Else - Actions
-













Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
-














If - Conditions
-















Multiple ConditionsOr - Any (Conditions) are true
-
















Conditions
-

















EXP_UnitKillLVL Equal to (==) ((Level of (Picked unit)) + 3)
-

















EXP_UnitKillLVL Equal to (==) ((Level of (Picked unit)) - 3)
-
-
-
-














Then - Actions
-














Else - Actions
-















Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
















If - Conditions
-

















Multiple ConditionsOr - Any (Conditions) are true
-


















Conditions
-



















EXP_UnitKillLVL Equal to (==) ((Level of (Picked unit)) + 4)
-



















EXP_UnitKillLVL Equal to (==) ((Level of (Picked unit)) - 4)
-
-
-
-
















Then - Actions
-
















Else - Actions
-

















Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
-


















If - Conditions
-



















Multiple ConditionsOr - Any (Conditions) are true
-




















Conditions
-





















EXP_UnitKillLVL Equal to (==) ((Level of (Picked unit)) + 5)
-





















EXP_UnitKillLVL Equal to (==) ((Level of (Picked unit)) - 5)
-
-
-
-


















Then - Actions
-


















Else - Actions
-



















Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
-




















If - Conditions
-





















Multiple ConditionsOr - Any (Conditions) are true
-






















Conditions
-























EXP_UnitKillLVL Equal to (==) ((Level of (Picked unit)) + 6)
-























EXP_UnitKillLVL Equal to (==) ((Level of (Picked unit)) - 6)
-
-
-
-




















Then - Actions
-





















Set EXP_Gain = (EXP_Gain x 0.90)
-
-




















Else - Actions
-





















Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
-






















If - Conditions
-























Multiple ConditionsOr - Any (Conditions) are true
-
























Conditions
-

























EXP_UnitKillLVL Equal to (==) ((Level of (Picked unit)) + 7)
-

























EXP_UnitKillLVL Equal to (==) ((Level of (Picked unit)) - 7)
-
-
-
-






















Then - Actions
-























Set EXP_Gain = (EXP_Gain x 0.70)
-
-






















Else - Actions
-























Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
























If - Conditions
-

























Multiple ConditionsOr - Any (Conditions) are true
-


























Conditions
-



























EXP_UnitKillLVL Equal to (==) ((Level of (Picked unit)) + 8)
-



























EXP_UnitKillLVL Equal to (==) ((Level of (Picked unit)) - 8)
-
-
-
-
























Then - Actions
-

























Set EXP_Gain = (EXP_Gain x 0.50)
-
-
























Else - Actions
-

























Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
-


























If - Conditions
-



























Multiple ConditionsOr - Any (Conditions) are true
-




























Conditions
-





























EXP_UnitKillLVL Equal to (==) ((Level of (Picked unit)) + 9)
-





























EXP_UnitKillLVL Equal to (==) ((Level of (Picked unit)) - 9)
-
-
-
-


























Then - Actions
-



























Set EXP_Gain = (EXP_Gain x 0.20)
-
-


























Else - Actions
-



























Set EXP_Gain = 0.00
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-







Set TempInt = (Player number of (Owner of (Picked unit)))
-








Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
-









If - Conditions
-










Multiple ConditionsOr - Any (Conditions) are true
-











Conditions
-












(Picked unit) Equal to (==) (Killing unit)
-












(Owner of (Picked unit)) Equal to (==) (Owner of (Killing unit))
-
-
-
-









Then - Actions
-










Set EXP_GainFinal = (Integer(EXP_Gain))
-










Hero - Add EXP_GainFinal experience to (Picked unit), Show level-up graphics
-










Custom script: if GetOwningPlayer(GetEnumUnit()) == GetLocalPlayer() then
-










Floating Text - Create floating text that reads (+ + ((String(EXP_GainFinal)) + Exp)) at TempLoc with Z offset 50.00, using font size 11.00, color (20.00%, 20.00%, 80.00%), and 0.00% transparency
-










Floating Text - Set the velocity of (Last created floating text) to 80.00 towards 90.00 degrees
-










Floating Text - Change (Last created floating text): Disable permanence
-










Floating Text - Change the lifespan of (Last created floating text) to 3.00 seconds
-










Floating Text - Change the fading age of (Last created floating text) to 2.50 seconds
-










Custom script: endif
-
-









Else - Actions
-










Set EXP_GainFinal = (Integer(EXP_Gain))
-










Hero - Add EXP_GainFinal experience to (Picked unit), Show level-up graphics
-










Custom script: if GetOwningPlayer(GetEnumUnit()) == GetLocalPlayer() then
-










Floating Text - Create floating text that reads (+ + ((String(EXP_GainFinal)) + Exp)) at TempLoc with Z offset 50.00, using font size 11.00, color (20.00%, 20.00%, 80.00%), and 0.00% transparency
-










Floating Text - Set the velocity of (Last created floating text) to 80.00 towards 90.00 degrees
-










Floating Text - Change (Last created floating text): Disable permanence
-










Floating Text - Change the lifespan of (Last created floating text) to 3.00 seconds
-










Floating Text - Change the fading age of (Last created floating text) to 2.50 seconds
-










Custom script: endif
-
-
-
-
-
-





Custom script: call RemoveLocation(udg_TempLoc)
-
-




Else - Actions
-





Set TempLoc = (Position of EXP_Unit)
-





Set EXP_GainGroup = (Units within EXP_ShareRange of TempLoc matching ((((Matching unit) belongs to an ally of (Owner of (Killing unit))) Equal to (==) True) and ((((Matching unit) is A Hero) Equal to (==) True) and ((((Matching unit) is alive) Equal to (==) True) and (((Matching
-





Set EXP_UnitKillLVL = (Level of EXP_Unit)
-





Set EXP_Gain = EXP_Gain_UnitLVL[EXP_UnitKillLVL]
-





Custom script: set bj_wantDestroyGroup=true
-





Unit Group - Pick every unit in EXP_GainGroup and do (Actions)
-






Loop - Actions
-







Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
-








If - Conditions
-









EXP_UnitKillLVL Equal to (==) (Level of (Picked unit))
-
-








Then - Actions
-








Else - Actions
-









Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
-










If - Conditions
-











Multiple ConditionsOr - Any (Conditions) are true
-












Conditions
-













EXP_UnitKillLVL Equal to (==) ((Level of (Picked unit)) + 1)
-













EXP_UnitKillLVL Equal to (==) ((Level of (Picked unit)) - 1)
-
-
-
-










Then - Actions
-











Set EXP_Gain = (EXP_Gain x 0.95)
-
-










Else - Actions
-











Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
-












If - Conditions
-













Multiple ConditionsOr - Any (Conditions) are true
-














Conditions
-















EXP_UnitKillLVL Equal to (==) ((Level of (Picked unit)) + 2)
-















EXP_UnitKillLVL Equal to (==) ((Level of (Picked unit)) - 2)
-
-
-
-












Then - Actions
-













Set EXP_Gain = (EXP_Gain x 0.85)
-
-












Else - Actions
-













Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
-














If - Conditions
-















Multiple ConditionsOr - Any (Conditions) are true
-
















Conditions
-

















EXP_UnitKillLVL Equal to (==) ((Level of (Picked unit)) + 3)
-

















EXP_UnitKillLVL Equal to (==) ((Level of (Picked unit)) - 3)
-
-
-
-














Then - Actions
-















Set EXP_Gain = (EXP_Gain x 0.60)
-
-














Else - Actions
-















Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
















If - Conditions
-

















Multiple ConditionsOr - Any (Conditions) are true
-


















Conditions
-



















EXP_UnitKillLVL Equal to (==) ((Level of (Picked unit)) + 4)
-



















EXP_UnitKillLVL Equal to (==) ((Level of (Picked unit)) - 4)
-
-
-
-
















Then - Actions
-

















Set EXP_Gain = (EXP_Gain x 0.40)
-
-
















Else - Actions
-

















Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
-


















If - Conditions
-



















Multiple ConditionsOr - Any (Conditions) are true
-




















Conditions
-





















EXP_UnitKillLVL Equal to (==) ((Level of (Picked unit)) + 5)
-





















EXP_UnitKillLVL Equal to (==) ((Level of (Picked unit)) - 5)
-
-
-
-


















Then - Actions
-



















Set EXP_Gain = (EXP_Gain x 0.30)
-
-


















Else - Actions
-



















Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
-




















If - Conditions
-





















Multiple ConditionsOr - Any (Conditions) are true
-






















Conditions
-























EXP_UnitKillLVL Equal to (==) ((Level of (Picked unit)) + 6)
-























EXP_UnitKillLVL Equal to (==) ((Level of (Picked unit)) - 6)
-
-
-
-




















Then - Actions
-





















Set EXP_Gain = (EXP_Gain x 0.15)
-
-




















Else - Actions
-





















Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
-






















If - Conditions
-























Multiple ConditionsOr - Any (Conditions) are true
-
























Conditions
-

























EXP_UnitKillLVL Equal to (==) ((Level of (Picked unit)) + 7)
-

























EXP_UnitKillLVL Equal to (==) ((Level of (Picked unit)) - 7)
-
-
-
-






















Then - Actions
-























Set EXP_Gain = (EXP_Gain x 0.10)
-
-






















Else - Actions
-























Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
























If - Conditions
-

























Multiple ConditionsOr - Any (Conditions) are true
-


























Conditions
-



























EXP_UnitKillLVL Equal to (==) ((Level of (Picked unit)) + 8)
-



























EXP_UnitKillLVL Equal to (==) ((Level of (Picked unit)) - 8)
-
-
-
-
























Then - Actions
-

























Set EXP_Gain = (EXP_Gain x 0.05)
-
-
























Else - Actions
-

























Set EXP_Gain = 0.00
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-







Set TempInt = (Player number of (Owner of (Picked unit)))
-








Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
-









If - Conditions
-










Multiple ConditionsOr - Any (Conditions) are true
-











Conditions
-












(Picked unit) Equal to (==) (Killing unit)
-












(Owner of (Picked unit)) Equal to (==) (Owner of (Killing unit))
-
-
-
-









Then - Actions
-










Set EXP_GainFinal = (Integer(EXP_Gain))
-










Hero - Add EXP_GainFinal experience to (Picked unit), Show level-up graphics
-










Custom script: if GetOwningPlayer(GetEnumUnit()) == GetLocalPlayer() then
-










Floating Text - Create floating text that reads (+ + ((String(EXP_GainFinal)) + Exp)) at TempLoc with Z offset 50.00, using font size 11.00, color (20.00%, 20.00%, 80.00%), and 0.00% transparency
-










Floating Text - Set the velocity of (Last created floating text) to 80.00 towards 90.00 degrees
-










Floating Text - Change (Last created floating text): Disable permanence
-










Floating Text - Change the lifespan of (Last created floating text) to 3.00 seconds
-










Floating Text - Change the fading age of (Last created floating text) to 2.50 seconds
-










Custom script: endif
-
-









Else - Actions
-










Set EXP_GainFinal = (Integer(EXP_Gain))
-










Hero - Add EXP_GainFinal experience to (Picked unit), Show level-up graphics
-










Custom script: if GetOwningPlayer(GetEnumUnit()) == GetLocalPlayer() then
-










Floating Text - Create floating text that reads (+ + ((String(EXP_GainFinal)) + Exp)) at TempLoc with Z offset 50.00, using font size 11.00, color (20.00%, 20.00%, 80.00%), and 0.00% transparency
-










Floating Text - Set the velocity of (Last created floating text) to 80.00 towards 90.00 degrees
-










Floating Text - Change (Last created floating text): Disable permanence
-










Floating Text - Change the lifespan of (Last created floating text) to 3.00 seconds
-










Floating Text - Change the fading age of (Last created floating text) to 2.50 seconds
-










Custom script: endif
-
-
-
-
-
-





Custom script: call RemoveLocation(udg_TempLoc)
-
-
-
-
-

