Skip to content

Commit

Permalink
catalog spawn expansion
Browse files Browse the repository at this point in the history
git-svn-id: svn://192.168.1.10/public/CoffeeMud@22442 0d6f1817-ed0e-0410-87c9-987e46238f29
  • Loading branch information
bozimmerman committed Aug 16, 2023
1 parent a868587 commit de79ac4
Show file tree
Hide file tree
Showing 19 changed files with 640 additions and 142 deletions.
3 changes: 3 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
40. Quests can now suppress local laws while they are running.
41. Prop_ClosedDayNight can now generate near-closing greetings.
42. MudChat now how syntax for adding marginal entries over the chat.dat entries.
43. Loyalty will report itself when you the leader looks at the loyal follower.
45. EXAMINE/LONGLOOK at mobs will now show wear positions like EQ LONG
46. CATALOG now supports spawn caps, random (masked) room spawns, and mob spawns.

# Build 5.10.2 Release 4/28/2023
* DATABASE CHANGED! (Enlarged CMDATE, and new expiration date added to CMJRNL table)
Expand Down
12 changes: 12 additions & 0 deletions com/planet_ink/coffee_mud/Abilities/Misc/Loyalty.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,18 @@ public boolean okMessage(final Environmental myHost, final CMMsg msg)
return true;
}

@Override
public void executeMsg(final Environmental myHost, final CMMsg msg)
{
super.executeMsg(myHost, msg);

if((msg.target()==affected)
&&((msg.targetMinor()==CMMsg.TYP_LOOK)
||(msg.targetMinor()==CMMsg.TYP_EXAMINE))
&&(msg.source().Name().equals(loyaltyName)))
msg.addTrailerMsg(CMClass.getMsg(msg.source(),null,affected,CMMsg.MSG_OK_VISUAL,L("^H<O-NAME> is loyal to you.^?"),CMMsg.NO_EFFECT,null,CMMsg.NO_EFFECT,null));
}

@Override
public boolean tick(final Tickable ticking, final int tickID)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,8 @@ public boolean fillOutWarrant(MOB mob,

/**
* Suppresses warrants for the given crime until the given
* RL timestamp, or Ability is uninvoked, or Quest is
* ended. "ALL" will suppress all crimes.
* Long timestamp, or Ability is uninvoked, or Quest is
* ended. A crime of "ALL" will suppress all crimes.
*
* @param crime the crime to suppress
* @param until the Object expiration for the suppression
Expand Down
120 changes: 85 additions & 35 deletions com/planet_ink/coffee_mud/Commands/Catalog.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.planet_ink.coffee_mud.Locales.interfaces.*;
import com.planet_ink.coffee_mud.Libraries.interfaces.*;
import com.planet_ink.coffee_mud.Libraries.interfaces.CatalogLibrary.CataData;
import com.planet_ink.coffee_mud.Libraries.interfaces.CatalogLibrary.CataSpawn;
import com.planet_ink.coffee_mud.Libraries.interfaces.CatalogLibrary.CatalogKind;
import com.planet_ink.coffee_mud.MOBS.interfaces.*;
import com.planet_ink.coffee_mud.Races.interfaces.*;
Expand Down Expand Up @@ -442,7 +443,6 @@ public void callBack()
final CatalogKind whatKind=getObjectType(commands);
final String ID=CMParms.combine(commands,0);
final StringBuffer list=new StringBuffer("");
int col=0;
MOB M=null;
Item I=null;
CatalogLibrary.CataData data;
Expand All @@ -463,8 +463,8 @@ public void callBack()
list.append("^HMobs ("+(cat)+")\n\r^N");
list.append(CMStrings.padRight(L("Name"),34)+" ");
list.append(CMStrings.padRight("#",3));
list.append(CMStrings.padRight(L("Name"),34)+" ");
list.append(CMStrings.padRight("#",3));
list.append(CMStrings.padRight(L("Spawn"),8)+" ");
list.append(CMStrings.padRight(L("Mask"),29)+" ");
list.append("\n\r"+CMStrings.repeat('-',78)+"\n\r");
final String[] names=CMLib.catalog().getCatalogMobNames(cat);
for (final String name : names)
Expand All @@ -477,15 +477,18 @@ public void callBack()
{
list.append(CMStrings.padRight(M.Name(),34)).append(" ");
list.append(CMStrings.padRight(Integer.toString(data.numReferences()),3));
if(col==0)
if(data.getSpawn() == CataSpawn.NONE)
{
col++;
list.append("N/A ");
list.append(CMStrings.padRight(" ",31));
}
else
{
col++;
list.append("\n\r");
list.append(data.getSpawn().name().charAt(0)+" ");
list.append(CMStrings.padRight(CMath.toPct(data.getRate()),6)+" ");
list.append(CMStrings.padRight(data.getMaskStr(),29));
}
list.append("\n\r");
}
}
}
Expand All @@ -497,8 +500,8 @@ public void callBack()
list.append("^HItems ("+(cat)+")\n\r^N");
list.append(CMStrings.padRight(L("Name"),34)+" ");
list.append(CMStrings.padRight("#",3)+" ");
list.append(CMStrings.padRight(L("Rate"),6)+" ");
list.append(CMStrings.padRight(L("Mask"),31)+" ");
list.append(CMStrings.padRight(L("Spawn"),8)+" ");
list.append(CMStrings.padRight(L("Mask"),29)+" ");
list.append("\n\r"+CMStrings.repeat('-',78)+"\n\r");
final String[] names=CMLib.catalog().getCatalogItemNames(cat);
for (final String name : names)
Expand All @@ -511,15 +514,15 @@ public void callBack()
{
list.append(CMStrings.padRight(I.Name(),34)+" ");
list.append(CMStrings.padRight(Integer.toString(data.numReferences()),3)+" ");
if(data.getRate()<=0.0)
if(data.getSpawn() == CataSpawn.NONE)
{
list.append("N/A ");
list.append(CMStrings.padRight(" ",31));
}
else
{
list.append(data.getSpawn().name().charAt(0)+" ");
list.append(CMStrings.padRight(CMath.toPct(data.getRate()),6)+" ");
list.append(data.getWhenLive()?"L ":"D ");
list.append(CMStrings.padRight(data.getMaskStr(),29));
}
list.append("\n\r");
Expand Down Expand Up @@ -604,45 +607,83 @@ public void callBack()
return false;
}
final CatalogLibrary.CataData data=CMLib.catalog().getCatalogData(P);
if(P instanceof MOB)
{
mob.tell(L("There is no extra mob data to edit. See help on CATALOG."));
}
else
if(P instanceof Item)
if(mob.session()!=null)
{
if(mob.session()!=null)
final String choice;
if(P instanceof MOB)
{
choice=mob.session().choose(L("Auto-Spawn: N)o, R)oom, (@x1): ",
""+data.getSpawn().name().charAt(0)),L("NR"), ""+data.getSpawn().name().charAt(0));
}
else
{
choice=mob.session().choose(L("Auto-Spawn: N)o, L)ive mobs, D)ead mobs, R)oom, (@x1): ",
""+data.getSpawn().name().charAt(0)),L("NLDR"), ""+data.getSpawn().name().charAt(0));
}
if(choice.trim().length()>0)
{
for(final CataSpawn s : CataSpawn.values())
{
if(s.name().startsWith(choice.toUpperCase().trim()))
data.setSpawn(s);
}
}
if(data.getSpawn()==CataSpawn.NONE)
{
data.setMaskStr("");
data.setRate(0.0);
data.setCap(0);
}
else
{
Integer newCap=null;
while(newCap == null)
{
final String newRate=mob.session().prompt(L("Enter a new Max number in world (@x1): ",
""+data.getCap()), ""+data.getCap());
if(newRate.trim().length()==0)
return false;
else
if(CMath.isInteger(newRate) && (CMath.s_int(newRate)>0))
newCap=Integer.valueOf(CMath.s_int(newRate));
else
mob.tell(L("'@x1' is not a valid maximum. Try something like 10",newRate));
}
data.setCap(newCap.intValue());

Double newPct=null;
while(newPct == null)
{
final String newRate=mob.session().prompt(L("Enter a new Drop Rate or 0% to disable (@x1): ",CMath.toPct(data.getRate())), CMath.toPct(data.getRate()));
final String newRate=mob.session().prompt(L("Enter a new Drop Rate (@x1): ",
CMath.toPct(data.getRate())), CMath.toPct(data.getRate()));
if(newRate.trim().length()==0)
return false;
else
if(CMath.isPct(newRate))
if(CMath.isPct(newRate) && (CMath.s_pct(newRate)>0.0))
newPct=Double.valueOf(CMath.s_pct(newRate));
else
mob.tell(L("'@x1' is not a valid percentage value. Try something like 10%",newRate));
}
data.setRate(newPct.doubleValue());
if(data.getRate()<=0.0)
String newMask="?";
if(data.getSpawn()==CataSpawn.ROOM)
{
data.setMaskStr("");
data.setRate(0.0);
CMLib.database().DBUpdateItem("CATALOG_ITEMS",(Item)P);
Log.sysOut("Catalog",mob.Name()+" modified catalog item "+P.Name());
mob.tell(L("No drop item."));
return false;
while(newMask.equalsIgnoreCase("?"))
{
newMask=mob.session().prompt(L("Enter new Room selection mask, or NULL (@x1)\n\r: ",data.getMaskStr()),data.getMaskStr());
if(newMask.equalsIgnoreCase("?"))
mob.tell(CMLib.masking().maskHelp("\n","disallow"));
}
}
final String choice=mob.session().choose(L("Is this for L)ive mobs or D)ead ones (@x1): ",(data.getWhenLive()?"L":"D")),L("LD"), (data.getWhenLive()?"L":"D"));
data.setWhenLive(choice.equalsIgnoreCase("L"));
String newMask="?";
while(newMask.equalsIgnoreCase("?"))
else
if((data.getSpawn()==CataSpawn.LIVE) || (data.getSpawn()==CataSpawn.DROP))
{
newMask=mob.session().prompt(L("Enter new MOB selection mask, or NULL (@x1)\n\r: ",data.getMaskStr()),data.getMaskStr());
if(newMask.equalsIgnoreCase("?"))
mob.tell(CMLib.masking().maskHelp("\n","disallow"));
while(newMask.equalsIgnoreCase("?"))
{
newMask=mob.session().prompt(L("Enter new MOB selection mask, or NULL (@x1)\n\r: ",data.getMaskStr()),data.getMaskStr());
if(newMask.equalsIgnoreCase("?"))
mob.tell(CMLib.masking().maskHelp("\n","disallow"));
}
}
if((newMask.length()==0)||(newMask.equalsIgnoreCase("null")))
{
Expand All @@ -654,9 +695,18 @@ public void callBack()
{
data.setMaskStr(newMask);
}
}
if(P instanceof Item)
{
CMLib.database().DBUpdateItem("CATALOG_ITEMS",(Item)P);
Log.sysOut("Catalog",mob.Name()+" modified catalog item "+P.Name());
mob.tell(L("Item '@x1 has been updated.",P.Name()));
mob.tell(L("Item '@x1' has been updated.",P.Name()));
}
else
{
CMLib.database().DBUpdateMOB("CATALOG_MOBS",(MOB)P);
Log.sysOut("Catalog",mob.Name()+" modified catalog mob "+P.Name());
mob.tell(L("Mob '@x1' has been updated.",P.Name()));
}
}
}
Expand Down
10 changes: 9 additions & 1 deletion com/planet_ink/coffee_mud/Commands/Equipment.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ public String[] getAccessWords()
return access;
}

private final static Class<?>[][] internalParameters=new Class<?>[][]{{MOB.class},{Boolean.class},{}};
private final static Class<?>[][] internalParameters=new Class<?>[][]{
{MOB.class},
{Boolean.class},
{},
{MOB.class, Boolean.class}
};

public StringBuilder getEquipment(final MOB seer, final MOB mob, final boolean allPlaces)
{
Expand Down Expand Up @@ -381,6 +386,9 @@ public Object executeInternal(final MOB mob, final int metaFlags, final Object..
if(!super.checkArguments(internalParameters, args))
return null;

if((args.length>1)&&(args[0] instanceof MOB)&&(args[1] instanceof Boolean))
return getEquipment((MOB)args[0],mob,((Boolean)args[1]).booleanValue());
else
if((args.length>0)&&(args[0] instanceof MOB))
return getEquipment((MOB)args[0],mob,false);
else
Expand Down
Loading

0 comments on commit de79ac4

Please sign in to comment.