Jump to content
  • 0

PK (pvp) mode and ClaymoreTraps to hurt caster


OscarScorp

Question


  • Group:  Members
  • Topic Count:  62
  • Topics Per Day:  0.02
  • Content Count:  217
  • Reputation:   16
  • Joined:  01/28/15
  • Last Seen:  

Hello everyone,

 

I have a server with a working PK mode which enables the user to enter a mode where it can attack and be attacked by others users only if they also have the PK mode turned on.

This affects the entire server to have all maps with PvP flags.

 

Everything was fine until Quagmire and traps such as Claymore Trap also affects the caster, in which cases, leads to the user not even wanting to use the skill since it's a huge risk when leveling.

 

We have made some changes so skills such as Quagmire and Claymore Trap does not affect the caster, this may also happen within WoE/BG.

 

Problem is, Shadow Chaser-users who wish to use Manhole > Shadow Form > proceed to lay multiple Claymore Traps and step on them to deal damage to the target in the Manhole, won't be able to trigger the Claymore Traps with this protection.

 

What I would like to have is to change the code so the mines/quagmire can affect you, regardless if you are inside or outside of WoE/BG maps, only if you activate the PK mode. Meaning, if you have PK mode OFF, these traps/claymore won't affect you if you step on them.

Another alternative which can also work, is to change the code so it always affect you if you are in WoE/BG maps.

 

Code within skill.c

...
	case HT_CLAYMORETRAP:
	case HT_LANDMINE:
	case MA_LANDMINE:
...
	case RA_ICEBOUNDTRAP:
	case RL_B_TRAP:
		{
			struct skill_condition req = skill_get_requirement(sd,skill_id,skill_lv);
			ARR_FIND(0, MAX_SKILL_ITEM_REQUIRE, i, req.itemid[i] && (req.itemid[i] == ITEMID_TRAP || req.itemid[i] == ITEMID_TRAP_ALLOY));
			if( i != MAX_SKILL_ITEM_REQUIRE && req.itemid[i] )
				req_item = req.itemid[i];
			if( map_flag_gvg(src->m) || map[src->m].flag.battleground )
				limit *= 4; // longer trap times in WOE [celest]
			//if( battle_config.vs_traps_bctall && map_flag_vs(src->m) && (src->type&battle_config.vs_traps_bctall) )
			//	target = BCT_ALL;
		}
		break;

As you can see, there are two commented lines so the casters won't get affected by these skills. How can I change this so casters can affect themselves only in WoE/BG maps or only if PK mode is enabled?

 

This is my PK mode in my atcommand.c, taken from https://rathena.org/board/topic/65606-pk-mode-onoff/

ACMD_FUNC(playerkilling)
{
	nullpo_retr(-1, sd);
	
	if (!sd->state.pk_mode) {
	sd->state.pk_mode = 1;
	clif_displaymessage(sd->fd, "PK mode OFF. You're safe, for now...");
	} else {
	sd->state.pk_mode = 0;
	clif_displaymessage(sd->fd, "<Player Killing (PK) ON>");
	}
	return 0;
}
Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  62
  • Topics Per Day:  0.02
  • Content Count:  217
  • Reputation:   16
  • Joined:  01/28/15
  • Last Seen:  

Sorry for necroposting but for anyone looking to fix this, I made it work by creating a SC_PKMODE status just as benching mentioned. Thank you!

if( battle_config.vs_traps_bctall && (src->type&battle_config.vs_traps_bctall) && map_flag_vs(src->m) && sc && sc->data[SC_PKMODE])
			target = BCT_ALL;

I'm just wondering how can I detect if the player is in combat, to disable the toggle of PK mode to off. Not sure where to do that.

Nevermind, I also managed to fix this by adding:

if (battle_config.prevent_logout && DIFF_TICK(gettick(), sd->canlog_tick) < battle_config.prevent_logout)
				clif_displaymessage(sd->fd, "Cannot escape from PK Mode during combat! Please wait 10 seconds.");

Problem solved! ? Hope this helps anyone looking for the same issue.

Edited by OscarScorp
Cannot toggle during combat question
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  26
  • Topics Per Day:  0.01
  • Content Count:  350
  • Reputation:   43
  • Joined:  09/07/12
  • Last Seen:  

I'm not sure bout myself, if i understand you or not, but let me try to help.

 

This sounds like more work to do than ppl usually ask,

 

Here's a pseudo-code i have for this case,

 

Character

  1. Create new skill, name it TogglePKStatus or something like that
  2. Add error checking or check for pkstatus <or put this in the skill, its your call>
  3. if pkstatus is on, affect the character/player

btw, you can add a delay for the TogglePkStatus that resets every specific seconds after receiving damage;

Its gonna be annoying if player can switch off when in battle with other player.

 

i'm not sure if this last one could somehow help in performance, but you may want to just allow switching pk status if player is in town.

Edited by Eat Sleep Dota
  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  34
  • Topics Per Day:  0.01
  • Content Count:  386
  • Reputation:   38
  • Joined:  04/28/13
  • Last Seen:  

You want to do that those traps only afect you if you are in PK mode? ignoring pvp/bg/woe? ONLY PK?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  62
  • Topics Per Day:  0.02
  • Content Count:  217
  • Reputation:   16
  • Joined:  01/28/15
  • Last Seen:  

Thanks for the replies guys,

 

@Eat Sleep Dota,

I'm not too advanced on the C code, I call myself a newbie on it, meaning my skills go so far, like, I can create the skill but I have no idea how to attach it to a variable(?) to check for the PKstatus, therefore adding a line in the skill.c to check if the player is in this mode, making it able to receive damage from their own Claymore Traps.

 

About the timer reset on hit, that would be awesome but then again, I'm not too experienced with C code.

 

@Promise

I want the player to be able to receive damage from their own traps:

- Always on BG and WoE Maps, regardless of the PK mode being on/off.

- Outside these maps, only if the caster has PK mode on, meaning the player can have the mode OFF and receive no damage from their own traps if the user is outside BG and WoE maps.

 

* I would love to have it so it also affects PvP maps but since I've edited the script so it's PvP mode in the whole server, I'm not too sure if I can achieve this last part.

Edited by OscarScorp
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...