Skip to content

Conversation

@emre1702
Copy link
Contributor

@emre1702 emre1702 commented Dec 1, 2017

With this function you can disable the collision of a element with all the elements of a type and also new created ones.
I had struggles to create this kind of script in my newbie-times and also experienced many other new scripters having problems. So why not create a simple function which does, what you want?

Syntax:
bool setElementCollidableWithType ( element theElement, string withType, bool enabled[, bool onlyWithCreated = false ])

Use "onlyWithCreated" if you don't want to consider new created elements (like it is right now in setElementCollidableWith).

Oh and the first commits could be strange.
Wanted to overload the setElementCollidableWith function, then decided to create a new function.

@Necktrox Necktrox added the enhancement New feature or request label Dec 1, 2017
CFastList < CClientEntity* > entities = CClientEntity::GetEntitiesFromRoot ( HashString ( szTypeName ), false );

CChildListType::const_iterator iter = entities.begin ();
for ( ; iter != entities.end (); iter++ )
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not certain if you can use a for-range loop here, but .begin() and .end() seem promising

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I change GetEntitiesFromRoot return to list instead of CFastList?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should rather wait for somebody else to comment or benchmark both variants and keep the better one, because I can't answer this question.

@emre1702
Copy link
Contributor Author

emre1702 commented Dec 1, 2017

Changed all, thanks for the infos (C++ newbie here ^^)

g_pCore->UpdateDummyProgress();

// Remove from m_DisabledCollisions
switch ( this->GetType () )
Copy link
Contributor Author

@emre1702 emre1702 Dec 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does someone understand why this line (without "this->" too) gives a "LNK2019" error?
Maybe because it's CClientVehicle is getting destructed before, so GetType is not implemented for the element anymore?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling any virtual member function in a destructor is a very bad idea.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GetType is virtual

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So either not check the type and do it for all element-types or get the type in another way.

@Einheit-101
Copy link

Is it possible to enhance this in a way so that its possible to make an element non-collidable with WORLD elements? This would allow vehicles to pass through certain default world objects.

@botder botder added refactor new-feature and removed enhancement New feature or request labels Jul 9, 2018
@patrikjuvonen patrikjuvonen added enhancement New feature or request and removed new feature labels Sep 4, 2018
@botder botder added this to the Backlog milestone Mar 4, 2019
@qaisjp
Copy link
Contributor

qaisjp commented Apr 2, 2020

A version of this PR with master merged in can be found here: https://github.com/qaisjp/mtasa-blue/tree/setElementCollidableWithImprovement

If someone wants to take it forward, please do so. I can't push to this PR because @emre1702 deleted their fork.

@Woovie
Copy link
Contributor

Woovie commented Oct 16, 2020

Replaced with #1719

@Woovie Woovie closed this Oct 16, 2020
@StrixG StrixG removed this from the Confirmed Issues milestone Oct 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants