Cool Pog Tricks
Re:
23 years 1 month ago
You can have FTP access to the the pogfiles directories. Drop me an email.
Please Log in or Create an account to join the conversation.
Re:
23 years 1 month agoOriginally posted by Flamineo
Do death scripts require a hisim? Maybe you can't cast icBullet to hisim? Probably not that simple: I had thought all hsims could be cast to hisims.
[edit]Oops.
Another behaviour of sets and lists, specifically when using them as globals or object properties:Not sure why. The working version ought to be atomic{} if more than one process might try to do it at once.Code:[i]don't work[/i] hobject thing = Sim.Create("ini:/thing"); Set.Add(Global.Set("things"), thing); [i]works[/i] hobject thing = Sim.Create("ini:/thing"); set things = Global.Set("things"); Set.Add(things, thing); Global.SetSet("things", things);
[/edit]
Many scripting languages seem to have numerous minor problems like this. I'm more worried about Gramps example. GrandpaTrout, did you try putting the whole statement into parentheses? Or using variables to hold the two constants?
Please Log in or Create an account to join the conversation.
Re:
23 years 1 month ago
The addition/subtraction bug? Don't remember that was back in May. Haarg hit the same problem. You can find his comments in the location finder code. Its easy to avoid. You just need to know.
-Gtrout
-Gtrout
Please Log in or Create an account to join the conversation.
Re:
23 years 1 month agoOriginally posted by GrandpaTrout
Some #2 items. I have not been able to get deathscripts to work with PBC bolt objects. They do work with REM missiles, but sometimes the player gets trapped with the dead sim. Cargo pods become targetable subsims when you child attach them to a ship. Countermeasure flares do not become targetable. Some can be fixed immobile. Some cannot. I will dig up a list of Object types. We can try to fill in the behavior. (like a group crossword!)
-Gtrout
Were you actually trying to get a bolt to go through a deathscript??
why would one want that?
Here is the way I handle Deathscripts for example:
Code:
//when I create the sim I add the function I want called
Object.SetStringProperty( guard_bot, "death_script", "<my package>.ObjectDeath" );
// then I do the function like this for example
task ObjectDeath( hsim sim )
{
hship last_attacker;
string message, object_name;
htask delay;
int frag_value;
int dropit;
hfaction aggressor_faction, object_faction;
hship player=iShip.FindPlayerShip();
hsim bomb;
atomic
{
object_faction = iSim.Faction( iSim.Cast(sim) );
last_attacker = iShip.Cast( iSim.LastAttacker(iSim.Cast(sim)) );
aggressor_faction = iSim.Faction( last_attacker );
object_name= Object.StringProperty( sim, "name" );
// update the score of out attacker ( increment by frag_value )
if ( iSim.Type(sim) == T_CargoPod )
{
// play around with different results of killing a pod
dropit = Math.RandomInt(1, 5);
if ( aggressor_faction != object_faction )
{
roMPUtils.increment_frags ( last_attacker, roMPUtils.get_frag_value(sim) );
}
else roMPUtils.decrement_frags ( last_attacker, roMPUtils.get_frag_value(sim) );
// give the lucky player a health power up
if (dropit <= 3 ) roMPUtils.SpawnKilledPodPowerUps (sim);
else //blow him up with AM
{
message = iMPUtils.MakeDeathMessage( last_attacker, sim );
//delay = start roMPUtils.delay_broadcast_message( sim, message, BMT_Event, 2.0 );
bomb = Sim.Create ( "ini:/sims/8km_am_explosion_wr", "big Big" );
Sim.PlaceAt ( bomb, sim );
start iDeathScript.Explosives( iSim.Cast(sim) );
Sim.Destroy( iSim.Cast(sim) );
//Task.Detach( delay );
return;
}
}
else
{
if (aggressor_faction == iFaction.Find(Text.Field("mp_flag_team_a", FT_Text)))
{
if (String.Left(object_name ,4) == "Beta" || object_faction == iFaction.Find(Text.Field("mp_flag_team_b", FT_Text)))
{
roMPUtils.increment_frags ( last_attacker, roMPUtils.get_frag_value(sim) );
}
else roMPUtils.decrement_frags ( last_attacker, roMPUtils.get_frag_value(sim) );
}
if (aggressor_faction == iFaction.Find(Text.Field("mp_flag_team_b", FT_Text)))
{
if (String.Left(object_name ,5) == "Alpha" || object_faction == iFaction.Find(Text.Field("mp_flag_team_b", FT_Text)))
{
roMPUtils.increment_frags ( last_attacker, roMPUtils.get_frag_value(sim) );
}
else roMPUtils.decrement_frags ( last_attacker, roMPUtils.get_frag_value(sim) );
}
}
// tell everyone about it
message = iMPUtils.MakeDeathMessage( last_attacker, sim );
delay = start roMPUtils.delay_broadcast_message( sim, message, BMT_Event, 2.0 );
if ( object_name == "Gunstar 8ty8" )
{
if (object_faction == iFaction.Find(Text.Field("mp_flag_team_b", FT_Text)))
//send a message that one can be re-deployed
ServerOnUserMessage( 154, last_attacker, none, " Beta Gunstar destroyed" );
else ServerOnUserMessage( 156, last_attacker, none, "Alpha Gunstar destroyed" );
bomb = Sim.Create ( "ini:/sims/1_5km_am_explosion_wr", "Lil Bigi" );
Sim.PlaceAt ( bomb, sim );
start iDeathScript.Explosives( iSim.Cast(sim) );
Sim.Destroy( iSim.Cast(sim) );
//Task.Detach( delay );
return;
}
start iDeathScript.Explosives( iSim.Cast(sim) );
Sim.Destroy( iSim.Cast(sim) );
Task.Detach( delay );
}
} //ObjectDeath
as you see I have different sim types going through the function and do all kinds of different stuff with em.
Edit: sorry the script got hard to read, I forget to close my code entry with /code
EOC/IWar2 Multiplayer Fansite
Please Log in or Create an account to join the conversation.
Re:
23 years 1 month ago
Well, this was fun to track down. Can anyone get Lock.Find() to return none for a non-existent lock object, rather than crashing Flux with no error message? I've tried a few configurations, with and without their own task context, and I can't.
Only obvious workaround that springs to mind:
If anyone can see a fix for this, please shout. If 2 or more others confirm the bug, it can join the other gotchas for future reference.
Only obvious workaround that springs to mind:
Code:
atomic
{
obj_lock = Lock.Create(lock_name);
if(obj_lock == none)
return Lock.Find(lock_name);
}
return obj_lock;
If anyone can see a fix for this, please shout. If 2 or more others confirm the bug, it can join the other gotchas for future reference.
Please Log in or Create an account to join the conversation.
Re:
23 years 1 month ago
This is tough question week for you! 
I have never used locks. I just use global booleans inside atomic statements. They are fast and tested. You may have already seen this, but just in case:
// Grab lock
atomic {
if (false == Global.Bool("myLock")){
// lock is clear, so grab it.
Global.SetBool("myLock",true);
}else {
// lock is held, so return.
return;
}
}// end atomic.
// Release Lock at end of use.
atomic {
Global.SetBool("myLock", false);
}
-Gtrout

I have never used locks. I just use global booleans inside atomic statements. They are fast and tested. You may have already seen this, but just in case:
// Grab lock
atomic {
if (false == Global.Bool("myLock")){
// lock is clear, so grab it.
Global.SetBool("myLock",true);
}else {
// lock is held, so return.
return;
}
}// end atomic.
// Release Lock at end of use.
atomic {
Global.SetBool("myLock", false);
}
-Gtrout
Please Log in or Create an account to join the conversation.