Fix suspicious_assignment warnings in Missions

master
Nicolas Hake 2018-07-23 09:43:23 +02:00
parent 806357e283
commit 05ca450111
9 changed files with 64 additions and 26 deletions

View File

@ -29,9 +29,10 @@ private func DoInit(int first_player)
// Horax
g_king.JumpSpeed = 200;
// Update AI stuff
var fx;
for (var enemy in FindObjects(Find_ID(Clonk), Find_Owner(NO_OWNER)))
if (fx = AI->GetAI(enemy))
{
var fx = AI->GetAI(enemy);
if (fx)
{
fx.weapon = fx.target = nil;
AI->BindInventory(enemy);
@ -41,6 +42,7 @@ private func DoInit(int first_player)
SetSpecialDeathMessage(enemy);
}
}
g_farmer.portrait = { Source=DialogueCastle };
// Start intro if not yet started
StartSequence("Intro", 0, GetCrew(first_player));
@ -124,4 +126,4 @@ public func OnGoalsFulfilled()
GainScenarioAchievement("Done");
GainScenarioAccess("S2Castle");
return false;
}
}

View File

@ -31,8 +31,8 @@ func SetIntact()
func Check4Head()
{
var head;
if (head = FindObject(Find_InRect(-23,-40,46,80), Find_ID(MinersStatue_Head)))
var head = FindObject(Find_InRect(-23,-40,46,80), Find_ID(MinersStatue_Head));
if (head)
{
SetIntact();
head->RemoveObject();
@ -50,4 +50,4 @@ local Collectible = false;
local Name = "$Name$";
local Description = "$Description$";
local Touchable = 0;
local Plane = 220;
local Plane = 220;

View File

@ -75,16 +75,27 @@ private func PlaceBatches(array item_ids, int n_per_batch, int batch_radius, int
{
// place a number (n_batches) of batches of objects of types item_ids. Each batch has n_per_batch objects.
// fewer batches and/or objects may be placed if no space is found
var loc,loc2,n_item_ids=GetLength(item_ids), n_created=0, obj;
var n_item_ids=GetLength(item_ids), n_created=0;
for (var i=0; i<n_batches; ++i)
if (loc = FindLocation(Loc_Material("Earth")))
{
var loc = FindLocation(Loc_Material("Earth"));
if (loc)
{
for (var j=0; j<n_per_batch; ++j)
if (loc2 = FindLocation(Loc_InRect(loc.x-batch_radius,loc.y-batch_radius,batch_radius*2,batch_radius*2), Loc_Material("Earth")))
if (obj=CreateObjectAbove(item_ids[Random(n_item_ids)],loc2.x,loc2.y))
{
var loc2 = FindLocation(Loc_InRect(loc.x-batch_radius,loc.y-batch_radius,batch_radius*2,batch_radius*2), Loc_Material("Earth"));
if (loc2)
{
var obj = CreateObjectAbove(item_ids[Random(n_item_ids)], loc2.x, loc2.y);
if (obj)
{
obj->SetPosition(loc2.x,loc2.y);
++n_created;
}
}
}
}
}
return n_created;
}

View File

@ -118,8 +118,9 @@ private func FxIntGemGlitterTimer(target)
// Glitter at random gem position
if (Random(2))
{
var i = Random(12), gem;
if (gem = target.gem_overlays[i])
var i = Random(12);
var gem = target.gem_overlays[i];
if (gem)
{
var x = CrystalCommunicator_GemsX[i]/5 - 45;
var y = CrystalCommunicator_GemsY[i]/5 - 35;

View File

@ -9,10 +9,12 @@ func Initialize()
// Rules
if (!ObjectCount(Find_ID(Rule_TeamAccount))) CreateObject(Rule_TeamAccount);
// Environment
var loc;
for (var i=0; i<5; ++i)
if (loc = FindLocation(Loc_InRect(0,80*8,40*8,20*8), Loc_Material("Earth")))
{
var loc = FindLocation(Loc_InRect(0,80*8,40*8,20*8), Loc_Material("Earth"));
if (loc)
CreateObjectAbove(Rock, loc.x, loc.y+3);
}
SetSkyParallax(1, 20,20, 0,0, nil, nil);
var relaunch_rule = GetRelaunchRule();
relaunch_rule->SetInventoryTransfer(true);

View File

@ -275,7 +275,8 @@ func FxNewtonHammeringTimer(object c, proplist fx, int time)
var len = c->GetAnimationLength("StrikePickaxe");
var a = len*70/100;
var b = len*94/100;
if (fx.phase = !fx.phase)
fx.phase = !fx.phase;
if (fx.phase)
{
if ((!Random(5) && GetPlayerCount()) || this.was_walk_interrupted)
{

View File

@ -114,13 +114,15 @@ func Dlg_Pyrit_15(object clonk)
// called every 10 frames after plane+oil task has been given
func CheckOilAtPlane()
{
var barrel;
for (var plane in FindObjects(Find_ID(Airplane)))
if (barrel = plane->FindObject(plane->Find_AtRect(-30,-10,60,20), Find_ID(MetalBarrel)))
for (var plane in FindObjects(Find_ID(Airplane)))
{
var barrel = plane->FindObject(plane->Find_AtRect(-30,-10,60,20), Find_ID(MetalBarrel));
if (barrel)
{
RemoveTimer(Scenario.CheckOilAtPlane);
ScheduleCall(nil, Global.GameCall, 1,1, "OnPlaneLoaded", plane, barrel);
}
}
return true;
}

View File

@ -117,7 +117,7 @@ func SetStorm(int dir_x, int dir_y, int astrength)
// create streams
n_streams = ((Abs(LandscapeWidth()*dir_y) + Abs(LandscapeHeight()*dir_x))/d - 2*stream_border_dist) / stream_density;
streams = CreateArray(n_streams);
var i_stream = 0, s, x0, y0, sgn_x=1, sgn_y=1;
var i_stream = 0, x0, y0, sgn_x=1, sgn_y=1;
var wdt = LandscapeWidth()-1, hgt = LandscapeHeight()-1;
if (dir_y<0) { y0 = hgt; sgn_y = -1; }
if (dir_x<0) { x0 = wdt; sgn_x = -1; }
@ -132,7 +132,8 @@ func SetStorm(int dir_x, int dir_y, int astrength)
if (dpos<=wdt)
{
// streams from horizontal border of landscape
if (s=CreateStream(wdt-x0-dpos*sgn_x, y0)) streams[i_stream++] = s;
var s = CreateStream(wdt - x0 - dpos * sgn_x, y0);
if (s) streams[i_stream++] = s;
continue;
}
pos -= Abs(wdt*dir_y/d);
@ -140,7 +141,8 @@ func SetStorm(int dir_x, int dir_y, int astrength)
// streams from vertical border of landscape
pos=Abs(pos*d/dir_x);
//Log("@%d", pos);
if (s=CreateStream(x0, y0+pos*sgn_y)) streams[i_stream++] = s;
var s = CreateStream(x0, y0 + pos * sgn_y);
if (s) streams[i_stream++] = s;
}
n_streams=i_stream;
//Log("%d total", n_streams);
@ -276,8 +278,9 @@ private func ExecuteStream(proplist s)
if (obj->Stuck()) continue;
if (!PathFree(x,y,obj->GetX(),obj->GetY())) continue; // don't push through solid
// determine push strength. subsequent pushes of overlapping storm pathes stack diminishingly
var push_strength = strength/20,pushfx;
if (pushfx=GetEffect("StormPush",obj))
var push_strength = strength/20;
var pushfx = GetEffect("StormPush",obj);
if (pushfx)
{
push_strength /= pushfx.count++;
if (!push_strength) continue;

View File

@ -12,9 +12,25 @@ local has_gem_task, got_oil, is_fulfilled;
public func IsFulfilled() { return is_fulfilled; }
public func OnGotGemTask() { SetGraphics("Hunt"); SetName("$Name2$"); return has_gem_task = true; }
public func OnTreasureSold() { SetGraphics(nil); SetName("$Name$"); return got_oil = true; }
public func OnOilDelivered() { return is_fulfilled = true; }
public func OnGotGemTask()
{
SetGraphics("Hunt");
SetName("$Name2$");
has_gem_task = true;
return true;
}
public func OnTreasureSold()
{
SetGraphics(nil);
SetName("$Name$");
got_oil = true;
return true;
}
public func OnOilDelivered()
{
is_fulfilled = true;
return true;
}
public func GetDescription(int plr)
{