Page 1 of 2
the Marauder's Map
Posted: Thu Jun 16, 2005 9:51 am
by wacko
I want to spawn a little script_object for each player entering the map.
The script would show/hide them at a certain position like this:
Code: Select all
the_thing:
while (1)
{
for (local.i=1;local.i<=$player.size;local.i++)
{
if (($player[local.i].dmteam == "allies") || ($player[local.i].dmteam == "axis") || ($player[local.i].dmteam == "freeforall"))
{
$thing[local.i].origin = some stuff defining their current position ;)
$thing[local.i] show
wait .8
$thing[local.i] hide
}
else
{
$thing[local.i] hide
}
}
wait .1
}
end
Now, in the map, i've got one script_object with targetname/thing. This is working for the 1st player entering, but for additional players, well, there aint no additional script_objects showing up.
Would I have to add more script_objects to the map (for each player that might come) or could I spawn them via script? What would their targetnames have to be?
These script_object, thinking about it, could be already existing models as well, even a glowing fx/dummy.tik would be nice. So maybe i'd need nothing at all in the map and would just spawn one of them each time a player enters... But how could this be done?!
Posted: Thu Jun 16, 2005 11:21 am
by bdbodger
Why?
Posted: Thu Jun 16, 2005 11:49 am
by wacko
bdbodger wrote:Why?
Cause each script_object is representing a player on a blueprint of the map, so once u are at the blueprint, u'd see the others running around

Posted: Thu Jun 16, 2005 11:59 am
by Elgan
Code: Select all
while (1)
{
for(level.i = 1; level.i <= $player.size; level.i++)
{
if ($player[level.i].has!=1 && $player[level.i] != NIL)
{
local.object = spawn script_object
local.object.origin = $player[level.i].origin
local.object glue $player[level.i]
$player[level.i].has=1
}
}
waitframe
}
why not just use the players origin?
if you put somethign on a player that glows everyone will see it no matter where they are. If you have a wall with the map worked out into coordinates well first WD! and why not just use the players origin again?
Posted: Thu Jun 16, 2005 1:35 pm
by wacko
Elgan wrote:why not just use the players origin?
if you put somethign on a player that glows everyone will see it no matter where they are. If you have a wall with the map worked out into coordinates well first WD! and why not just use the players origin again?
Answer: I have a map on a table (could be a wall aswell, np) and I do use the players origins to calculate the script_objects position. I just cut these pieces out of the script to make it shorter. If u want the whole thing, gimme a pm and I'll send it
As I said, it's working fine for one player, the $thing moves around on the blueprint perfectly. It's just that for the other player(s), there's no $thing showing up...
Question:
What means WD?
$thing[local.i] = spawn script_object ??
What would that do? what is script_object? Wouldn't I have to define somewhere, what this script_object
is?
Posted: Thu Jun 16, 2005 1:42 pm
by jv_map
You can do:
local.mynewobject = spawn script_object model $thing.brushmodel
Which would effectively clone your $thing.
Posted: Thu Jun 16, 2005 2:00 pm
by wacko
Okay. I'm giving the whole script now. Anything else seems to make not much sense
Code: Select all
main:
level waittill spawn
thread the_radar_setup
thread the_radar
end
the_radar_setup: //defining the map's and blueprint's dimensions
level.map_x_min = -1664
level.map_x_max = 1664
level.map_y_min = -1664
level.map_y_max = 1664
level.radar_x_min = -320
level.radar_x_max = -256
level.radar_y_min = 256
level.radar_y_max = 320
level.map_x_size = (level.map_x_max - level.map_x_min)
level.map_y_size = (level.map_y_max - level.map_y_min)
level.radar_x_size = (level.radar_x_max - level.radar_x_min)
level.radar_y_size = (level.radar_y_max - level.radar_y_min)
level.radar_x_cen = level.radar_x_size / 2 + level.radar_x_min
level.radar_y_cen = level.radar_y_size / 2 + level.radar_y_min
level.final_x_pos = (level.map_x_size / level.radar_x_size)
level.final_y_pos = (level.map_y_size / level.radar_y_size)
level.clock = 0
end
the_radar:
while (1)
{
for (local.i=1;local.i<=$player.size;local.i++)
{
if (($player[local.i].dmteam == "allies") || ($player[local.i].dmteam == "axis") || ($player[local.i].dmteam == "freeforall"))
{
//floor offset---------------------------------------------------
$radar_light[local.i].xoffset = 64
$radar_light[local.i].yoffset = 0
if ($player[local.i].origin[2]<144)
{
$radar_light[local.i].xoffset = 0
$radar_light[local.i].yoffset = -64
}
if ($player[local.i].origin[2]>400)
{
$radar_light[local.i].xoffset = 0
$radar_light[local.i].yoffset = 0
}
//floor offset---------------------------------------------------
$radar_light[local.i].origin = (($player[local.i].origin[0] / level.final_x_pos + level.radar_x_cen + $radar_light[local.i].xoffset) (($player[local.i].origin[1] / level.final_y_pos) + level.radar_y_cen + $radar_light[local.i].yoffset) 335)
wait .3
$radar_light[local.i] show
$radar_light[local.i] light 0 0 1 20
wait .3
$radar_light[local.i] hide
$radar_light[local.i] light 1 1 1 0
}
else
{
$radar_light[local.i] hide
}
}
wait .1
}
end
So. At the moment, I've got in the map one script_model of model/fx/dummy.tik and targetname/radar_light. Testing the map, I get a blinking yellow thingy (when I'm in the console, it'S white though) the blue light isn'T visible at all, but else it's behaving (moving) very well.

But, I'd prefered s/th like just a little light (the fx/dummy.tik is supposed to be invisible)
Where should I put that $thing[local.i] = spawn script_object model $thing.brushmodel? There will have to be another if clause, so it wouldn't be spawned for a player already having one, right?!
Posted: Thu Jun 16, 2005 7:24 pm
by Elgan
oki
WD = well done.
also why not just spawn a tiny corona instead of having brush models ?
how big is the maps map map:S? thing..hehe. dummy.tik nodraw on?
Posted: Thu Jun 16, 2005 8:58 pm
by wacko
Elgan wrote:oki
WD = well done.
also why not just spawn a tiny corona instead of having brush models ?
how big is the maps map map:S? thing..hehe. dummy.tik nodraw on?
well, if I knew how to spawn coronas, I'd be more than satisfied (and probably could even change it to Bratwursts or whatever

).
The dimensions are in the_radar_setup thread: map is level.map_x_size and level.map_y_size, map's map is level.radar_x_size and level.radar_y_size

, so once this is working, it would be easily adjustable to whatever map u wanted to

Posted: Fri Jun 17, 2005 12:49 am
by lizardkid
well, if I knew how to spawn coronas, I'd be more than satisfied
From Second Squad directly:
Code: Select all
spawn fx/corona_red.tik "targetname" "flashy" "scale" "2.5"
Posted: Fri Jun 17, 2005 6:39 am
by wacko
thanks so far
mmm, almost there.

But the code like below doesn't work. Do u spot the error?
Code: Select all
the_radar:
while (1)
{
for (local.i=1;local.i<=$player.size;local.i++)
{
if ($player[local.i].has!=1 && $player[local.i] != NIL)
{
local.mynewobject = spawn script_object "model" "fx/corona_red.tik" "scale" "2.5" "targetname" ("radar_light"+local.i)
$radar_light[local.i].origin = ((level.radar_x_cen + level.radar_x_min) (level.radar_y_cen + level.radar_y_min) 340)
$player[local.i].has=1
}
if (($player[local.i].dmteam == "allies") || ($player[local.i].dmteam == "axis") || ($player[local.i].dmteam == "freeforall"))
{
//floor offset---------------------------------------------------
$radar_light[local.i].xoffset = 64
$radar_light[local.i].yoffset = 0
if ($player[local.i].origin[2]<144)
{
$radar_light[local.i].xoffset = 0
$radar_light[local.i].yoffset = -64
}
if ($player[local.i].origin[2]>400)
{
$radar_light[local.i].xoffset = 0
$radar_light[local.i].yoffset = 0
}
//floor offset---------------------------------------------------
$radar_light[local.i].origin = (($player[local.i].origin[0] / level.final_x_pos + level.radar_x_cen + $radar_light[local.i].xoffset) (($player[local.i].origin[1] / level.final_y_pos) + level.radar_y_cen + $radar_light[local.i].yoffset) 340)
wait .3
$radar_light[local.i] show
$radar_light[local.i] light 0 0 1 20
wait .3
$radar_light[local.i] hide
$radar_light[local.i] light 1 1 1 0
}
else
{
$radar_light[local.i] hide
}
}
wait .1
}
end
Posted: Fri Jun 17, 2005 7:11 am
by lizardkid
what's the error?
this i think is an enclosing error..
Code: Select all
"targetname" ("radar_light"+local.i)
should be (i think)
Code: Select all
"targetname" "(radar_light+local.i)"
you could do it variably like you're probably more comfortable doing like this...
Code: Select all
local.shiny = spawn script_object
local.shiny.model = fx/corona_red.tik
local.shiny.scale = 2.5
local.shiny.targetname = (radar_light+local.i)
Posted: Fri Jun 17, 2005 8:10 am
by bdbodger
local.mynewobject = spawn script_object "model" "fx/corona_red.tik" "scale" "2.5" "targetname" ("radar_light"+local.i)
$radar_light[local.i].origin = ((level.radar_x_cen + level.radar_x_min) (level.radar_y_cen + level.radar_y_min) 340)
if local.i is 1 and you do it that way then the first script object's targetname will be $radar_light1 , $radar_light[1] is part of an array of objects with targetname $radar_light not a single object with targetname $radar_light1 . I would use the array and forget about targetnames it maybe easier
Code: Select all
if(level.radar_light[local.i] == NIL || level.radar_light[local.i] == NULL)
level.radar_light[local.i] = spawn script_object "model" "fx/corona_red.tik" "scale" "2.5"
That will spawn the script_object if there isn't one already if there is one already then just move it where you want it . If you want to get rid of one of them say when a player leaves then you can do
Code: Select all
if(level.radar_light.size >= 1 && level.radar_light.size > $player.size)
level.radar_light= waitthread take_extra_radars
....
end
take_extra_radars:
local.players = $player.size
for(local.i = level.radar_light.size ,local.i > local.players,local.i--)
{
level.radar_light[local.i] remove
}
if(local.players >= 1)
{
for(local.i=1,local.i <= local.players,local.i++)
{
local.temp_array[local.i] = level.radar_light[local.i]
}
end local.temp_array
}
end // or maybe end NULL or NIL
That way you can use an array called level.radar_light instead . Of course you will have to do other things as well for example $player[3] leaves the game I think maybe $player[4] may become $player[3] so you may have to keep checking what team that player in on and maybe change the script_object or model to the one for that team and position level.radar_light[?] where $player[?] 's marker position is suppose to be .
Posted: Fri Jun 17, 2005 11:48 am
by wacko
Coooool, it really seems to work
Check it out
here and tell me what I did wrong
Thanks for all the help. Once again, I'd never had made it without you!
Posted: Fri Jun 17, 2005 11:49 am
by wacko
Coooool, it really seems to work
Check it out
here and tell me what I did wrong
Thanks for all the help. Once again, I'd never had made it without you!