- Joined
- Oct 12, 2011
- Messages
- 3,449
please, gy this. I've tried to make the extension and I realized that this library is far too simple.
Thanks
Thanks
Last edited:
that's all can be included in the extension (I will write them all later), well, yeah, it's simple indeed, but custom exp can't be better than this, custom attribute is just addition (in the extension perhaps you can give'em name) I add it just because the library name is custom hero not custom exp, so they must have attributes. and there is only one accepted custom exp system in the spell section and imo it lacks improvements, this library only provides everything that is very basic for custom hero..I think this is way too simple to actually justify a system resource.
Anyone with enough JASS knowledge to use structs can write something like that customized for his map needs on his own.
It also lacks basic functionality like attribute modifiers (linear and multipliers).
If I'd have to manually keep track of all temporary attribute modifiers, I don't see the point in using an external library in the first place.
Every custom attribute should have a base value, linear bonus and multiplier factor all seperate from each other.
Then a GetAttribute call returns (base value + linear bonus) * multiplier.
but this library is very basic so that it can "tailors to every needs", even if you want to completely create your own custom combat system. so copy pasteing this library is more reasonable than re-writing them all with less efficiency. But about custom attribute, let me think about it, maybe you are right and I will remove it..That's because almost every map maker wants to make their own XP system tailored to their needs.
perhaps, but except me. xDI don't see why anyone would ever use this.
that's right but actually this library also provide the best possible xp calculation, that's the main point. and I will remove custom attribute btw..The only real functionality this system provides is the XP part
A good resource is a resource that has a clear purpose and performs only that. The less things it does, the better. This may sound silly to you, but it's great to do so because modular design allows you to debug things far more quickly.
Simplicity != Serves no purpose.you better read this
it does serve, what mostly I can think about custom xp are just level up, storing and adding them, what else?And your library serves no real purpose. It just replicates the way XP is calculated in WC3 and that's it. And there's snippets that do exactly that already without all the useless wrappers.
where? gimme the link, I will request to gy if soAnd there's snippets that do exactly that already without all the useless wrappers.
okay, but why not using RegisterVariableEvent ? can you prove that it's "bad"? no one has ever complained about my "way" to fire the event except you (EDIT: actually I found this method after reading Bribe's GUI indexer, he was using the same way with mine, but the difference is that I use elegant wrapper.)But remove the RegisterVariableEvent thing. That's not how we do custom events nowadays.
really? prove that all of my wrappers are "useless"without all the useless wrappers.
It's used in GUI indexer because this is the only custom event that can be accessed and used in GUI.okay, but why not using RegisterVariableEvent ? can you prove that it's "bad"? no one has ever complained about my "way" to fire the event except you (EDIT: actually I found this method after reading Bribe's GUI indexer, he was using the same way with mine, but the difference is that I use elegant wrapper.)
can you prove that using TriggerEvaluate is any better? if yes it is, perhaps the difference wont be more than 0.0000001 milisecond, problem for you? and it's not any overhead :> deal with it.adds a lot of useless overhead.
I don't need to prove anything, as this event is totally redundant here.can you prove that using TriggerEvaluate is any better? if yes it is, perhaps the difference wont be more than 0.0000001 milisecond, problem for you? and it's not any overhead :> deal with it.
I don't need to prove anything, as this event is totally redundant here.
Instead of setting TriggerEvent to -1 and back to 0, you can just call TriggerEvaluate(Trigger).
I'm sorry?Also this code generates useless TriggerEvaulations, because functions SetCustomHeroXp amd SetCustomHeroLevel are defined before the function you try to call from them(Hero.addXp and Hero.addLevel respectively)
different xp target for each unit? sounds imbalanceAlso currently this system is really basic, because you dont even give the oppoturnity to set up different XpTargets for different units
simple calculation really doesn't hurt anythingSo far I can do everything your system can with less overhead, because I dont calculate anything, but the engine does by calling the natives on real heroes
I dont get that partbut the engine does by calling the natives on real heroes
SetHeroXP or AddHeroXP
. The only difference is that your system works for units.function aa takes A a returns nothing
call a.b()
endfunction
struct A
method b takes nothing returns nothing
endmethod
endstruct
function aa takes integer a returns nothing
set SomeGlobalHolder = a
call TriggerExecute(someJHGeneratedTrig[someInteger])
endfunction
function A__b takes integer this returns nothing
endfunction
function JH_GENERATED_SHIT takes nothing returns nothing
local integer a = SomeGlobalHolder
call A__b(a)
endfunction
function TheFunctionThatIsAtTheBottom takes nothing returns nothing
//random shit
call TriggerAddAction(someJHGeneratedTrig[someInteger])
//other random shit
endfunction
uhm, helloo, this system is indeed intended for normal units, soThe only difference is that your system works for units.
SetHeroXP or AddHeroXP
are obviously not working.I don't I just evaluating trigger, and you can add the condition anytime, what's wrong with that? TH is doing the same thing (link)you should therefor never call stuff that is defined below the place where you call it.
globals
//globals from CustomXp:
constant boolean LIBRARY_CustomXp=true
// Initial Xp target when a custom hero is created/registered
constant integer CustomXp___INITIAL_XP_TARGET= 500
// Constant Xp target addition when level up. Added after the new target has been factored
constant integer CustomXp___NEXT_LEVEL_CONSTANT= 0
// Factor increment of Xp target when level up
constant real CustomXp___NEXT_LEVEL_FACTOR= 0.25
// Furthermore, edit them with your own risk
trigger CustomXp___Trigger= CreateTrigger()
unit CustomXp___EventUnit= null
//endglobals from CustomXp
// Generated
trigger gg_trg_Melee_Initialization= null
//JASSHelper struct globals:
constant integer si__Hero=1
integer si__Hero_F=0
integer si__Hero_I=0
integer array si__Hero_V
integer array s__Hero_XpTarget
integer array s__Hero_XpCurrent
integer array s__Hero_Level
unit array s__Hero_Unit
trigger st__Hero_addXp
trigger st__Hero_addLevel
integer f__arg_integer1
integer f__arg_this
integer f__result_integer
endglobals
//Generated method caller for Hero.addXp
function sc__Hero_addXp takes integer this,integer amount returns integer
set f__arg_this=this
set f__arg_integer1=amount
call TriggerEvaluate(st__Hero_addXp)
return f__result_integer
endfunction
//Generated method caller for Hero.addLevel
function sc__Hero_addLevel takes integer this,integer amount returns integer
local unit u
loop
exitwhen amount == 0
set s__Hero_XpTarget[this]=s__Hero_XpTarget[this] + R2I(I2R(s__Hero_XpTarget[this]) * CustomXp___NEXT_LEVEL_FACTOR) + CustomXp___NEXT_LEVEL_CONSTANT
set s__Hero_Level[this]=s__Hero_Level[this] + 1
set u=CustomXp___EventUnit
set CustomXp___EventUnit=s__Hero_Unit[this]
call TriggerEvaluate(CustomXp___Trigger)
set CustomXp___EventUnit=u
set amount=amount - 1
endloop
set u=null
return s__Hero_Level[this]
endfunction
//Generated allocator of Hero
function s__Hero__allocate takes nothing returns integer
local integer this=si__Hero_F
if (this!=0) then
set si__Hero_F=si__Hero_V[this]
else
set si__Hero_I=si__Hero_I+1
set this=si__Hero_I
endif
if (this>8190) then
return 0
endif
set si__Hero_V[this]=-1
return this
endfunction
//Generated destructor of Hero
function s__Hero_deallocate takes integer this returns nothing
if this==null then
return
elseif (si__Hero_V[this]!=-1) then
return
endif
set si__Hero_V[this]=si__Hero_F
set si__Hero_F=this
endfunction
//library CustomXp:
function SetCustomHeroXp takes integer whichHero,integer newValue returns nothing
call sc__Hero_addXp(whichHero,newValue + ( newValue - s__Hero_XpCurrent[whichHero] ))
endfunction
function SetCustomHeroLevel takes integer whichHero,integer newValue returns nothing
call sc__Hero_addLevel(whichHero,newValue + ( newValue - s__Hero_Level[whichHero] ))
endfunction
function RegisterCustomHeroLevelUpEvent takes code func returns triggercondition
return TriggerAddCondition(CustomXp___Trigger, Condition(func))
endfunction
function RemoveCustomHeroLevelUpEvent takes triggercondition tc returns nothing
call TriggerRemoveCondition(CustomXp___Trigger, tc)
endfunction
function GetLevelingCustomHero takes nothing returns unit
return CustomXp___EventUnit
endfunction
function s__Hero_create takes player p,integer id,real x,real y,real face returns integer
local integer this= s__Hero__allocate()
set s__Hero_Unit[this]=CreateUnit(p, id, x, y, face)
set s__Hero_XpCurrent[this]=0
set s__Hero_XpTarget[this]=CustomXp___INITIAL_XP_TARGET
set s__Hero_Level[this]=1
return this
endfunction
function s__Hero_add takes unit whichUnit returns integer
local integer this= s__Hero__allocate()
set s__Hero_Unit[this]=whichUnit
set s__Hero_XpCurrent[this]=0
set s__Hero_XpTarget[this]=CustomXp___INITIAL_XP_TARGET
set s__Hero_Level[this]=1
return this
endfunction
function s__Hero_remove takes integer this returns nothing
call s__Hero_deallocate(this)
endfunction
function s__Hero_addXp takes integer this,integer amount returns integer
set s__Hero_XpCurrent[this]=s__Hero_XpCurrent[this] + amount
loop
exitwhen s__Hero_XpCurrent[this] < s__Hero_XpTarget[this]
set s__Hero_XpCurrent[this]=s__Hero_XpCurrent[this] - s__Hero_XpTarget[this]
call sc__Hero_addLevel(this,1)
endloop
return s__Hero_XpCurrent[this]
endfunction
function s__Hero_addLevel takes integer this,integer amount returns integer
local unit u
loop
exitwhen amount == 0
set s__Hero_XpTarget[this]=s__Hero_XpTarget[this] + R2I(I2R(s__Hero_XpTarget[this]) * CustomXp___NEXT_LEVEL_FACTOR) + CustomXp___NEXT_LEVEL_CONSTANT
set s__Hero_Level[this]=s__Hero_Level[this] + 1
set u=CustomXp___EventUnit
set CustomXp___EventUnit=s__Hero_Unit[this]
call TriggerEvaluate(CustomXp___Trigger)
set CustomXp___EventUnit=u
set amount=amount - 1
endloop
set u=null
return s__Hero_Level[this]
endfunction
function main takes nothing returns nothing
call SetCameraBounds(- 3328.0 + GetCameraMargin(CAMERA_MARGIN_LEFT), - 3584.0 + GetCameraMargin(CAMERA_MARGIN_BOTTOM), 3328.0 - GetCameraMargin(CAMERA_MARGIN_RIGHT), 3072.0 - GetCameraMargin(CAMERA_MARGIN_TOP), - 3328.0 + GetCameraMargin(CAMERA_MARGIN_LEFT), 3072.0 - GetCameraMargin(CAMERA_MARGIN_TOP), 3328.0 - GetCameraMargin(CAMERA_MARGIN_RIGHT), - 3584.0 + GetCameraMargin(CAMERA_MARGIN_BOTTOM))
call SetDayNightModels("Environment\\DNC\\DNCLordaeron\\DNCLordaeronTerrain\\DNCLordaeronTerrain.mdl", "Environment\\DNC\\DNCLordaeron\\DNCLordaeronUnit\\DNCLordaeronUnit.mdl")
call NewSoundEnvironment("Default")
call SetAmbientDaySound("LordaeronSummerDay")
call SetAmbientNightSound("LordaeronSummerNight")
call SetMapMusic("Music", true, 0)
call InitBlizzard()
call ExecuteFunc("jasshelper__initstructs12467755")
call InitGlobals()
call InitCustomTriggers()
call RunInitializationTriggers()
endfunction
//Struct method generated initializers/callers:
function sa__Hero_addXp takes nothing returns boolean
local integer this=f__arg_this
local integer amount=f__arg_integer1
set s__Hero_XpCurrent[this]=s__Hero_XpCurrent[this] + amount
loop
exitwhen s__Hero_XpCurrent[this] < s__Hero_XpTarget[this]
set s__Hero_XpCurrent[this]=s__Hero_XpCurrent[this] - s__Hero_XpTarget[this]
call sc__Hero_addLevel(this,1)
endloop
set f__result_integer= s__Hero_XpCurrent[this]
return true
endfunction
function sa__Hero_addLevel takes nothing returns boolean
local integer this=f__arg_this
local integer amount=f__arg_integer1
local unit u
loop
exitwhen amount == 0
set s__Hero_XpTarget[this]=s__Hero_XpTarget[this] + R2I(I2R(s__Hero_XpTarget[this]) * CustomXp___NEXT_LEVEL_FACTOR) + CustomXp___NEXT_LEVEL_CONSTANT
set s__Hero_Level[this]=s__Hero_Level[this] + 1
set u=CustomXp___EventUnit
set CustomXp___EventUnit=s__Hero_Unit[this]
call TriggerEvaluate(CustomXp___Trigger)
set CustomXp___EventUnit=u
set amount=amount - 1
endloop
set u=null
set f__result_integer= s__Hero_Level[this]
return true
endfunction
function jasshelper__initstructs12467755 takes nothing returns nothing
set st__Hero_addXp=CreateTrigger()
call TriggerAddCondition(st__Hero_addXp,Condition( function sa__Hero_addXp))
set st__Hero_addLevel=CreateTrigger()
call TriggerAddCondition(st__Hero_addLevel,Condition( function sa__Hero_addLevel))
endfunction
Then again that would probably be better in the spells section.