Page 1 of 1
Checking for jv_bot01.pk3
Posted: Fri Jan 16, 2004 2:22 pm
by Krane
I'm figuring out a way to check if the guy have jvbots inside the main. jv had the idea to spawn a testbot to see if it works. If yes, it removes the testbot and sets a condition "level.botspk3inmain = 1", pretty cool...he came with this thread:
Code: Select all
checkbots:
local.testbot = spawn human/multiplayer_allied_airborne_soldier.tik
if(local.testbot) // see if spawn command succeeded
{
level.botspk3inmain = 1
local.testbot remove
}
else
level.botspk3inmain = 0
end
The main purpose is to spawn my custom models only if the player have jvbots inside the main, so I came with this:
Code: Select all
crazy_boris:
if(level.botspk3inmain == 1)
{
local.boris = spawn script_model "targetname" "alliesspawnpreset"
local.boris model "models/human/multiplayer_allied_boris.tik"
local.boris solid
wait 1
iprintln "Crazy Boris is OK!"
}
else
wait 2
iprintln "Boris not ok"
end
More problems: I want to run these threads from a separate script, so let's say, the whole thing would be:
THE MAP SCRIPT:
Code: Select all
main:
blabla
level waittill spawn
exec global/russian_bots.scr
blabla
end
THE RUSSIAN BOTS SCRIPT:
Code: Select all
waitthread checkbots
thread crazy_boris
end
checkbots:
local.testbot = spawn human/multiplayer_allied_airborne_soldier.tik
if(local.testbot) // see if spawn command succeeded
{
level.botspk3inmain = 1
local.testbot remove
}
else
level.botspk3inmain = 0
end
crazy_boris:
if(level.botspk3inmain == 1)
{
local.boris = spawn script_model "targetname" "alliesspawnpreset"
local.boris model "models/human/multiplayer_allied_boris.tik"
local.boris solid
wait 1
iprintln "Crazy Boris is OK!"
}
else
wait 2
iprintln "Boris not ok"
end
Well, you know why I'm here, right? It's not working. I'll keep frying my brain with this but, if anyone out there knows what I'm doing wrong, any help would be very cool...
Thanks.
Posted: Fri Jan 16, 2004 3:35 pm
by jv_map
How exactly does it not work? I.e. does it say 'Boris not OK' when the bot pk3 is in main? Or does it say 'Boris is OK' when it isn't? or something completely different?
Posted: Fri Jan 16, 2004 5:10 pm
by Krane
Thanks jv, I decided to share my problem w/ the others instead of filling your mailbox w/ my emails...
Well, if jvbots is inside the main, it returns BOTH println lines...But if jvbots are not inside the main, it returns only "Boris is not OK" as it suppose to do. Hmm, actually it seems to work, Boris is not spawned if jvbots are not inside, it just both messages appearing...
Another thing:
In the future, I'd like ppl to be able to choose which models they want in their maps, so I was thinking in something like (in the map script):
exec global/russian_bots.scr::crazy_boris
to spawn only this model. The problem is that, this way the checkbots thread will not run and the models will not be spawned....right?
I'm affraid my "scripting I.Q." doesn't allow me to go any further.
Posted: Fri Jan 16, 2004 5:40 pm
by jv_map
The double message is a result of a silly syntax error
Code: Select all
else
wait 2
iprintln "Boris not ok"
should be
Code: Select all
else
{
wait 2
iprintln "Boris not ok"
}
In the future, I'd like ppl to be able to choose which models they want in their maps, so I was thinking in something like (in the map script):
exec global/russian_bots.scr::crazy_boris
to spawn only this model. The problem is that, this way the checkbots thread will not run and the models will not be spawned....right?
Not sure what you mean exactly

Posted: Fri Jan 16, 2004 10:09 pm
by Krane
Thanks jv. I'm very complex person but I'll try to make myself more "clear"

:
This is my actual russian_bots.scr:
Code: Select all
// RUSSIAN_BOTS
// by Krane
// mrkrane@hotmail.com
http://www22.brinkster.com/krane
waitthread checkbots
thread crazy_boris
thread recon_scout
thread recon_soldier
thread russian_corporal
end
//--------CHECK_JVBOTS (thread by jv_map)--------//
checkbots:
local.testbot = spawn human/multiplayer_allied_airborne_soldier.tik
if(local.testbot) // see if spawn command succeeded
{
level.botspk3inmain = 1
local.testbot remove
}
else
level.botspk3inmain = 0
end
//-----------BORIS----------//
crazy_boris:
if(level.botspk3inmain == 1)
{
local.boris = spawn script_model "targetname" "alliesspawnpreset"
local.boris model "models/human/multiplayer_allied_boris.tik"
local.boris solid
wait 1
iprintln "Crazy Boris is OK!"
}
else
{
wait 2
iprintln "Boris not ok"
}
end
//-----------RECONSCOUT----------//
recon_scout:
if(level.botspk3inmain == 1)
{
local.rscout = spawn script_model "targetname" "alliesspawnpreset"
local.rscout model "models/human/multiplayer_allied_russian_ReconScout.tik"
local.rscout solid
wait 1
iprintln "Recon Scout is OK!"
}
else
{
wait 2
iprintln "Scout not ok"
}
end
//-----------RECONSOLDIER----------//
recon_soldier:
if(level.botspk3inmain == 1)
{
local.rsoldier = spawn script_model "targetname" "alliesspawnpreset"
local.rsoldier model "models/human/multiplayer_allied_russian_ReconSoldier.tik"
local.rsoldier solid
wait 1
iprintln "Recon Soldier is OK!"
}
else
{
wait 2
iprintln "Soldier not ok"
}
end
//-----------CORPORAL----------//
russian_corporal:
if(level.botspk3inmain == 1)
{
local.rcorp = spawn script_model "targetname" "alliesspawnpreset"
local.rcorp model "models/human/multiplayer_allied_russian_corporal.tik"
local.rcorp solid
wait 1
iprintln "Corporal is OK!"
}
else
{
wait 2
iprintln "Corporal not ok"
}
end
Why using separate threads for each model? Cos this way, if you want only a particular model in your map, you can type in your map script:
exec global/russian_bots.scr::crazy_boris
And, if you want for ex. lots of boris, few scouts and no corporal or soldier, you can do like:
exec global/russian_bots.scr::crazy_boris
exec global/russian_bots.scr::crazy_boris
exec global/russian_bots.scr::recon_scout
I tested and seems to work fine. But, this way, the checkbots thread will NOT run, right? And we will not check if jvbots are in the main.
It's a minor issue, I will release this jvbot-mod-skin-pack the way it is (as long as others I already made while figuring out this problem

).
btw: Do you think I should live the messages there? I mean, "Boris OK" etc... That was just for testing purposes but sounds nice...What do ya think?
Cheers
Posted: Sat Jan 17, 2004 8:04 am
by jv_map
Well you could do it like this:
Code: Select all
crazy_boris:
if(level.botspk3inmain == NIL)
waitthread checkbots
if(level.botspk3inmain == 1)
{
local.boris = spawn script_model "targetname" "alliesspawnpreset"
local.boris model "models/human/multiplayer_allied_boris.tik"
local.boris solid
wait 1
iprintln "Crazy Boris is OK!"
}
else
{
wait 2
iprintln "Boris not ok"
}
end
You might also want to make just 1 thread with a bot argument... this way you don't have to change about 20 threads when you find a bug
Like this:
Code: Select all
exec global/russian_bots.scr::addbotmodel crazy_boris allies
Then in your russian_bots.scr:
Code: Select all
addbotmodel local.name local.team:
if(level.botspk3inmain == NIL)
waitthread checkbots
if(level.botspk3inmain == 1)
{
local.model = waitthread getmodel local.name
local.boris = spawn script_model "targetname" (local.team + "spawnpreset")
local.boris model ("models/human/" + local.model + ".tik")
local.boris solid
wait 1
iprintln "Crazy Boris is OK!"
}
else
{
wait 2
iprintln local.name " not ok"
}
end
getmodel local.name:
switch(local.name)
{
crazy_boris:
local.model = multiplayer_allied_boris
break // <<-- don't forget!!!
recon_scout:
local.model = multiplayer_allied_russian_ReconScout
break
// etc.
default:
println "unknown bot " local.name
local.model = multiplayer_allied_airborne_soldier
}
end local.model
Yes I would take out the 'boris is ok' message, but the 'not ok' message serves some use.
Posted: Sun Jan 18, 2004 4:28 pm
by Krane

Amazing!!! I must say, without you I'd never makei it!

Thanks,m8!
I'm using the first method, I just added the:
if(level.botspk3inmain == NIL)
waitthread checkbots
to the threads and it's working like a beauty!!!
About the 2nd method, I didn't test yet but I must say I'm very satisfied with the first method, but I''ll probably try it out later.
Thanks a lot!
