Scripts / Radar script

Author
Message
sacdaly
10
Years of Service
User Offline
Joined: 31st Oct 2013
Location:
Posted: 11th May 2023 15:43
Hello, i can not script, i have been using the Radar script and came across this thread https://forum.game-guru.com/thread/215583.
Dvader's extra markers/colours, I have copied what he has done on the Radar script , but in the video he is using a custom objective script , I have named a new objective script 'newobj' haven't changed that script though so is just a copy of the green objective script that's in the radar folder, so when I play what I want to be a green maker on the map it still shows as yellow.
Has anyone got the original scripts I have PM'ed Dvader but not sure if he will respond or is still on this forum.
s clarke
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 15th May 2023 22:20
if you rename a script you need to also rename the init and main functions
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
sacdaly
10
Years of Service
User Offline
Joined: 31st Oct 2013
Location:
Posted: 16th May 2023 20:17 Edited at: 23rd May 2023 07:33
Hi smallg, here are the scripts, the the radar I changed to what Dvader did in the video, and I have included the orrig objective script and the newobj I created hoping it will show green. cheers
s clarke

Attachments

Login to view attachments
sacdaly
10
Years of Service
User Offline
Joined: 31st Oct 2013
Location:
Posted: 16th May 2023 20:19
cant seem to attach the scripts
s clarke
sacdaly
10
Years of Service
User Offline
Joined: 31st Oct 2013
Location:
Posted: 16th May 2023 20:21
radar script
s clarke
sacdaly
10
Years of Service
User Offline
Joined: 31st Oct 2013
Location:
Posted: 16th May 2023 20:23
-- Radar using sprites
-- added new x y positions for easy setup - Dvader aka retrogamebloke

enemyCount = 0
radarFoundEnemies = 0
radarEnemies = {}
radarEnemySprites = {}
radarObjectiveSprites = {}
radarSprite = 0
radarImageBack = 0
radarImageRed = 0
radarImageGreen = 0
radarImageYellow = 0
aspectRatio = 0
waitForAllEntities = 1
radarx=90
radary=15
radarMakeInvisible=0

newobj=0

function radar_init(e)
radarImageBack = LoadImage ( "scriptbank\\radar\\radar-back.png" )
radarImageRed = LoadImage ( "scriptbank\\radar\\radar-red.png" )
radarImageGreen = LoadImage ( "scriptbank\\radar\\radar-green.png" )
radarImageYellow = LoadImage ( "scriptbank\\radar\\radar-yellow.png" )
radarSprite = CreateSprite ( radarImageBack )
SetSpriteDepth ( radarSprite , 100 )
end

function radar_main(e)

SetSpriteSize ( radarSprite , 15 , -1 )
SetSpriteOffset ( radarSprite , 7.5 , -1 )
if radarMakeInvisible == 0 then
SetSpritePosition ( radarSprite , radarx , radary )
else
SetSpritePosition ( radarSprite , 200 , 200 )
end
SetSpriteAngle ( radarSprite , -g_PlayerAngY )

if waitForAllEntities == 1 then
waitForAllEntities = 0
return
end

if radarFoundEnemies == 0 then
enemyCount = 0
for c = 1, 3000 do
if ai_bot_state[c] ~= nil then
if g_Entity[c] ~= nil then
enemyCount = enemyCount + 1
radarEnemies[enemyCount] = c
radarEnemySprites[enemyCount] = CreateSprite( radarImageRed )
SetSpriteOffset ( radarEnemySprites[enemyCount] , 0.25 , -1 )
SetSpriteSize ( radarEnemySprites[enemyCount] , 0.5 , -1 )
SetSpritePosition ( radarEnemySprites[enemyCount] , 200 , 200 )
end
end
end
radarFoundEnemies = 1
end

newEntity = GetFirstEntitySpawn()
if newEntity ~= 0 then
if ai_bot_state[newEntity] ~= nil then
if g_Entity[newEntity] ~= nil then
enemyCount = enemyCount + 1
radarEnemies[enemyCount] = newEntity
radarEnemySprites[enemyCount] = CreateSprite( radarImageRed )
SetSpriteOffset ( radarEnemySprites[enemyCount] , 0.25 , -1 )
SetSpriteSize ( radarEnemySprites[enemyCount] , 0.5 , -1 )
SetSpritePosition ( radarEnemySprites[enemyCount] , 200 , 200 )
end
end
end

for c = 1 , enemyCount do
e = radarEnemies[c]
if g_Entity[e] ~= nil then
if g_Entity[e]['health'] > 0 and GetEntityVisibility(e) == 1 and radarMakeInvisible == 0 then
angle = pointAtPlayer(e) + math.rad(g_PlayerAngY)
dist = GetPlayerDistance(e)
if dist > 2576 then
dist = 2576
end
x = radarx + (( math.sin(angle) * ( dist / 200.0 ) * (GetDeviceHeight()/GetDeviceWidth()) ))
y = radary + ( math.cos(angle) * ( dist / 200.0 ) )
SetSpritePosition ( radarEnemySprites[c] , x , y )
else
SetSpritePosition ( radarEnemySprites[c] , 200 , 200 )
end
end
end

for c = 1 , g_objectiveCount do
e=radarObjectives[c]
if g_Entity[e] ~= nil then
if g_Entity[e]['health'] > 0 and radarMakeInvisible == 0 then
angle = pointAtPlayer(radarObjectives[c]) + math.rad(g_PlayerAngY)
dist = GetPlayerDistance(radarObjectives[c])
if dist > 2576 then
dist = 2576
end
x = radarx + (( math.sin(angle) * ( dist / 200.0 ) * (GetDeviceHeight()/GetDeviceWidth()) ))
y = radary + ( math.cos(angle) * ( dist / 200.0 ) )
SetSpritePosition ( radarObjectiveSprites[c] , x , y )
else
SetSpritePosition ( radarObjectiveSprites[c] , 200 , 200 )
end
end
end

end

function radar_hideallsprites()
radarMakeInvisible = 1
end

function radar_showallsprites()
radarMakeInvisible = 0
end

function pointAtPlayer (i)
if g_Entity[i] ~= nil then
x = g_PlayerPosX - g_Entity[i]['x'];
z = g_PlayerPosZ - g_Entity[i]['z'];
angle = math.atan2( z , x );
angle = angle + (-90.0*0.0174533);
return angle;
end
end

function addObjective (i)
g_objectiveCount = g_objectiveCount + 1
radarObjectives[g_objectiveCount] = i
if newobj==0 then
radarObjectiveSprites[g_objectiveCount] = CreateSprite( radarImageYellow )
SetSpriteSize ( radarObjectiveSprites[g_objectiveCount] , 0.5 , -1 )
SetSpriteOffset ( radarObjectiveSprites[g_objectiveCount] , 0.25 , -1 )
SetSpritePosition ( radarObjectiveSprites[g_objectiveCount] , 200 , 200 )
end
if newobj==1 then
radarObjectiveSprites[g_objectiveCount] = CreateSprite( radarImageGreen )
SetSpriteSize ( radarObjectiveSprites[g_objectiveCount] , 0.5 , -1 )
SetSpriteOffset ( radarObjectiveSprites[g_objectiveCount] , 0.25 , -1 )
SetSpritePosition ( radarObjectiveSprites[g_objectiveCount] , 200 , 200 )
end
newobj=0
--end

end



s clarke
sacdaly
10
Years of Service
User Offline
Joined: 31st Oct 2013
Location:
Posted: 16th May 2023 20:24
-- use to add objectives to your level

haveAddedObjective = {}

function objective_init(e)
haveAddedObjective[e] = 0
end

function objective_main(e)
if haveAddedObjective[e] == 0 then
if addObjective ~= nil then
addObjective(e)
end
haveAddedObjective[e] = 1
end
PlayerDist = GetPlayerDistance(e)
if PlayerDist < 150 and g_PlayerHealth > 0 then
PromptDuration("You have reached an objective",3000)
PlaySound(e,0)
SetEntityHealth(e,0)
Destroy(e)
end
end
s clarke
sacdaly
10
Years of Service
User Offline
Joined: 31st Oct 2013
Location:
Posted: 16th May 2023 20:25
-- use to add objectives to your level

haveAddedObjective = {}

function objective_init(e)
haveAddedObjective[e] = 0
end

function objective_main(e)
if haveAddedObjective[e] == 0 then
if addObjective ~= nil then
addObjective(e)
end
haveAddedObjective[e] = 1
end
PlayerDist = GetPlayerDistance(e)
if PlayerDist < 150 and g_PlayerHealth > 0 then
PromptDuration("You have reached an objective",3000)
PlaySound(e,0)
SetEntityHealth(e,0)
Destroy(e)
end
end
s clarke
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 17th May 2023 13:04
too attach files you need to edit the post, it won't let you attach on the first try
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11

Login to post a reply

Server time is: 2024-04-20 17:22:40
Your offset time is: 2024-04-20 17:22:40