Unit Controller Updates

* Added missing UMOB_CANMOVETICK option.
* Restructured script command getunittype return values to match the order of script command getmapxy to allow for more universal usage.
* Created constants for script commands getmapxy and getunittype.
* Updated NPCs using script command getmapxy to use the new constant values.
* Updated Battleground NPCs to use constant value for script command setunitdata.
This commit is contained in:
aleos89 2016-02-04 10:47:16 -05:00
parent c0f2ee85fd
commit 0a77835029
22 changed files with 90 additions and 61 deletions

View File

@ -2883,24 +2883,27 @@ not variables or the search was not successful.
Type is the type of object to search for:
0 - Character object
1 - NPC object
2 - Pet object
3 - Monster object -- See 'getunitdata' for monster.
4 - Homunculus object
5 - Mercenary object
6 - Elemental object
While 3 is meant to look for a monster object, no searching will be done if you
specify type 3, and the function will always return -1.
UNITTYPE_PC - Character object
UNITTYPE_NPC - NPC object
UNITTYPE_PET - Pet object
UNITTYPE_MOB - Monster object -- See 'getunitdata' for monster.
UNITTYPE_HOM - Homunculus object
UNITTYPE_MER - Mercenary object
UNITTYPE_ELEM - Elemental object
While UNITTYPE_MOB is meant to look for a monster object, no searching will
be done and the function will always return -1.
The search string is optional. If it is not specified, the location of the
invoking character will always be returned for types 0 and 2, the location of
the NPC running this function for type 1.
If a search string is specified, for types 0 and 1, the character or NPC with
the specified name will be located. If type is 3, the search will locate the
current pet of the character who's name is given in the search string, it will
NOT locate a pet by name.
invoking character will always be returned for types UNITTYPE_PC and UNITTYPE_PET,
the location of the NPC running this function for type 1.
If a search string is specified, for types UNITTYPE_PC and UNITTYPE_NPC, the
character or NPC with the specified name will be located.
If type is UNITTYPE_PET/UNITTYPE_HOM/UNITTYPE_MER/UNITTYPE_ELEM, the search
will locate the current object of the character who's name is given in the
search string, it will NOT locate the object by name.
Example:
@ -2912,7 +2915,7 @@ Example:
prontera,164,299,3%TAB%script%TAB%Nyah%TAB%730,{
mes "My name is Nyah.";
mes "I will now search for Meh all across the world!";
if (getmapxy(@mapname$,@mapx,@mapy,1,"Meh")!=0) {
if (getmapxy(@mapname$, @mapx, @mapy, UNITTYPE_NPC, "Meh") !=0) {
mes "I can't seem to find Meh anywhere!";
close;
}
@ -7120,12 +7123,13 @@ For the position, the x and y are given in the UnitSkillUsePos.
Returns the type of object from the given Game ID. Returns -1 if the given <GID> does not
exist.
0 - Monster
1 - Homunculus
2 - Pet
3 - Mercenary
4 - Elemental
5 - NPC
UNITTYPE_PC 0
UNITTYPE_NPC 1
UNITTYPE_PET 2
UNITTYPE_MOB 3
UNITTYPE_HOM 4
UNITTYPE_MER 5
UNITTYPE_ELEM 6
---------------------------------------
@ -7183,6 +7187,7 @@ Parameters (indexes) for monsters are:
UMOB_SHIELD
UMOB_WEAPON
UMOB_LOOKDIR
UMOB_CANMOVETICK
UMOB_STR
UMOB_AGI
UMOB_VIT

View File

@ -246,7 +246,7 @@ bat_room,148,150,5 script Teleporter#Battlefield 124,{
mes "[Maroll Battle Recruiter]";
mes "May the war god bless you.";
close2;
getmapxy(.@mapname$,.@x,.@y,1);
getmapxy(.@mapname$,.@x,.@y,UNITTYPE_NPC);
if (.@mapname$ == "prontera")
set bat_return,1;
else if (.@mapname$ == "moc_ruins")

View File

@ -154,7 +154,7 @@ OnTimer10000:
bat_b01,1,1,3 script OBJ#bat_b01_a 844,{
OnEnable:
$@FlavBG1_C1_ID = bg_monster($@FlaviusBG1_id1,"bat_b01",61,150,"Pink Crystal",1915,"OBJ#bat_b01_a::OnMyMobDead");
setunitdata $@FlavBG1_C1_ID,30,1; // Make Crystal immune to damage until Guardians are defeated
setunitdata $@FlavBG1_C1_ID,UMOB_DMGIMMUNE,1; // Make Crystal immune to damage until Guardians are defeated
end;
OnKill:
@ -188,7 +188,7 @@ OnMyMobDead:
bat_b01,1,2,3 script OBJ#bat_b01_b 844,{
OnEnable:
$@FlavBG1_C2_ID = bg_monster($@FlaviusBG1_id2,"bat_b01",328,150,"Blue Crystal",1914,"OBJ#bat_b01_b::OnMyMobDead");
setunitdata $@FlavBG1_C2_ID,30,1; // Make Crystal immune to damage until Guardians are defeated
setunitdata $@FlavBG1_C2_ID,UMOB_DMGIMMUNE,1; // Make Crystal immune to damage until Guardians are defeated
end;
OnKill:
@ -233,7 +233,7 @@ OnMyMobDead:
if (mobcount("bat_b01","guardian#bat_b01_a::OnMyMobDead") < 1) {
donpcevent "cell#bat_b01_a::OnGreen";
mapannounce "bat_b01", "The Guardian protecting Guillaume's Crystal has been slain.",bc_map,"0xFFCE00";
setunitdata $@FlavBG1_C1_ID,30,0; // Make Crystal damageable again
setunitdata $@FlavBG1_C1_ID,UMOB_DMGIMMUNE,0; // Make Crystal damageable again
}
end;
}
@ -252,7 +252,7 @@ OnMyMobDead:
if (mobcount("bat_b01","guardian#bat_b01_b::OnMyMobDead") < 1) {
donpcevent "cell#bat_b01_b::OnGreen";
mapannounce "bat_b01", "The Guardian protecting Croix's Crystal has been slain.",bc_map,"0xFFCE00";
setunitdata $@FlavBG1_C2_ID,30,0; // Make Crystal damageable again
setunitdata $@FlavBG1_C2_ID,UMOB_DMGIMMUNE,0; // Make Crystal damageable again
}
end;
}

View File

@ -155,7 +155,7 @@ OnTimer10000:
bat_b02,1,1,3 script OBJ#bat_b02_a 844,{
OnEnable:
$@FlavBG2_C1_ID = bg_monster($@FlaviusBG2_id1,"bat_b02",61,150,"Pink Crystal",1915,"OBJ#bat_b02_a::OnMyMobDead");
setunitdata $@FlavBG2_C1_ID,30,1; // Make Crystal immune to damage until Guardians are defeated
setunitdata $@FlavBG2_C1_ID,UMOB_DMGIMMUNE,1; // Make Crystal immune to damage until Guardians are defeated
end;
OnKill:
@ -189,7 +189,7 @@ OnMyMobDead:
bat_b02,1,2,3 script OBJ#bat_b02_b 844,{
OnEnable:
$@FlavBG2_C2_ID = bg_monster($@FlaviusBG2_id2,"bat_b02",328,150,"Blue Crystal",1914,"OBJ#bat_b02_b::OnMyMobDead");
setunitdata $@FlavBG2_C2_ID,30,1; // Make Crystal immune to damage until Guardians are defeated
setunitdata $@FlavBG2_C2_ID,UMOB_DMGIMMUNE,1; // Make Crystal immune to damage until Guardians are defeated
end;
OnKill:
@ -234,7 +234,7 @@ OnMyMobDead:
if (mobcount("bat_b02","guardian#bat_b02_a::OnMyMobDead") < 1) {
donpcevent "cell#bat_b02_a::OnGreen";
mapannounce "bat_b02", "The Guardian protecting Guillaume's Crystal has been slain.",bc_map,"0xFFCE00";
setunitdata $@FlavBG2_C1_ID,30,0; // Make Crystal damageable again
setunitdata $@FlavBG2_C1_ID,UMOB_DMGIMMUNE,0; // Make Crystal damageable again
}
end;
}
@ -253,7 +253,7 @@ OnMyMobDead:
if (mobcount("bat_b02","guardian#bat_b02_b::OnMyMobDead") < 1) {
donpcevent "cell#bat_b02_b::OnGreen";
mapannounce "bat_b02", "The Guardian protecting Croix's Crystal has been slain.",bc_map,"0xFFCE00";
setunitdata $@FlavBG2_C2_ID,30,0; // Make Crystal damageable again
setunitdata $@FlavBG2_C2_ID,UMOB_DMGIMMUNE,0; // Make Crystal damageable again
}
end;
}

View File

@ -107,7 +107,7 @@ OnClock2200:
disablenpc "ord11-12"; //from npc/warps/pvp.txt
disablenpc "Devil Square Guardian#2";
mapannounce "ordeal_1-1","Devil Square is now closed.", bc_map;
getmapxy .@map$, .@x, .@y, 1;
getmapxy .@map$, .@x, .@y, UNITTYPE_NPC;
mapwarp "ordeal_1-1", .@map$, .@x, .@y;
killmonsterall "ordeal_1-1";
announce "Devil Square is OPEN. The event will begin in 5 minutes.", bc_all;

View File

@ -309,7 +309,7 @@ OnInit:
// Config Ends --------------------------------------------------------------
mapannounce .eventmap$, "An administrator has refreshed the server. Please re-register. We apologize for the inconvenience.", bc_map;
getmapxy .map$, .x, .y, 1;
getmapxy .map$, .x, .y, UNITTYPE_NPC;
mapwarp .eventmap$, .map$, .x, .y;
killmonsterall .eventmap$;
.@size = getarraysize( .@mapflag );

View File

@ -280,7 +280,7 @@ OnNPCKillEvent:
}
} else if (.Party) {
.@mob = killedrid;
getmapxy(.@map1$,.@x1,.@y1,0);
getmapxy(.@map1$,.@x1,.@y1,UNITTYPE_PC);
getpartymember getcharid(1),1;
getpartymember getcharid(1),2;
for (.@i = 0; .@i < $@partymembercount; .@i++) {
@ -290,7 +290,7 @@ OnNPCKillEvent:
set .@HP, getvar(HP, $@partymembercid[.@i]);
if (.@Mission_Count && .@Mission0 && .@HP > 0) {
getmapxy(.@map2$,.@x2,.@y2,0);
getmapxy(.@map2$,.@x2,.@y2,UNITTYPE_PC);
if ((.@map1$ == .@map2$ || .Party == 1) && (distance(.@x1,.@y1,.@x2,.@y2) <= 30 || .Party < 3)) {
for (.@j = 0; .@j < .Quests; .@j++) {
if (strmobinfo(1,.@mob) == strmobinfo(1,getvar(getd("Mission"+.@j), $@partymembercid[.@i]))) {

View File

@ -244,7 +244,7 @@ prontera,220,72,5 duplicate(09Treats) Trick or Treater#iRO8 706,2,2
mes "[Halloween Wizard]";
mes "Which town do you want to play a trick on?";
next;
getmapxy(.@mapname$,.@mapx,.@mapy,0,""+strcharinfo(0)+"");
getmapxy(.@mapname$,.@mapx,.@mapy,UNITTYPE_PC,""+strcharinfo(0)+"");
if (.@mapname$ == "prontera") {
switch(select("Geffen:Payon:Alberta:Aldebaran")) {
case 1:

View File

@ -53,7 +53,7 @@ function script F_CashStore {
function script F_CashPartyCall {
warp "Random",0,0;
if(getpartyleader(getcharid(1),2) == getcharid(0)) {
getmapxy .@mapl$, .@xl, .@yl, 0;
getmapxy .@mapl$, .@xl, .@yl, UNITTYPE_PC;
warpparty .@mapl$, .@xl, .@yl, getcharid(1), .@mapl$;
}
return;

View File

@ -21,7 +21,7 @@ function script F_GM_NPC {
// To set a minimum GM level to access the NPCs, edit the line below.
if (getgmlevel() < 99) {
// Log the event.
getmapxy(.@map$,.@x,.@y,1);
getmapxy(.@map$,.@x,.@y,UNITTYPE_NPC);
logmes strcharinfo(0)+" attempted to access GM NPC "+strnpcinfo(0)+" ("+.@map$+","+.@x+","+.@y+").";
end;
}

View File

@ -209,7 +209,7 @@ OnInit:
OnEnable:
emotion e_gasp;
enablenpc strnpcinfo(0);
getmapxy(.@m$,.@x,.@y,1);
getmapxy(.@m$,.@x,.@y,UNITTYPE_NPC);
setarray .@mob[1], 1725,1726,1727,1728,1730,1729;
.@n = atoi( strnpcinfo(2) );
monster "p_track01",58,.@y,"The "+ callfunc("F_GetNumSuffix",.@n) +" Racer",.@mob[.@n],1,strnpcinfo(0)+"::OnMyMobDead";
@ -1692,7 +1692,7 @@ function MN {
OnEnable:
enablenpc strnpcinfo(0);
setarray .@n[1], 1725,1726,1727,1728,1730,1729;
getmapxy(.@m$,.@x,.@y,1);
getmapxy(.@m$,.@x,.@y,UNITTYPE_NPC);
.@i = MN;
monster "p_track02",58,.@y,"Monster "+.@i,.@n[.@i],1,strnpcinfo(0)+"::OnMyMobDead";
end;

View File

@ -302,7 +302,7 @@ poring_w01,96,97,3 script Sweet Devi#wop 738,{
}
OnPCLogoutEvent:
getmapxy .@map$,.@x,.@y,0;
getmapxy .@map$,.@x,.@y,UNITTYPE_PC;
if (.@map$ == "poring_w02") {
if (WoP_SaveMap$ != "") {
savepoint WoP_SaveMap$,WoP_SaveMap_X,WoP_SaveMap_Y;
@ -316,7 +316,7 @@ OnPCLogoutEvent:
end;
OnPCDieEvent:
getmapxy .@map$,.@x,.@y,0;
getmapxy .@map$,.@x,.@y,UNITTYPE_PC;
if (.@map$ == "poring_w02" && wop_team) {
if (getsavepoint(0) != "poring_w02" && WoP_SaveMap$ == "") {
set WoP_SaveMap$,getsavepoint(0);
@ -333,7 +333,7 @@ OnPCDieEvent:
end;
OnPCKillEvent:
getmapxy .@map$,.@x,.@y,0;
getmapxy .@map$,.@x,.@y,UNITTYPE_PC;
if (.@map$ == "poring_w02" && wop_team) {
getnameditem 7773,rid2name(killedrid);
}

View File

@ -1222,7 +1222,7 @@
- script RelayDummy2::GuildRelay2 754,{
set .@name$,strnpcinfo(1);
getmapxy(.@m$,.@x,.@x,1);
getmapxy(.@m$,.@x,.@x,UNITTYPE_NPC);
set .@GID, GetCastleData(.@m$,1);
if (checkweight(1201,1) == 0) {
mes "^3355FFWait a minute! You're";
@ -1731,7 +1731,7 @@
- script RelayDummy3::GuildRelay3 754,{
set .@name$,strnpcinfo(1);
getmapxy(.@m$,.@x,.@x,1);
getmapxy(.@m$,.@x,.@x,UNITTYPE_NPC);
set .@GID, GetCastleData(.@m$,1);
if (checkweight(1201,1) == 0) {
mes "^3355FFWait a minute! You're";
@ -2416,7 +2416,7 @@
- script GuildDummy4::GuildRelay4 754,{
set .@name$,strnpcinfo(1);
getmapxy(.@m$,.@x,.@x,1);
getmapxy(.@m$,.@x,.@x,UNITTYPE_NPC);
set .@GID, GetCastleData(.@m$,1);
if (checkweight(1201,1) == 0) {
mes "^3355FFWait a minute! You're";

View File

@ -2474,7 +2474,7 @@ payon,168,314,3 script Lospii#payon::RelayLospii 706,{
close;
}
set .@relaytime,gettime(3);
getmapxy(.@m$,.@x,.@y,1,strnpcinfo(3));
getmapxy(.@m$,.@x,.@y,UNITTYPE_NPC,strnpcinfo(3));
set .@juwi,getareausers(.@m$,.@x-8,.@y-8,.@x+8,.@y+8);
if (party_relay == 32) {
mes "[Lospii]";

View File

@ -736,7 +736,7 @@ OnEnable:
areamonster .@map$,.@c[0],.@c[1],.@c[2],.@c[3],"Ancient Kukre",2179,rand(1,3),.@label$;
areamonster .@map$,.@c[0],.@c[1],.@c[2],.@c[3],"Abysmal Cornutus",2177,rand(1,3),.@label$;
specialeffect EF_MAPPILLAR2,ALL_SAMEMAP; //currently broken
getmapxy(.@map$,.@x,.@y,1);
getmapxy(.@map$,.@x,.@y,UNITTYPE_NPC);
getpartymember 'party_id,2;
copyarray .@partymemberaid[0],$@partymemberaid[0],$@partymembercount;
for(set .@i,0; .@i<$@partymembercount; set .@i,.@i+1) {

View File

@ -970,7 +970,7 @@ OnTouch:
else if (.@i == 3) set .@mobs,5;
else if (.@i < 7) set .@mobs,6;
else set .@mobs,7;
getmapxy(.@map$,.@x,.@y,1);
getmapxy(.@map$,.@x,.@y,UNITTYPE_NPC);
specialeffect EF_VENOMDUST;
monster .@map$,.@x,.@y,"Muck Worm",2467,.@mobs,instance_npcname(strnpcinfo(0))+"::OnMyMobDead";
disablenpc instance_npcname(strnpcinfo(0));
@ -1946,7 +1946,7 @@ OnTimer80000:
mes "Now, I may erase your memory again. Perhaps you will have a different fate next time.";
specialeffect2 EF_FREEZE;
close2;
getmapxy(.@map$,.@x,.@y,0);
getmapxy(.@map$,.@x,.@y,UNITTYPE_PC);
warp .@map$,.@x,.@y;
end;
} else {

View File

@ -3442,7 +3442,7 @@ OnTouch:
OnTimer:
//FIXME: This is a workaround for...
//var pccount_tt = GetNeighborPcNumber 2
getmapxy(.@map$,.@x,.@y,1);
getmapxy(.@map$,.@x,.@y,UNITTYPE_NPC);
setarray .@x[1],.@x-2,.@x+2;
setarray .@y[1],.@y-2,.@y+2;
sleep 1000;

View File

@ -1582,7 +1582,7 @@ OnInit:
OnEnable:
enablenpc strnpcinfo(0);
initnpctimer;
getmapxy(.@map$,.@x,.@y,1);
getmapxy(.@map$,.@x,.@y,UNITTYPE_NPC);
monster "job3_rang02",.@x,.@y,"Egg Bomb",1047,1,strnpcinfo(0)+"::OnMyMobDead";
switch(atoi(strnpcinfo(2))%3) {
case 0: set .@str$,"Hey, I am going to explode. What are you going to do?"; break;

View File

@ -4184,7 +4184,7 @@ malangdo,133,134,0 script Strange Pile of Sand#7 557,{
setquest .@quest;
if (!rand(3)) {
emotion e_omg;
getmapxy(.@map$,.@x,.@y,1);
getmapxy(.@map$,.@x,.@y,UNITTYPE_NPC);
monster .@map$,.@x,.@y,"Quick Dark Shadow",2209,1;
} else
getitem 11536,1; //Cat_Hard_Biscuit

View File

@ -16752,12 +16752,14 @@ BUILDIN_FUNC(getunittype)
}
switch (bl->type) {
case BL_MOB: value = 0; break;
case BL_HOM: value = 1; break;
case BL_PC: value = 0; break;
case BL_NPC: value = 1; break;
case BL_PET: value = 2; break;
case BL_MER: value = 3; break;
case BL_ELEM: value = 4; break;
case BL_NPC: value = 5; break;
case BL_MOB: value = 3; break;
case BL_HOM: value = 4; break;
case BL_MER: value = 5; break;
case BL_ELEM: value = 6; break;
default: value = -1; break;
}
script_pushint(st, value);
@ -16834,6 +16836,7 @@ BUILDIN_FUNC(getunitdata)
getunitdata_sub(UMOB_SHIELD, md->vd->shield);
getunitdata_sub(UMOB_WEAPON, md->vd->weapon);
getunitdata_sub(UMOB_LOOKDIR, md->ud.dir);
getunitdata_sub(UMOB_CANMOVETICK, md->ud.canmove_tick);
getunitdata_sub(UMOB_STR, md->status.str);
getunitdata_sub(UMOB_AGI, md->status.agi);
getunitdata_sub(UMOB_VIT, md->status.vit);
@ -17126,7 +17129,7 @@ BUILDIN_FUNC(setunitdata)
status_calc_npc(nd, SCO_NONE);
break;
default:
ShowError("buildin_setunitdata: Invalid object!");
ShowError("buildin_setunitdata: Invalid object!\n");
return SCRIPT_CMD_FAILURE;
}
@ -17139,7 +17142,7 @@ BUILDIN_FUNC(setunitdata)
else if (data_isint(data))
value = conv_num(st, data);
else {
ShowError("buildin_setunitdata: Invalid data type for argument #3 (%d).", data->type);
ShowError("buildin_setunitdata: Invalid data type for argument #3 (%d).\n", data->type);
return SCRIPT_CMD_FAILURE;
}
@ -17173,6 +17176,7 @@ BUILDIN_FUNC(setunitdata)
case UMOB_SHIELD: clif_changelook(bl, LOOK_SHIELD, (unsigned short)value); break;
case UMOB_WEAPON: clif_changelook(bl, LOOK_WEAPON, (unsigned short)value); break;
case UMOB_LOOKDIR: unit_setdir(bl, (uint8)value); break;
case UMOB_CANMOVETICK: md->ud.canmove_tick = value > 0 ? (unsigned int)value : 0; break;
case UMOB_STR: md->status.str = (unsigned short)value; status_calc_misc(bl, &md->status, md->level); break;
case UMOB_AGI: md->status.agi = (unsigned short)value; status_calc_misc(bl, &md->status, md->level); break;
case UMOB_VIT: md->status.vit = (unsigned short)value; status_calc_misc(bl, &md->status, md->level); break;

View File

@ -363,6 +363,16 @@ enum questinfo_types {
#define FW_HEAVY 900
#endif
enum getmapxy_types {
UNITTYPE_PC = 0,
UNITTYPE_NPC,
UNITTYPE_PET,
UNITTYPE_MOB,
UNITTYPE_HOM,
UNITTYPE_MER,
UNITTYPE_ELEM,
};
enum unitdata_mobtypes {
UMOB_SIZE = 0,
UMOB_LEVEL,
@ -387,6 +397,7 @@ enum unitdata_mobtypes {
UMOB_SHIELD,
UMOB_WEAPON,
UMOB_LOOKDIR,
UMOB_CANMOVETICK,
UMOB_STR,
UMOB_AGI,
UMOB_VIT,

View File

@ -2743,6 +2743,14 @@
export_constant(SCSTART_NORATEDEF);
export_constant(SCSTART_NOICON);
export_constant(UNITTYPE_PC);
export_constant(UNITTYPE_NPC);
export_constant(UNITTYPE_PET);
export_constant(UNITTYPE_MOB);
export_constant(UNITTYPE_HOM);
export_constant(UNITTYPE_MER);
export_constant(UNITTYPE_ELEM);
/* unit control - mob */
export_constant(UMOB_SIZE);
export_constant(UMOB_LEVEL);
@ -2767,6 +2775,7 @@
export_constant(UMOB_SHIELD);
export_constant(UMOB_WEAPON);
export_constant(UMOB_LOOKDIR);
export_constant(UMOB_CANMOVETICK);
export_constant(UMOB_STR);
export_constant(UMOB_AGI);
export_constant(UMOB_VIT);