Author Topic: Node coloring  (Read 3288 times)

Alright, so I have this AI I am trying to color every node black. I thought this was done by setting all the color codes to 0, however that just resulted in making all the nodes white.
Code: [Select]
%obj.name = "Renderman";
%obj.chestcolor = "1 .0 0 0";
%obj.hatcolor = "1 .0 0 0";
%obj.rarmcolor = "1 .0 0 0";
%obj.larmcolor = "1 .0 0 0";
%obj.hipcolor = "1 .0 0 0";
%obj.llegcolor = "1 .0 0 0";
%obj.rlegcolor = "1 .0 0 0";

%obj.chest = "0";
%obj.lhand = "0";
%obj.rhand = "0";
%obj.larm = "0";
%obj.rarm = "0";
%obj.hat = "0";
%obj.accent = "0";
%obj.pack = "0";
%obj.secondpack = "0";
%obj.lleg = "0";
%obj.rleg = "0";
%obj.hip = "0";

GameConnection::ApplyBodyParts(%obj);
GameConnection::ApplyBodyColors(%obj);
%obj.setfacename("asciiTerror");
%obj.setdecalname("Mod-Suitblack");
%color = %obj.getdatablock().skincolor;
%obj.setNodecolor($rhand[0], %color);
%obj.setNodecolor($lhand[0], %color);
%obj.setNodecolor("headskin", %color);

Can anyone tell me what I'm doing wrong or fix it?

That color code makes no sense. Try either "0 0 0" or "0 0 0 1".

Also,
Code: [Select]
       GameConnection::ApplyBodyParts(%obj);
GameConnection::ApplyBodyColors(%obj);
Should be

Code: [Select]
       %obj.ApplyBodyParts();
        %obj.ApplyBodyColors();
and I'm not sure what you're trying to do with all the code after that part, those are all set by the .applyBody_____()



I have something that uses a bot with a customized appearance, here's all the code I have for it to spawn on map load, and automatically respawn if it dies

Code: [Select]
package AdambotBody
{
function AIConnection::spawnPlayer(%this,%location)
{
if(%this $= Adambot)
{
%this.player = new AIPlayer()
{
datablock = PlayerStandardArmor;
};
%this.player.client = %this;
%this.player.setTransform(%location);
%this.applyBodyParts();
%this.applyBodyColors();
%this.player.setScale("0.7 0.7 0.7");
}
else
Parent::spawnPlayer(%this,%location);
}

function AIConnection::onDeath(%this,%obj,%name,%something,%location)
{
if(%this $= Adambot)
%this.spawnPlayer(pickSpawnLocation());
else
Parent::spawnPlayer(%this,%obj,%name,%something,%location);
}

function onMissionLoaded()
{
Parent::onMissionLoaded();
new AIConnection(Adambot){};
Adambot.chestColor = "0.078 0.078 0.078 1";
Adambot.decalName = "Mod-Suit";
Adambot.faceName = "smiley";
Adambot.headColor = "1 0.878 0.611 1";
Adambot.hidColor = "0.078 0.078 0.078 1";
Adambot.larmColor = "0.078 0.078 0.078 1";
Adambot.lhandColor = "1 0.878 0.611 1";
Adambot.llegColor = "0.078 0.078 0.078 1";
Adambot.rarmColor = "0.078 0.078 0.078 1";
Adambot.rhandColor = "1 0.878 0.611 1";
Adambot.rlegColor = "0.078 0.078 0.078 1";
Adambot.name = "Adambot";
Adambot.netName = "Adambot";
Adambot.spawnPlayer(pickSpawnPoint());
AdambotBody::Tick();
}

function onServerDestroyed()
{
Parent::onServerDestroyed();
Adambot.delete();
}
};
Activatepackage(AdambotBody);
« Last Edit: September 14, 2011, 12:19:53 PM by Headcrab Zombie »

You guys are thinking about this too hard.

Code: [Select]
package blah
{
function GameConnection::applyBodyColors(%this)
{
parent::applyBodyColors(%this);
%this.player.setNodeColor("ALL","0 0 0 1");
}
};
activatePackage(blah);

You guys are thinking about this too hard.

Code: [Select]
package blah
{
function GameConnection::applyBodyColors(%this)
{
parent::applyBodyColors(%this);
%this.player.setNodeColor("ALL","0 0 0 1");
}
};
activatePackage(blah);

Didn't seem to work.
Quote from: console
Add-Ons/Ai_Renderman/Ai_Renderman.cs (0): Unable to find object: '' attempting to call function 'setNodeColor'
BackTrace: ->Kingfy->[blah]GameConnection::ApplyBodyColors

Lol renderman. I was making an AI for this, but its fubar.

Didn't seem to work.
That means that the person hadn't spawned yet. ApplyBodyColors shouldn't be called until the player has spawned. Can you post the rest of your code?

Code: [Select]
datablock AudioProfile(kingDieSound)
{
   fileName = "./death.wav";
   description = AudioClose3d;
   preload = true;
};

datablock PlayerData(KingZombie : PlayerStandardArmor)
{
//category = "Vehicles";
minJetEnergy = 1;
jetEnergyDrain = 1;
canJet = 1;
maxItems   = 0; //total number of bricks you can carry
maxWeapons = 0; //this will be controlled by mini-game code
maxTools = 0;
runforce = 100 * 30;
maxForwardSpeed = 35;
maxBackwardSpeed = 30;
maxSideSpeed = 6;
attackpower = 800;
//jumpsound = "ZombieJumpSound";
cameradefaultFOV = 90;
cameraMaxFov = 120;
cameraMinFov = 10;
//minlookangle = -1;
//maxlookangle = -1;
minlookangle = -1.5708;
maxlookangle = 1.5708;
BrickDestroyMaxVolume = 250;
BrickMaxJumpHeight = 5;// 10
uiName = "Renderman";
rideable = true;
canRide = false;
BrickKillRadius = 2;
skinColor = "1 0.79 0.57 1";
FollowAnim = "Flailarms";
randomwalk = 1;
aimatplayer = 1;
SpecialAttack = 1;
NoBloodyHands = 1;
DoNotZombify = 1;
chance = 90;
ZombieTeam = "King";
};
function KingZombie::SpecialAttack(%this,%onshot)
{
if(getsimtime() >= %this.lastspecial+3000 && %this.getstate() !$= "Dead")
{
%ran = getrandom(-1,1);
%ran2 = getrandom(-1,1);
%this.setmovex(%ran);
%this.setmovey(%ran2);
schedule(0,0,BotShootMode,%this);
schedule(500,0,BotShootMode,%this);// (500...
schedule(1000,0,BotShootMode,%this);// (1000...
schedule(1500,0,BotShootMode,%this);// (1500...
%this.schedule(2800,clearmovex);
%this.schedule(2800,clearmovey);
%this.lastspecial = getsimtime();
}
}
function KingZombie::ondisabled(%this,%obj)
{
parent::ondisabled(%this,%obj);
ZombieDefault::ondisabled(%this,%obj);
}
function KingZombie::onCollision(%this, %obj, %col, %fade, %pos, %norm)
{
parent::oncollision(%this, %obj, %col, %fade, %pos, %norm);
ZombieDefault::onCollision(%this, %obj, %col, %fade, %pos, %norm);
}
function KingZombie::onMount(%a,%player,%vehicle,%d,%e,%f)
{
ZombieDefault::onMount(%a,%player,%vehicle,%d,%e,%f);
parent::onMount(%a,%player,%vehicle,%d,%e,%f);
}
function KingZombie::onUnMount(%a,%player,%vehicle,%d,%e,%f)
{
ZombieDefault::onUnMount(%a,%player,%vehicle,%d,%e,%f);
parent::onUnMount(%a,%player,%vehicle,%d,%e,%f);
}
function KingZombie::onAdd(%this,%obj)
{
parent::onAdd(%this,%obj);
ZombieDefault::onAdd(%this,%obj);
schedule(15,0,Kingfy,%obj);
%obj.mountimage(LauncherImage,0);
//%obj.mountimage(spearImage,0);
%obj.setscale("0.75 0.75 1.5");
}

function Kingfy(%obj)
{
%obj.name = "Renderman";
%obj.chestcolor = "0 0 0 1";
%obj.hatcolor = "0 0 0 1";
%obj.rarmcolor = "0 0 0 1";
%obj.larmcolor = "0 0 0 1";
%obj.hipcolor = "0 0 0 1";
%obj.llegcolor = "0 0 0 1";
%obj.rlegcolor = "0 0 0 1";

%obj.chest = "0";
%obj.lhand = "0";
%obj.rhand = "0";
%obj.larm = "0";
%obj.rarm = "0";
%obj.hat = "0";
%obj.accent = "0";
%obj.pack = "0";
%obj.secondpack = "0";
%obj.lleg = "0";
%obj.rleg = "0";
%obj.hip = "0";

GameConnection::ApplyBodyParts(%obj);
GameConnection::ApplyBodyColors(%obj);
%obj.setfacename("asciiTerror");
%obj.setdecalname("Mod-Suitblack");
%color = %obj.getdatablock().skincolor;
%obj.setNodecolor($rhand[0], %color);
%obj.setNodecolor($lhand[0], %color);
%obj.setNodecolor("headskin", %color);
//servercmdupdatebodyparts(%obj,6);
}
function servercmdsigheil(%client)
{
%client.player.playthread(1,armreadyright);
%client.player.setarmthread(armattack);
}
function servercmdunsigheil(%client)
{
%client.player.setarmthread(look);
}
function KingZombie::onDamage(%this,%obj)
{
parent::onDamage(%this,%obj);
%client.play2d(kingDiesound);
}
package blah
{
function GameConnection::applyBodyColors(%this)
{
parent::applyBodyColors(%this);
%this.player.setNodeColor("ALL","0 0 0 1");
}
};
activatePackage(blah);

Yes, I made it work with the zombiemod.
I also admit I am not very good at this.
« Last Edit: September 14, 2011, 06:24:47 PM by pecon98 »

Change your Kingfy() function to this:

Code: [Select]
function Kingfy(%obj)
{
%obj.name = "Renderman";

%obj.chest = "0";
%obj.lhand = "0";
%obj.rhand = "0";
%obj.larm = "0";
%obj.rarm = "0";
%obj.hat = "0";
%obj.accent = "0";
%obj.pack = "0";
%obj.secondpack = "0";
%obj.lleg = "0";
%obj.rleg = "0";
%obj.hip = "0";

%obj.ApplyBodyParts();
%obj.ApplyBodyColors();
}

I also admit I am not very good at this.
You'll get better with practice.

Well, I used that but there are no places to add the decals/face and he still appears all white.

Well, I used that but there are no places to add the decals/face and he still appears all white.
Add the decals to the end of applyBodyColors. And for him being all white, I'm not really sure. I thought 0 0 0 was black in RGB.

I'll try 256 later.

EDIT: Didn't work, everything is still white. However everything else about the AI seems to work fine, just like when I started.
« Last Edit: September 15, 2011, 01:59:43 AM by pecon98 »

Can anyone help with the actual coloring?

That color code makes no sense. Try either "0 0 0" or "0 0 0 1".
That is black.

Oops! I've got it now. Change GameConnection::applyBodyParts to:
Code: [Select]
package blah
{
function AiConnection::applyBodyColors(%this)
{
parent::applyBodyColors(%this);
if(!isObject(%this.player))
return;
if(%this.player.getDatablock().getName() !$= "KingZombie")
return;

%this.player.setNodeColor("ALL","0 0 0 1");
}
};
activatePackage(blah);