Page 1 of 3
Spawn an entity ? (randomly) (dog: ai_german_hund_dog-real)
Posted: Sat Jun 05, 2004 10:57 am
by Cigs
...morelike "when it's destroyed". in this case "when it died"
Greetings,
with the help off bdbodger I was able to make a testmap with attacking dogs innit.
( /forum/viewtopic.php?p=59657#59657 ; post of Sat Jun 05, 2004 2:08 am )
One attacking only allies. One attacking only axis.
Works Great!!
Now I like those entities (
ai_german_hund_dog-real)
to spawn about every 30-40 seconds after they died
OR rather randomly (max 60 secs)
so i removed them & tried to spawn them with as
script_object,
script_model,
script_origin.
each time the dogs were
solid
like this.. (last try;
script_origin)
Code: Select all
level waittill spawn ///////////////////////***********************************************************
thread spawnalliesdog
thread spawnaxisdog
end
spawnalliesdog:
local.static = spawn script_origin
local.static model "animal/german_shepherd.tik"
local.static.origin = ( -272.00 -112.00 8.00 )
local.static.angles = ( 0 15 0 )
end
//-----------------------------------------------------------------------------
spawnaxisdog:
local.static = spawn script_origin
local.static model "animal/german_shepherd.tik"
local.static.origin = ( -272.00 88.00 8.00 )
local.static.angles = ( 0 345 0 )
end
but the dogs are just
solid ingame. logical.
i dno
how can I spawn an (working) entity, morelike an ai(
ai_german_hund_dog-real) and have it respawn a few seconds later after dieing ?
(each time after a different ammount of seconds later; randomly)
Same thing could be done with barrels. spwawning them after they're destroyed. wouldn't tht be nice
PS: when i didn't try to spawn them, when they were just placed as an entity,,,they both had targetnames
(but that was just to amke m only attack axis or allies)
allies dog:
key:
targetname
value:
allies_dog
axis dog:
key:
targetname
value:
axis_dog
trying to spwn them with
script_origin... they didn't have a targetname anymore.
Hope this is easier then I'm guessing

thank U.
Cigs
Sat Jun 05, 2004 2:08 am
Posted: Sat Jun 05, 2004 12:45 pm
by bdbodger
Don't spawn it as a script_model or object try this out .
main:
thread dog
...
end
dog:
while(1)
(
local.dog = spawn models/animal/german_shepherd.tik
local.dog origin ( ?? ?? ?? ) // put your origin here
local.dog angle 90 // or what ever
local.dog waittill death
wait 10 // maybe wait a bit before respawning
}
end // you don't really need this because the thread does not end but I use it as a habit .
no, they don't spawn :s
Posted: Sat Jun 05, 2004 1:08 pm
by Cigs
Code: Select all
...
// prep
$axis_dog german // dog guards german soldiers - attacks allies
$allies_dog american //dog guards american soldiers - attacks axis
$axis_dog health 275
$allies_dog health 275
level waittill spawn ///////////////////////***********************************************************
thread player_teams
thread spawnalliesdog
thread spawnaxisdog
end
//-----------------------------------------------------------------------------
spawnalliesdog:
while(1)
(
local.spawnalliesdog = spawn models/animal/german_shepherd.tik "targetname" "allies_dog"
local.spawnalliesdog origin ( -292.00 -164.00 0.00 )
local.spawnalliesdog angle 15
local.spawnalliesdog waittill death
wait 25
}
end
//-----------------------------------------------------------------------------
spawnaxisdog:
while(1)
(
local.spawnaxisdog = spawn models/animal/german_shepherd.tik "targetname" "axis_dog"
local.spawnaxisdog origin ( -292.00 124.00 0.00 )
local.spawnaxisdog angle 345
local.spawnaxisdog waittill death
wait 25
}
end
//-----------------------------------------------------------------------------
player_teams:
...
they spawn! :] :]
Posted: Sat Jun 05, 2004 1:39 pm
by Cigs
it was the "( " under "while (1) "
{
I tried giving them targetnames in the script, but seems they both attack only allies
And they attack in spectatormode

Posted: Sat Jun 05, 2004 1:58 pm
by bdbodger
Ok I was not thinking about you wanting american and german dogs . Didn't we talk about this before ? If you want an american dog then use it's targetname and make it american .
$allies_dog american
and use that player team thread like you did before to make the players either american or german and have the dogs ignore spectators.
correct
Posted: Sat Jun 05, 2004 2:40 pm
by Cigs
Yes, that's correct.
they
only attack one team.
($axis_dog german (in //prep)
above level waittill spawn)
(player_teams thread at the very bottom)
That scripting part is right!
that scriptingpart can only has an effect when the targetnames are set correct!
the thing is, i tried but wasn't able to targetname those spawned TIK's ?
i 'searched & found' like this
local.spawnalliesdog = spawn models/animal/german_shepherd.tik
"targetname" "allies_dog"
local.spawnaxisdog = spawn models/animal/german_shepherd.tik
"targetname" "axis_dog"
but

n0 reslults (THEY AREN'T targetnamed!) i think.

Posted: Sat Jun 05, 2004 6:18 pm
by Cigs
yes it works,

Thx alot
found it
$axis_dog health 140
$axis_dog german
$allies_dog health 140
$allies_dog american
SHOULD BE set each time they spawn !
like this:
Code: Select all
// ALLIESAXISDOGS
// ARCHITECTURE: CIGS
// SCRIPTING: BDBODGER,
main:
// set scoreboard messages
setcvar "g_obj_alliedtext1" ""
setcvar "g_obj_alliedtext2" ""
setcvar "g_obj_alliedtext3" ""
setcvar "g_obj_axistext1" ""
setcvar "g_obj_axistext2" ""
setcvar "g_obj_axistext3" ""
setcvar "g_scoreboardpic" "" // your score board picture
// call additional stuff for playing this map round based is needed
if(level.roundbased)
thread roundbasedthread
level waittill prespawn ///////////////////////****************************************
//*** Precache Dm Stuff
exec global/DMprecache.scr
// level.script = maps/dm/mapname.scr //remember to put in your map name
level.script = maps/dm/.scr
// exec global/door_locked.scr // trigger_use: targetname/door_locked | setthread/lock | type/wood | message/This door is locked!
exec global/door_locked.scr
// exec global/ambient.scr stockmapname ; may want to make your own ambient sounds, read the tut
exec global/ambient.scr mohdm1
//add more codes here after you add more features to your maps
// prep
level waittill spawn ///////////////////////*******************************************
thread player_teams
thread spawnalliesdog
thread spawnaxisdog
$axis_dog health 140
$axis_dog german
$allies_dog health 140
$allies_dog american
end
//-------------------------------------------------------------------------------------
spawnalliesdog:
while(1)
{
local.spawnalliesdog = spawn models/animal/german_shepherd.tik "targetname" "allies_dog"
local.spawnalliesdog origin ( -292.00 -164.00 0.00 )
local.spawnalliesdog angle 15
$allies_dog health 140
$allies_dog american
local.spawnalliesdog waittill death
wait 6
}
end
//-------------------------------------------------------------------------------------
spawnaxisdog:
while(1)
{
local.spawnaxisdog = spawn models/animal/german_shepherd.tik "targetname" "axis_dog"
local.spawnaxisdog origin ( -292.00 124.00 0.00 )
local.spawnaxisdog angle 345
$axis_dog health 140
$axis_dog german
local.spawnaxisdog waittill death
wait 6
}
end
//-------------------------------------------------------------------------------------
player_teams:
while (1)
{
for (local.playtm=1;local.playtm <= $player.size;local.playtm++)
{
if ($player[local.playtm].dmteam == axis)
$player[local.playtm] german
$player[local.playtm] threatbias 1000
if ($player[local.playtm].dmteam == allies)
$player[local.playtm] american
$player[local.playtm] threatbias 1000
if ($player[local.playtm].dmteam == "spectator")
$player[local.playtm] threatbias ignoreme
}
waitframe
}
end
//-------------------------------------------------------------------------------------
roundbasedthread:
// Can specify different scoreboard messages for round based games here.
level waitTill prespawn
level waittill spawn
// set the parameters for this round based match
level.dmrespawning = 0 // 1 or 0
level.dmroundlimit = 5 // round time limit in minutes
level.clockside = kills // set to axis, allies, kills, or draw
level waittill roundstart
end
"spectator" - ignoreme
Posted: Sun Jun 06, 2004 12:30 am
by Cigs
very, very strange ... looking at the script ... but the dogs still attack when "spectator" ?
lats say im allied and an axis dog runs towards. i die

i go into 'free look' (?"spectator"?) and it's as if it still thinks im american... ?
i 'free look' some more and it runs after me, biting in air
normally it ignores in "spectator" vieuw(s). but
maybe im not in "spectator" vieuw when i just died !!?
maybe im in 'free look'_after_dying_vieuw, something totallydifferent ?
just a thought
hope you understand me. but how can it be if player_teams thread works in stockmaps ? right
right
i dno, im beefed
bdbodger ?

Posted: Sun Jun 06, 2004 8:50 am
by bdbodger
Yes you can't set health or the team of the dog until it is spawnd
local.spawnalliesdog = spawn models/animal/german_shepherd.tik "targetname" "allies_dog"
when you do that you are createing a dog with the targetname allies_dog
you can't tell a dog that it is on a certain team if it does not exist yet .
I have not noticed a problem with the dogs and spectators not a big issue just respawn and get back in the battle . You can try if you think you need to
if ($player[local.playtm].dmteam == "spectator" || $player[local.playtm].health < 1)
$player[local.playtm] threatbias ignoreme
Posted: Sun Jun 06, 2004 10:01 am
by Cigs
yes,
$player[local.playtm].health < 1
great idea
would off worked, but health bar is at 100 when you spectate
the reason i like this to work is because i wouldn't like players messing with the dog in "spectator" vieuw...
still looking for a command that can states one is 'inactive'
in MOH_game_commands_and_varaibles. maybe you know another
'dead' & 'is_enemy_visible' (g_allclasses.html)
Posted: Sun Jun 06, 2004 10:56 am
by Cigs
I found 2 commands.
Player (player) -> Sentient -> Animate -> Entity -> SimpleEntity -> Listener -> Class
dead
Called when the player is dead.
Actor (Actor) -> SimpleActor -> Sentient -> Animate -> Entity -> SimpleEntity -> Listener -> Class
is_enemy_visible
0 if the enemy is not currently visible, 1 if he is
how can i use this those commands ?
i tried if ($player[local.playtm].dmteam == "spectator" || $player[local.playtm].dead == 1)
if ($player[local.playtm].dmteam == "spectator" || $player.dead = 1)
if ($player[local.playtm].dmteam == "spectator" || $player[local.playtm] == dead)
Posted: Sun Jun 06, 2004 11:50 am
by jv_map
Well a brush with the actor texture (I suppose common/monsterclip?) hmmm I think that's not going to do much more than prevent the dogs from going there (it's like a playerclip for players).
Posted: Sun Jun 06, 2004 11:50 am
by bdbodger
if(!($player[local.playtm].dmteam == "axis") && (!($player[local.playtm] == "allies")) ???
! = not
maybe ?
Posted: Sun Jun 06, 2004 11:52 am
by jv_map
You can also do
$player[local.playtm].dmteam != "axis"
btw this thread is going to
scripting
easy
Posted: Sun Jun 06, 2004 12:45 pm
by Cigs
i see, didn't know that about the actor (i never found it explained) nice to know
and yes

!= not
but sadly i have to state that
? 'both != axis & != allies are only ignored when "spectator"' (dogs never attack any team; infact they dissapeared)
? 'only != axis are ignored', then the axis_dog
never attacks allies.
i still think it'd be better scripting to check if $player[local.playtm] is dead or alive
'
dead' or '
isAlive' ?
thx for replying