toons: change some invokers to targets

This commit is contained in:
Master Jumblespeed 2015-08-23 21:21:31 -04:00
parent bde13775cb
commit 1e3fc86d8c

View file

@ -4256,20 +4256,20 @@ def cheesyEffect(value, hood=0, expire=0):
return 'Invalid cheesy effect value: %d' % value return 'Invalid cheesy effect value: %d' % value
if (hood != 0) and (not 1000 <= hood < ToontownGlobals.DynamicZonesBegin): if (hood != 0) and (not 1000 <= hood < ToontownGlobals.DynamicZonesBegin):
return 'Invalid hood ID: %d' % hood return 'Invalid hood ID: %d' % hood
invoker = spellbook.getInvoker() target = spellbook.getTarget()
invoker.b_setCheesyEffect(value, hood, expire) target.b_setCheesyEffect(value, hood, expire)
return 'Set your cheesy effect to: %d' % value return 'Set %s\'s cheesy effect to: %d' % (target.getName(), value)
@magicWord(category=CATEGORY_PROGRAMMER, types=[int]) @magicWord(category=CATEGORY_PROGRAMMER, types=[int])
def hp(hp): def hp(hp):
""" """
Modify the invoker's current HP. Modify the target's current HP.
""" """
invoker = spellbook.getInvoker() target = spellbook.getTarget()
maxHp = invoker.getMaxHp() maxHp = target.getMaxHp()
if not -1 <= hp <= maxHp: if not -1 <= hp <= maxHp:
return 'HP must be in range (-1-%d).' % maxHp return 'HP must be in range (-1-%d).' % maxHp
invoker.b_setHp(hp) target.b_setHp(hp)
return 'Set your HP to: %d' % hp return 'Set your HP to: %d' % hp
@magicWord(category=CATEGORY_PROGRAMMER, types=[int]) @magicWord(category=CATEGORY_PROGRAMMER, types=[int])
@ -4296,14 +4296,14 @@ def textColor(color):
@magicWord(category=CATEGORY_MODERATOR, types=[str]) @magicWord(category=CATEGORY_MODERATOR, types=[str])
def allSummons(): def allSummons():
""" """
Max the invoker's summons Max the target's summons
""" """
invoker = spellbook.getInvoker() target = spellbook.getTarget()
numSuits = len(SuitDNA.suitHeadTypes) numSuits = len(SuitDNA.suitHeadTypes)
fullSetForSuit = 1 | 2 | 4 | 8 | 16 | 32 fullSetForSuit = 1 | 2 | 4 | 8 | 16 | 32
allSummons = numSuits * [fullSetForSuit] allSummons = numSuits * [fullSetForSuit]
invoker.b_setCogSummonsEarned(allSummons) target.b_setCogSummonsEarned(allSummons)
return 'Lots of summons!' return 'Lots of summons!'
@magicWord(category=CATEGORY_PROGRAMMER, types=[str]) @magicWord(category=CATEGORY_PROGRAMMER, types=[str])
@ -4401,17 +4401,17 @@ def maxToon(missingTrack=None):
@magicWord(category=CATEGORY_PROGRAMMER) @magicWord(category=CATEGORY_PROGRAMMER)
def unlocks(): def unlocks():
""" """
Unlocks the invoker's teleport access, emotions, and pet trick phrases. Unlocks the target's teleport access, emotions, and pet trick phrases.
""" """
invoker = spellbook.getInvoker() target = spellbook.getTarget()
# First, unlock their teleport access: # First, unlock their teleport access:
hoods = list(ToontownGlobals.HoodsForTeleportAll) hoods = list(ToontownGlobals.HoodsForTeleportAll)
invoker.b_setHoodsVisited(hoods) target.b_setHoodsVisited(hoods)
invoker.b_setTeleportAccess(hoods) target.b_setTeleportAccess(hoods)
# Next, unlock all of their emotions: # Next, unlock all of their emotions:
emotes = list(invoker.getEmoteAccess()) emotes = list(target.getEmoteAccess())
for emoteId in OTPLocalizer.EmoteFuncDict.values(): for emoteId in OTPLocalizer.EmoteFuncDict.values():
if emoteId >= len(emotes): if emoteId >= len(emotes):
continue continue
@ -4420,20 +4420,20 @@ def unlocks():
if emoteId in (17, 18, 19): if emoteId in (17, 18, 19):
continue continue
emotes[emoteId] = 1 emotes[emoteId] = 1
invoker.b_setEmoteAccess(emotes) target.b_setEmoteAccess(emotes)
# Finally, unlock all of their pet phrases: # Finally, unlock all of their pet phrases:
if simbase.wantPets: if simbase.wantPets:
invoker.b_setPetTrickPhrases(range(7)) target.b_setPetTrickPhrases(range(7))
return 'Unlocked teleport access, emotions, and pet trick phrases!' return 'Unlocked teleport access, emotions, and pet trick phrases!'
@magicWord(category=CATEGORY_PROGRAMMER, types=[int, str]) @magicWord(category=CATEGORY_PROGRAMMER, types=[int, str])
def sos(count, name): def sos(count, name):
""" """
Modifies the invoker's specified SOS card count. Modifies the target's specified SOS card count.
""" """
invoker = spellbook.getInvoker() target = spellbook.getTarget()
if not 0 <= count <= 100: if not 0 <= count <= 100:
return 'Your SOS count must be in range (0-100).' return 'Your SOS count must be in range (0-100).'
for npcId, npcName in TTLocalizer.NPCToonNames.items(): for npcId, npcName in TTLocalizer.NPCToonNames.items():
@ -4443,43 +4443,43 @@ def sos(count, name):
break break
else: else:
return 'SOS card %s was not found!' % name return 'SOS card %s was not found!' % name
if (count == 0) and (npcId in invoker.NPCFriendsDict): if (count == 0) and (npcId in target.NPCFriendsDict):
del invoker.NPCFriendsDict[npcId] del target.NPCFriendsDict[npcId]
else: else:
invoker.NPCFriendsDict[npcId] = count target.NPCFriendsDict[npcId] = count
invoker.d_setNPCFriendsDict(invoker.NPCFriendsDict) target.d_setNPCFriendsDict(target.NPCFriendsDict)
return "You were given %d %s SOS cards." % (count, name) return "%s was given %d %s SOS cards." % (target.getName(), count, name)
@magicWord(category=CATEGORY_PROGRAMMER, types=[int]) @magicWord(category=CATEGORY_PROGRAMMER, types=[int])
def unites(value=32767): def unites(value=32767):
""" """
Restock all resistance messages. Restock all resistance messages.
""" """
invoker = spellbook.getInvoker() target = spellbook.getTarget()
value = min(value, 32767) value = min(value, 32767)
invoker.restockAllResistanceMessages(value) target.restockAllResistanceMessages(value)
return 'Restocked %d unites!' % value return 'Restocked %d unites for %s!' % (value, target.getName())
@magicWord(category=CATEGORY_PROGRAMMER, types=[int]) @magicWord(category=CATEGORY_PROGRAMMER, types=[int])
def fires(count): def fires(count):
""" """
Modifies the invoker's pink slip count. Modifies the target's pink slip count.
""" """
invoker = spellbook.getInvoker() target = spellbook.getTarget()
if not 0 <= count <= 255: if not 0 <= count <= 255:
return 'Your fire count must be in range (0-255).' return 'Your fire count must be in range (0-255).'
invoker.b_setPinkSlips(count) target.b_setPinkSlips(count)
return 'You were given %d fires.' % count return '%s was given %d fires.' % (target.getName(), count)
@magicWord(category=CATEGORY_PROGRAMMER, types=[int]) @magicWord(category=CATEGORY_PROGRAMMER, types=[int])
def crateKeys(count): def crateKeys(count):
""" """
Modifies the invoker's crate key count. Modifies the invoker's crate key count.
""" """
invoker = spellbook.getInvoker() target = spellbook.getTarget()
if not 0 <= count <= 255: if not 0 <= count <= 255:
return 'Your crate key must be in range (0-255).' return 'Your crate key must be in range (0-255).'
invoker.b_setCrateKeys(count) target.b_setCrateKeys(count)
return 'You were given %d crate keys.' % count return 'You were given %d crate keys.' % count
@magicWord(category=CATEGORY_PROGRAMMER, types=[int]) @magicWord(category=CATEGORY_PROGRAMMER, types=[int])
@ -4577,66 +4577,54 @@ def squish(laff):
@magicWord(category=CATEGORY_CREATIVE, types=[int, int]) @magicWord(category=CATEGORY_CREATIVE, types=[int, int])
def hat(hatIndex, hatTex=0): def hat(hatIndex, hatTex=0):
""" """
Modify the invoker's hat. Modify the target's hat.
""" """
if not 0 <= hatIndex < len(ToonDNA.HatModels): if not 0 <= hatIndex < len(ToonDNA.HatModels):
return 'Invalid hat index.' return 'Invalid hat index.'
if not 0 <= hatTex < len(ToonDNA.HatTextures): if not 0 <= hatTex < len(ToonDNA.HatTextures):
return 'Invalid hat texture.' return 'Invalid hat texture.'
invoker = spellbook.getInvoker()
target = spellbook.getTarget() target = spellbook.getTarget()
if target != invoker: target.b_setHat(hatIndex, hatTex, 0)
target.b_setHat(hatIndex, hatTex, 0) return "Set %s's hat to %d, %d!" % (target.getName(), hatIndex, hatTex)
return "Set %s's hat to %d, %d!" % (target.getName(), hatIndex, hatTex)
invoker.b_setHat(hatIndex, hatTex, 0)
return "Set %s's hat to %d, %d!" % (invoker.getName(), hatIndex, hatTex)
@magicWord(category=CATEGORY_CREATIVE, types=[int, int]) @magicWord(category=CATEGORY_CREATIVE, types=[int, int])
def glasses(glassesIndex, glassesTex=0): def glasses(glassesIndex, glassesTex=0):
""" """
Modify the invoker's glasses. Modify the target's glasses.
""" """
if not 0 <= glassesIndex < len(ToonDNA.GlassesModels): if not 0 <= glassesIndex < len(ToonDNA.GlassesModels):
return 'Invalid glasses index.' return 'Invalid glasses index.'
if not 0 <= glassesTex < len(ToonDNA.GlassesTextures): if not 0 <= glassesTex < len(ToonDNA.GlassesTextures):
return 'Invalid glasses texture.' return 'Invalid glasses texture.'
invoker = spellbook.getInvoker()
target = spellbook.getTarget() target = spellbook.getTarget()
if target != invoker: target.b_setGlasses(glassesIndex, glassesTex, 0)
target.b_setGlasses(glassesIndex, glassesTex, 0) return "Set %s's glasses to %d, %d!" % (target.getName(), glassesIndex, glassesTex)
return "Set %s's glasses to %d, %d!" % (target.getName(), glassesIndex, glassesTex)
invoker.b_setGlasses(glassesIndex, glassesTex, 0)
return "Set %s's glasses to %d, %d!" % (invoker.getName(), glassesIndex, glassesTex)
@magicWord(category=CATEGORY_CREATIVE, types=[int, int]) @magicWord(category=CATEGORY_CREATIVE, types=[int, int])
def backpack(backpackIndex, backpackTex=0): def backpack(backpackIndex, backpackTex=0):
""" """
Modify the invoker's backpack. Modify the target's backpack.
""" """
if not 0 <= backpackIndex < len(ToonDNA.BackpackModels): if not 0 <= backpackIndex < len(ToonDNA.BackpackModels):
return 'Invalid backpack index.' return 'Invalid backpack index.'
if not 0 <= backpackTex < len(ToonDNA.BackpackTextures): if not 0 <= backpackTex < len(ToonDNA.BackpackTextures):
return 'Invalid backpack texture.' return 'Invalid backpack texture.'
invoker = spellbook.getInvoker() target = spellbook.getTarget()
invoker.b_setBackpack(backpackIndex, backpackTex, 0) target.b_setBackpack(backpackIndex, backpackTex, 0)
return "Set %s's backpack to %d, %d!" % (invoker.getName(), backpackIndex, backpackTex) return "Set %s's backpack to %d, %d!" % (target.getName(), backpackIndex, backpackTex)
@magicWord(category=CATEGORY_CREATIVE, types=[int, int]) @magicWord(category=CATEGORY_CREATIVE, types=[int, int])
def shoes(shoesIndex, shoesTex=0): def shoes(shoesIndex, shoesTex=0):
""" """
Modify the invoker's shoes. Modify the target's shoes.
""" """
if not 0 <= shoesIndex < len(ToonDNA.ShoesModels): if not 0 <= shoesIndex < len(ToonDNA.ShoesModels):
return 'Invalid shoes index.' return 'Invalid shoes index.'
if not 0 <= shoesTex < len(ToonDNA.ShoesTextures): if not 0 <= shoesTex < len(ToonDNA.ShoesTextures):
return 'Invalid shoes texture.' return 'Invalid shoes texture.'
invoker = spellbook.getInvoker()
target = spellbook.getTarget() target = spellbook.getTarget()
if target != invoker: target.b_setShoes(shoesIndex, shoesTex, 0)
target.b_setShoes(shoesIndex, shoesTex, 0) return "Set %s's shoes to %d, %d!" % (target.getName(), shoesIndex, shoesTex)
return "Set %s's shoes to %d, %d!" % (target.getName(), shoesIndex, shoesTex)
invoker.b_setShoes(shoesIndex, shoesTex, 0)
return "Set %s's shoes to %d, %d!" % (invoker.getName(), shoesIndex, shoesTex)
@magicWord(category=CATEGORY_COMMUNITY_MANAGER) @magicWord(category=CATEGORY_COMMUNITY_MANAGER)
def ghost(): def ghost():
@ -4689,8 +4677,8 @@ def cogIndex(index):
@magicWord(category=CATEGORY_PROGRAMMER, types=[str, int, int]) @magicWord(category=CATEGORY_PROGRAMMER, types=[str, int, int])
def inventory(a, b=None, c=None): def inventory(a, b=None, c=None):
invoker = spellbook.getInvoker() target = spellbook.getTarget()
inventory = invoker.inventory inventory = target.inventory
if a == 'reset': if a == 'reset':
maxLevelIndex = b or 5 maxLevelIndex = b or 5
if not 0 <= maxLevelIndex < len(ToontownBattleGlobals.Levels[0]): if not 0 <= maxLevelIndex < len(ToontownBattleGlobals.Levels[0]):
@ -4701,7 +4689,7 @@ def inventory(a, b=None, c=None):
for track in xrange(0, len(ToontownBattleGlobals.Tracks)): for track in xrange(0, len(ToontownBattleGlobals.Tracks)):
if (targetTrack == -1) or (track == targetTrack): if (targetTrack == -1) or (track == targetTrack):
inventory.inventory[track][:maxLevelIndex + 1] = [0] * (maxLevelIndex+1) inventory.inventory[track][:maxLevelIndex + 1] = [0] * (maxLevelIndex+1)
invoker.b_setInventory(inventory.makeNetString()) target.b_setInventory(inventory.makeNetString())
if targetTrack == -1: if targetTrack == -1:
return 'Inventory reset.' return 'Inventory reset.'
else: else:
@ -4713,10 +4701,10 @@ def inventory(a, b=None, c=None):
targetTrack = -1 or c targetTrack = -1 or c
if not -1 <= targetTrack < len(ToontownBattleGlobals.Tracks): if not -1 <= targetTrack < len(ToontownBattleGlobals.Tracks):
return 'Invalid target track index: ' + str(targetTrack) return 'Invalid target track index: ' + str(targetTrack)
if (targetTrack != -1) and (not invoker.hasTrackAccess(targetTrack)): if (targetTrack != -1) and (not target.hasTrackAccess(targetTrack)):
return "You don't have target track index: " + str(targetTrack) return "You don't have target track index: " + str(targetTrack)
inventory.NPCMaxOutInv(targetTrack=targetTrack, maxLevelIndex=maxLevelIndex) inventory.NPCMaxOutInv(targetTrack=targetTrack, maxLevelIndex=maxLevelIndex)
invoker.b_setInventory(inventory.makeNetString()) target.b_setInventory(inventory.makeNetString())
if targetTrack == -1: if targetTrack == -1:
return 'Inventory restocked.' return 'Inventory restocked.'
else: else:
@ -4726,14 +4714,14 @@ def inventory(a, b=None, c=None):
targetTrack = int(a) targetTrack = int(a)
except: except:
return 'Invalid first argument.' return 'Invalid first argument.'
if not invoker.hasTrackAccess(targetTrack): if not target.hasTrackAccess(targetTrack):
return "You don't have target track index: " + str(targetTrack) return "You don't have target track index: " + str(targetTrack)
maxLevelIndex = b or 6 maxLevelIndex = b or 6
if not 0 <= maxLevelIndex < len(ToontownBattleGlobals.Levels[0]): if not 0 <= maxLevelIndex < len(ToontownBattleGlobals.Levels[0]):
return 'Invalid max level index: ' + str(maxLevelIndex) return 'Invalid max level index: ' + str(maxLevelIndex)
for _ in xrange(c): for _ in xrange(c):
inventory.addItem(targetTrack, maxLevelIndex) inventory.addItem(targetTrack, maxLevelIndex)
invoker.b_setInventory(inventory.makeNetString()) target.b_setInventory(inventory.makeNetString())
return 'Restored %d Gags to: %d, %d' % (c, targetTrack, maxLevelIndex) return 'Restored %d Gags to: %d, %d' % (c, targetTrack, maxLevelIndex)
@magicWord(category=CATEGORY_CREATIVE, types=[str, str]) @magicWord(category=CATEGORY_CREATIVE, types=[str, str])
@ -5061,7 +5049,7 @@ def summoncogdo(track="s", difficulty=5):
av = spellbook.getInvoker() av = spellbook.getInvoker()
building = av.findClosestDoor() building = av.findClosestDoor()
if building == None: if building == None:
return "No bldg found!" return "No Toon building found!"
building.cogdoTakeOver(difficulty, 2, track) building.cogdoTakeOver(difficulty, 2, track)
return 'Successfully spawned cogdo with track %s and difficulty %d' % (track, difficulty) return 'Successfully spawned cogdo with track %s and difficulty %d' % (track, difficulty)