Data Realms Fan Forums
http://45.55.195.193/

Edited the Assassination mission for co-op, problems
http://45.55.195.193/viewtopic.php?f=73&t=14598
Page 1 of 1

Author:  mewarmo990 [ Wed May 13, 2009 1:41 am ]
Post subject:  Edited the Assassination mission for co-op, problems

Hey everyone, I just got CC and I love it. Thanks for this great scene, too.

So after forcing myself to learn the very basics of LUA coding, through some excruciating trial and error I clumsily managed to make this scene two-player co-op. It's very playable, but there are some kinks I'm still trying to work out.

I edited "assassination.rte\Activities.ini" so that
Code:
PlayerCount = 2


Then, in "assassination.rte\Scenes\Scripts\assassination.lua",
Code:
-- Set up players
    for player = 0, self.PlayerCount - 0 do
   --Set the brain to playerActor.  The only reason we do this is that the game crashes without a brain.  Even if the playerActor dies, it won't matter, though.
   pl = CreateAHuman("Shinobi Tengu", "DarkStorm.rte");
   pl.AIMode = Actor.AIMODE_SENTRY;
   pl.Team = 0;
   pl:AddInventoryItem(CreateHDFirearm("D17-S Pistol", "DarkStorm.rte"));
   pl:AddInventoryItem(CreateHDFirearm("D35-S Carbine", "DarkStorm.rte"));
   pl:AddInventoryItem(CreateTDExplosive("D61 Chaff Grenade Type 1", "DarkStorm.rte"));
   pl:AddInventoryItem(CreateTDExplosive("P.A. Frag Nade", "PelianArmy.rte"));
   pl:AddInventoryItem(CreateTDExplosive("P.A. Plasma Nade", "PelianArmy.rte"));
   pl.Pos = Vector(79,429);
   MovableMan:AddActor(pl)

   playerActor = pl;
   self:SetPlayerBrain(playerActor, player);
   self:SetLandingZone(playerActor.Pos, player);
   
   end
In the second line I changed "self.Playercount - 0" instead of 1. Anything besides 0 doesn't spawn anything and causes a Mission Failure since Player 1 is the brain.

The game spawns three copies of the actor I specified - two are controlled by the players and the third just does his own AIMODE thing. I can't for the life of me figure out how to spawn a second, unique actor for Player 2 to control. Everything I've tried has resulted in the scene not loading because of an "end expected" or some incomplete argument. :x
Player 2 must attempt to switch actors in order to control the one he is supposed to start with.

I have some questions:
1. The scene is set so that you cannot switch actors (both players) - it makes sense in the gameplay of this mission, but can somebody please explain to me where this is scripted so I can figure out how to change it in the future?
2. Is there a way to spawn a second, different actor as Player 2?
3. Why is that third actor there, and how do I stop it from spawning?
4. Whenever Player 2 dies, the game crashes. Huh?

Author:  Disst [ Wed May 13, 2009 1:57 am ]
Post subject:  Re: Edited the Assassination mission for co-op, problems

This belongs in the mission's thread.

Author:  piipu [ Wed May 13, 2009 5:34 am ]
Post subject:  Re: Edited the Assassination mission for co-op, problems

Give me the .lua, I'll see about it. Always wanted to learn how to do this anyway.

Author:  mewarmo990 [ Wed May 13, 2009 5:59 am ]
Post subject:  Re: Edited the Assassination mission for co-op, problems

Sure, thanks. I'm feeling pretty clueless so I'd appreciate any advice you can give me.

Attachments:
File comment: Don't forget to change PlayerCount in Activities
assassination.lua.zip [2.62 KiB]
Downloaded 226 times

Author:  mail2345 [ Wed May 13, 2009 7:14 am ]
Post subject:  Re: Edited the Assassination mission for co-op, problems

The issue is that both players are using the same actor variable.

BTW, I have no idea why there is that loop.

Get rid of it.

Author:  piipu [ Wed May 13, 2009 5:37 pm ]
Post subject:  Re: Edited the Assassination mission for co-op, problems

What mail said. That is, replace your codeblock with this:
Code:
   pl = CreateAHuman("Soldier Heavy");
   pl.AIMode = Actor.AIMODE_SENTRY;
   pl.Team = 0;
   pl:AddInventoryItem(CreateHDFirearm("Pistol"));
   pl.Pos = Vector(89,429);
   MovableMan:AddActor(pl)

   playerActor = pl;
   self:SetPlayerBrain(playerActor, 0);
   self:SetLandingZone(playerActor.Pos, 0);
   
   pl2 = CreateAHuman("Soldier Heavy");
   pl2.AIMode = Actor.AIMODE_SENTRY;
   pl2.Team = 0;
   pl2:AddInventoryItem(CreateHDFirearm("Pistol"));
   pl2.Pos = Vector(49,429);
   MovableMan:AddActor(pl2)

   playerActor = pl2;
   self:SetPlayerBrain(playerActor, 1);
   self:SetLandingZone(playerActor.Pos, 1);

Doesn't cause splitscreen to happen, but at least it gives the other guy to player 2.

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/