Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add setElementCollidableWithType #181

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
emre1702 wants to merge 19 commits into multitheftauto:master from emre1702:setElementCollidableWithImprovement
Closed

Add setElementCollidableWithType #181

emre1702 wants to merge 19 commits into multitheftauto:master from emre1702:setElementCollidableWithImprovement

Conversation

@emre1702
Copy link
Contributor

@emre1702 emre1702 commented Dec 1, 2017
edited
Loading

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.

CrosRoad95, theSarrum, StrixG, Tru-KaaN, and jayceon123 reacted with thumbs up emoji
@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

@Necktrox Necktrox Dec 1, 2017

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

@emre1702 emre1702 Dec 1, 2017

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

@Necktrox Necktrox Dec 1, 2017

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.

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
edited
Loading

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

@Necktrox Necktrox Dec 2, 2017

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

@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.

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

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
Copy link
Contributor

qaisjp commented Apr 2, 2020
edited
Loading

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.

Copy link
Contributor

Woovie commented Oct 16, 2020

Replaced with #1719

@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

Reviewers

@sbx320 sbx320 sbx320 left review comments

+1 more reviewer

@Necktrox Necktrox Necktrox left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

enhancement New feature or request refactor

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /