Gametype

Have a question about modding, modelling or skinning? Have a tutorial to post? Post here!

Moderator: Core Staff

Post Reply
LikeAMutter
CJ Wannabe
CJ Wannabe
Posts: 11
Joined: March 24th, 2013, 6:39 pm

Gametype

Post by LikeAMutter » March 25th, 2013, 7:33 pm

Hey, i've been trying to make a gametype for my mod, and its not going as planned...

I've made a copy of the dm gametype, so you can Start a new server with it on any map, and you can play it.

But if i edit it, for example:

Original:

Code: Select all

if(isPlayer(attacker))
        {
                              
                if(attacker == self) // killed himself
                {
                        doKillcam = false;
 
                        attacker.score--;
 
                        
                }
                else
                {
                        attackerNum = attacker getEntityNumber();
                        doKillcam = true;
 
                        attacker.score++;
                        attacker checkScoreLimit();
                }
Edited:

Code: Select all

if(isPlayer(attacker))
        {
if (self.pers["team"] == "allies")
                        {
                                if (Number_On_Team("axis") < 1)
                                        self thread respawn("auto");
                                else
                                {
                                        self move_to_axis();
                                CheckAllies_andMoveAxis_to_Allies(undefined, self);
                                        self thread respawn();
                                }
                }
                              
                if(attacker == self) // killed himself
                {
                        doKillcam = false;
 
                        attacker.score--;
 
                        
                }
                else
                {
                        attackerNum = attacker getEntityNumber();
                        doKillcam = true;
 
                        attacker.score++;
                        attacker checkScoreLimit();
                }
And that's my biggest attempt of change so far..

I've been thinking on a mod, 1 vs all, but the lonely 1 player got more health and stuff like that.

Does anyone know where you can learn this?
I know the basics of C++, and i've been trying to mess around with the gametype, but all my changes just gives me a script compiler error when i try to launch it.

Thank you so much in advance :/
Last edited by Anonymous on March 25th, 2013, 7:42 pm, edited 1 time in total.
Reason: Added [code=cod] to make it easier to read :)

megazor
CJ Worshipper
CJ Worshipper
Posts: 414
Joined: July 22nd, 2009, 3:02 am
Location: Russia, Vladivostok

Re: Gametype

Post by megazor » March 26th, 2013, 3:55 am

This part is wrong:

Code: Select all

 self move_to_axis();
CheckAllies_andMoveAxis_to_Allies(undefined, self);
self thread respawn(); 
It's a piece of bel.gsc - a script file of a cod1 gametype Behind Enemy Lines.
That file has its own functions, which are not defined in dm.gsc (on which you based your gametype). You should bring all necessary functions from bel.gsc to your file.

And another thing, move_to_axis() will spawn an axis player. So, using respawn() after that is a mistake.

LikeAMutter
CJ Wannabe
CJ Wannabe
Posts: 11
Joined: March 24th, 2013, 6:39 pm

Re: Gametype

Post by LikeAMutter » March 26th, 2013, 1:50 pm

Yeah, i see now, thanks ;)

How did you learn scirpting..? just being curious :)

megazor
CJ Worshipper
CJ Worshipper
Posts: 414
Joined: July 22nd, 2009, 3:02 am
Location: Russia, Vladivostok

Re: Gametype

Post by megazor » March 26th, 2013, 3:28 pm

Mainly by thoughtfully reading various .gsc files and trying, like you are now. It is likely 90% of what made my current knowledge, the rest 10% is tutorials and conversations with experienced modders.

LikeAMutter
CJ Wannabe
CJ Wannabe
Posts: 11
Joined: March 24th, 2013, 6:39 pm

Re: Gametype

Post by LikeAMutter » March 26th, 2013, 3:43 pm

Alright thanks =)

Umm...if its ok, may i add you on xfire, in case i need some help..? :)

megazor
CJ Worshipper
CJ Worshipper
Posts: 414
Joined: July 22nd, 2009, 3:02 am
Location: Russia, Vladivostok

Re: Gametype

Post by megazor » March 26th, 2013, 4:01 pm

mega9317

LikeAMutter
CJ Wannabe
CJ Wannabe
Posts: 11
Joined: March 24th, 2013, 6:39 pm

Re: Gametype

Post by LikeAMutter » March 26th, 2013, 7:25 pm

Is there any way to check a players origin, and if it's not moving for an amount of time, it change a boolean to true ,or smth like that? and, is there a site/book, with all of theese commands? :D

LikeAMutter
CJ Wannabe
CJ Wannabe
Posts: 11
Joined: March 24th, 2013, 6:39 pm

Re: Gametype

Post by LikeAMutter » March 26th, 2013, 8:04 pm

Woah, thank you sam, been looking forever to find a site like that <3

thx :DD

LikeAMutter
CJ Wannabe
CJ Wannabe
Posts: 11
Joined: March 24th, 2013, 6:39 pm

Re: Gametype

Post by LikeAMutter » March 26th, 2013, 8:36 pm

Yeah, i've been experimenting a bit, and none of the code has worked sofar, but im still hoping lol ;)

And your scrip i tried too:

Code: Select all

CheckMove()
{
playerMoved = false;
lastOrigin = self.origin;
while(playerMoved == false){
       wait(10);
       if (lastOrigin != self.origin){
            playerMoved = true;
			}
       }
I open CoDMP, click "Start New Server", pick my gametpye and map, and turn pure=no.

Then i get the error:
"Script compiler error"
"Check the console for details."

I check the console, and the only thing it says is: Error:Bad syntax


So it's not that much help from the console :/


i also tried changing player.origin to self.origin, but it didnt make any diffrence..

Well, im gonna keep experimenting and hope for the best :/

Thanks.


Yeah, and also, i tried this code:

Code: Select all

UnkillablePl()
{
if([team] == "axis"){

while(1)
{
wait 5;
iprintln("Godmode is ON");
self.god = true;
wait 10;
iprintln("Godmode is OFF");
self.god = false;
wait 5;
}
}
}
And then, in the beginning of main() i add: thread UnkillablePl();



What am i doing wrong..? :/

This feels kinda bad..^^

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Gametype

Post by Drofder2004 » March 26th, 2013, 9:27 pm

Type "developer 1" in console, before starting server. Open the console, the error and line will be displayed. Sometimes syntax errors are from the previous line.

To be able to interact with players in multiplayer, you must first determine all the players that exist (level.player = singleplayer).

".god" is not a valid member. God mode is a built in function - there are two ways to stop damage (or dying).
1. Increase the health of the player (self.health = 9999)
2. Modify the playerDamage callback to ignore damage to a certain player.

I have not checked the following code and I haven't coded properly in a while, but this should work to cover the basics of a no-move script.

Code: Select all

main()
{
   // set a global variable for duration until camping
   level.campTime = 10;
 
   // get all current players
   players = getEntArray("player", "classname");
 
   // Create a loop and run a function on each individual player
   for(i=0;i<players.size;i++)
      players[i] checkMove();
}
 
checkMove()
{
   // player[i] is now set to the variable "'self'
   // Create an infinite loop - to continuously check the movement
   while(1)
   {
      // place a flag/member on the player
      self.camping = false;
 
      // record current position
      self.oldOrigin = self.origin;
 
      // create a temporary counter
      count = 0;
 
      // create a loop to 'wait' while the origin does not change
      // when origin changes, loop will end
      while(self.origin == self.oldOrigin)
      {
         // check counter for duration not moving
         if(count > level.campTime)
         {
            // player is camping
            self.camping = true;
 
            // Debug print, to check it is working.
            iprintln("Player: " + self.name + "^7 is camping.");
         }
 
         // tick counter and wait
         count++;
         wait 1;
      }
 
      // end loop and reset flag
   }
}
If you are editing a gametype, then instead of placing "function();" inside the code, you should write the code directly into the existing code (vCoD is not very efficiently coded in comparison to CoD4).

If you find "callback_PlayerConnect()", then scroll to the last "}" for that function.
Just before the "}", add "self checkMove();". And then ignore the whole "main()" and just use the checkMove() function.
You will however need to add "level.campTime" inside the existing "main()".
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

LikeAMutter
CJ Wannabe
CJ Wannabe
Posts: 11
Joined: March 24th, 2013, 6:39 pm

Re: Gametype

Post by LikeAMutter » March 27th, 2013, 7:50 am

I actually i think i got it to work :DDD


I also created a colt45 skin to have to my gamemode, i created it in photoshop, its a .dds with DXT5 and Generate MIP maps.

I have it in a folder called "skins" in my .pk3, and the file itself is called: metal@weapon_colt45.dds
and i aslo added another file called: viewmodel@weapon_colt45.dds


But nothing works in game,but when i download skins they works great, they have their .pk3 setup as i, but mine doesnt show ingame :/

I kinda need this for the mod and gametype itself :)

I understand if i've already asked for too much..

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Gametype

Post by Drofder2004 » March 27th, 2013, 1:03 pm

I don't do modeling/skinning, try modsonline.com for a tutorial.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

LikeAMutter
CJ Wannabe
CJ Wannabe
Posts: 11
Joined: March 24th, 2013, 6:39 pm

Re: Gametype

Post by LikeAMutter » March 27th, 2013, 2:52 pm

i did, but my texture wont show ingame :/

LikeAMutter
CJ Wannabe
CJ Wannabe
Posts: 11
Joined: March 24th, 2013, 6:39 pm

Re: Gametype

Post by LikeAMutter » March 27th, 2013, 6:51 pm

Alright, the texture work now, i somehow made it x)

Any inbuild function to check if, for example if team (allies) > 0, then you cant join team/auto assigned to axis?

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Gametype

Post by Drofder2004 » March 28th, 2013, 9:24 pm

Auto-Assign Script.
vCoD did not have built in function for it, but newer games do.
This is how the CoD checks team count.

Code: Select all

if(response == "autoassign")
{
        numonteam["allies"] = 0;
        numonteam["axis"] = 0;
 
        players = getentarray("player", "classname");
        for(i = 0; i < players.size; i++)
        {
                player = players[i];
        
                if(!isdefined(player.pers["team"]) || player.pers["team"] == "spectator" || player == self)
                        continue;
 
                numonteam[player.pers["team"]]++;
        }
        
        // if teams are equal return the team with the lowest score
        if(numonteam["allies"] == numonteam["axis"])
        {
                if(getTeamScore("allies") == getTeamScore("axis"))
                {
                        teams[0] = "allies";
                        teams[1] = "axis";
                        response = teams[randomInt(2)];
                }
                else if(getTeamScore("allies") < getTeamScore("axis"))
                        response = "allies";
                else
                        response = "axis";
        }
        else if(numonteam["allies"] < numonteam["axis"])
                response = "allies";
        else
                response = "axis";
}
 
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 3 guests