| Blockland Forums > Modification Help |
| Avatar Viewer |
| (1/2) > >> |
| lilboarder32:
How does the avatar viewer in the avatar options GUI work? How can I replicate that on a separate GUI? |
| Iban:
It's been a long, long time since I wrote this code. Some things may be poorly written. I apologize. If anything is unclear, just ask. Client_CityRPG/scripts/stats.cs GUI Initilization. The GUI itself contains the dynamic object. --- Code: ---// Stats exec($CRPG_C::Path @ "guis/stats.gui"); // Clear CRPG_Avatar.setEmpty(); // Name CRPG_Avatar.dynamicObject = "fffObject"; // Object Creation and Sequences CRPG_Avatar.setObject(CRPG_Avatar.dynamicObject, "base/data/shapes/player/m.dts", "", 0); --- End code --- Updates the player model. --- Code: ---function CRPG_Stats::adjustAvatar(%gui) { CRPG_Avatar.setSequence(CRPG_Avatar.dynamicObject, 0, "headup", 0); CRPG_Avatar.setSequence(CRPG_Avatar.dynamicObject, 1, "run", 0.85); CRPG_Avatar.setOrbitDist(4.34); CRPG_Avatar.setCameraRot(0.25, 0, 4.25); if(CRPG_Avatar.parts > 0) { %gui.hideAllNodes(); %gui.adjustAvatarNodes(); %gui.adjustAvatarColors(); } else { %gui.applyDefaultPrefs(); } } --- End code --- Hides all nodes. --- Code: ---function CRPG_Stats::hideAllNodes(%gui) { %nodeCount = 0; %node[%nodeCount++] = "plume"; %node[%nodeCount++] = "triPlume"; %node[%nodeCount++] = "septPlume"; %node[%nodeCount++] = "Visor"; %node[%nodeCount++] = "helmet"; %node[%nodeCount++] = "pointyHelmet"; %node[%nodeCount++] = "flareHelmet"; %node[%nodeCount++] = "scoutHat"; %node[%nodeCount++] = "bicorn"; %node[%nodeCount++] = "copHat"; %node[%nodeCount++] = "knitHat"; %node[%nodeCount++] = "chest"; %node[%nodeCount++] = "femchest"; %node[%nodeCount++] = "pants"; %node[%nodeCount++] = "skirtHip"; %node[%nodeCount++] = "armor"; %node[%nodeCount++] = "bucket"; %node[%nodeCount++] = "cape"; %node[%nodeCount++] = "pack"; %node[%nodeCount++] = "quiver"; %node[%nodeCount++] = "tank"; %node[%nodeCount++] = "epaulets"; %node[%nodeCount++] = "epauletsRankA"; %node[%nodeCount++] = "epauletsRankB"; %node[%nodeCount++] = "epauletsRankC"; %node[%nodeCount++] = "epauletsRankD"; %node[%nodeCount++] = "ShoulderPads"; %node[%nodeCount++] = "LArm"; %node[%nodeCount++] = "LArmSlim"; %node[%nodeCount++] = "LHand"; %node[%nodeCount++] = "LHook"; %node[%nodeCount++] = "RArm"; %node[%nodeCount++] = "RArmSlim"; %node[%nodeCount++] = "RHand"; %node[%nodeCount++] = "RHook"; %node[%nodeCount++] = "pants"; %node[%nodeCount++] = "skirtHip"; %node[%nodeCount++] = "LShoe"; %node[%nodeCount++] = "LPeg"; %node[%nodeCount++] = "RShoe"; %node[%nodeCount++] = "RPeg"; %node[%nodeCount++] = "SkirtTrimLeft"; %node[%nodeCount++] = "SkirtTrimRight"; %node[%nodeCount++] = "LSki"; %node[%nodeCount++] = "RSki"; for(%i = 1; %i <= %nodeCount; %i++) { CRPG_Avatar.hideNode(CRPG_Avatar.dynamicObject, %node[%i]); } } --- End code --- Unhides nodes we want to show. --- Code: ---function CRPG_Stats::adjustAvatarNodes(%gui) { CRPG_Avatar.unHideNode(CRPG_Avatar.dynamicObject, "headskin"); if(CRPG_Avatar.parts > 0) { for(%i = 0; %i < CRPG_Avatar.parts; %i++) { CRPG_Avatar.unHideNode(CRPG_Avatar.dynamicObject, CRPG_Avatar.part[%i]); } } CRPG_Avatar.setIflFrame(CRPG_Avatar.dynamicObject, "face", getIflFrame("face", $Pref::Avatar::FaceName)); CRPG_Avatar.setIflFrame(CRPG_Avatar.dynamicObject, "decal", getIflFrame("decal", CRPG_Avatar.decal)); } --- End code --- Colors those parts. --- Code: ---function CRPG_Stats::adjustAvatarColors(%gui) { if(CRPG_Avatar.parts > 0) { CRPG_Avatar.setNodeColor(CRPG_Avatar.dynamicObject, "headskin", $pref::Avatar::HeadColor); for(%i = 0; %i < CRPG_Avatar.parts; %i++) { %color = CRPG_Avatar.color[%i]; if(%color $= "skin") { %color = $pref::Avatar::HeadColor; } CRPG_Avatar.setNodeColor(CRPG_Avatar.dynamicObject, CRPG_Avatar.part[%i], %color); } } } --- End code --- Sets the character to the default blockhead model. Same as applyDefaultPrefs to a player in-game. --- Code: ---function CRPG_Stats::applyDefaultPrefs(%gui) { %gui.hideAllNodes(); %nodeCount = 0; %node[%nodeCount++] = "headSkin" TAB "1 1 0 1"; %node[%nodeCount++] = "chest" TAB "1 1 1 1"; %node[%nodeCount++] = "LArm" TAB "1 1 1 1"; %node[%nodeCount++] = "RArm" TAB "1 1 1 1"; %node[%nodeCount++] = "LHand" TAB "1 1 0 1"; %node[%nodeCount++] = "RHand" TAB "1 1 0 1"; %node[%nodeCount++] = "pants" TAB "0 0 0.8 1"; %node[%nodeCount++] = "LShoe" TAB "0.2 0.2 0.2 1"; %node[%nodeCount++] = "RShoe" TAB "0.2 0.2 0.2 1"; for(%i = 1; %i <= %nodeCount; %i++) { CRPG_Avatar.unHideNode(CRPG_Avatar.dynamicObject, getField(%node[%i], 0)); CRPG_Avatar.setNodeColor(CRPG_Avatar.dynamicObject, getField(%node[%i], 0), getField(%node[%i], 1)); } CRPG_Avatar.setIflFrame(CRPG_Avatar.dynamicObject, "face", 0); CRPG_Avatar.setIflFrame(CRPG_Avatar.dynamicObject, "decal", 0); } --- End code --- Fetches the IFL frame index. --- Code: ---function getIflFrame(%node, %name) { %file = "base/data/shapes/player/" @ %node @ ".ifl"; if(isFile(%file)) { %name = stripTrailingSpaces(fileBase(%name)); if(%name !$= "") { %fo = new FileObject() {}; %fo.openForRead(%file); %hasFound = false; %lineNum = 0; while(!%fo.isEOF()) { %line = %fo.readLine(); %thisDecal = stripTrailingSpaces(fileBase(%line)); if(%thisDecal $= %name) { %hasFound = true; break; } else { %lineNum++; } } %fo.close(); %fo.delete(); if(%hasFound) { return %lineNum; } else { return 0; } } else { return 0; } } else { echo("\c2getIflFrame(\"" @ %node @ "\", \"" @ %name @ "\") : You did not supply a proper IFL file name to read from."); return 0; } } --- End code --- Client_CityRPG/guis/stats.gui --- Code: --- new GuiObjectView(CRPG_Avatar) { profile = "GuiDefaultProfile"; horizSizing = "right"; vertSizing = "bottom"; position = "-25 27"; extent = "258 387"; minExtent = "8 2"; visible = "1"; cameraZRot = "0"; forceFOV = "35"; lightDirection = "0.721277 0.57735 0.57735"; lightColor = "1.000000 1.000000 1.000000 1.000000"; ambientColor = "0.500000 0.500000 0.500000 1.000000"; }; --- End code --- |
| lilboarder32:
Wow, that's great Iban, thanks a ton. |
| MegaScientifical:
Can this be adapted to the Beta-Retail Playertype, lilboarder32? :P |
| Iban:
--- Quote from: MegaScientifical on March 21, 2011, 09:24:33 PM ---Can this be adapted to the Beta-Retail Playertype, lilboarder32? :P --- End quote --- I had pictures of a pink horse and the tank vehicle but that was before I got a virus and had to clean it. if you can see the model in-game, you can put it in the viewer. |
| Navigation |
| Message Index |
| Next page |