Spawn an entity ? (randomly) (dog: ai_german_hund_dog-real)

Post your scripting questions / solutions here

Moderator: Moderators

User avatar
Cigs
Colour Sergeant
Posts: 90
Joined: Fri May 28, 2004 1:04 pm
Location: Gent - BELGIUM

Spawn an entity ? (randomly) (dog: ai_german_hund_dog-real)

Post 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!! :D

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 :lol:





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. :roll:



Hope this is easier then I'm guessing :?
thank U.
Cigs

Sat Jun 05, 2004 2:08 am
Last edited by Cigs on Sat Jun 05, 2004 2:12 pm, edited 2 times in total.
Image
TS217.172.173.37:9095
Spearhead SDK Q's
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post 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 .
Image
User avatar
Cigs
Colour Sergeant
Posts: 90
Joined: Fri May 28, 2004 1:04 pm
Location: Gent - BELGIUM

no, they don't spawn :s

Post 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: 

...
Last edited by Cigs on Sat Jun 05, 2004 1:57 pm, edited 3 times in total.
Image
TS217.172.173.37:9095
Spearhead SDK Q's
User avatar
Cigs
Colour Sergeant
Posts: 90
Joined: Fri May 28, 2004 1:04 pm
Location: Gent - BELGIUM

they spawn! :] :]

Post 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 :shock: :arrow: :?:
Image
TS217.172.173.37:9095
Spearhead SDK Q's
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post 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.
Image
User avatar
Cigs
Colour Sergeant
Posts: 90
Joined: Fri May 28, 2004 1:04 pm
Location: Gent - BELGIUM

correct

Post 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! :P


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 :shock: n0 reslults (THEY AREN'T targetnamed!) i think. :o
Image
TS217.172.173.37:9095
Spearhead SDK Q's
User avatar
Cigs
Colour Sergeant
Posts: 90
Joined: Fri May 28, 2004 1:04 pm
Location: Gent - BELGIUM

Post by Cigs »

yes it works, :D 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 !

:P

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 
Image
TS217.172.173.37:9095
Spearhead SDK Q's
User avatar
Cigs
Colour Sergeant
Posts: 90
Joined: Fri May 28, 2004 1:04 pm
Location: Gent - BELGIUM

"spectator" - ignoreme

Post by Cigs »

very, very strange ... looking at the script ... but the dogs still attack when "spectator" ? :o

lats say im allied and an axis dog runs towards. i die :shock: :wink: i go into 'free look' (?"spectator"?) and it's as if it still thinks im american... ? :shock:
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 ? :roll:

just a thought
:idea:
hope you understand me. but how can it be if player_teams thread works in stockmaps ? right

right

i dno, im beefed
bdbodger ? :lol:
Image
TS217.172.173.37:9095
Spearhead SDK Q's
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post 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
Image
User avatar
Cigs
Colour Sergeant
Posts: 90
Joined: Fri May 28, 2004 1:04 pm
Location: Gent - BELGIUM

Post by Cigs »

yes,

$player[local.playtm].health < 1

great idea
would off worked, but health bar is at 100 when you spectate :? :oops:

the reason i like this to work is because i wouldn't like players messing with the dog in "spectator" vieuw... :roll:

still looking for a command that can states one is 'inactive'
in MOH_game_commands_and_varaibles. maybe you know another
Last edited by Cigs on Sun Jun 06, 2004 11:39 am, edited 1 time in total.
Image
TS217.172.173.37:9095
Spearhead SDK Q's
User avatar
Cigs
Colour Sergeant
Posts: 90
Joined: Fri May 28, 2004 1:04 pm
Location: Gent - BELGIUM

'dead' & 'is_enemy_visible' (g_allclasses.html)

Post 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)
Last edited by Cigs on Sun Jun 06, 2004 11:51 am, edited 1 time in total.
Image
TS217.172.173.37:9095
Spearhead SDK Q's
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post 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).
Last edited by jv_map on Sun Jun 06, 2004 11:50 am, edited 1 time in total.
Image
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

if(!($player[local.playtm].dmteam == "axis") && (!($player[local.playtm] == "allies")) ???

! = not

maybe ?
Image
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

You can also do

$player[local.playtm].dmteam != "axis"

:)

btw this thread is going to :arrow: scripting
Image
User avatar
Cigs
Colour Sergeant
Posts: 90
Joined: Fri May 28, 2004 1:04 pm
Location: Gent - BELGIUM

easy

Post by Cigs »

i see, didn't know that about the actor (i never found it explained) nice to know
and yes :oops: != not :oops:

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' ?

:idea:

thx for replying
Image
TS217.172.173.37:9095
Spearhead SDK Q's
Post Reply