// Colored Ping Quest System by deathismyfriend
// version 1.0.0.3
// This function sets the ping on the minimap just like u would normally do.
// To use this u need to use custom script. its rather easy tho. Here is how u call it in custom script.
// Custom script: call AddQuestColoredPingsLoc( string questName, location loc, real duration)
// the things in the parenthesis are the arguements.
// So for for example call AddQuestColoredPingsLoc( "Your Quest Name", udg_tempPoint, 10.00)
// This will set the quest name to Your Quest Name. This is how u will do commands for the ping of the quest.
// it will set the position to a tempPoint u have made and the time to 10.00 till it disapears.
// function AddQuestColoredPingsLoc takes string questName, location loc, real duration returns nothing
// This function sets the ping on the minimap just like above but u use X/Y values rather than locations that leak.
// Custom script: call AddQuestColoredPingsXY( string questName, real x, real y, real duration)
// function AddQuestColoredPingsXY takes string questName, real x, real y, real duration returns nothing
// This function allows you to change the quests ping location at any point in the game you want.
// changes the location and duration
// Custom script: call ChangeQuestPingColorLoc( string questName, location loc, real duration)
// function ChangeQuestPingColorLoc takes string questName, location loc, real duration returns nothing
// This function changes the ping location on the minimap just like above but u use X/Y values rather than locations that leak.
// Custom script: call ChangeQuestPingColorXY( string questName, real x, real y, real duration)
// function ChangeQuestPingColorXY takes string questName, real x, real y, real duration returns nothing
// This function allows you to delete the ping after the quest has been completed.
// Custom script: call function RemoveQuestColoredPing( string questName)
// function RemoveQuestColoredPing takes string questName returns nothing
function SetPingColorIndex takes nothing returns integer
local integer r = GetRandomInt( 1, udg_pingColorCodesMaxIndex)
local integer i = udg_pingIntegerColorIndex[ r]
// this array keeps track of the indexes used for the color codes.
set udg_pingIntegerColorIndex[ r] = udg_pingIntegerColorIndex[ udg_pingColorCodesMaxIndex]
// this integer keeps track of the # of available color codes.
set udg_pingColorCodesMaxIndex = udg_pingColorCodesMaxIndex - 1
return i
endfunction
function GetPingColorIndex takes string questName returns integer
local integer L = 1
loop
exitwhen L > udg_pingQuestNameIndex
if udg_pingString[ L] == questName then
return L
endif
set L = L + 1
endloop
return 0
endfunction
function RegisterPingColorXYDuration takes integer i, real x, real y, real duration returns nothing // i is the index
set udg_pingQuestColoredDuration[ i] = duration
set udg_pingQuestColoredX[ i] = x
set udg_pingQuestColoredY[ i] = y
endfunction
function AddQuestColoredPingsLoc takes string questName, location loc, real duration returns nothing
local integer i
local real x = GetLocationX( loc)
local real y = GetLocationY( loc)
set udg_pingQuestNameIndex = udg_pingQuestNameIndex + 1
if udg_pingQuestNameIndex >= udg_pingColorCodesMaxIndex then
set udg_pingQuestNameIndex = 1
endif
set udg_pingString[ udg_pingQuestNameIndex] = questName
// the integer array links the quest string with the integer used for the pings colors.
set udg_pingQuestIntArray[ udg_pingQuestNameIndex] = SetPingColorIndex()
// i set this to a variable to make the code easier to read.
set i = udg_pingQuestIntArray[ udg_pingQuestNameIndex]
call RegisterPingColorXYDuration( udg_pingQuestNameIndex, x, y, duration)
call PingMinimapEx( x, y, duration, udg_pingColorRed[ i], udg_pingColorGreen[ i], udg_pingColorBlue[ i], false)
endfunction
function AddQuestColoredPingsXY takes string questName, real x, real y, real duration returns nothing
local integer i
set udg_pingQuestNameIndex = udg_pingQuestNameIndex + 1
if udg_pingQuestNameIndex >= udg_pingColorCodesMaxIndex then
set udg_pingQuestNameIndex = 1
endif
set udg_pingString[ udg_pingQuestNameIndex] = questName
// the integer array links the quest string with the integer used for the pings colors.
set udg_pingQuestIntArray[ udg_pingQuestNameIndex] = SetPingColorIndex()
// i set this to a variable to make the code easier to read.
set i = udg_pingQuestIntArray[ udg_pingQuestNameIndex]
// These are keyed to the same index as the pingString index
call RegisterPingColorXYDuration( udg_pingQuestNameIndex, x, y, duration)
call PingMinimapEx( x, y, duration, udg_pingColorRed[ i], udg_pingColorGreen[ i], udg_pingColorBlue[ i], false)
endfunction
function ChangeQuestColoredPing takes nothing returns boolean
local string entered = GetEventPlayerChatString()
local integer old
local integer new
local integer i
local integer i1
local integer r
// QCP means quest colored ping
if SubString( entered, 0, udg_changeQCPLength) == udg_changeQCPString then
// loads the old index key that was used for the colors.
set i = GetPingColorIndex( SubString( entered, udg_changeQCPLength, StringLength( entered)))
if i != 0 then
// the integer array links the quest string with the integer used for the pings colors.
// this is the old value.
set old = udg_pingQuestIntArray[ i]
set r = GetRandomInt( 1, udg_pingColorCodesMaxIndex)
set new = udg_pingIntegerColorIndex[ r]
// Now I have to change out the integers.
set udg_pingIntegerColorIndex[ r] = old
// this is now the new value.
set udg_pingQuestIntArray[ i] = new
set i1 = udg_pingQuestIntArray[ i]
call PingMinimapEx( udg_pingQuestColoredX[ i], udg_pingQuestColoredY[ i], udg_pingQuestColoredDuration[ i], udg_pingColorRed[ i1], udg_pingColorGreen[ i1], udg_pingColorBlue[ i1], false)
else
call DisplayTextToPlayer( GetTriggerPlayer(), 0, 0, "Sorry the quest name you have entered does not exist in the Ping Color Database.")
endif
endif
return false
endfunction
// changes the location and duration
function ChangeQuestPingColorLoc takes string questName, location loc, real duration returns nothing
local integer i = GetPingColorIndex( questName)
call RegisterPingColorXYDuration( i, GetLocationX( loc), GetLocationY( loc), duration)
endfunction
// changes the location and duration
function ChangeQuestPingColorXY takes string questName, real x, real y, real duration returns nothing
local integer i = GetPingColorIndex( questName)
call RegisterPingColorXYDuration( i, x, y, duration)
endfunction
function QuestColoredPingRepeat takes nothing returns boolean
local string entered = GetEventPlayerChatString()
local integer i
local integer i1
// QCP means quest colored ping
if SubString( entered, 0, udg_pingAgainQCPLength) == udg_pingAgainQCPString then
// loads the old index key that was used for the colors.
set i = GetPingColorIndex( SubString( entered, udg_pingAgainQCPLength, StringLength( entered)))
if i != 0 then
set i1 = udg_pingQuestIntArray[ i]
call PingMinimapEx( udg_pingQuestColoredX[ i], udg_pingQuestColoredY[ i], udg_pingQuestColoredDuration[ i], udg_pingColorRed[ i1], udg_pingColorGreen[ i1], udg_pingColorBlue[ i1], false)
else
call DisplayTextToPlayer( GetTriggerPlayer(), 0, 0, "Sorry the quest name you have entered does not exist in the Ping Color Database.")
endif
endif
return false
endfunction
function RemoveQuestColoredPing takes string questName returns nothing
local integer i = GetPingColorIndex( questName)
// de-index everything
set udg_pingString[ i] = udg_pingString[ udg_pingQuestNameIndex]
set udg_pingString[ udg_pingQuestNameIndex] = null
set udg_pingQuestColoredX[ i] = udg_pingQuestColoredX[ udg_pingQuestNameIndex]
set udg_pingQuestColoredX[ udg_pingQuestNameIndex] = 0.00
set udg_pingQuestColoredY[ i] = udg_pingQuestColoredY[ udg_pingQuestNameIndex]
set udg_pingQuestColoredY[ udg_pingQuestNameIndex] = 0.00
set udg_pingQuestColoredDuration[ i] = udg_pingQuestColoredDuration[ udg_pingQuestNameIndex]
set udg_pingQuestColoredDuration[ udg_pingQuestNameIndex] = 0.00
// Now add the old index key for the colors back into the group to allow it to be picked again.
// this integer keeps track of the # of available color codes.
set udg_pingColorCodesMaxIndex = udg_pingColorCodesMaxIndex + 1
// this array keeps track of the indexes used for the color codes. I add the one that was used for that quest back to the array to be used again.
set udg_pingIntegerColorIndex[ udg_pingColorCodesMaxIndex] = udg_pingQuestIntArray[ i]
set udg_pingQuestIntArray[ i] = udg_pingQuestIntArray[ udg_pingQuestNameIndex]
set udg_pingQuestIntArray[ udg_pingQuestNameIndex] = 0
// Finally reduce the index
set udg_pingQuestNameIndex = udg_pingQuestNameIndex - 1
endfunction
function ColoredPingSetup takes nothing returns nothing
local timer tmr = GetExpiredTimer()
local integer L = 0
local trigger t = CreateTrigger()
local trigger t1 = CreateTrigger()
// This loop checks if the color was set to the attacked unit color ping and changes it slightly.
loop
exitwhen L > udg_pingColorCodesMaxIndex
set udg_pingIntegerColorIndex[ L] = L
// This sets the index used to determine which color gets paired with which quest.
if udg_pingColorRed[ L] == 255 and udg_pingColorGreen[ L] == 0 and udg_pingColorBlue[ L] == 0 then
set udg_pingColorRed[ L] = 254
endif
set L = L + 1
endloop
set L = 0
loop
exitwhen L > 11
if GetPlayerSlotState( Player( L)) == PLAYER_SLOT_STATE_PLAYING and GetPlayerController( Player( L)) == MAP_CONTROL_USER then
call TriggerRegisterPlayerChatEvent( t, Player(L), udg_changeQCPString, false)
call TriggerRegisterPlayerChatEvent( t1, Player(L), udg_pingAgainQCPString, false)
endif
set L = L + 1
endloop
set udg_changeQCPLength = StringLength( udg_changeQCPString)
set udg_pingAgainQCPLength = StringLength( udg_pingAgainQCPString)
call TriggerAddCondition( t, Condition( function ChangeQuestColoredPing))
call TriggerAddCondition( t1, Condition( function QuestColoredPingRepeat))
call DestroyTimer( tmr)
set tmr = null
set t = null
set t1 = null
endfunction
//===========================================================================
function InitTrig_ColoredPingCode takes nothing returns nothing
local trigger t = CreateTrigger()
local timer tmr = CreateTimer()
call TimerStart( tmr, 0.00, false, function ColoredPingSetup)
set tmr = null
endfunction