- Joined
- Jun 5, 2008
- Messages
- 1,768
Yeah, well. I was going to ask my friend to help me out, since he said it was easy.
Sadly, he's offline and unable to answer me, so I gave it my best shot.
The idea was to add a number of abilities. Clicking one of these abilities would then increase the level of the spellbook ability to a certain level and to get back you would simply click a back ability, which set the level of the spellbook ability to 1.
Excuse my noobiness. This is an attempted edit, alright. But hey, it's still something to learn from working with. Any help at all would be appreciated.
Well, I'd prefer a working example though, but I couldn't find any downloadable spells that was similar to what I was looking for.
The idea is to keep all building recipes in these books. ^^
Sadly, he's offline and unable to answer me, so I gave it my best shot.
The idea was to add a number of abilities. Clicking one of these abilities would then increase the level of the spellbook ability to a certain level and to get back you would simply click a back ability, which set the level of the spellbook ability to 1.
JASS:
// The two /'s means that any text written behind it is ignored by the game.
// Usefull when I want to tell you how this works :)
// Read the trigger called "Spellbook Instructions" for instructions.
constant function Spellbook_Back_ID takes nothing returns integer
return 'A004' // This is the ability rawcode of the Previous Page ability.
endfunction
constant function Spellbook_Civil_ID takes nothing returns integer
return 'A049' // This is the ability rawcode of the Next Page ability.
endfunction
constant function Spellbook_Defensive_ID takes nothing returns integer
return 'A04C' // This is the ability rawcode of the Next Page ability.
endfunction
constant function Spellbook_Agriculture_ID takes nothing returns integer
return 'A048' // This is the ability rawcode of the Next Page ability.
endfunction
constant function Spellbook_Economy_ID takes nothing returns integer
return 'A044' // This is the ability rawcode of the Next Page ability.
endfunction
constant function Spellbook_Religion_ID takes nothing returns integer
return 'A04D' // This is the ability rawcode of the Next Page ability.
endfunction
constant function Spellbook_Military_ID takes nothing returns integer
return 'A04A' // This is the ability rawcode of the Next Page ability.
endfunction
constant function Spellbook_CurrPageId takes nothing returns integer
return 'A019' // This is the ability rawcode of the Current Page ability.
endfunction
function InitSpellbookId takes nothing returns nothing
// This is a list of every spellbook ability that is used in the map. Fill in new spellbook rawcodes here.
set udg_SpellbookId[0] = 'A01D'
set udg_SpellbookId[1] = 'A018'
set udg_SpellbookId[2] = 'A026'
set udg_SpellbookId[3] = 'A025'
set udg_SpellbookId[4] = 'A024'
set udg_SpellbookId[5] = 'A023'
set udg_SpellbookId[6] = 'A028'
set udg_SpellbookId[7] = 'A027'
set udg_SpellbookId[8] = 'A022'
set udg_SpellbookId[9] = 'A00R'
set udg_SpellbookId[10] = 'A029'
// set udg_SpellbookId[2] = 'new ID here'
endfunction
// Following lines are not to be toutched unless you know what you are doing.
function Trig_SpellbookPages_Conditions takes nothing returns boolean
return GetSpellAbilityId() == Spellbook_Back_Id() or GetSpellAbilityId() == Spellbook_Civil_ID() or GetSpellAbilityId() == Spellbook_Defensive_ID() or GetSpellAbilityId() == Agriculture_ID() or GetSpellAbilityId() == Economy_ID() or GetSpellAbilityId() == Religion_ID() or GetSpellAbilityId() == Military_ID()
endfunction
function Trig_SpellbookPages_Actions takes nothing returns nothing
local unit caster = GetTriggerUnit()
local integer i = 0
if GetSpellAbilityId() == Spellbook_Back_Id() then
loop
exitwhen udg_SpellbookId[i] == 0
if GetUnitAbilityLevel(caster, udg_SpellbookId[i]) > 0 then
call DecUnitAbilityLevel(caster, udg_SpellbookId[i] )
call SetUnitAbilityLevel(caster, Spellbook_CurrPageId(), GetUnitAbilityLevel(caster, udg_SpellbookId[i]))
endif
set i = i+1
endloop
elseif GetSpellAbilityId() == Spellbook_Spellbook_Civil_ID() then
loop
exitwhen udg_SpellbookId[i] == 0
if GetUnitAbilityLevel(caster, udg_SpellbookId[i] ) > 0 then
call SetUnitAbilityLevel(caster, udg_SpellbookId[i], GetUnitAbilityLevel(caster, udg_SpellbookId[i])+1)
call SetUnitAbilityLevel(caster, Spellbook_CurrPageId(), GetUnitAbilityLevel(caster, udg_SpellbookId[i]))
endif
set i = i+1
endloop
elseif GetSpellAbilityId() == Spellbook_Defensive_ID() then
loop
exitwhen udg_SpellbookId[i] == 0
if GetUnitAbilityLevel(caster, udg_SpellbookId[i] ) > 0 then
call SetUnitAbilityLevel(caster, udg_SpellbookId[i], GetUnitAbilityLevel(caster, udg_SpellbookId[i])+1)
call SetUnitAbilityLevel(caster, Spellbook_CurrPageId(), GetUnitAbilityLevel(caster, udg_SpellbookId[i]))
endif
set i = i+1
endloop
elseif GetSpellAbilityId() == Spellbook_Agriculture_ID() then
loop
exitwhen udg_SpellbookId[i] == 0
if GetUnitAbilityLevel(caster, udg_SpellbookId[i] ) > 0 then
call SetUnitAbilityLevel(caster, udg_SpellbookId[i], GetUnitAbilityLevel(caster, udg_SpellbookId[i])+1)
call SetUnitAbilityLevel(caster, Spellbook_CurrPageId(), GetUnitAbilityLevel(caster, udg_SpellbookId[i]))
endif
set i = i+1
endloop
elseif GetSpellAbilityId() == Spellbook_Economy_ID() then
loop
exitwhen udg_SpellbookId[i] == 0
if GetUnitAbilityLevel(caster, udg_SpellbookId[i] ) > 0 then
call SetUnitAbilityLevel(caster, udg_SpellbookId[i], GetUnitAbilityLevel(caster, udg_SpellbookId[i])+1)
call SetUnitAbilityLevel(caster, Spellbook_CurrPageId(), GetUnitAbilityLevel(caster, udg_SpellbookId[i]))
endif
set i = i+1
endloop
elseif GetSpellAbilityId() == Spellbook_Religion_ID() then
loop
exitwhen udg_SpellbookId[i] == 0
if GetUnitAbilityLevel(caster, udg_SpellbookId[i] ) > 0 then
call SetUnitAbilityLevel(caster, udg_SpellbookId[i], GetUnitAbilityLevel(caster, udg_SpellbookId[i])+1)
call SetUnitAbilityLevel(caster, Spellbook_CurrPageId(), GetUnitAbilityLevel(caster, udg_SpellbookId[i]))
endif
set i = i+1
endloop
elseif GetSpellAbilityId() == Spellbook_Military_ID() then
loop
exitwhen udg_SpellbookId[i] == 0
if GetUnitAbilityLevel(caster, udg_SpellbookId[i] ) > 0 then
call SetUnitAbilityLevel(caster, udg_SpellbookId[i], GetUnitAbilityLevel(caster, udg_SpellbookId[i])+1)
call SetUnitAbilityLevel(caster, Spellbook_CurrPageId(), GetUnitAbilityLevel(caster, udg_SpellbookId[i]))
endif
set i = i+1
endloop
endif
set caster = null
endfunction
//===========================================================================
function InitTrig_SpellbookPages_Copy takes nothing returns nothing
call InitSpellbookId()
set gg_trg_SpellbookPages_Copy = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( gg_trg_SpellbookPages_Copy, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_SpellbookPages_Copy, Condition( function Trig_SpellbookPages_Conditions ) )
call TriggerAddAction( gg_trg_SpellbookPages_Copy, function Trig_SpellbookPages_Actions )
endfunction
Excuse my noobiness. This is an attempted edit, alright. But hey, it's still something to learn from working with. Any help at all would be appreciated.
Well, I'd prefer a working example though, but I couldn't find any downloadable spells that was similar to what I was looking for.
The idea is to keep all building recipes in these books. ^^