library QuestLib initializer Init
globals
constant integer MAX_UNITTYPE_CAP = 5
constant string COMPLETE_COLOR = "|cff808080"
constant string UPDATE_STRING = " - "
constant string Ln = "|n"
constant integer TALK_ID = 'A000'
hashtable q
endglobals
struct heros
unit hero
endstruct
/* Quest Types:
Kill Quest - 1
Item Quest - 2
Travel Quest - 3
Event Quest - 4
*/
struct Quest
unit giver = null
integer quests = 0
integer level = 0
string name = ""
boolean array Qtypes[4]
integer killunits
integer array killunit[MAX_UNITTYPE_CAP]
integer array howmany[MAX_UNITTYPE_CAP]
integer array rewarditem[12]
integer ritems=0
integer exp
integer gold
integer lumber
string intro
string info
string complete
string reinfo
method InitGiver takes unit u returns nothing
set this.giver = u
endmethod
method IntQuest takes integer i, string s returns nothing
set this.level = i
set this.name = s
set this.quests = this.quests+1
call SaveInteger(q, GetHandleId(this.giver), this.quests, this)
endmethod
method IntKillQuest takes nothing returns nothing
set this.Qtypes[1] = true
set this.killunits = 0
endmethod
method IntKillUnit takes integer u, integer i returns nothing
set this.killunits = this.killunits+1
set this.killunit[this.killunits] = u
set this.howmany[this.killunits] = i
call SaveInteger(q, u, this.killunits, this)
endmethod
method AddRItem takes integer i returns nothing
set this.ritems = this.ritems+1
set this.rewarditem[this.ritems] = i
endmethod
method AddReward takes integer e, integer g, integer l returns nothing
set this.exp = e
set this.gold = g
set this.lumber = l
endmethod
method IntStrings takes string a, string b, string c, string d returns nothing
set this.intro = a
set this.info = b
set this.complete = c
set this.reinfo = d
endmethod
endstruct
private function talk takes nothing returns nothing
local real angle = GetUnitFacing(GetSpellTargetUnit())+180
call SetCameraTargetControllerNoZForPlayer( GetOwningPlayer(GetTriggerUnit()), GetSpellTargetUnit(), 0, 0, false )
//call RotateCameraAroundLocBJ( 360.00, GetUnitLoc(GetTriggerUnit()), GetOwningPlayer(GetSpellTargetUnit()), 100000000.00 )
call SetCameraFieldForPlayer( GetOwningPlayer(GetTriggerUnit()), CAMERA_FIELD_ROTATION, angle, 3 )
call SetCameraFieldForPlayer( GetOwningPlayer(GetTriggerUnit()), CAMERA_FIELD_TARGET_DISTANCE, 250, 3 )
call SetCameraFieldForPlayer( GetOwningPlayer(GetTriggerUnit()), CAMERA_FIELD_ANGLE_OF_ATTACK, 0, 3 )
call SetCameraFieldForPlayer( GetOwningPlayer(GetTriggerUnit()), CAMERA_FIELD_ZOFFSET, 100, 3 )
endfunction
private function KillDeath takes nothing returns nothing
local Quest dat
local integer i
set dat = LoadInteger(q, GetUnitTypeId(GetTriggerUnit()), i)
endfunction
private function cond takes nothing returns boolean
if ( not ( GetSpellAbilityId() == TALK_ID ) ) then
return false
endif
return true
endfunction
private function KillCond takes nothing returns boolean
if ( not ( GetOwningPlayer(GetTriggerUnit()) == Player(PLAYER_NEUTRAL_AGGRESSIVE) ) ) then
return false
endif
return true
endfunction
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerAddAction(t, function talk)
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t, Condition(function cond))
set t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddCondition( t, Condition( function KillCond ) )
call TriggerAddAction( t, function KillDeath )
endfunction
endlibrary