MULTIPLAYER AI

Post your scripting questions / solutions here

Moderator: Moderators

User avatar
Alcoholic
General
Posts: 1470
Joined: Sat May 17, 2003 5:57 am
Location: California
Contact:

Post by Alcoholic »

i know im gonna do something "special" with my mp map hehehehehehe. :twisted:


and jv_map:

is that one .tik for all axis players? or do i have to rewrite all the axis .tiks????
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

You have to rewrite all :(
Image
User avatar
Alcoholic
General
Posts: 1470
Joined: Sat May 17, 2003 5:57 am
Location: California
Contact:

Post by Alcoholic »

so how exactly do i do this? what do i change? i looked in ur .tik, cant tell :(
User avatar
Alcoholic
General
Posts: 1470
Joined: Sat May 17, 2003 5:57 am
Location: California
Contact:

Post by Alcoholic »

hmmm i looked in include.txt cant i just do this at the start of each round?

level waittill roundstart

Code: Select all

for (local.i = 1; local.i <= $player.size; local.i++)
{
    if ($player[local.i].dmteam == "allies")
    {
        $player[local.i] american
    }
    else if ($player[local.i].dmteam == "axis")
    {
        $player[local.i] german
    }
wouldnt that work?
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

No this won't work for players who join later :(
Image
User avatar
Alcoholic
General
Posts: 1470
Joined: Sat May 17, 2003 5:57 am
Location: California
Contact:

Post by Alcoholic »

so how do i go about changing their race in a dm respawning map?
User avatar
Alcoholic
General
Posts: 1470
Joined: Sat May 17, 2003 5:57 am
Location: California
Contact:

Post by Alcoholic »

what about a dynamic one?

would this lag the server any?


Code: Select all

level waittill roundstart

level.players = $player.size
while (1)
{
    while (level.players == $player.size)
    {
        wait 0.1
    }
    thread teams
    level.players = $player.size
    end
}
end

teams:

for (local.i = 1; local.i <= level.players; local.i++)
{
    if ($player[local.i].dmteam == "allies")
    {
        $player[local.i] american
    }
    else if ($player[local.i].dmteam == "axis")
    {
        $player[local.i] german
    }
}
end

that should work shouldnt it? but would it make lots of lag?
User avatar
Alcoholic
General
Posts: 1470
Joined: Sat May 17, 2003 5:57 am
Location: California
Contact:

Post by Alcoholic »

oh yeah the first while loop should have a wait 0.1
nuggets
General
Posts: 1006
Joined: Fri Feb 28, 2003 2:57 am
Location: U-england-K (england in the UK) :P
Contact:

Post by nuggets »

why use 2 while loops? the both dependant on each other to act

level waittill roundstart

level.players = $player.size
while (1)
{
thread teams $player.size
wait 0.1
}
end

teams level.players:
for (local.i = 1; local.i <= level.players; local.i++)
{
if ($player[local.i].dmteam == "allies")
{
$player[local.i] american
}
if ($player[local.i].dmteam == "axis")
{
$player[local.i] german
}
}
end

/*i'm not sure if this would work or not, but seems like the answer you may be looking for :D */
hope this helps, prob not cos it's all foreign 2 me :-/
User avatar
Alcoholic
General
Posts: 1470
Joined: Sat May 17, 2003 5:57 am
Location: California
Contact:

Post by Alcoholic »

the outer loop is just so that it never stops. the inner loop is just there to hold off executing the rest until its ready.

if you have this:

Code: Select all

while (1)
{
    wait 1
}

println "HAHAHAHA"
the message "HAHAHAHAHA" will never be printed on your console. while loops halt the progress of the script, and the inner while loop is a sort of "waittill" function i made.
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Either way, though it's starting to look ok ;), there's still a major issue left. I'm afraid a player won't remember his 'american' or 'german' setting when he (re)spawns :?.
Image
User avatar
Alcoholic
General
Posts: 1470
Joined: Sat May 17, 2003 5:57 am
Location: California
Contact:

Post by Alcoholic »

what about this...

use the code from my 2:19 p.m. post:

then add this after $player[local.i] german

Code: Select all

$player[local.i].race = german
and after $player[local.i]american

Code: Select all

$player[local.i].race = american
then add these independant lines:

Code: Select all

$player thread myrace

myrace:

while (1)
{
    wait 0.1
    if (self.race == german)
    {
        self german
    }
    else if (self.race == american)
    {
        self american
    }
}
end
    
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

That actually might work :) but you have a problem when a player switches teams.

Why not do this?

Code: Select all

while(1)
{
  for(local.i = 1; local.i <= $player.size; local.i++)
  {
    local.player = $player[local.i]
    if(local.player.dmteam == allies)
      local.player american
    else 
      local.player german
  }
  waitframe
}
This does bring up the next issue though :(. AI will attack spectators. :?
Image
User avatar
Alcoholic
General
Posts: 1470
Joined: Sat May 17, 2003 5:57 am
Location: California
Contact:

Post by Alcoholic »

why dont you put else if local.player.dmteam == "axis" ?? eh? eh?
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

I guessed they were not Russian :roll: so that saves one if :)
Image
Post Reply