MSDP Script: Difference between revisions

From Dyrdex.com
Jump to navigation Jump to search
No edit summary
No edit summary
Line 114: Line 114:
         #UNVARIABLE {msdp_info[OPPONENT_HEALTH]};
         #UNVARIABLE {msdp_info[OPPONENT_HEALTH]};
         #UNVARIABLE {msdp_info[OPPONENT_LEVEL]};
         #UNVARIABLE {msdp_info[OPPONENT_LEVEL]};
#VAR {fighting} {0};
     };
     };
     #ELSEIF {"%0" == "OPPONENT_NAME" && "%1" != ""} {
     #ELSEIF {"%0" == "OPPONENT_NAME" && "%1" != ""} {
#VARIABLE {msdp_info[OPPONENT_NAME]} {%1};
#VARIABLE {msdp_info[OPPONENT_NAME]} {%1};
#VAR {fighting} {1};
     };
     };
     #ELSEIF {"%0" == "OPPONENT_LEVEL" && "%1" == "0"} {
     #ELSEIF {"%0" == "OPPONENT_LEVEL" && "%1" == "0"} {

Revision as of 18:47, 7 November 2022

Copy the full code below into a file, named like msdp.tin perhaps

Trigger or manually do #read msdp.tin upon starting your new session to the mud, or at the welcome screen.

This creates a nest of vars under $msdp_info. Affects and Room Exits are sub-nests:

Show all vars:    #var msdp_info
Show one var:     #var msdp_info[HEALTH]
Show affects:     #var msdp_info[AFFECTS]

Use these in your code like:

#IF {"$msdp_info[CLASS]" == "Thief"} {say I'm a Thief};
#IF {!&{msdp_info[AFFECTS][sanctuary]} {q sanc basket};
#IF {$msdp_info[OPPONENT_HEALTH] < 10} {say I've got you now!}

Code


#CLASS {MSDP} {OPEN}

#NOP -- For usage: realmsofdespair.com 4000;
#NOP -- Saves MSDP data to $msdp_info;
#NOP -- Based on Mitik's plugin. I stripped out a ton of non-functional non-essential code; 
#NOP -- Should 'just work' provided you read this file and then connect to the mud;

#NOP -- Alias to manually force msdp update from server:  "msdp_report"

#NOP -- Bugs;
#NOP --  1. AREA_NAME not received upon login sometimes (realms skips or maybe reports too fast for tintin to catch?);
#NOP        moving one room will get it;


#NOP --Debugging;
#CONFIG {debug telnet} {off};


#FORMAT {IAC}  {%a} {255};
#FORMAT {DONT} {%a} {254};
#FORMAT {DO}   {%a} {253};
#FORMAT {WONT} {%a} {252};
#FORMAT {WILL} {%a} {251};
#FORMAT {SB} {%a} {250};
#FORMAT {SE} {%a} {240};
#FORMAT {MSDP} {%a} {69};
#FORMAT {VAR} {%a} {01};
#FORMAT {VAL} {%a} {02};

#VARIABLE {msdp_reportable_variables} {{CHARACTER_NAME};{RACE};{CLASS};
   {PLAYER_COUNT};{ROOM_TERRAIN};{PLAYERS_PEAK};{PLUGIN_ID};{ROOM_VNUM};
   {SERVER_ID};{SERVER_TIME};{SOUND};{UTF_8};{XTERM_256_COLORS};
   {HEALTH_MAX};{HEALTH};{MANA_MAX};{MANA};{MOVEMENT_MAX};{MOVEMENT};
   {EXPERIENCE_MIN};{EXPERIENCE_MAX};{EXPERIENCE};{BLOOD};{LEVEL};
   {HITROLL};{DAMROLL};{AC};{STR};{INT};{WIS};{DEX};{CON};{CHA};{LCK};
   {STR_PERM};{INT_PERM};{WIS_PERM};{DEX_PERM};{CON_PERM};{CHA_PERM};
   {LCK_PERM};{ALIGNMENT};{AFFECTS};{FAVOR};{WIMPY};{WEIGHT};{WEIGHT_MAX};
   {PRACTICE};{MONEY};{ROOM_EXITS};{AREA_NAME};{ROOM_NAME};{WORLD_TIME};
   {AUCTION};{GEO};{AUTOSAC};{FLYING};{VIS};{COMBAT_STYLE};{OPPONENT_NAME};
   {OPPONENT_HEALTH};{OPPONENT_LEVEL};{WAIT_TIME};{ANSI_COLORS};{MXP};};

#ALIAS {msdp_report} {
    #VARIABLE {result} {$IAC$SB$MSDP${VAR}REPORT};
    #FOREACH {*msdp_reportable_variables[]} {tmp} {
        #VARIABLE {result} {$result${VAL}$tmp};
    };
    #SEND {$result$IAC$SE\};
    #UNVARIABLE {tmp};
}


#EVENT {IAC WILL MSDP} {
    #SEND {$IAC$DO$MSDP\};
    msdp_report;
}


#NOP -- Parsing the reported var/val pairs is handled by the following 3 events;

#EVENT {IAC SB MSDP AFFECTS}
{
    #unvariable {msdp_info[AFFECTS]};
        #variable {msdp_affects_raw} {%1};
        #replace {msdp_affects_raw} {\a\a} {;};
        #replace {msdp_affects_raw} {\a} {;};
    #foreach {$msdp_affects_raw} {tmp} 
    {
        #regex {$tmp} {%*,%d} {#var msdp_info[AFFECTS][&1] &2} {#NOP};
    };
    #unvar tmp;
    #unvar msdp_affects_raw
};

#EVENT {IAC SB MSDP ROOM_EXITS}
{
    #UNVARIABLE msdp_info[ROOM_EXITS];
    #CLASS msdp_data OPEN;
    #VARIABLE {msdp_room_exits_raw} {%1};
    #REPLACE {msdp_room_exits_raw} {\a} {;};
    #FOREACH {$msdp_room_exits_raw} {tmp}
    {
        #regex {$tmp} {%w,%w} {#var msdp_info[ROOM_EXITS][&1] &2} {#NOP};
    };
    #UNVARIABLE tmp;
    #UNVARIABLE msdp_room_exits_raw;
    #CLASS msdp_data CLOSE;
};

#EVENT {IAC SB MSDP} {
    #NOP {Save all variables in array at var $msdp_info};
    #CLASS MSDP open;
    #IF {"%0" == "AFFECTS"} {#NOP -- Handled by more specific event above};
    #ELSEIF {"%0" == "ROOM_EXITS"} {#NOP -- Handled by more specific event above};
    #ELSEIF {"%0" == "OPPONENT_NAME" && "%1" == ""} {
        #UNVARIABLE {msdp_info[OPPONENT_NAME]};
        #UNVARIABLE {msdp_info[OPPONENT_HEALTH]};
        #UNVARIABLE {msdp_info[OPPONENT_LEVEL]};
    };
    #ELSEIF {"%0" == "OPPONENT_NAME" && "%1" != ""} {
	#VARIABLE {msdp_info[OPPONENT_NAME]} {%1};
    };
    #ELSEIF {"%0" == "OPPONENT_LEVEL" && "%1" == "0"} {
        #UNVARIABLE {msdp_info[OPPONENT_NAME]};
        #UNVARIABLE {msdp_info[OPPONENT_HEALTH]};
        #UNVARIABLE {msdp_info[OPPONENT_LEVEL]};
    };
    #ELSE {
        #VARIABLE {msdp_info[%0]} {%1};
    };
#class MSDP close;
}

#NOP This event is generated at the end of an MSDP sub negotiation.;

#EVENT {IAC SB MSDP IAC SE} {
	#NOP {};
}

#NOP fixes the split command sending screen resize garbage screen data to the server for some reason;
#event {CATCH IAC SB NAWS} {#NOP}


#NOP ===================================================================================
#CLASS {MSDP} {CLOSE}