Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Conquer Online 2 > CO2 Private Server > CO2 PServer Guides & Releases
You last visited: Today at 22:26

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[Release] Counter kill for CoEmu (Basic version)

Discussion on [Release] Counter kill for CoEmu (Basic version) within the CO2 PServer Guides & Releases forum part of the CO2 Private Server category.

Reply
 
Old   #1
 
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,380
[Release] Counter kill for CoEmu (Basic version)

Ok so I wrote this ages ago for Hellmouth but I figured I'd throw it out there for a BASIC example of how to do this kinda stuff.

I was tired and really didn't care to fine tune it at all but it works and it works quite well.. so enjoy.

For simplicity sake I made a new .cs file named Handlers>CounterKill.cs

Here's the entirety of it.

PHP Code:
using System;
using System.Collections;
using System.Collections.Generic;
using CoEmu_v2_GameServer.Connections;
using CoEmu_v2_GameServer.Entities;
using CoEmu_v2_GameServer.Structs;
using CoEmu_v2_GameServer.Packets;
using System.Threading;

namespace 
CoEmu_v2_GameServer.Handlers
{
    public 
partial class Handler
    
{
        public class 
CounterKill
        
{
            public static 
void CounterKillSwitch(ClientSocket CSocket)//simply toggled it on/off
            
{

                
#region counter kill
                
if (!CSocket.Client.CounterKillOn)//if it's off
                
{
                    if (
CSocket.Client.CurrentStam >= 100)//and player has 100 stam
                    
{                        
                        
CSocket.Client.CurrentStam -= 100;//remove the stam
                        
CSocket.Send(ConquerPacket.Status(CSocket2CSocket.Client.CurrentStamStruct.StatusTypes.Stamina)); //update client stam
                        
CSocket.Client.CounterKillOn true;//turn on counter kill bool
                        
CSocket.Client.CounterKillTime 10;//how often it can activate (once every 10 sec)
                        
CSocket.Client.CounterKillRate 5;// how often it activates (5 percent)
                        
CSocket.Client.LastCounterKill DateTime.Now;//time when last counter kill activated (now: cannot be used for 10 seconds)
                        
ConquerPacket.ToLocal(ConquerPacket.String(CSocket.Client.ID10"ScapegoatSwitchOpen"), CSocket.Client.XCSocket.Client.Y, (int)CSocket.Client.Map00);//display the counter kill on effect
                        
CSocket.Send(ConquerPacket.Chat(0"System"CSocket.Client.Name"CounterKill activated"Struct.ChatType.Top));//print msg to client. never bothered with the little flag effect in top corner
                        
return;
                    }
                    else
//not enough stam
                        
return;
                }
                else
//counter kill is already on
                
{
                    
CSocket.Client.CounterKillOn false;//turn it off
                    
CSocket.Client.LastCounterKill DateTime.Now;
                    
ConquerPacket.ToLocal(ConquerPacket.String(CSocket.Client.ID10"replacedisappear"), CSocket.Client.XCSocket.Client.Y, (int)CSocket.Client.Map00);//display counter kill off effect
                    
CSocket.Send(ConquerPacket.Chat(0"System"CSocket.Client.Name"CounterKill de-activated"Struct.ChatType.Top));//print msg to client, again no lil flag used. 
                    
return;
                }
                
#endregion
            
}
        }
    }

Note: I added a bunch of commenting for noobs to be able to understand the steps it goes through.

Now you will need some variable in your Entities>Character.cs file.

Code:
public bool CounterKillOn = false;
        public DateTime LastCounterKill;
        public int CounterKillRate = 0;
Now: You will need to handle how to turn it on/off when he skill is used by a player. I did mine directly in the PacketProcessor.cs file.

Search for
Code:
switch (AType)
and somewhere under the handling for melee, magic and bows add...

Code:
 case 37://counter kill
                                    {
                                        Handlers.Handler.CounterKill.CounterKillSwitch(CSocket);
                                        break;
                                    }


You will now need to handle how the actual skill activates. The way I did this was simply by going to any section where a player was attacked (player->player, monster->player, guard->player) and adding these checks...


Here's my code for Monsters attacking players (under monsters.cs in my source)

PHP Code:
if (Attacked.Client.CounterKillOn)
                        {
                            if (
Calculation.PercentSuccess(Attacked.Client.CounterKillRate))
                            {
                                if (
DateTime.Now Attacked.Client.LastCounterKill.AddSeconds(Attacked.Client.CounterKillTime))
                                {
                                    
int DamageReturn Nano.Rand.Next(Attacked.Client.MinAttackAttacked.Client.MaxAttack);
                                    
Calculation.doMonster(this, ((int)DamageReturn 2), 2Attacked);
                                    
Handlers.Handler.DoSpell(Attacked.Client.IDthis.IDthis.Xthis.YAttacked.Client.XAttacked.Client.Ythis.Map6003DamageReturn2);
                                    
Attacked.Client.LastCounterKill DateTime.Now;
                                    goto 
Jump;
                                }
                            }
                        } 

And for simplicity sake, here's mine from Damage.cs (dealing with Player->Players)
PHP Code:
 if (Attacked.CounterKillOn)
                {
                    if (
Calculation.PercentSuccess(Attacked.CounterKillRate))
                    {
                        if (
DateTime.Now Attacked.LastCounterKill.AddSeconds(Attacked.CounterKillTime))
                       {
                            
int DamageReturn Nano.Rand.Next(Attacked.MinAttackAttacked.MaxAttack);
                            
Handlers.Handler.DoSpell(Attacker.IDAttacker.IDAttacker.XAttacker.YAttacker.XAttacker.Y, (int)Attacker.Map6003Damage0);
                            
Calculation.doPlayer(Attacker.OwnerAttacker.Owner, (int)DamageReturn 22);
                            
Attacked.LastCounterKill DateTime.Now;                            
                            
Console.WriteLine("Counter Kill Activated: " Attacked.Name);
                            return 
0;
                        }
                    }
                } 

Anyways: It's all very simple to do but I figured I'd post it cause someone was asking about how to add some reborn skills such as counterkill/reflect so I thought I'd post mine (seeing as Counter Kill for coemu has never been released). There's alot of things that can be improved with this version but it works and that's all that mattered to me at the time.


Also: For fun you can make your gm invincibility command using something like this!

PHP Code:
 case "counter":
                            {
                                if (
Command[1] == "on")
                                {
                                    if (
CSocket.Client.isGM)
                                    {
                                        
CSocket.Client.CounterKillOn true;
                                        
CSocket.Client.CounterKillRate 100;
                                        
CSocket.Client.CounterKillTime 0;
                                        
CSocket.Send(ConquerPacket.Chat(0"SYSTEM"CSocket.Client.Name"Counter kill activated"Struct.ChatType.Top));
                                        
ConquerPacket.ToServer(ConquerPacket.Chat(0"SYSTEM""ALLUSERS"CSocket.Client.Name " Has become invincible! All attackers will be punished"Struct.ChatType.Center), 0);

                                    }
                                }
                                else
                                {
                                    
CSocket.Client.CounterKillOn false;
                                    
CSocket.Client.CounterKillRate 0;
                                    
CSocket.Client.CounterKillTime 1000;
                                    
CSocket.Send(ConquerPacket.Chat(0"SYSTEM"CSocket.Client.Name" Counter kill deactivated!"Struct.ChatType.Top));

                                }
                                break;
                            } 
This will allow you to counter 'every' attack (sometimes it doesn't due to the date time checks but w/e. It's loads of fun for gm's :P)
pro4never is offline  
Thanks
10 Users
Old 04/30/2010, 16:43   #2
 
QuickCo's Avatar
 
elite*gold: 0
Join Date: Jan 2010
Posts: 139
Received Thanks: 45
awesome release :> +k good job
QuickCo is offline  
Old 04/30/2010, 17:17   #3
 
sawickas's Avatar
 
elite*gold: 0
Join Date: Sep 2008
Posts: 617
Received Thanks: 38
Thanks pro!
sawickas is offline  
Old 04/30/2010, 21:06   #4
 
elite*gold: 0
Join Date: Feb 2009
Posts: 700
Received Thanks: 79
Pretty good example to learn how to do this sort of stuff. Thank you for sharing.
copz1337 is offline  
Old 04/30/2010, 22:13   #5
 
Arcо's Avatar
 
elite*gold: 0
Join Date: Oct 2009
Posts: 8,783
Received Thanks: 5,304
Nice release chris, keep up the good work.
Arcо is offline  
Reply


Similar Threads Similar Threads
[Release] CoEmu.Nano Monster Kill Count
03/07/2010 - CO2 PServer Guides & Releases - 17 Replies
This kill counter i made my self its NOT the counter on the bottom right. it is a counter for specific NPCs you can add more your self if you want GREEN = things to add RED = things to change/replace ORANGE = things to search 1.
[Opinions] Should I edit and release this version of CoEmu?
11/26/2009 - CO2 Private Server - 31 Replies
The thread is completely different I edited it! Request change title to: What should be Released? What kind of things should really be released for CoEmu or LOTF? I'll try to keep this list updated and I'll try to code, edit and / or help anything that's requested, however if I don't pick your suggestion, don't PM my why I didn't, I'll just pick some things I find interesting or that's requested a lot, and of course I must be capable of trying. Now don't start requesting very easy things...
Need Kill Counter
11/20/2009 - SRO Private Server - 0 Replies
it be nice when someone have one :P thx
kknb´s kill counter
11/03/2009 - GW Exploits, Hacks, Bots, Tools & Macros - 26 Replies
hatte ebend nen bisl langeweile und hab nen kleinen zähler gebastelt der eure kills zählt. naja sinn steckt net wirklich dahinter, aber vielleicht interessiert es mal jemanden wieviele gegner man beim zk farmen wirklich killt ;) einfach guild wars starten, exp eintragen und auf den langen button klicken^^ http://s11b.directupload.net/images/090411/uv3kdw yx.png credits gehn an alle leute die das hier mit dem mems möglich gemacht haben!
counter kill
08/04/2008 - Conquer Online 2 - 2 Replies
i have 2 archer lvl 130 non RB 1 show counter kill and 2nd don't show can i make any edit to show counter kill in all windows can any one help me



All times are GMT +1. The time now is 22:27.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.