Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → AI in multiplayer
AI in multiplayer
2005-02-25, 10:35 PM #1
How come a placed enemy in JK wont be there in a multiplayer level? It seems enemies only show up if you spawn it during the game.

Would it be possible to assign a cog to the template of an npc so it would spawn itself on startup? :o
Jedi Knight Enhanced
Freelance Illustrator
2005-02-26, 12:31 AM #2
Someone correct me if im wrong, but im pretty sure that if you spawn an ai in mp, every player has a different unit, eg if you kill it the other players still have to kill thiers. I think that you have to synchronise the ai, but dont ask me how its done. Try looking into the cog section at massassi.
Spoting an error in post will result in a $100 reward.
Offer expires on 6/6/06. Valid one per customer, per day.

Rangi
2005-02-26, 1:22 AM #3
yeah I got a cog for it

pm me on msn massassian@hotmail.de
SpriteMod (JO 2003) Roger Wilco Skin

Snail racing: (500 posts per line) ---@%
2005-02-26, 4:35 PM #4
Right.. There is a cog for placing them in custom levels (which is pretty complex, and I can't figure it out)

The goal is to play a single player level in multiplayer, without having to replace every npc with a ghost, and link it to a cog.
Jedi Knight Enhanced
Freelance Illustrator
2005-02-26, 6:44 PM #5
well, I shuffled around the templates so I dont have to change them by hand in JED :D so now all the enemy positions are ghost positions and they have a cog in thier template to spawn an enemy on startup.

But its acting odd.. no enemies spawn in the right place, but one of each spawns at the first walkplayer.

all I have in the startup message is:

CreateThingNR(rfist,GetSourceRef());

Seems like it should work
:confused:
Jedi Knight Enhanced
Freelance Illustrator
2005-02-26, 8:15 PM #6
GetSourceRef() doesn't work for the startup message. (ie there is no source or sender for the startup message).

Try this one.
It finds all instances of some template ('oldtemp') and creates a certain enemy ('enemy') at the same position.

[edit] I really ought to be more specific :rolleyes: This is a level cog not a class cog.
Code:
flags=0x240
symbols

template   enemy           # enemy template to be created at all old templates
template   oldtemp         #old template in your level

int        i               local

message    startup

end

code
startup:
   sleep(0.1);
   for(i = 0; i < GetThingCount(); i = i + 1) if(GetThingTemplate(i) == oldtemp) CreateThing(enemy, i);

return;
end
May the mass times acceleration be with you.
2005-02-26, 9:50 PM #7
Ah, awesome :D

It doesnt work when trying to replace an enemy template, but I changed all placed instances of an enemy to my own custom ghost templates via a text editor, and it works with that.


Now.. how am I going to sync them :o

I'm thinking a trigger sent in via the killed message. Will their positions stay synced while alive though?
Jedi Knight Enhanced
Freelance Illustrator
2005-02-27, 1:13 AM #8
I dont think so, since the each player has to kill his/her enemy it means that the enemy is different on all comps. Im not quite sure how to sinc it. Try asking a cog master.
Spoting an error in post will result in a $100 reward.
Offer expires on 6/6/06. Valid one per customer, per day.

Rangi
2005-02-27, 8:52 AM #9
No, they aren't synced while alive, unless it's specifically done, which is the point of the Nightmare AI Sync cog. Problem is, syncing them generally introduces some amount of lag.
_ _ _____________ _ _
Wolf Moon
Cast Your Spell On Me
Beware
The Woods At Night
The Wolf Has Come
2005-02-27, 9:25 AM #10
did some testing, yeah, they aren't synced at all, but the times they become most un-synced are when one player kills one, but it doesnt get killed on the other computers :)

Ok, heres what I came up with:

in the enemy templates cog ive got:

Code:
created:
reeyees=GetSenderRef(); 
Setpulse(3.0);
Return;

pulse:
SyncThingPos(reeyees);		//sync over multi
Print("syncing!");
return;


I could probably set the pulse higher, maybe 5 or 6 seconds.

then in the killed message, I sent a trigger:

Code:
trigger:
if(GetSourceRef() == 20001)
	{
Print("damagetodeath!");
		if(GetThingHealth(reeyees) > 0)	//call killed here.
{
DamageThing(reeyees, 200, 0x1, -1);
}


That should make sure it dies on every computer at once. Anyone think this will work?
Jedi Knight Enhanced
Freelance Illustrator
2005-02-27, 9:40 AM #11
I think the problem is, that the reeyees thing is not the same on every computer. Each player gets an own set of enemies, acting completely independent from other player's set. So it's probably not just the killing act that has to be synced.
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2005-02-27, 11:37 AM #12
Nothing is really synced. In ideal network conditions, the ai will probably make the same decisions on all machines and appear to be synced until death. But if things get a little iffy and the pos gets off...it'll get ugly.

The solution to this is of course to write an entirely new set of AI in cog, run the logic only on the server and sync the movements and reactions to everyone. Thats basically what nightmare's cog does.
-El Scorcho

"Its dodgeball time!" -Stormy Waters
2005-02-28, 6:23 PM #13
...at great, great length.
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2005-03-01, 1:35 PM #14
OK, the positional syncing works, and quite well :D

occasionally an enemy will snap back to it's correct position (that of the hosts) It happens rarely, and its definately playable.

The death syncing on the other hand doesnt work. I've run into one situation where an enemy stayed alive on my computer after dying on the hosts.

The server is the one that creates the enemies, btw. Any ideas?

I'm thinking I should get the thing number, and destoy it if it doesnt exist on all computers or something..
Jedi Knight Enhanced
Freelance Illustrator
2005-03-01, 1:40 PM #15
except the thing number could be different on each computer

atm, I have no ideas for you, because thing signatures could then also be different.
May the mass times acceleration be with you.
2005-03-02, 1:08 AM #16
Im not sure if it will work but you could try doing something when the thing is created, I think object = thing or something like that does it. Then check to see if object is dead on a comp and instead of destroything do the DamageThing(getthinghealth(thing),thing)

NOTE: Cog verbs I say may not, and probably are not right. It may pay to look it up.

Or the CaptureThing verb may help?

Or you could make each enemy under a different under a different template so that if one dies on someones comp you will just be able to kill everything on the template.

Would any of that work? Or am I just speaking crap.
Spoting an error in post will result in a $100 reward.
Offer expires on 6/6/06. Valid one per customer, per day.

Rangi
2005-03-02, 4:04 PM #17
maybe when creating the template, set the user data to some unique value (like the thing signature that is assigned on only the host, so we don't have duplicate values). Then when suchandsuch an enemy is killed (on any comp), send a trigger with the userdata as one of the parameters and all enemy templates with that user data value will receive the trigger and die also.
May the mass times acceleration be with you.
2005-03-03, 2:47 PM #18
GetThingUserData isn't synced though. Why not just just in the damaged message and have:

If(!IsServer)
{
returnex(0);
return;
}

Then it'll only die if the server got wind of it.

I'm surprised anything else is synced though, but I guess I figured it was a new thing being created on each machine not one created on the server.
-El Scorcho

"Its dodgeball time!" -Stormy Waters
2005-03-03, 3:22 PM #19
Quote:
Originally posted by Darth Slaw
except the thing number could be different on each computer

atm, I have no ideas for you, because thing signatures could then also be different.


Thing numbers (and signatures) are the same on all computers for every Thing, so long as the template being created isn't in static.jkl
-Hell Raiser
2005-03-03, 4:35 PM #20
I know userdata isn't synced.
I'm so vague sometimes... Server creates thing on host comp only, sets the userdata, then sends a trigger with the userdata to create an enemy on all clients and set their userdata as well.

I also assumed the 0x240 flag was in use, so the thing numbers wouldn't necessarily be the same on all computers (I don't think anyway... lack of experience so I dunno for sure...)

I assume too much... And to think I just had assume broken down for me the other day "if you assume you make an a** of u and me"
May the mass times acceleration be with you.

↑ Up to the top!