mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-18 17:27:50 -05:00
feat(pets): play as your pet in any room, from the pet chooser
A switch in the pet chooser (the settings menu's own On/Off switch, at
the top left of the pet's picture) puts the pet that is out in the
avatar's place, for everyone, as at a Play-As-Your-Pet party: the pet
at the party's size where the avatar stands, turning as it walks, its
name on the name bar, chat balloons and emotes over it, the pet in the
HUD. Hidden at the party itself.
- kept as user var 9008 (9007 is the performance profile), so it holds
through rooms and logins and is kept for the next pet when the pet is
put away. the server tells the room by user communication type 13,
also to players coming in later.
- WorldPet and AvatarWorldView ask the avatar's own form instead of the
room-wide party test; a pet that cannot come into the room leaves the
avatar shown.
- the type-13 handler read a variable it never set, so every client took
every message for "off" and nobody else saw the form.
- the action menu's pet button does the pet's trick again (5c9b2e0 had
made it the switch, which only hid the avatar).
Flying pets keep to the ground's walls (the party lets them over).
buildVersion 74.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
2344270291
commit
096ceafea7
12 files changed
+627
-67
No files matched your search
@@ -608,6 +608,14 @@ package
|
||||
return settingOf(9006) != 1;
|
||||
}
|
||||
|
||||
// the pet chooser's "play as your pet" switch (gui.PetInventory): the
|
||||
// pet that is out stands in for the avatar in any room. user var 9008,
|
||||
// which the server also reads to show the pet form to everyone.
|
||||
public static function petFormOn() : Boolean
|
||||
{
|
||||
return settingOf(9008) == 1;
|
||||
}
|
||||
|
||||
// an item's picture version, or null for none or with them hidden
|
||||
private static function artOf(param1:String, param2:int) : String
|
||||
{
|
||||
@@ -1542,6 +1550,7 @@ package
|
||||
// 9007 Performance profile: 1 Low-end, 2 High, unset Balanced. A
|
||||
// profile changes only optional rendering work, never the
|
||||
// game's native 24 FPS (which would slow its animations).
|
||||
// 9008 Play as your pet (gui.PetInventory, lib/pets.js): 1 on.
|
||||
|
||||
|
||||
private static var _smoothTimer:Timer;
|
||||
|
||||
@@ -700,19 +700,6 @@ package gui
|
||||
{
|
||||
var _loc2_:WorldPet = null;
|
||||
param1.stopPropagation();
|
||||
// Outside a play-as-your-pet event this button is the personal
|
||||
// pet-form switch. The server echoes the change to everybody in
|
||||
// the room, so this is not merely a local visual effect.
|
||||
if(!GuiManager.isBeYourPetRoom())
|
||||
{
|
||||
if(AvatarManager.playerAvatarWorldView && AvatarManager.playerAvatarWorldView.getActivePet())
|
||||
{
|
||||
UserCommXtCommManager.sendPetPlayerMode(!GuiManager.isPlayingAsPet());
|
||||
}
|
||||
actionBtn.dispatchEvent(new MouseEvent("mouseDown"));
|
||||
param1.currentTarget.downToUpState();
|
||||
return;
|
||||
}
|
||||
if(AvatarManager.playerAvatarWorldView)
|
||||
{
|
||||
_loc2_ = AvatarManager.playerAvatarWorldView.getActivePet();
|
||||
|
||||
+73
-15
@@ -335,6 +335,12 @@ package avatar
|
||||
private var _currPetName:String;
|
||||
|
||||
private var _shouldShowPetOnly:Boolean;
|
||||
|
||||
// the pet chooser's switch as last heard for this avatar (type-13 user
|
||||
// communication), and the pet last set, to make it again in either form
|
||||
private var _petPlayerMode:Boolean;
|
||||
|
||||
private var _petArgs:Array;
|
||||
|
||||
private var _emitParticles:Boolean;
|
||||
|
||||
@@ -552,7 +558,7 @@ package avatar
|
||||
_loc12_ = 1;
|
||||
}
|
||||
_chatBalloon = GETDEFINITIONBYNAME("ChatBalloonAsset",false);
|
||||
_chatBalloon.init(_avatar.avTypeId,AvatarUtility.getAvatarEmoteBgOffset,false,_loc12_,RoomManagerWorld.instance.layerManager.bkg.scaleX,SBTextField,onChatBallonAdventureDown,onChatBalloonPVPDown);
|
||||
_chatBalloon.init(_avatar.avTypeId,emoteBgOffset,false,_loc12_,RoomManagerWorld.instance.layerManager.bkg.scaleX,SBTextField,onChatBallonAdventureDown,onChatBalloonPVPDown);
|
||||
_chatLayer.addChild(_chatBalloon);
|
||||
_moving = 0;
|
||||
_lastMoveAngle = 2;
|
||||
@@ -605,7 +611,7 @@ package avatar
|
||||
_hudViewHolder.mouse.gotoAndStop(offScreenDefaultMouseFrameLabel());
|
||||
}
|
||||
}
|
||||
_shouldShowPetOnly = GuiManager.isBeYourPetRoom() || userId == AvatarManager.playerSfsUserId && GuiManager.isPlayingAsPet();
|
||||
_shouldShowPetOnly = GuiManager.isBeYourPetRoom() || (userId == AvatarManager.playerSfsUserId ? GuiManager.isPlayingAsPet() : _petPlayerMode);
|
||||
if(_shouldShowPetOnly)
|
||||
{
|
||||
_layerAnim.alpha = 0;
|
||||
@@ -2066,6 +2072,7 @@ package avatar
|
||||
|
||||
public function setActivePet(param1:Number, param2:uint, param3:uint, param4:uint, param5:String, param6:int, param7:int, param8:int, param9:int = 0) : void
|
||||
{
|
||||
_petArgs = [param1,param2,param3,param4,param5,param6,param7,param8,param9];
|
||||
if(_pet)
|
||||
{
|
||||
if(_pet.parent == this)
|
||||
@@ -2094,6 +2101,17 @@ package avatar
|
||||
{
|
||||
_splash.showShadow(true);
|
||||
}
|
||||
// another pet out in the pet form: the HUD shows the new one
|
||||
if(_shouldShowPetOnly && userId == AvatarManager.playerSfsUserId)
|
||||
{
|
||||
GuiManager.setPersonalPetMode(true);
|
||||
}
|
||||
}
|
||||
// a pet that cannot come into this room leaves the avatar shown
|
||||
if(_shouldShowPetOnly && !_pet && !GuiManager.isBeYourPetRoom())
|
||||
{
|
||||
_shouldShowPetOnly = false;
|
||||
showPetForm();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2102,8 +2120,30 @@ package avatar
|
||||
// own state instead of asking the room-wide GuiManager predicate.
|
||||
public function setPetPlayerMode(param1:Boolean) : void
|
||||
{
|
||||
var _loc2_:Boolean = param1 && _pet != null;
|
||||
_shouldShowPetOnly = _loc2_ || GuiManager.isBeYourPetRoom();
|
||||
var _loc2_:Boolean = false;
|
||||
_petPlayerMode = param1;
|
||||
_loc2_ = GuiManager.isBeYourPetRoom() || param1 && _petArgs != null && _petArgs[1] != 0;
|
||||
if(_loc2_ != _shouldShowPetOnly)
|
||||
{
|
||||
_shouldShowPetOnly = _loc2_;
|
||||
// WorldPet takes its size and place from the form when it is
|
||||
// made, so the pet is made again
|
||||
if(_petArgs != null)
|
||||
{
|
||||
setActivePet.apply(this,_petArgs);
|
||||
}
|
||||
}
|
||||
showPetForm();
|
||||
if(userId == AvatarManager.playerSfsUserId)
|
||||
{
|
||||
GuiManager.setPersonalPetMode(_shouldShowPetOnly);
|
||||
}
|
||||
}
|
||||
|
||||
// the avatar or its pet, as _shouldShowPetOnly says
|
||||
private function showPetForm() : void
|
||||
{
|
||||
var _loc1_:UserInfo = null;
|
||||
_layerAnim.alpha = _shouldShowPetOnly ? 0 : 1;
|
||||
_layerAnim.avatarEnabled = !_shouldShowPetOnly;
|
||||
if(_shouldShowPetOnly && _pet)
|
||||
@@ -2117,12 +2157,32 @@ package avatar
|
||||
else
|
||||
{
|
||||
_splash.showShadow(true);
|
||||
_namebar.setAvName(_avatar.avName);
|
||||
}
|
||||
if(userId == AvatarManager.playerSfsUserId)
|
||||
{
|
||||
GuiManager.setPersonalPetMode(_loc2_);
|
||||
_loc1_ = gMainFrame.userInfo.getUserInfoByUserName(_avatar.userName);
|
||||
_namebar.setAvName(_avatar,Utility.isSettingOn(MySettings.SETTINGS_USERNAME_BADGE),_loc1_);
|
||||
}
|
||||
placeChatBalloon();
|
||||
updateChatBallonBgOffsets();
|
||||
}
|
||||
|
||||
// the pet stands in for this avatar: the party's or quest's form, or
|
||||
// the pet chooser's switch (WorldPet asks)
|
||||
public function isPetForm() : Boolean
|
||||
{
|
||||
return _shouldShowPetOnly;
|
||||
}
|
||||
|
||||
// chat balloons and emotes sit over the pet in its form, as the
|
||||
// party's do (AvatarUtility's pet offsets)
|
||||
private function placeChatBalloon() : void
|
||||
{
|
||||
var _loc1_:Point = _shouldShowPetOnly ? new Point(10,-80) : AvatarUtility.getAvatarChatOffset(_avatar.avTypeId);
|
||||
_chatBalloon.x = this.x + _loc1_.x;
|
||||
_chatBalloon.y = this.y + _loc1_.y;
|
||||
}
|
||||
|
||||
private function emoteBgOffset(param1:int) : Point
|
||||
{
|
||||
return _shouldShowPetOnly ? new Point(-5,-25) : AvatarUtility.getAvatarEmoteBgOffset(param1);
|
||||
}
|
||||
|
||||
public function getActivePet() : WorldPet
|
||||
@@ -2281,9 +2341,7 @@ package avatar
|
||||
param2 *= _scale.y;
|
||||
this.x = param1;
|
||||
this.y = param2;
|
||||
var _loc3_:Point = AvatarUtility.getAvatarChatOffset(_avatar.avTypeId);
|
||||
_chatBalloon.x = this.x + _loc3_.x;
|
||||
_chatBalloon.y = this.y + _loc3_.y;
|
||||
placeChatBalloon();
|
||||
if(_avSwitchedNPC)
|
||||
{
|
||||
_avSwitchedNPC.x = param1;
|
||||
@@ -2359,9 +2417,9 @@ package avatar
|
||||
{
|
||||
_hudViewHolder.mouse.gotoAndStop(offScreenDefaultMouseFrameLabel());
|
||||
}
|
||||
if(GuiManager.isBeYourPetRoom())
|
||||
_loc7_ = gMainFrame.userInfo.getAvatarInfoByUsernamePerUserAvId(userName,perUserAvId);
|
||||
if(_shouldShowPetOnly && _loc7_ && _loc7_.currPet)
|
||||
{
|
||||
_loc7_ = gMainFrame.userInfo.getAvatarInfoByUsernamePerUserAvId(userName,perUserAvId);
|
||||
_hudAvtOrPetView = new GuiPet(_loc7_.currPet.createdTs,0,_loc7_.currPet.lBits,_loc7_.currPet.uBits,_loc7_.currPet.eBits,_loc7_.currPet.type,_loc7_.currPet.name,_loc7_.currPet.personalityDefId,_loc7_.currPet.favoriteToyDefId,_loc7_.currPet.favoriteFoodDefId,onHudAvtOrPetView);
|
||||
}
|
||||
else
|
||||
@@ -2479,7 +2537,7 @@ package avatar
|
||||
var _loc3_:Number = NaN;
|
||||
if(_hudAvtOrPetView)
|
||||
{
|
||||
if(GuiManager.isBeYourPetRoom())
|
||||
if(_hudAvtOrPetView is GuiPet)
|
||||
{
|
||||
_hudAvtOrPetView.y = 15;
|
||||
}
|
||||
|
||||
+5
-11
@@ -181,10 +181,6 @@ package gui
|
||||
|
||||
private static var _petInventory:PetInventory;
|
||||
|
||||
// A player's voluntary pet form. Party and quest pet forms remain
|
||||
// room-wide and are still reported by isBeYourPetRoom().
|
||||
private static var _personalPetMode:Boolean = false;
|
||||
|
||||
private static var _joeyPopup:MovieClip;
|
||||
|
||||
private static var _secondaryJoeyPopup:MovieClip;
|
||||
@@ -2616,7 +2612,7 @@ package gui
|
||||
{
|
||||
mainHud.charWindow.charLayer.removeChildAt(0);
|
||||
}
|
||||
if(isBeYourPetRoom())
|
||||
if(isPlayingAsPet())
|
||||
{
|
||||
_loc1_ = PetManager.myActivePet;
|
||||
if(_loc1_)
|
||||
@@ -2911,18 +2907,16 @@ package gui
|
||||
return QuestManager.isBeYourPetQuest() || PartyManager.isBeYourPetParty();
|
||||
}
|
||||
|
||||
// A player's own pet form: the party's and the quest's for everyone in
|
||||
// the room, or the pet chooser's switch with a pet out.
|
||||
public static function isPlayingAsPet() : Boolean
|
||||
{
|
||||
return _personalPetMode || isBeYourPetRoom();
|
||||
return isBeYourPetRoom() || AJClient.petFormOn() && PetManager.myActivePet != null;
|
||||
}
|
||||
|
||||
// the player's own avatar came into or out of its pet form
|
||||
public static function setPersonalPetMode(param1:Boolean) : void
|
||||
{
|
||||
if(_personalPetMode == param1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_personalPetMode = param1;
|
||||
if(mainHud)
|
||||
{
|
||||
showHudAvt();
|
||||
|
||||
@@ -3,6 +3,7 @@ package gui
|
||||
import Party.PartyManager;
|
||||
import adoptAPet.AdoptAPetManager;
|
||||
import avatar.AvatarManager;
|
||||
import avatar.UserCommXtCommManager;
|
||||
import com.sbi.analytics.SBTracker;
|
||||
import com.sbi.popup.SBOkPopup;
|
||||
import com.sbi.popup.SBYesNoPopup;
|
||||
@@ -43,6 +44,12 @@ package gui
|
||||
private var _inventoryMC:MovieClip;
|
||||
|
||||
private var _loadingMediaHelper:MediaHelper;
|
||||
|
||||
// "play as your pet": the settings menu's on/off switch, in any room
|
||||
// but a Play-As-Your-Pet party's (AJClient.petFormOn)
|
||||
private var _petFormSwitch:MovieClip;
|
||||
|
||||
private var _petFormOn:Boolean;
|
||||
|
||||
private var _loadingSpiralBig:LoadingSpiral;
|
||||
|
||||
@@ -222,6 +229,7 @@ package gui
|
||||
_guiLayer.addChild(_inventoryMC);
|
||||
DarkenManager.darken(_inventoryMC);
|
||||
createItemWindows();
|
||||
addPetFormSwitch();
|
||||
addEventListeners();
|
||||
if(_openCheckListImmediately)
|
||||
{
|
||||
@@ -246,6 +254,58 @@ package gui
|
||||
}
|
||||
|
||||
// A double click on the big pet's name lets the player type another.
|
||||
// the switch sits at the top left of the pet's picture, across from
|
||||
// the certificate. on, whichever pet is out stands in for the avatar,
|
||||
// for everyone (the server keeps it with the user vars and tells the
|
||||
// room: UserCommXtCommManager type 13).
|
||||
private function addPetFormSwitch() : void
|
||||
{
|
||||
var _loc1_:MovieClip = null;
|
||||
if(GuiManager.isBeYourPetRoom())
|
||||
{
|
||||
return;
|
||||
}
|
||||
_loc1_ = GETDEFINITIONBYNAME("mySettingsToggle",false);
|
||||
_petFormSwitch = _loc1_.toggleBtn;
|
||||
_loc1_.removeChild(_petFormSwitch);
|
||||
_petFormSwitch.x = 78;
|
||||
_petFormSwitch.y = -143;
|
||||
_petFormSwitch.buttonMode = true;
|
||||
_petFormSwitch.useHandCursor = true;
|
||||
_petFormSwitch.toggleBtn.toggleKnob.gotoAndStop("up");
|
||||
_petFormSwitch.toggleBtn.toggleBG.gotoAndStop("up");
|
||||
_petFormOn = AJClient.petFormOn();
|
||||
_petFormSwitch.toggleBtn.gotoAndStop(_petFormOn ? "startingOn" : "startingOff");
|
||||
LocalizationManager.translateId(_petFormSwitch.toggleBtn.valueTxt.onTxt,6324);
|
||||
LocalizationManager.translateId(_petFormSwitch.toggleBtn.valueTxt.offTxt,6322);
|
||||
_inventoryMC.addChild(_petFormSwitch);
|
||||
}
|
||||
|
||||
private function onPetFormSwitch(param1:MouseEvent) : void
|
||||
{
|
||||
param1.stopPropagation();
|
||||
_petFormOn = !_petFormOn;
|
||||
_petFormSwitch.toggleBtn.gotoAndPlay(_petFormOn ? "on" : "off");
|
||||
UserCommXtCommManager.sendPetPlayerMode(_petFormOn);
|
||||
}
|
||||
|
||||
private function onPetFormSwitchOver(param1:MouseEvent) : void
|
||||
{
|
||||
param1.stopPropagation();
|
||||
_petFormSwitch.toggleBtn.toggleBG.gotoAndStop("over");
|
||||
_petFormSwitch.toggleBtn.toggleKnob.gotoAndStop("over");
|
||||
GuiManager.toolTip.init(_petFormSwitch,"Play as your pet",58,-10);
|
||||
GuiManager.toolTip.startTimer(param1);
|
||||
}
|
||||
|
||||
private function onPetFormSwitchOut(param1:MouseEvent) : void
|
||||
{
|
||||
param1.stopPropagation();
|
||||
_petFormSwitch.toggleBtn.toggleBG.gotoAndStop("up");
|
||||
_petFormSwitch.toggleBtn.toggleKnob.gotoAndStop("up");
|
||||
GuiManager.toolTip.resetTimerAndSetVisibility();
|
||||
}
|
||||
|
||||
private function onPetRenamed(param1:String) : void
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
@@ -852,6 +912,12 @@ package gui
|
||||
_inventoryMC.salonBtn.addEventListener("mouseDown",onSalonBtn,false,0,true);
|
||||
_inventoryMC.checklistBtn.addEventListener("mouseDown",onChecklistBtn,false,0,true);
|
||||
_inventoryMC.certBtn.addEventListener("mouseDown",onCertBtn,false,0,true);
|
||||
if(_petFormSwitch)
|
||||
{
|
||||
_petFormSwitch.addEventListener("mouseDown",onPetFormSwitch,false,0,true);
|
||||
_petFormSwitch.addEventListener("rollOver",onPetFormSwitchOver,false,0,true);
|
||||
_petFormSwitch.addEventListener("rollOut",onPetFormSwitchOut,false,0,true);
|
||||
}
|
||||
}
|
||||
|
||||
private function removeEventListeners() : void
|
||||
@@ -866,6 +932,14 @@ package gui
|
||||
_inventoryMC.salonBtn.removeEventListener("mouseDown",onSalonBtn);
|
||||
_inventoryMC.checklistBtn.removeEventListener("mouseDown",onChecklistBtn);
|
||||
_inventoryMC.certBtn.removeEventListener("mouseDown",onCertBtn);
|
||||
if(_petFormSwitch)
|
||||
{
|
||||
_petFormSwitch.removeEventListener("mouseDown",onPetFormSwitch);
|
||||
_petFormSwitch.removeEventListener("rollOver",onPetFormSwitchOver);
|
||||
_petFormSwitch.removeEventListener("rollOut",onPetFormSwitchOut);
|
||||
GuiManager.toolTip.resetTimerAndSetVisibility();
|
||||
_petFormSwitch = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -725,7 +725,7 @@ package avatar
|
||||
{
|
||||
if(AvatarManager.avatarViewList[_loc19_])
|
||||
{
|
||||
AvatarManager.avatarViewList[_loc19_].setPetPlayerMode(_loc2_ == "on");
|
||||
AvatarManager.avatarViewList[_loc19_].setPetPlayerMode(param1[3] == "on");
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -0,0 +1,421 @@
|
||||
package pet
|
||||
{
|
||||
import avatar.AvatarWorldView;
|
||||
import avatar.UserCommXtCommManager;
|
||||
import flash.display.MovieClip;
|
||||
import flash.events.MouseEvent;
|
||||
import flash.geom.Matrix;
|
||||
import gui.GuiManager;
|
||||
|
||||
public class WorldPet extends PetBase
|
||||
{
|
||||
|
||||
public static const ANIM_IDLE:int = 0;
|
||||
|
||||
public static const ANIM_MOVE:int = 1;
|
||||
|
||||
public static const ANIM_IDLE_UP:int = 2;
|
||||
|
||||
public static const ANIM_MOVE_UP:int = 3;
|
||||
|
||||
public static const ANIM_CLICK:int = 4;
|
||||
|
||||
public static const ANIM_IDLE_WATER:int = 10;
|
||||
|
||||
public static const ANIM_IDLE_MUD:int = 20;
|
||||
|
||||
public static const ANIM_DANCE:int = 31;
|
||||
|
||||
public static const ANIM_SLEEP_OR_DIVE:int = 32;
|
||||
|
||||
public static const ANIM_HOP_OR_SWIRL:int = 33;
|
||||
|
||||
public static const ANIM_PLAY:int = 34;
|
||||
|
||||
public static const ANIM_SIT_OR_POSE:int = 35;
|
||||
|
||||
public static const ACTION_CLICK:int = 0;
|
||||
|
||||
public static const ACTION_SPARKLE:int = 1;
|
||||
|
||||
public static const PET_SPARKLE_TIME:int = 7200;
|
||||
|
||||
public static var _actionLookup:Array = [{
|
||||
"name":":dance:",
|
||||
"animId":31
|
||||
},{
|
||||
"name":":sleep:",
|
||||
"animId":32
|
||||
},{
|
||||
"name":":dive:",
|
||||
"animId":32
|
||||
},{
|
||||
"name":":hop:",
|
||||
"animId":33
|
||||
},{
|
||||
"name":":swirl:",
|
||||
"animId":33
|
||||
},{
|
||||
"name":":play:",
|
||||
"animId":34
|
||||
},{
|
||||
"name":":sit:",
|
||||
"animId":35
|
||||
},{
|
||||
"name":":sitNW:",
|
||||
"animId":35
|
||||
},{
|
||||
"name":":sitSW:",
|
||||
"animId":35
|
||||
},{
|
||||
"name":":sitSE:",
|
||||
"animId":35
|
||||
},{
|
||||
"name":":sitNE:",
|
||||
"animId":35
|
||||
},{
|
||||
"name":":pose:",
|
||||
"animId":35
|
||||
},{
|
||||
"name":":poseLeft:",
|
||||
"animId":35
|
||||
},{
|
||||
"name":":poseRight:",
|
||||
"animId":35
|
||||
}];
|
||||
|
||||
private var _parent:AvatarWorldView;
|
||||
|
||||
private var _mode:int;
|
||||
|
||||
private var _x:int;
|
||||
|
||||
private var _y:int;
|
||||
|
||||
private var _targetX:int;
|
||||
|
||||
private var _targetY:int;
|
||||
|
||||
private var _bNewTarget:Boolean;
|
||||
|
||||
private var _dirX:Number;
|
||||
|
||||
private var _dirY:Number;
|
||||
|
||||
private var _speed:Number;
|
||||
|
||||
private var _lastAnim:int;
|
||||
|
||||
private var _bFlip:Boolean;
|
||||
|
||||
private var _bBack:Boolean;
|
||||
|
||||
private var _bUpdateState:Boolean;
|
||||
|
||||
private var _parentLastX:Number;
|
||||
|
||||
private var _parentLastY:Number;
|
||||
|
||||
private var _bSpecialMove:Boolean;
|
||||
|
||||
private var _petLoaded:Boolean;
|
||||
|
||||
private var _sparkle:int;
|
||||
|
||||
private var _offsetX:int = 100;
|
||||
|
||||
private var _offsetY:int = -50;
|
||||
|
||||
private var _maxSpeed:Number = 1;
|
||||
|
||||
private var _accel:Number = 0.03;
|
||||
|
||||
private var _scale:Number = 1;
|
||||
|
||||
private var _minX:Number = -70;
|
||||
|
||||
private var _maxX:Number = 55;
|
||||
|
||||
private var _airPetYOffest:Number = -80;
|
||||
|
||||
private var _oceanPetXOffset:Number = 55;
|
||||
|
||||
private var _petLandLowXOffset:Number = 30;
|
||||
|
||||
public function WorldPet(param1:AvatarWorldView, param2:Number, param3:uint, param4:uint, param5:uint, param6:uint, param7:uint, param8:uint, param9:int = 0)
|
||||
{
|
||||
super(param2,param3,param4,param5,param6,param7,param8,onPetLoaded);
|
||||
_sparkle = param9;
|
||||
_parent = param1;
|
||||
_targetX = 0;
|
||||
_bNewTarget = true;
|
||||
_mode = 1;
|
||||
_lastAnim = -1;
|
||||
_bUpdateState = true;
|
||||
_bFlip = false;
|
||||
_bBack = false;
|
||||
_bSpecialMove = false;
|
||||
_parent.addChild(this);
|
||||
if(param1.userName.toLowerCase() == gMainFrame.server.userName.toLowerCase() && !_parent.isPetForm())
|
||||
{
|
||||
this.addEventListener("mouseDown",onClick,false,0,true);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.mouseChildren = false;
|
||||
this.mouseEnabled = false;
|
||||
}
|
||||
if(isEggAndHasNotHatched || (getType() == 0 || getType() == 2 || getType() == 4))
|
||||
{
|
||||
if(_parent.isPetForm())
|
||||
{
|
||||
_y = -5;
|
||||
GuiManager.actionMgr.grayOutPetDanceBtn(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
_y = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GuiManager.actionMgr.grayOutPetDanceBtn(true);
|
||||
if(_parent.isPetForm())
|
||||
{
|
||||
_y = -5;
|
||||
}
|
||||
else
|
||||
{
|
||||
_y = _airPetYOffest;
|
||||
}
|
||||
}
|
||||
_parentLastX = _parent.x;
|
||||
_parentLastY = _parent.y;
|
||||
if(_parent.isPetForm())
|
||||
{
|
||||
_minX = 25;
|
||||
_maxX = -30;
|
||||
_x = _maxX;
|
||||
_parentLastX = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(getType() == 2)
|
||||
{
|
||||
_minX -= _oceanPetXOffset;
|
||||
_maxX += _oceanPetXOffset;
|
||||
}
|
||||
else if(getType() == 0)
|
||||
{
|
||||
if(param1.avTypeId != 5)
|
||||
{
|
||||
_minX -= _petLandLowXOffset;
|
||||
}
|
||||
}
|
||||
_x = 0;
|
||||
}
|
||||
_targetX = 0;
|
||||
}
|
||||
|
||||
override public function destroy() : void
|
||||
{
|
||||
super.destroy();
|
||||
this.removeEventListener("mouseDown",onClick);
|
||||
}
|
||||
|
||||
public function heartbeat(param1:int, param2:Boolean) : void
|
||||
{
|
||||
var _loc5_:int = 0;
|
||||
var _loc3_:Matrix = null;
|
||||
var _loc4_:int = 0;
|
||||
if(_content && _parent && !_parent.isOffScreen)
|
||||
{
|
||||
if(_parent.isPetForm())
|
||||
{
|
||||
if(_parentLastX != _parent.x)
|
||||
{
|
||||
if(_parent.x > _parentLastX)
|
||||
{
|
||||
if(!_bFlip)
|
||||
{
|
||||
_parent.flipSplash(true);
|
||||
_bFlip = true;
|
||||
_x = _minX;
|
||||
}
|
||||
}
|
||||
else if(_bFlip)
|
||||
{
|
||||
_parent.flipSplash(false);
|
||||
_bFlip = false;
|
||||
_x = _maxX;
|
||||
}
|
||||
_parentLastX = _parent.x;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(_targetX == 0)
|
||||
{
|
||||
_targetX = _parent.hFlip ? _minX : _maxX;
|
||||
}
|
||||
if(_parentLastX != _parent.x)
|
||||
{
|
||||
_bFlip = _parent.x > _parentLastX ? true : false;
|
||||
if(Math.abs(_parentLastX - _parent.x) > 13)
|
||||
{
|
||||
_targetX = _bFlip ? _minX : _maxX;
|
||||
}
|
||||
_parentLastX = _parent.x;
|
||||
}
|
||||
if(_parentLastY != _parent.y)
|
||||
{
|
||||
_bBack = _parent.y < _parentLastY - 10 ? true : false;
|
||||
_parentLastY = _parent.y;
|
||||
}
|
||||
if(_x > _targetX)
|
||||
{
|
||||
_x -= 10;
|
||||
if(_x <= _targetX)
|
||||
{
|
||||
_x = _targetX;
|
||||
}
|
||||
_bFlip = _x == _targetX ? true : false;
|
||||
}
|
||||
if(_x < _targetX)
|
||||
{
|
||||
_x += 10;
|
||||
if(_x > _targetX)
|
||||
{
|
||||
_x = _targetX;
|
||||
}
|
||||
_bFlip = _x == _targetX ? false : true;
|
||||
}
|
||||
}
|
||||
if(_bUpdateState)
|
||||
{
|
||||
PetManager.setPetState(_content,_lBits,_uBits,_eBits);
|
||||
_bUpdateState = false;
|
||||
}
|
||||
_loc5_ = _parent.inSplashVolume() ? 10 : 0;
|
||||
if(_loc5_ && _parent.splashLiquid == "mud")
|
||||
{
|
||||
_loc5_ = 20;
|
||||
}
|
||||
if(_parent.splashLiquid != "mud" && _parent.splashLiquid != "water")
|
||||
{
|
||||
_loc5_ = 0;
|
||||
}
|
||||
_loc3_ = _content.transform.matrix;
|
||||
_loc3_.identity();
|
||||
_loc3_.scale(_bFlip ? -_scale : _scale,_scale);
|
||||
_loc3_.translate(_x,_y - param1);
|
||||
_content.transform.matrix = _loc3_;
|
||||
_loc4_ = _loc5_ + param2;
|
||||
if(_bBack)
|
||||
{
|
||||
_loc4_ += 2;
|
||||
}
|
||||
if((param2 || _lastAnim <= 4) && _lastAnim != _loc4_)
|
||||
{
|
||||
_lastAnim = _loc4_;
|
||||
_content.pet.setAnim(_loc4_);
|
||||
}
|
||||
if(_bSpecialMove)
|
||||
{
|
||||
_bSpecialMove = false;
|
||||
if(!param2)
|
||||
{
|
||||
_content.pet.setAnim(4 + _loc5_);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function setState(param1:Array) : void
|
||||
{
|
||||
_lBits = param1[0];
|
||||
_uBits = param1[1];
|
||||
_eBits = param1[2];
|
||||
_bUpdateState = true;
|
||||
}
|
||||
|
||||
public function setAction(param1:int, param2:int = 0) : void
|
||||
{
|
||||
switch(param1)
|
||||
{
|
||||
case 0:
|
||||
onClick();
|
||||
break;
|
||||
case 1:
|
||||
setSparkle(param2);
|
||||
}
|
||||
}
|
||||
|
||||
public function setActionByName(param1:String) : void
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
for each(var _loc3_:Object in _actionLookup)
|
||||
{
|
||||
if(_loc3_.name == param1)
|
||||
{
|
||||
_loc2_ = int(_loc3_.animId);
|
||||
if(_loc2_ > 0)
|
||||
{
|
||||
_lastAnim = _loc2_;
|
||||
if(_content)
|
||||
{
|
||||
_content.pet.setAnim(_loc2_);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function onClick(param1:MouseEvent = null) : void
|
||||
{
|
||||
if(param1)
|
||||
{
|
||||
param1.stopPropagation();
|
||||
UserCommXtCommManager.sendPetAction(0);
|
||||
}
|
||||
_bSpecialMove = true;
|
||||
}
|
||||
|
||||
private function onPetLoaded(param1:MovieClip) : void
|
||||
{
|
||||
if(_parent.isPetForm())
|
||||
{
|
||||
_content.pet.scaleX = _content.pet.scaleY = 2;
|
||||
}
|
||||
_content.pet.setSparkle(_sparkle);
|
||||
}
|
||||
|
||||
private function convertAvtAnimToPetAnim() : int
|
||||
{
|
||||
switch(_parent.animId)
|
||||
{
|
||||
case 23:
|
||||
case 38:
|
||||
return 31;
|
||||
case 22:
|
||||
case 41:
|
||||
return 32;
|
||||
case 17:
|
||||
case 33:
|
||||
return 33;
|
||||
case 6:
|
||||
case 39:
|
||||
return 34;
|
||||
case 2:
|
||||
case 4:
|
||||
case 40:
|
||||
break;
|
||||
default:
|
||||
return _parent.isPetMovingTest() ? 0 : 1;
|
||||
}
|
||||
return 35;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user