Thx, i will use that and keep it in my toolbox.

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts MenuQuote from: dkh on Tue 26/06/2012 16:00:53Thx, checking for the npcs in the current room, brings a lot of performance, i think it could work this way.
1.) You're looping through all the characters in your game. Maybe it would be better to check if the character is actually in the same room as the player first.
2.) What's wrong with the commented code? It should work well in most cases and be a LOT faster.
function ROC_FUNC_Get_Distance_From(this Character*, Character*c) {
float dx = IntToFloat(c.x - this.x);
float dy = IntToFloat(c.y - this.y);
float dis = Maths.Sqrt(dx*dx + dy*dy);
return FloatToInt(dis, eRoundNearest);
}
function room_RepExec()
{
int i = 0;
while(i < Game.CharacterCount)
{
if(Guard[i].alerted)
{
/*
int j = 0;
while(j < Game.CharacterCount)
{
if(i != j)
if(Guard[j].alive)
if(character[i].ROC_FUNC_Get_Distance_From(character[j]) < 300)
character[j].ROC_FUNC_Guard_Alerted();
*/
if(character[i].IsCollidingWithChar(player))
if(thief.guards_alerted > 1)
player.ChangeRoom(5);
else
{
character[i].ROC_FUNC_JB_Startfight();
}
// j++;
//}
}
i++;
}
}
function Get_Character_Height(this Character*)
{
ViewFrame *frame = Game.GetViewFrame(this.View, this.Loop, this.Frame);
return Game.SpriteHeight[frame.Graphic];
}
Quote from: monkey_05_06 on Wed 20/06/2012 21:12:33This is the greatest thing about AGS, codesnippets are laying around everywhere.
Blast! That guy's always leaving code snippets laying around.
ViewFrame *frame = Game.GetViewFrame(cGuard_1.View,cGuard_1.Loop, cGuard_1.Frame);
int sprite_height = (Game.SpriteHeight[frame.Graphic]);
function khrismuc_knows_everything_always()
Quote from: AGS-HelpTo create repeatedly_execute_always, you can simply paste it into the script as above -- but you can also paste it into room scripts.
function room_RepExec_always()
Quote from: placyd on Fri 20/08/2010 08:59:08
I've read back and found this quote by Tanique, that he had the same problem, when not even numbers was used as coordinates.
If I use 624 instead of 625 in the script it works perfectly!
Quote from: Tanique on Mon 16/11/2009 01:02:06
I know this thread hasn't been used in a while but I think it makes more sense to post it here than start a new one. I was playing with this module for my game (monkey's .85 version using AGS 3.1.2) and I've noticed what might be a bug in the WALK scripting. If I ever program my background character to walk to any x,y coordinates with odd values, she'll walk there, but won't continue the rest of the script. As long as her WALK coordinates are even numbers, the script runs smoothly. Is this a known bug? I'm thinking it may have something to do with AGS 3's ability to run high resolution coordinates in the script.....but I'm really not sure.
// globalscript.ash
import int gameprogress;
enum eGameprogress
{
eProlog = 0,
eMiddle = 1,
eFinal = 2,
};
// globalscript.asc
int gameprogress;
export gameprogress;
function game_start()
{
gameprogress = eMiddle;
}
// Roomsript
function room_Load()
{
if(gameprogress == eProlog)
{
StartCutscene(eSkipESCOrRightButton);
cKlaus.ChangeRoom(10, 423, 119);
cMichael.EnterRoom(10,460, 139, eDirLeft);
.
.
}
else if(gameprogress == eMiddle)
{
//StartCutscene(eSkipESCOrRightButton);
cKlaus.ChangeRoom(10, 423, 119);
player.Walk(325, 127, eBlock, eWalkableAreas);
.
}
}
By continuing to use this site you agree to the use of cookies. Please visit this page to see exactly how we use these.
Page created in 0.100 seconds with 14 queries.