• Unfortunately, we have experienced significant hard drive damage that requires urgent maintenance and rebuilding. The forum will be a state of read only until we install our new drives and rebuild all the configurations needed. Please follow our Facebook page for updates, we will be back up shortly! (The forum could go offline at any given time due to the nature of the failed drives whilst awaiting the upgrades.) When you see an Incapsula error, you know we are in the process of migration.

Pokemmo PVP Development

Elite Diviner
Joined
Feb 27, 2012
Messages
446
Reaction score
46
Ok so i am working on a pvp script but i dont know javascript (well i do know the basics) so if somebody could help me debug/figure this out that would be great. One of the main things i need to figure out is how to send messages to the player being requested for a pvp match.

I am pretty sure the command works its the function that just needs to be finished. Also I still don't know how to use the database so that makes a bigger problem xD.

anyway here is my code so far:

Commands
Code:
if(str.indexOf("/reqpvp ") == 0 && pokemmo.Game.accountLevel >= 0) {
		pokemmo.Connection.socket.emit("pvpPlayer",{ username : str.substr("/reqpvp ".length)});
		pokemmo.Chat.resetChat();
		pokemmo.Main.jq(pokemmo.Main.onScreenCanvas).focus();
		return;
	}
	if(str.indexOf("/pvpreply ") == 0 && pokemmo.Game.accountLevel >= 0) {
		pokemmo.Connection.socket.emit("pvpAcceptDecline",{ username : str.substr("/pvpreply ".length)});
		pokemmo.Chat.resetChat();
		pokemmo.Main.jq(pokemmo.Main.onScreenCanvas).focus();
		return;
	}


Code:
if(client.accountLevel >= 0) client.socket.on("pvpPlayer",function(data) {
		pokemmo_s.GameServer.pvpPlayer(data.username);
	}
);
if(client.accountLevel >= 0) client.socket.on("pvpAcceptDecline",function(data) {
		pokemmo_s.GameServer.pvpPlayer(data.username);
	});

Function:
Code:
	var ispvp=false
pokemmo_s.GameServer.pvpAcceptDecline = function() {
	if (ispvp=true){
	return //something saying "This player is already being requested for pvp";
	}else{
	var $char = client.character;
	if (str.indexOf("accept")){
		return true;
	}else{
		return false;
	}
	}
}
pokemmo_s.GameServer.pvpPlayer = function(username) {
	if (ispvp=true){
	return ;//something saying "This player is already being requested for pvp";
	}else{
			//send a message about /pvpreply accept/decline

			while (x<=60000){
				x++;
				$char.ispvp=true;
				username.ispvp=true;
				if(pokemmo_s.GameServer.pvpAcceptDecline==false){
					$char.ispvp=false;
				        username.ispvp=false;
					x=60000;
				}else{			
				        //initiate battle with player, check who wins and display instance announcement
				}
			} 
		$char.ispvp=false;
		username.ispvp=false;
		client.character.restorePokemon();
	}
}

I was also trying to add a check to keep players with extremely high lvl pokemon battle players with low levels but i am like 90% sure i completely got that wrong xD:
Code:
	var $char = client.character;
		var mypvplevel=$char.pokemon[0].level+$char.pokemon[1].level+$char.pokemon[2].level+$char.pokemon[3].level+$char.pokemon[4].level+$char.pokemon[5].level;
		var theirpvplevel=username.pokemon[0].level+username.pokemon[1].level+username.pokemon[2].level+username.pokemon[3].level+username.pokemon[4].level+username.pokemon[5].level
 
Last edited:
Skilled Illusionist
Joined
Aug 5, 2008
Messages
377
Reaction score
33
Looks like it has potential, you want a PvP System for 6vs6 pokemon?
Did you code the switch fainted pokemon function?

Hope you make it work :p
 
Elite Diviner
Joined
Feb 27, 2012
Messages
446
Reaction score
46
right now im trying to get a 1v1 pvp system to work, ill work on multiple pokemon after. currently writing the accept/decline command its probally gonna be /pvpreply accept or decline
 
Elite Diviner
Joined
Feb 27, 2012
Messages
446
Reaction score
46
would that just be something like
Code:
}
   	client.character.restorePokemon();
		}else{[code]
or do i need any parameters or anything?
 
Experienced Elementalist
Joined
May 28, 2012
Messages
289
Reaction score
51
A Git Repository is setted up by bitou, here's the Link:
I think he'll upload his PokeRPG tomorrow, so everyone can upload his fixes and changes to this git.

@hamisgood87: Great work!
 
Newbie Spellweaver
Joined
Apr 30, 2013
Messages
42
Reaction score
9
I've checked the source some and there are already some adjustments based on PvP if I'm correct. They just need to be called and some functionality has to be coded, but that can be done based on "BattleWild"
 
Back
Top