AnnieRuru 957 Posted October 30, 2015 (edited) yesterday @@Aeromesi asked in IRC about is there a script commands to prevent the player to attack makes me remember I did something similar before https://rathena.org/board/topic/91115-event-watcher/?p=238849 yes, we really need to have these script commands *pcblockmove has already existed for ages, which meant for block players from moving but we are missing out commands to block players from attacking and chat . . I made this patch http://upaste.me/870121811d11a19ff it looks clean I think this should go inside hercules as default EDIT: tested with prontera,154,185,5 script can attack 1_F_MARIA,{ pcblockattack getcharid(3), 0;}prontera,157,185,5 script no attack 1_F_MARIA,{ pcblockattack getcharid(3), 1;}prontera,154,181,5 script can chat 1_F_MARIA,{ pcblockchat getcharid(3), 0;}prontera,157,181,5 script no chat 1_F_MARIA,{ pcblockchat getcharid(3), 1;}prontera,154,177,5 script vulnerable 1_F_MARIA,{ pcimmune getcharid(3), 0;}prontera,157,177,5 script immune 1_F_MARIA,{ pcimmune getcharid(3), 1;}prontera,154,173,5 script can skill 1_F_MARIA,{ pcblockskill getcharid(3), 0;}prontera,157,173,5 script no skill 1_F_MARIA,{ pcblockskill getcharid(3), 1;}.EDIT2: *pcimmune is equivalent to @monsterignore I just don't like using *atcommand in scripts Edited October 30, 2015 by AnnieRuru 2 evilpuncker and Alexandria reacted to this Quote Share this post Link to post Share on other sites
GmOcean 92 Posted October 30, 2015 (edited) I like this. It would be useful in a number of situations. Such as event and utility scripts. Edited October 30, 2015 by GmOcean Quote Share this post Link to post Share on other sites
Aeromesi 180 Posted October 30, 2015 I also converted "@damageignore" that's an atcommand in rAthena into the Hercules source (just renamed clif_displaymessage(fd,) to clif_message->)It works as intended, like you can't hit mob or use skills or you can when activated. it says it Fails but it really doesn't.Anyone else that wants '@damageignore' just do this to your src:../src/map/atcommand.c Under ACMD_DEF(lang), Add: ACMD_DEF(damageignore), and Under ACMD(lang) { uint8 i; if( !message || !*message ) { clif->messages(fd,"Usage: @%s <Language>",info->command); clif->messages(fd,"There are %d languages available:",script->max_lang_id); for(i = 0; i < script->max_lang_id; i++) clif->messages(fd,"- %s",script->languages[i]); return false; } for(i = 0; i < script->max_lang_id; i++) { if( strcmpi(message,script->languages[i]) == 0 ) { if( i == sd->lang_id ) { clif->messages(fd,"%s is already set as your language",script->languages[i]); } else { clif->messages(fd,"Your language has been changed from '%s' to '%s'",script->languages[sd->lang_id],script->languages[i]); sd->lang_id = i; } break; } } Add: /*========================================== // Small fix for Herc by: Aeromesi * @damageignore * => Makes any attack or skill by user to receiver miss. * PS: It will say "@damageignore Failed." * but the output will say you are now unable to use skills or attacks vise verca *------------------------------------------*/ACMD(damageignore){ nullpo_retr(-1, sd); if (!sd->state.damage_ignore) { sd->state.damage_ignore = 1; clif->messages(fd, "You are now unable to use skills or attacks."); } else { sd->state.damage_ignore = 0; clif->messages(fd, "You are now allowed to use skills or attacks."); } return 0;} Quote Share this post Link to post Share on other sites
Gerz 7 Posted October 31, 2015 (edited) @@AnnieRuru how about this? /** * pcblock <account_id>, <value>, <type> * <value>: 1 = on, 0 = off * <type> can be: * 0 = block move * 1 = block attack * 2 = block skill * 3 = block chat * 4 = immune attack **/BUILDIN(pcblock) { int id, flag, type; TBL_PC *sd = NULL; id = script_getnum(st,2); flag = script_getnum(st,3); type = script_getnum(st,4); if( id ) sd = map->id2sd(id); else sd = script->rid2sd(st); switch( type ) { case 0: sd->state.blockedmove = flag > 0; break; case 1: sd->state.blockedattack = flag > 0; break; case 2: sd->state.blockedskill = flag > 0; break; case 3: sd->state.blockedchat = flag > 0; break; case 4: sd->state.monster_ignore = flag > 0; break; } return true;} BUILDIN_DEF(pcblock,"iii"), Edited October 31, 2015 by Gerz 1 AnnieRuru reacted to this Quote Share this post Link to post Share on other sites
Emistry 145 Posted October 31, 2015 about Gerz method, just thinking how about make it into support bitmask ? * 1 = block move * 2 = block attack * 4 = block skill * 8 = block chat * 16 = immune attack we can block several state at once. With these you can update these states at once without need to call the script command for multiple times ? btw, can make us of const.txt to support constants usage for better readability.Example : BLOCK_MOVE | BLOCK_ATTACK | BLOCK_SKILL | BLOCK_CHAT Example Usage : // to enable blockpcblock 2000000, BLOCK_MOVE , true;pcblock 2000000, BLOCK_MOVE | BLOCK_ATTACK | BLOCK_SKILL , true;// to disable blockpcblock 2000000, BLOCK_MOVE , false;pcblock 2000000, BLOCK_MOVE | BLOCK_ATTACK | BLOCK_SKILL , false; then we can deprecate the pcblockmove Quote Share this post Link to post Share on other sites
AnnieRuru 957 Posted October 31, 2015 (edited) I was already started this before I saw emistry post http://upaste.me/73e3218206ebac76e the problem though, is I saw a topic about a list of configuration to disallow players to do specific actions in hercules suggestion section before yes, I'm talking about adding BLOCK_STORAGE BLOCK_SENDMAIL BLOCK_EQUIPMENT BLOCK_USEITEM BLOCK_.... PLEASE_SUGGEST_MORE @@Emistry no, KEEP the *pcblockmove for god sake I used this command since eathena period and I'm sure you can google search 'annieruru pcblockmove', a lot gvg and battleground script pops up after giving a lot of thought, I have to list them out and gives a proper reason for which one should be add, and which one should deny BLOCK_MOVE => its a must - keep the pcblockmove for backward compatibility, but add this in for a better management control BLOCK_ATTACK => its a must BLOCK_SKILL => its a must - I don't like using OPTION_XMAS or SC_XMAS to prevent the player to attack/skill, need a proper script command BLOCK_CHAT => its a must - I don't like using SC_BERSERK to prevent player to chat, need a proper script command BLOCK_IMMUNE => its a must - I don't like using atcommand "@monsterignore" in scripts, it will create unnecessary log BLOCK_USEITEM => look like a must - although I have a noitem mapflag to do the same, but preventing player to attack, then skill, its logical to prevent item next BLOCK_STORAGE => redundant - already have nostorage mapflag errr .... BLOCK_SENDMAIL => no... - the idea is that, some private server has a special map where players can try out godly item in a closed, nowarp+nowarpto map however there is an exploit where players can send item away into another account using friend list-> send mail I will make a pull request to prevent this exploit by adding a battle config BLOCK_EQUIPMENT => no... - doesn't make sense, should use map_zone_db.conf or my noitem mapflag BLOCK_TELEPORT => no.. - already have noteleport mapflag BLOCK_SITSTAND => looks ok - we have script command *sit, *stand and *issit(), means we can actually script it to make the player sit, then pcblocksit to prevent them standing up BLOCK_VENDING => no .. - already has novending mapflag and cell_novending BLOCK_TRADING => no... - I think *getitembound already make this useless. - Since the special created item for event is already bound, there is no way for them to trade anymore BLOCK_PICKITEM => maybe... - not sure about this one brainstorming ... Edited October 31, 2015 by AnnieRuru Quote Share this post Link to post Share on other sites
Emistry 145 Posted October 31, 2015 if you want ... BLOCK_SKILL BLOCK_COMMAND BLOCK_DROP BLOCK_ATCOMMAND BLOCK_GSTORAGE BLOCK_NOIDEAWHATELSETOPOSTHERE i just random post..O_O about this part + unsigned int blockedattack :1;+ unsigned int blockedskill :1;+ unsigned int blockedchat :1; how about just make use only one variable and store all the enum value since it's bitmask ?? with this, we can easily create another script command that get all the blocked state. Example : if ( getpcblock() & BLOCK_MOVE ) { mes "your movement is still blocked.";} 1 AnnieRuru reacted to this Quote Share this post Link to post Share on other sites
AnnieRuru 957 Posted October 31, 2015 (edited) current formathttp://upaste.me/c7ed2182125d6a31balready tested with - script sdfhdskfj FAKE_NPC,{OnInit: bindatcmd "@pcblock", strnpcinfo(0)+"::Onaaa"; setarray .name$, "BLOCK_MOVE", "BLOCK_ATTACK", "BLOCK_SKILL", "BLOCK_USEITEM", "BLOCK_CHAT", "BLOCK_IMMUNE", "BLOCK_SITSTAND"; setarray .flag$, " [^ff0000OFF^000000]", "[^0000ffON^000000]"; end;Onaaa: for ( .@i = 0; .@i < 7; .@i++ ) .@menu$ = .@menu$ + .name$[.@i] + .flag$[ !!( checkpcblock() & (1 << .@i) ) ] +":"; .@s = select( .@menu$ ) -1; pcblock 1 << .@s, !( checkpcblock() & (1 << .@s) ); close;} .BLOCK_COMMAND !!omg how can I miss this one, need this one asapthe rest are redundantBLOCK_ATCOMMAND- repeated ???BLOCK_DROP- already has nodrop mapflagBLOCK_GSTORAGE- I seriously think this should belongs to nostorage mapflagima thinking of making oneBLOCK_NOIDEAWHATELSETOPOSTHEREhmm ... this long name makes me google 'what is the longest identifier in c++'answer is 2048 -> https://msdn.microsoft.com/en-us/library/565w213d.aspx.. how about just make use only one variable and store all the enum value since it's bitmask ?? I actually thought about thisbut the blockedmove and monster_ignore is quite everywhere in the source ... don't feel like touching them with this, we can easily create another script command that get all the blocked state. ima thinking of changing checkpcblock into getpcblock after 2nd thought, I change them 1st then see how Haru react to it Edited October 31, 2015 by AnnieRuru 2 Emistry and Huitzilopotchli reacted to this Quote Share this post Link to post Share on other sites