Page 1 of 1

ACR Creature Events

Posted: Tue Sep 18, 2007 11:53 pm
by AcadiusLost
Noticed the ACR_CreatureOnHeartbeat() event grew some with a recent update, looks like some kind of manual handling of Perception coded in for when the creature is a PC (PC Events don't exist, so I'm not sure when this code would even be invoked).

Does this serve some purpose, or would it better be handled in the OnPerception() event?

Code: Select all

  241 	// if this is a pc, check if they perceive any creatures
  242 	if (GetIsPC(OBJECT_SELF))
  243 	{
  244 		// ignore DMs
  245 		if (GetIsDM(OBJECT_SELF) || GetIsDMPossessed(OBJECT_SELF)) { return; }
  246 
  247 		// do the math - calculate an coordinate offset based on orientation angle
  248 
  249 		vector vPosition = GetPositionFromLocation(GetLocation(OBJECT_SELF));
  250 		float fX, fY, fLength = RADIUS_SIZE_VAST, fRatio = fLength/90.0, fFacing = GetFacing(OBJECT_SELF);
  251 		int nNumIncrements = FloatToInt(fFacing) % 90;
  252 
  253 		// handle angle rollovers
  254 		if (fFacing == 360.0) { fFacing = 0.0; }
  255 
  256 		// compute the target x and y coordinates based on the orientation quadrant
  257 		if (fFacing < 90.0 && fFacing >= 0.0)
  258 		{
  259 			fX = vPosition.x + fLength - (nNumIncrements * fRatio); fY = vPosition.y + (nNumIncrements * fRatio);
  260 		}
  261 		else if (fFacing < 180.0 && fFacing >= 90.0)
  262 		{
  263 			fX = vPosition.x - (nNumIncrements * fRatio); fY = vPosition.y + fLength - (nNumIncrements * fRatio);
  264 		}
  265 		else if (fFacing < 270.0 && fFacing >= 180.0)
  266 		{
  267 			fX = vPosition.x - fLength + (nNumIncrements * fRatio); fY = vPosition.y - (nNumIncrements * fRatio);
  268 		}
  269 		else if (fFacing < 360.0 && fFacing >= 270.0)
  270 		{
  271 			fX = vPosition.x + (nNumIncrements * fRatio); fY = vPosition.y - fLength + (nNumIncrements * fRatio);
  272 		}
  273 
  274 		// generate the location marking the endpoint of the cone
  275 		location lLocation = Location(GetArea(OBJECT_SELF), Vector(fX, fY, vPosition.z), fFacing);
  276 
  277 		// find objects within their viewing range
  278 		object oTarget = GetFirstObjectInShape(SHAPE_SPELLCONE, fLength, lLocation, TRUE);
  279 
  280 		// loop through the matching creature objects and check if the pc identifies any he sees
  281 		while(GetIsObjectValid(oTarget))
  282 		{
  283 			if (GetObjectSeen(oTarget)) { ACR_CreatureIdentify(OBJECT_SELF, oTarget); }
  284 			oTarget = GetNextObjectInShape(SHAPE_SPELLCONE, fLength, lLocation, TRUE);
  285 		}
  286 	}
  287 	else
  288 	{
  289 	    // apply any effects on the creature
  290     	ACR_VFXOnHeartBeat(OBJECT_SELF);
  291 
  292 		// still call the Obsidian script for AI for now.
  293 		ExecuteScript("nw_c2_default1", OBJECT_SELF);
  294 	}
Found it while searching for the probable cause for the CPU cycle buildup on the OAS2, but that problem predated the recent acr_creature_i.nss update.

Posted: Wed Sep 19, 2007 2:18 am
by ç i p h é r
That shouldn't ever run. I was simply fiddling around with perception/auto identification of creatures (for PCs) when it came up on the 03 forums, and I wanted to commit it for safe keeping so I can return to it at a later time. It's a very rough/crude prototype, which I was using to validate the idea.

FYI - PC events exist but are defined by 2DAs. The events mirror creature events, but they don't all work, heartbeats being one of the few that do, and according to the last note on the subject by OE, it's unlikely that they'll actually make it into the game. Seems like they got started on it but never finished it up.

Posted: Wed Sep 19, 2007 2:21 am
by ç i p h é r
By the way AL, speaking of creature events, have you had any trouble with creature events firing, or acf_cre_* scripts running, on creatures spawned via scripts (ie CreateObject())?

Posted: Wed Sep 19, 2007 6:16 am
by AcadiusLost
Well, any creature created by the ALFA spawn system is, at some level, made with CreateObject(), and in my experience their scripts work fine. I would recommend opening the offending blueprint and opening up the dialog box to switch one of the acf_cre scripts - if the "preview" box is empty, then you've likely got the same "broken association" bug that Teric posted about (and I've frequently seen, seems endemic to imported blueprints). If this is the case, reapplying the event script associations by importing a script set should fix the behaviour.

If that isn't the symptom/solution, let's get into some more detail and see if we can't ferret out the bug.

Posted: Thu Sep 20, 2007 12:10 am
by ç i p h é r
Yeah that's not it. It was the first thing I looked at. :S

I'll fiddle around some more and see what I can deduce.