Please approve GuscriptedPawn

Discussions about Coding and Scripting
User avatar
Gustavo6046
Godlike
Posts: 1462
Joined: Mon Jun 01, 2015 7:08 pm
Personal rank: Resident Wallaby
Location: Porto Alegre, Brazil
Contact:

Please approve GuscriptedPawn

Post by Gustavo6046 »

Another part of GusPack.u, this ScriptedPawn subclass would in theory have better pawn hierarchy support through boss pawn reference...
Open/close code
lass GuscriptedPawn expands ScriptedPawn;

var GuscriptedPawn ChildPawns[32];
var() GuscriptedPawn BossPawn;
var byte Childs;
var GuscriptedPawn BrotherPawns[32];
var byte Brothers;

function BeginPlay()
{
Super.BeginPlay();
if( BossPawn!=None )
{
BossPawn.Childs = BossPawn.Childs + 1;
BossPawn.ChildPawns[BossPawn.Childs - 1] = Self;
};
}

function PostBeginPlay()
{
if( BossPawn!=None )
{
Brothers = BossPawn.Childs;
LoopFindBrothers(0);
};
}

function LoopFindBrothers(byte BrotherIndex)
{
BrotherPawns[BrotherIndex] = BossPawn.ChildPawns[BrotherIndex];
if( BrotherIndex!=31 )
{
LoopFindBrothers(BrotherIndex + 1);
};
}
"Everyone is an idea man. Everybody thinks they have a revolutionary new game concept that no one else has ever thought of. Having cool ideas will rarely get you anywhere in the games industry. You have to be able to implement your ideas or provide some useful skill. Never join a project whose idea man or leader has no obvious development skills. Never join a project that only has a web designer. You have your own ideas. Focus on them carefully and in small chunks and you will be able to develop cool projects."

Weapon of Destruction
User avatar
Darkelarious
Skilled
Posts: 175
Joined: Sat Feb 08, 2014 12:02 pm
Personal rank: 333networks admin
Location: Phobos Moon
Contact:

Re: Please approve GuscriptedPawn

Post by Darkelarious »

I am not really sure what there is to be approved here..

We can acknowledge the existence of this code, but I don't see the context of this class. Is this thread meant to be part of another discussion, perhaps?

Codewise, I have a few small comments, More like nitpicking, actually.

BossPawn.Childs = BossPawn.Childs + 1;
could become
BossPawn.Childs++;

and

if( BrotherIndex!=31 )
{
LoopFindBrothers(BrotherIndex + 1);
};
is probably better written
if (BrotherIndex < 31) {
LoopFindBrothers(BrotherIndex + 1);
}
Especially this last one might be important. Rather specify within which values BrotherIndex has to be before the if(){} block is executed. The datatype is a byte, which means that 255+1 = 0 and 0 - 1 = 255. In above code, if BrotherIndex becomes higher than 31 somehow, it will cause an array-out-of-bounds error. Uscript has funny ways of dealing with those, like failing to report this error and continuing the program if nothing happened, or simply crashing with some cryptic general protection fault.
--Darkelarious
Image
Masterserver | Discord Channel
Oh, and we still are ready to receive donations. The url works, right? It doesn't seem to be doing anything...
User avatar
Gustavo6046
Godlike
Posts: 1462
Joined: Mon Jun 01, 2015 7:08 pm
Personal rank: Resident Wallaby
Location: Porto Alegre, Brazil
Contact:

Re: Please approve GuscriptedPawn

Post by Gustavo6046 »

The script must have cross-Pawn hierarchy support (references to boss, childs and brothers) and must be still able to do general Pawn stuff. Even if Hierarchy is limited to GuscriptedPawn and it's subclasses.
"Everyone is an idea man. Everybody thinks they have a revolutionary new game concept that no one else has ever thought of. Having cool ideas will rarely get you anywhere in the games industry. You have to be able to implement your ideas or provide some useful skill. Never join a project whose idea man or leader has no obvious development skills. Never join a project that only has a web designer. You have your own ideas. Focus on them carefully and in small chunks and you will be able to develop cool projects."

Weapon of Destruction
User avatar
sektor2111
Godlike
Posts: 6403
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: Please approve GuscriptedPawn

Post by sektor2111 »

Approval denied - code seems to contain enough None Accesed errors and non-functional things.

Code: Select all

//Where is declared BossPawn ? Who is that ?
if( BossPawn!=None ) //Won't achieve this purpose if is not declared, if yes, see bellow
{
BossPawn.Childs = BossPawn.Childs + 1; //Undeclared unassigned - slot empty
...
I did not see "BrotherIndex" declaration. Does this compile ?
User avatar
Gustavo6046
Godlike
Posts: 1462
Joined: Mon Jun 01, 2015 7:08 pm
Personal rank: Resident Wallaby
Location: Porto Alegre, Brazil
Contact:

Re: Please approve GuscriptedPawn

Post by Gustavo6046 »

sektor2111 wrote:Approval denied - code seems to contain enough None Accesed errors and non-functional things.

Code: Select all

//Where is declared BossPawn ? Who is that ?
if( BossPawn!=None ) //Won't achieve this purpose if is not declared, if yes, see bellow
{
BossPawn.Childs = BossPawn.Childs + 1; //Undeclared unassigned - slot empty
...
I did not see "BrotherIndex" declaration. Does this compile ?
They are reference vars in the begin of the code.

EDIT: Updated code! (not exactly finished so expect missing ; and vars in {}s and function calls, respectively.

Code: Select all

//=============================================================================
// GuscriptedPawn. Hierarchy, sex and family support.
//=============================================================================
class GuscriptedPawn expands ScriptedPawn;

var		GuscriptedPawn	ChildPawns[32];
var()	GuscriptedPawn	BossPawn;
var		byte			Childs;
var		GuscriptedPawn	BrotherPawns[32];
var		byte			Brothers;
var		enum			Sex
{
SEX_Male,
SEX_Female,
}ESex;
var		GuscriptedPawn	PossibleConjuges[32];
var()	GuscriptedPawn	Conjuge;
var()	string			FirstName;
var()	string			Surname;
var		string			EntireName;
var		GuscriptedPawn	A;
var		vector			conjvector;
var		GuscriptedPawn	PretendentConjuge;
var()	GuscriptedPawn	Mother;
var()	GuscriptedPawn	Father;
var()	enum			ConjugeState
{
CSE_Alone,
CSE_Loving,
CSE_Married,
}EConjugeState;
var()	bool			bWantLove;
var()	bool			bExcitated;

function BeginPlay()
{
	Super.BeginPlay();
	if( BossPawn!=None )
	{
		BossPawn.Childs = BossPawn.Childs + 1;
		BossPawn.ChildPawns[BossPawn.Childs - 1] = Self;
	};
}

function Tick(float DeltaTime)
{
	Super.Tick();
	if( Conjuge==None && Intelligence==BRAINS_Reptile && PretendentConjuge!=None )
	{
		ConjugeState = CSE_Married;
		Conjuge = PretendentConjuge;
		bWantLove = False;
	}
	else
	{
		if( Conjuge==None && ( Intelligence==BRAINS_Mammal || Intelligence==BRAINS_Human ) && PretendentConjuge!=None )
		{
			SetTimer(30, False);
			ConjugeState = CSE_Loving;
			bExcitated = true;
		}
}

function PostBeginPlay()
{
	CheckBoss();
	EntireName = EntireName @ Surname;
}

Timer()
{
	WantLove=True;
	WantLove();
}

function bool WantLove()
{
	if(Conjuge==None && bWantLove;)
	{
		CheckLove();
		return true;
	}
	else
	{
		return false;
	}
}

function CheckLove(optional out bool bChecking)
{
	foreach AllActors(GuscriptedPawn, A)
	{
		if( A==None )
		{
			bChecking = False;
			break;
		};
		If( ( Conjuge==None || A.Location - Locaction < Conjuge.Location - Location ) && A.Sex!=Sex )
		{
			PretendentConjuge = A;
			bChecking = True;
			Continue;
		}
		Else
		{
			bChecking = True;
			Continue;
		};
	};
}

function bool CheckBoss()
{
	if( BossPawn!=None )
	{
		Brothers = BossPawn.Childs;
		LoopFindBrothers(0);
		return true;
	}
	else
		return false;
}

function bool CheckBrothers(byte BroNum)
{
	if( BrotherPawns[BroNum]!=None )
		return true;
	else
		return false;
}

function bool CheckChilds(byte KidNum)
{
	if( ChildPawns[KidNum]!=None )
		return true;
	else
		return false;
}


function LoopFindBrothers(byte BrotherIndex)
{
	BrotherPawns[BrotherIndex] = BossPawn.ChildPawns[BrotherIndex];
	if( BrotherIndex!=31 )
	{
		LoopFindBrothers(BrotherIndex + 1);
	};
}
"Everyone is an idea man. Everybody thinks they have a revolutionary new game concept that no one else has ever thought of. Having cool ideas will rarely get you anywhere in the games industry. You have to be able to implement your ideas or provide some useful skill. Never join a project whose idea man or leader has no obvious development skills. Never join a project that only has a web designer. You have your own ideas. Focus on them carefully and in small chunks and you will be able to develop cool projects."

Weapon of Destruction
User avatar
sektor2111
Godlike
Posts: 6403
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: Please approve GuscriptedPawn

Post by sektor2111 »

Now I understand the request for approval... How old were you saying to have ? 12 ? Interesting...

So, I would pay attention at meshes because there is a pawn-soup there and maybe you wanna prevent some nasty relations code, right ? Or you might need help for some state...

I'm tracking things here because I'm curious when some moderator/admin will lose patience related to this kinda chat-forum and wil take some decision.
User avatar
Gustavo6046
Godlike
Posts: 1462
Joined: Mon Jun 01, 2015 7:08 pm
Personal rank: Resident Wallaby
Location: Porto Alegre, Brazil
Contact:

Re: Please approve GuscriptedPawn

Post by Gustavo6046 »

Why lose the patience? I change enum Sex name to Gender later.
"Everyone is an idea man. Everybody thinks they have a revolutionary new game concept that no one else has ever thought of. Having cool ideas will rarely get you anywhere in the games industry. You have to be able to implement your ideas or provide some useful skill. Never join a project whose idea man or leader has no obvious development skills. Never join a project that only has a web designer. You have your own ideas. Focus on them carefully and in small chunks and you will be able to develop cool projects."

Weapon of Destruction
User avatar
papercoffee
Godlike
Posts: 10443
Joined: Wed Jul 15, 2009 11:36 am
Personal rank: coffee addicted !!!
Location: Cologne, the city with the big cathedral.
Contact:

Re: Please approve GuscriptedPawn

Post by papercoffee »

??? ...you google translate must be broken...
User avatar
Gustavo6046
Godlike
Posts: 1462
Joined: Mon Jun 01, 2015 7:08 pm
Personal rank: Resident Wallaby
Location: Porto Alegre, Brazil
Contact:

Re: Please approve GuscriptedPawn

Post by Gustavo6046 »

papercoffee wrote:??? ...you google translate must be broken...
What is Google Translate? I don't have one. What does it have to do with our chat? Google?
"Everyone is an idea man. Everybody thinks they have a revolutionary new game concept that no one else has ever thought of. Having cool ideas will rarely get you anywhere in the games industry. You have to be able to implement your ideas or provide some useful skill. Never join a project whose idea man or leader has no obvious development skills. Never join a project that only has a web designer. You have your own ideas. Focus on them carefully and in small chunks and you will be able to develop cool projects."

Weapon of Destruction
SC]-[WARTZ_{HoF}
Adept
Posts: 426
Joined: Tue Feb 21, 2012 7:29 pm

Re: Please approve GuscriptedPawn

Post by SC]-[WARTZ_{HoF} »

Gustavo6046 wrote:
papercoffee wrote:??? ...you google translate must be broken...
What is Google Translate? I don't have one. What does it have to do with our chat? Google?
LMAO..... :loool:
Image
Image
Image
JackGriffin
Godlike
Posts: 3774
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: Please approve GuscriptedPawn

Post by JackGriffin »

I changed my mind Heston. I think this is DK-Destroyer and he's trolling the board really hard.
So long, and thanks for all the fish
User avatar
papercoffee
Godlike
Posts: 10443
Joined: Wed Jul 15, 2009 11:36 am
Personal rank: coffee addicted !!!
Location: Cologne, the city with the big cathedral.
Contact:

Re: Please approve GuscriptedPawn

Post by papercoffee »

Gustavo6046 wrote:
papercoffee wrote:??? ...you google translate must be broken...
What is Google Translate? I don't have one. What does it have to do with our chat? Google?
Because this sentence makes no sense.
Gustavo6046 wrote:Why lose the patience? I change enum Sex name to Gender later.
And this is google translate...
https://translate.google.com/
User avatar
Darkelarious
Skilled
Posts: 175
Joined: Sat Feb 08, 2014 12:02 pm
Personal rank: 333networks admin
Location: Phobos Moon
Contact:

Re: Please approve GuscriptedPawn

Post by Darkelarious »

Gustavo6046 wrote:The script must have cross-Pawn hierarchy support (references to boss, childs and brothers) and must be still able to do general Pawn stuff. Even if Hierarchy is limited to GuscriptedPawn and it's subclasses.
Okay, all mud-throwing and jokes aside, there are a few questions and points I'd like to make. A lot of things are unclear to me. It would be very nice if these questions could be answered one-on-one (read: answer every number separately).

1) What is GuscriptedPawn, is it a new project or is it part of something else? In case of the latter, part of which project? Can you please place it into context for us to understand?

2) Is this thread meant to ask for help (with coding, problem solving or otherwise) or is it to show your current progress?

3) You asked for approval, why do we have to approve this code? Why does our opinion/approval matter? Or is this an incorrect translation of "what do you think of my code <GuscriptedPawn>"? Please clarify.

4) The code that you post, is that a working code and will it compile? If not, why do you post it? Please clarify WHY you post code and what you expect from us.

5) We pointed out a few flaws in your code, but I did not see that you used our comments/feedback in newer pasted code. Are you planning to implement these suggestions?

6) (Bonus question) I am just guessing this from your name and writing style, is your native language Brazilian/Portuguese by any chance? If yes, perhaps a few other native speakers could report in this thread to help with translation issues?

One more thing to keep in mind when posting in this topic, if you want help or if you want to show your code/script; please post a "minimum working code" example, describe your problem in detail and clearly write what you expect from us to do. A lot of us have over 10-20 years of programming experience and can really help, if you are willing to listen and willing to provide useful information.
--Darkelarious
Image
Masterserver | Discord Channel
Oh, and we still are ready to receive donations. The url works, right? It doesn't seem to be doing anything...
User avatar
Gustavo6046
Godlike
Posts: 1462
Joined: Mon Jun 01, 2015 7:08 pm
Personal rank: Resident Wallaby
Location: Porto Alegre, Brazil
Contact:

Re: Please approve GuscriptedPawn

Post by Gustavo6046 »

Darkelarious wrote: 1) What is GuscriptedPawn, is it a new project or is it part of something else? In case of the latter, part of which project? Can you please place it into context for us to understand?

2) Is this thread meant to ask for help (with coding, problem solving or otherwise) or is it to show your current progress?

3) You asked for approval, why do we have to approve this code? Why does our opinion/approval matter? Or is this an incorrect translation of "what do you think of my code <GuscriptedPawn>"? Please clarify.

4) The code that you post, is that a working code and will it compile? If not, why do you post it? Please clarify WHY you post code and what you expect from us.

5) We pointed out a few flaws in your code, but I did not see that you used our comments/feedback in newer pasted code. Are you planning to implement these suggestions?

6) (Bonus question) I am just guessing this from your name and writing style, is your native language Brazilian/Portuguese by any chance? If yes, perhaps a few other native speakers could report in this thread to help with translation issues?
1) This is part of the Package GusPack, of my own project of custom content for UT99, which becomes part of my Gustavo6046 Unnoficial Pack every week.

2) Both of them. People post nitpicks, code fixes as no one is a perfect coder, much less myself.

3) Neither. It means I want you to check for errors in my code and to make sure that vital functions and interactor relations of the code are still working.

4) It is already compiled everytime I save it. I make it gradually in UnrealEd2. I post it here because I want people to see it and help.

5) Yes, I am going to implement suggestions in the next update and in the others that follow it.

6) Yes! There is no translation issue as it is since the five years I learnt basic English I made much evolution... this remembers me Age of Empires II, "cara"!
"Everyone is an idea man. Everybody thinks they have a revolutionary new game concept that no one else has ever thought of. Having cool ideas will rarely get you anywhere in the games industry. You have to be able to implement your ideas or provide some useful skill. Never join a project whose idea man or leader has no obvious development skills. Never join a project that only has a web designer. You have your own ideas. Focus on them carefully and in small chunks and you will be able to develop cool projects."

Weapon of Destruction
User avatar
papercoffee
Godlike
Posts: 10443
Joined: Wed Jul 15, 2009 11:36 am
Personal rank: coffee addicted !!!
Location: Cologne, the city with the big cathedral.
Contact:

Re: Please approve GuscriptedPawn

Post by papercoffee »

Gustavo6046 wrote: There is no translation issue as it is since the five years I learnt basic English I made much evolution...
He doesn't mean, that you can't understand us ... We have sometimes problems to understand you, because the words you use make sense in Portuguese maybe, but not so much in English.

We had once a Portuguese guy on our forum ...he was one of the best coder.
Post Reply