mse / RSOD (public) (License: CC0 and other licenses) (since 2025-03-01) (hash sha1)
Free software FPS engine
List of commits:
Subject Hash Author Date (UTC)
Add weapon particle support dc972a7f2cc0019d663b3284a1e49c3be313c74f MSE 2024-06-09 20:21:23
Initial commit c4f36c095752bd4e7090caf48320d041fb2328bb MSE 2024-06-09 02:33:29
Commit dc972a7f2cc0019d663b3284a1e49c3be313c74f - Add weapon particle support
Author: MSE
Author date (UTC): 2024-06-09 20:21
Committer name: MSE
Committer date (UTC): 2024-06-09 20:21
Parent(s): c4f36c095752bd4e7090caf48320d041fb2328bb
Signer:
Signing key:
Signing status: N
Tree: 6ab2680e4c8a5433052790da4bfdc8c762341fc4
File Lines added Lines deleted
src/fdungeon.cpp 34 8
src/rsod.cpp 6 6
File src/fdungeon.cpp changed (mode: 100644) (index 4b02db3..306c5ec)
... ... struct InventoryInstance {
69 69 struct Weapon { struct Weapon {
70 70 std::map<std::string,std::string> names; std::map<std::string,std::string> names;
71 71 std::map<std::string,std::string> descriptions; std::map<std::string,std::string> descriptions;
72 ParticleTemplate particleFire;
72 73 std::string ammo; std::string ammo;
73 std::string particleFire;
74 74 std::string soundFire; std::string soundFire;
75 75 std::string soundReload; std::string soundReload;
76 76 std::string soundHit; std::string soundHit;
 
... ... void Dungeon::appendWeapons( std::string weaponPath, std::string filePath ){
1419 1419 viewToString( prop.value.getString() ); viewToString( prop.value.getString() );
1420 1420 } }
1421 1421 } }
1422 ParticleTemplate particleFire{};
1423 if( weapDef.value["particle_fire"] ){
1424 particleFire =
1425 loadParticles(viewToString(weapDef.value["particle_fire"].getString()));
1426 particleServers[particleFire.texture] = ParticleServer();
1427 }
1422 1428 std::string ammo; std::string ammo;
1423 1429 if( weapDef.value["ammo"] ){ if( weapDef.value["ammo"] ){
1424 1430 ammo = viewToString( weapDef.value["ammo"].getString() ); ammo = viewToString( weapDef.value["ammo"].getString() );
1425 1431 } }
1426 std::string particleFire;
1427 if( weapDef.value["particle_fire"] ){
1428 particleFire =
1429 viewToString( weapDef.value["particle_fire"].getString() );
1430 }
1431 1432 std::string soundFire; std::string soundFire;
1432 1433 if( weapDef.value["sound_fire"] ){ if( weapDef.value["sound_fire"] ){
1433 1434 soundFire = soundFire =
 
... ... void Dungeon::appendWeapons( std::string weaponPath, std::string filePath ){
1596 1597 weapons[weapName] = { weapons[weapName] = {
1597 1598 localizedNames, localizedNames,
1598 1599 localizedBlurbs, localizedBlurbs,
1599 ammo,
1600 1600 particleFire, particleFire,
1601 ammo,
1601 1602 soundFire, soundFire,
1602 1603 soundReload, soundReload,
1603 1604 soundHit, soundHit,
 
... ... std::pair<bool,Agent*> Dungeon::agentFireWeapon( Agent *a, std::string weapon, s
3329 3330 if( fire_it != a->avatar.bodyAnimations.end() ) if( fire_it != a->avatar.bodyAnimations.end() )
3330 3331 a->avatar.bodyFrame = fire_it->second.x; a->avatar.bodyFrame = fire_it->second.x;
3331 3332 bool pitch = a != playerAgent || !thirdPerson || weap.thirdPersonPitch; bool pitch = a != playerAgent || !thirdPerson || weap.thirdPersonPitch;
3333 auto ray = getAgentGazeRay(a, weap.range, pitch);
3334 // Emit particles.
3335 auto ps_it = particleServers.find(weap.particleFire.texture);
3336 if(ps_it != particleServers.end()){
3337 double startScale = weap.particleFire.startScale,
3338 endScale = weap.particleFire.endScale,
3339 startMass = weap.particleFire.startMass,
3340 endMass = weap.particleFire.endMass,
3341 maxAge = weap.particleFire.maxAge;
3342 double svel = (endScale - startScale) / maxAge;
3343 double mvel = (endMass - startMass) / maxAge;
3344 // TODO: Randomly emit weap.particleFire.num particles.
3345 for(size_t i = 0; i < 1; ++i){
3346 Particle part{};
3347 part.tvel = linalg::normalize(ray.second - ray.first)
3348 * weap.particleFire.vel;
3349 part.translation = ray.first;
3350 part.svel = svel;
3351 part.scale = startScale;
3352 part.mvel = mvel;
3353 part.mass = startMass;
3354 part.maxAge = maxAge;
3355 ps_it->second.particles.push_back(part);
3356 }
3357 }
3332 3358 return { return {
3333 3359 true, true,
3334 rayImpact(a, getAgentGazeRay(a, weap.range, pitch), weap.impact, weap.damage, defenseSkill)
3360 rayImpact(a, ray, weap.impact, weap.damage, defenseSkill)
3335 3361 }; };
3336 3362 } }
3337 3363
File src/rsod.cpp changed (mode: 100644) (index 9b70a84..84da87e)
... ... int main( int argc, char* argv[] ){
697 697 // Make the dungeon engine use FileOpen to open files. // Make the dungeon engine use FileOpen to open files.
698 698 dungeon.ModFopen = FileOpen; dungeon.ModFopen = FileOpen;
699 699
700 // Set paths. TODO: Custom paths.
701 dungeon.dungeonPath = data_path + "/dungeons";
702 dungeon.agentPath = data_path + "/agents";
703 dungeon.avatarPath = data_path + "/avatars";
704 dungeon.particlePath = data_path + "/particles";
705
700 706 // Load the weapons. // Load the weapons.
701 707 dungeon.appendWeapons( data_path + "/weapons", data_path + "/weapons/unique_weapons.json" ); dungeon.appendWeapons( data_path + "/weapons", data_path + "/weapons/unique_weapons.json" );
702 708 // Load the trinkets. // Load the trinkets.
 
... ... int main( int argc, char* argv[] ){
724 730 dungeon.collisionDamageCallback = collisionDamage; dungeon.collisionDamageCallback = collisionDamage;
725 731 dungeon.aiFrameCallback = aiFrame; dungeon.aiFrameCallback = aiFrame;
726 732
727 // Set paths. TODO: Custom paths.
728 dungeon.dungeonPath = data_path + "/dungeons";
729 dungeon.agentPath = data_path + "/agents";
730 dungeon.avatarPath = data_path + "/avatars";
731 dungeon.particlePath = data_path + "/particles";
732
733 733 // Log the start of the game. // Log the start of the game.
734 734 //analytics::LogEvent("Engine start."); //analytics::LogEvent("Engine start.");
735 735
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/mse/RSOD

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/mse/RSOD

Clone this repository using git:
git clone git://git.rocketgit.com/user/mse/RSOD

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main