Jump to content


Member Since 28 Aug 2009
Offline Last Active Yesterday, 01:46 PM

Topics I've Started


15 October 2016 - 09:24 AM

I am curious, has there been any update regarding this?


I am referring to this some months ago, it would be a well appreciated addition. 


array factory error with angelscript class

16 March 2016 - 09:33 PM

Getting an issue with latest revision this has worked since forever until now.

array (0, 0)
ERROR:  : 
The subtype has no default factory
Has Compile Errors: True

Data/Script/Node.as (108, 8)
ERROR:  : 
Attempting to instantiate invalid template type 'array<Status>'
Has Compile Errors: True
class Status
   Status(BTNode @no,BH_STATUS b){@node=@no; BH=b;}
   BTNode@ node;
class Node
   array<Status> childrenStatus;

Angelscript Crash or Reporting null pointer access

12 August 2015 - 02:47 PM

void Spell(Spell& spell, Character& ast, Character& trg){
Party @part=ast.GetParty();
	for (int i = 0; i<part.GetEnemies(); i++){
		Character &chara=cast<Character>(part.GetEnemy(i));
void Spell(Spell& spell, Character& ast, Character& trg){
for (int i = 0; i<ast.party.GetEnemies(); i++){
		Character @handle=cast<Character>(ast.party.GetEnemy(0));
		int dmg = ast.Stat("Mag").VECI2().y + spell.Stat("Power").VECI2().x;
		dmg = dmg * (265 - handle.Stat("Spr").VECI2().y) / 4;
		dmg = dmg * spell.Stat("Power").VECI2().x / 256;
		dmg = dmg * (Random(0, 32) + 240) / 256;

		dmg = Mul(dmg, (handle.Res(spell.Stat("Element").ST()).FT()));

		dmg = Mul(dmg, (((handle.Status("Shell").VECI().z>0) ? ShellMod : 1)));
		handle.ReceiveDamage(ast, dmg);

First codebox won't complain but crashes only if that cast exists, the crash occurs only on second run or exiting application.


Will complain about nullpointer access on dmg = dmg * (265 - handle.Stat("Spr").VECI2().y) / 4;
and crash the program if I run the function again or if I exit the application, no ability to trace it properly.


party is registered like

int Party::GetCharacters(){ return m_chars.elms(); }
asIScriptObject *Party::GetCharacter(int i){ return m_chars[i].GetController(); }
BaseEntity *Party::InsertCharacter(){ return &m_chars.New(); }

int Party::GetEnemies(){ return m_enemies.elms(); }
asIScriptObject *Party::GetEnemy(int i){ return m_enemies[i].GetController(); }
BaseEntity *Party::InsertEnemy(){ return &m_enemies.New(); }

void Party::Register(CScriptMgr &m){
	// Registering the class method
        MYASSERT(m.RegClass<Party>("Party", asOBJ_REF|asOBJ_NOCOUNT));
	MYASSERT(m.RegClassMethod("Party", "int GetCharacters()", asMETHOD(Party, GetCharacters)));
	MYASSERT(m.RegClassMethod("Party", "IController @GetCharacter(int i)", asMETHOD(Party, GetCharacter)));
	MYASSERT(m.RegClassMethod("Party", "BaseEntity &InsertCharacter()", asMETHOD(Party, InsertCharacter)));
	MYASSERT(m.RegClassMethod("Party", "int GetEnemies()", asMETHOD(Party, GetEnemies)));
	MYASSERT(m.RegClassMethod("Party", "IController @GetEnemy(int i)", asMETHOD(Party, GetEnemy)));
	MYASSERT(m.RegClassMethod("Party", "BaseEntity &InsertEnemy()", asMETHOD(Party, InsertEnemy)));

Character is extending in angelscript like

class Character : IController

Character(BaseEntity @obj)
@o = obj;

BaseEntity @o;

and IController is registered through C++ by

MYASSERT(m.GetEngine()->RegisterInterface("IController") >= 0);


so my question would be, any ideas what I am doing wrong? do I have to register it in some special way to extend and cast the object from IController to Character?

or is it the Get functions from party that is wrong? eg I am using asIScriptObject as return type.


Angelscript Operators

31 December 2014 - 08:46 PM

I was wondering if there isn't a way to adding different operators for 

<= opCmpLE Lesser Equal

opCmpL Lesser

opCmpG Greater

>= opCmpGE Greater Equal

== opEqual

!= opInequal


or is there a way of


to differ between them being either of these?

const parameter

31 December 2014 - 12:18 PM

I have a question regarding const in Angelscript with const parameters


I notice that 

MYASSERT(e->RegisterObjectMethod("Mouse", "void pos(const Vector2 &in)", asMETHODPR(Mouse, pos, (C Vector2 &), void), asCALL_THISCALL) >= 0);

I still have to specify &in else it will complain about &inout, is there anyway for auto handling that if const for the parameter is specified a single & would be done as &in for you? as I doubt anyone want to pass &inout for a const parameter anyway.

MYASSERT(e->RegisterObjectMethod("Mouse", "void pos(const Vector2 &)", asMETHODPR(Mouse, pos, (C Vector2 &), void), asCALL_THISCALL) >= 0);