Nexus Modding > Mod Development / Released Mods

Freespace modding issues

<< < (2/2)

Arparso:

--- Quote from: nips on February 14, 2011, 23:14:39 ---I've found another error
--- End quote ---

Thanks for reporting. Try to replace the first "Tick" rule in the "_include_me.inc" with this one:
(didn't test it much, but should at least fix the crash)


--- Code: ---            // periodically check, if AA weapons need to be activated again
            RULE event Tick
            :action
                // select all fighter-carried anti-fighter weapons
                SelectEx(s.weapon & Purpose(s.this, 5) & InSet(s.this, 37) & s.owner:boat,

                    // check, if we're shooting at a valid target in range right now
                    If(!IsValid(s.target) | Distance(s.owner, s.target) > #FCAA_MAXDISTANCE,           
                        // disable weapon (may be re-enabled again, see below)
                        s.this:active := 0;
                   
// the squad the fighter belongs to
                        E.squad := s.owner:launcherWeapon;

// squad might be 0, because the carrier left the scene and the
// launcherWeapon doesn't exist anymore
If(E.squad != 0,
// the current attack mode of the squadron (attack, guard, etc.)
E.weaponMode := E.squad:mode;
// the targetted squad of this fighter's squad
E.squadTarget := E.squad:target;

// handle all relevant cases for the attack mode of the squadron
ChooseFirst(
// squad guards something and fighter tries to intercept an enemy boat
E.weaponMode = 3 & IsValid(s.this:owner:target) & s.this:owner:target:boat & GetRelation(s.this:owner:race, s.this:owner:target:race) = #UREL_ENEMY,
// Debug("Guarding", E.squadTarget, ",current target", s.this:owner:target);
If(Distance(s.owner, s.this:owner:target) <= #FCAA_MAXDISTANCE,
s.this:active := 1;
s.this:target := s.this:owner:target;
);
,
// squad patrols somewhere and fighter tries to intercept an enemy boat
E.weaponMode = 4 & IsValid(s.this:owner:target) & s.this:owner:target:boat & GetRelation(s.this:owner:race, s.this:owner:target:race) = #UREL_ENEMY,
If(Distance(s.owner, s.this:owner:target) <= #FCAA_MAXDISTANCE,
s.this:active := 1;
s.this:target := s.this:owner:target;
);
,
// squad attacks another squad (targets a "weapon")
E.weaponMode = 5 & E.squad:target:weapon & IsValid(s.this:owner:target) & s.this:owner:target:boat & GetRelation(s.this:owner:race, s.this:owner:target:race) = #UREL_ENEMY,

// // disable device, if target is out of range
// If(IsValid(s.target) & Distance(s.owner, s.target) > #FCAA_MAXDISTANCE,
// s.this:active := 0;
// );
If(Distance(s.owner, s.this:owner:target) <= #FCAA_MAXDISTANCE,
s.this:active := 1;
s.this:target := s.this:owner:target;
);

// device isn't active (has been disabled before?)
// If(s.this:active = 0,
// E.aaWeapon := s.this;

// // loop through all fighters of the targetted squadron
// SelectEx(s.boat & s.launcherWeapon = E.squadTarget,
// // if an enemy fighter has entered firing range,
// // activate the device again and assign a target
// If(Distance(E.aaWeapon:owner, s.this) <= #FCAA_MAXDISTANCE,
// E.aaWeapon:active := 1;
// E.aaWeapon:target := s.this;
// );
// );
// );
);
);
                    );
                );
            :end
            END
--- End code ---




--- Quote from: nips on February 14, 2011, 23:14:39 ---Also is there a way to make the AI kind of override its survival instinct? Like if a damaged cruiser warps in, I want it to get to the node no matter what, instead of running away like a wuss.
--- End quote ---
Sure, just give it a move order and a high enough intensity to override its survival instinct:


--- Code: ---ship:tMoveTo(x, y, z, stealth);
ship:tMoveToIntensity(intensity);
--- End code ---

(intensity > 100 should be more than enough)

nips:
It works! Thank you so much!


I have another question... How does PutShipRel works? I tried calling it like this

M.Agr:=Appear(M.Agr);
PutShipRel(M.Agr,M.Lys,1000,250,0,0);
MEvent(MakeShipWarpIn,M.Agr);


The only thing that putshiprel changes is the ship's orientation :/

nips:
sad bump

Mularac:
Damn... I totally missed that one.

In my previous tests using the PutShipRel command I could only make it to work properly if both ships, the one you'd be moving and the one you'd be moving in relation to, have the same position.

So, your code should be like this:

M.Agr:=Appear(M.Agr);
PutShip(M.agr,M.lyz:positionX, M.lyz:positiony, M.lyz:positionZ, m.agr:heading, m.agr:pitch, m.agr:bank);
PutShipRel(M.Agr,M.Lys,1000,250,0,0);
MEvent(MakeShipWarpIn,M.Agr);

That should do it, I think.

Navigation

[0] Message Index

[*] Previous page

Go to full version